Most answered questions in Python

0 votes
1 answer

What is the preferred way to concatenate strings in python??

If the strings you are concatenating are ...READ MORE

Dec 21, 2018 in Python by charlie_brown
• 7,720 points
642 views
0 votes
1 answer

I have a dictonary in python how to access the value field?

dic={"car":["limo","sedan"]} print (dic.keys())    <-----------------------Fetch the key "car" print (dic['car'][0])   <------------------------Fetch ...READ MORE

Dec 20, 2018 in Python by Shuvodip
525 views
0 votes
1 answer

What is the difference between staticmethod and classmethod?

A staticmethod is a method that knows nothing about ...READ MORE

Dec 18, 2018 in Python by abc
675 views
0 votes
1 answer

sys.argv[1] what is the meaning of it?

sys.argv[1] contains the first command line argument passed to your script. For ...READ MORE

Dec 18, 2018 in Python by abc
10,182 views
0 votes
1 answer

Empty a list in python.

You could use the clear() method of list which is parallel ...READ MORE

Dec 18, 2018 in Python by Shuvodip
500 views
0 votes
1 answer

What does calling a function means in Python?

Calling a function means that you are ...READ MORE

Dec 18, 2018 in Python by Shuvodip
829 views
0 votes
1 answer

How to handle AssertionError in Python and find out which line or statement it occurred on?

Use the traceback module: import sys import traceback try: ...READ MORE

Dec 18, 2018 in Python by charlie_brown
• 7,720 points
5,412 views
0 votes
1 answer

How to calculate cosine similarity between two lists using Pythong?

You should try SciPy. It has a bunch ...READ MORE

Dec 18, 2018 in Python by charlie_brown
• 7,720 points
8,754 views
0 votes
1 answer

How can I change the data type to string in Python?

You can use str(variablename) This is called conversion ...READ MORE

Dec 18, 2018 in Python by Shuvodip
734 views
0 votes
1 answer

Signed angle between vectors

If you have an atan2() function in ...READ MORE

Dec 11, 2018 in Python by SDeb
• 13,300 points
3,640 views
0 votes
1 answer

Linter Pylint not installed

Try the following steps: 1. Open a terminal ...READ MORE

Dec 11, 2018 in Python by SDeb
• 13,300 points
2,447 views
0 votes
1 answer

How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?

UPDATED: One way is to look at sys.maxsize as ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
1,546 views
0 votes
1 answer

How can I use indices in math using python

Operator ^ is a bitwise operator, which does "bitwise exclusive or". More: http://wiki.python.org/moin/BitwiseOperators The ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
1,772 views
0 votes
1 answer

How can I represent an Enum in Python?

Here is one implementation: class Enum(set): ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
613 views
0 votes
1 answer

How can I turn an input date into a readable string in Python?

The datetime class has a method strftime. strftime() ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
423 views
0 votes
1 answer

Cursor Position in Python

You can use the following to retrieve ...READ MORE

Dec 11, 2018 in Python by SDeb
• 13,300 points
2,753 views
0 votes
1 answer

Execute PHP code in Python

Try the following Code: import subprocess # if the ...READ MORE

Dec 11, 2018 in Python by SDeb
• 13,300 points
13,526 views
+1 vote
1 answer

How to read hdfs file using python?

