Most voted questions in Python

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
615 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
425 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,757 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,531 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,498 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,870 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,548 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,184 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,821 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,082 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,479 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
957 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
507 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,402 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,469 views
0 votes
4 answers

How to print objects of class using print function in Python?

>>> class Test: ... ...READ MORE

Dec 16, 2020 in Python by Roshni
• 10,520 points
77,716 views
0 votes
3 answers

How to get the return value from a thread using python?

FWIW, the multiprocessing module has a nice interface for ...READ MORE

Dec 15, 2020 in Python by Roshni
• 10,520 points
105,690 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,073 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,067 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,856 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
716 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,465 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,984 views
0 votes
3 answers

Python error "NameError: name 'sr' is not defined"

NameError: name 'xx' is not defined Python knows ...READ MORE

Mar 19, 2020 in Python by rahul
• 360 points
41,580 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,091 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
527 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
923 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,334 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,633 views
0 votes
2 answers

Error: Speech to Text Codec cannot decode the bytes in position

import speech_recognition as sr r = sr.Recognizer() audio ='C\Users\Desktop\audiofile1.wav' with ...READ MORE

Nov 28, 2018 in Python by Nabarupa Das
2,512 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,463 views
0 votes
2 answers

Is Python fully object oriented?

Python supports all the concept of "object ...READ MORE

Sep 13, 2020 in Python by Anjali Chauhan
17,632 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,563 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,964 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,607 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
651 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,116 views
0 votes
1 answer

Python math module

pow is built into the language but ...READ MORE

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

Count elements in list

Try the following method: len() >>> someList=[] >>> ...READ MORE

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

Can you help me understand the Global Interpreter Lock in Python

Suppose you have multiple threads which don't really touch ...READ MORE

Nov 23, 2018 in Python by aryya
• 7,450 points
510 views
0 votes
2 answers

How can I rename multiple files in a certain directory using Python?

import os from optparse import OptionParser, Option class MyOption ...READ MORE

Jul 29, 2020 in Python by The real slim shady
4,469 views
0 votes
1 answer

How to convert an integer to a string using Python?

Here is an easy solution: def numberToBase(n, b): ...READ MORE

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

edited Dec 12, 2018 by Nymeria 829 views
0 votes
1 answer

How to put a variable inside a String using Python?

In the easiest way, you can create ...READ MORE

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

edited Dec 12, 2018 by Nymeria 933 views
0 votes
1 answer

floor of a float in python

As long as your numbers are positive, ...READ MORE

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

Create a GUID/UUID in Python

The uuid module, in Python 2.5 and ...READ MORE

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

How to set Colorbar Range in matplotlib using Python

You could scale your data to the ...READ MORE

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

Is multi-threading supported in Python and can it speed up execution time as well?

The GIL does not prevent threading. All ...READ MORE

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

Convert upper case letters to lower case

You can convert upper case to lower ...READ MORE

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

How can I parse a YAML file in Python?

Read & Write YAML files with Python ...READ MORE

Nov 21, 2018 in Python by Nymeria
• 3,560 points
10,293 views