subprocess.Popen(["hadoop", "fs", "-cat", "/path/to/myfile"], stdou ...READ MORE

Dec 7, 2018 in Python by Omkar
• 69,230 points
5,420 views
+1 vote
1 answer

Python function to run hdfs commands

proc = subprocess.Popen(args_list, stdout=subprocess.PIPE, stderr=s ...READ MORE

Dec 7, 2018 in Python by Omkar
• 69,230 points
4,184 views
0 votes
1 answer

Measurement of time elapsed

If you just want to measure the ...READ MORE

Dec 5, 2018 in Python by SDeb
• 13,300 points
453 views
0 votes
1 answer

Empty while loop in Python

while file.readline().startswith("#"):     pass The pass statement does nothing. It ...READ MORE

Dec 5, 2018 in Python by SDeb
• 13,300 points
3,494 views
0 votes
1 answer

How can I prevent or alter access to class variables in Python?

The ActiveState solution that Pynt references makes instances of ...READ MORE

Dec 5, 2018 in Python by aryya
• 7,450 points
2,861 views
0 votes
1 answer

How can I make Python's UnitTest Framework fail if an exception is raised by any thread?

I've come across this problem myself, and ...READ MORE

Dec 5, 2018 in Python by aryya
• 7,450 points
7,539 views
0 votes
1 answer

How to measure time elapsed in Python?

If you just want to measure the ...READ MORE

Dec 4, 2018 in Python by SDeb
• 13,300 points
12,182 views
0 votes
1 answer

Why does the AttributeError occur?

This happens because the scipy module doesn't ...READ MORE

Dec 4, 2018 in Python by SDeb
• 13,300 points
2,817 views
0 votes
1 answer

How to change one character in a string in Python?

Python strings are immutable, you change them ...READ MORE

Dec 4, 2018 in Python by Nymeria
• 3,560 points
1,081 views
0 votes
1 answer

How to write inline if statement for print in Python?

Inline if-else expression must always contain the else ...READ MORE

Dec 4, 2018 in Python by Nymeria
• 3,560 points

edited Dec 6, 2018 by Nymeria 16,477 views
0 votes
1 answer

AWSCLI error

You can Try the following command and ...READ MORE

Dec 3, 2018 in Python by SDeb
• 13,300 points
955 views
0 votes
1 answer

Single line Webserver in Python

It is pretty difficult to have a ...READ MORE

Dec 3, 2018 in Python by SDeb
• 13,300 points
506 views
0 votes
1 answer

How to correctly return an a dictionary as an output in zappier code using python?

David here, from the Zapier Platform team. ...READ MORE

Dec 3, 2018 in Python by charlie_brown
• 7,720 points
1,392 views
0 votes
1 answer

Problem while using local dynamoDB container (Boto3 put_item error)

DynamoDB does not autogenerate the ID when ...READ MORE

Dec 3, 2018 in Python by charlie_brown
• 7,720 points
3,464 views
0 votes
1 answer

What is absolute import in Python and how is it used?

An absolute {import, path, URL} tells you exactly how ...READ MORE

Nov 30, 2018 in Python by Nymeria
• 3,560 points

edited Dec 10, 2018 by Nymeria 1,070 views
0 votes
1 answer

How to use Pandas HDF5 as a Database in Python?

HDF5 works fine for concurrent read only ...READ MORE

Nov 30, 2018 in Python by Nymeria
• 3,560 points

edited Dec 10, 2018 by Nymeria 1,064 views
0 votes
1 answer

Read & write data in mifare card

Hi, you can check out the following ...READ MORE

Nov 29, 2018 in Python by SDeb
• 13,300 points
1,849 views
0 votes
1 answer

site.py deleted

You can download a new copy from ...READ MORE

Nov 29, 2018 in Python by SDeb
• 13,300 points
715 views
0 votes
1 answer

How do I use urllib to see if a website is 404 or 200 in Python?

For Python 3, try doing this: import urllib.request, ...READ MORE

Nov 29, 2018 in Python by Nymeria
• 3,560 points

edited Dec 11, 2018 by Nymeria 13,457 views
0 votes
1 answer

How to calculate time interval between two time strings in Python

Try doing this - It is efficient for ...READ MORE

Nov 29, 2018 in Python by Nymeria
• 3,560 points

edited Dec 11, 2018 by Nymeria 2,975 views
0 votes
1 answer

Python argparse error "NameError: name 'file' is not defined"

The right datatype for destination in argpasrse module ...READ MORE

Nov 28, 2018 in Python by Omkar
• 69,230 points
13,078 views
0 votes
1 answer

Array values in Python

You can use the enumerate function and ...READ MORE

Nov 28, 2018 in Python by SDeb
• 13,300 points
522 views
0 votes
1 answer

Equivalent for easy_install & pip

For pip you can check the User ...READ MORE

Nov 28, 2018 in Python by SDeb
• 13,300 points
921 views
0 votes
1 answer

How to run django unit-tests on production database in Python?

In case someone googles here searching for ...READ MORE

Nov 28, 2018 in Python by Nymeria
• 3,560 points
1,329 views
0 votes
1 answer

How to install OpenCV for python3 in Ubuntu?

I found this: https://pypi.python.org/pypi/opencv-python OpenCV on wheels 'Unofficial OpenCV packages ...READ MORE

Nov 28, 2018 in Python by Nymeria
• 3,560 points
2,632 views
0 votes
1 answer

Command history in interactive Python

You can use the following to get ...READ MORE

Nov 27, 2018 in Python by SDeb
• 13,300 points
3,458 views
+2 votes
1 answer

How to install pip in windows?

Step 1:  Open the following link and go to ...READ MORE

Nov 27, 2018 in Python by Priyaj
• 58,090 points
4,908 views
0 votes
1 answer

Question on PyQt: How to connect a signal to a slot to start a background operation in Python

It shouldn't matter whether the connection is ...READ MORE

Nov 27, 2018 in Python by Nymeria
• 3,560 points
1,560 views
0 votes
1 answer

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

Nov 27, 2018 in Python by Nymeria
• 3,560 points
1,960 views
0 votes
1 answer

NaN variable without NumPy

Yes, It is possible to use the ...READ MORE

Nov 26, 2018 in Python by SDeb
• 13,300 points
1,598 views
0 votes
1 answer

.replace() regex in Python

No,  .replace() does not support regex. Regular expressions ...READ MORE

Nov 26, 2018 in Python by SDeb
• 13,300 points
646 views
0 votes
1 answer

Is it possible in Python requests to print entire HTTP request?

A better idea is to use the ...READ MORE

Nov 26, 2018 in Python by Nymeria
• 3,560 points
22,100 views
+1 vote
1 answer

Need some help with Python memory leaks

As far as best practices, keep an ...READ MORE

Nov 26, 2018 in Python by Nymeria
• 3,560 points
744 views