Trending questions in Python

+1 vote
1 answer

What's the difference between eval, exec, and compile in Python?

exec is not an expression: a statement ...READ MORE

Aug 28, 2018 in Python by Priyaj
• 58,020 points
5,062 views
0 votes
1 answer

Restart python script automatically even when it crashes in Linux

Maybe this would be more robust? 1) save ...READ MORE

Sep 21, 2018 in Python by Priyaj
• 58,020 points
4,018 views
0 votes
1 answer

How should I write tests for Forms in Django with Python?

from django.tests import TestCase class MyTests(TestCase): ...READ MORE

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

Know/change current directory in Python shell?

This will work  >>> import os >>> os.getcwd() '/home/user' >>> os.chdir("/tmp/") >>> ...READ MORE

Nov 12, 2018 in Python by Priyaj
• 58,020 points
1,758 views
0 votes
1 answer

What's the right way to concatenate files and appending the New Line character in Python? Text or binary mode?

It seems like you're using the wrong ...READ MORE

Nov 13, 2018 in Python by Anirudh
• 2,090 points

edited Dec 14, 2018 by Anirudh 1,668 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 1,209 views
0 votes
1 answer

Python's logo meaning

I guess its pretty obvious that they're ...READ MORE

Nov 14, 2018 in Python by Theodor
• 740 points
1,591 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
674 views
0 votes
1 answer

What does hash do in python?

A hash is an fixed sized integer ...READ MORE

Nov 14, 2018 in Python by charlie_brown
• 7,720 points
1,545 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
994 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 1,162 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
894 views
0 votes
1 answer

Is there a stack/heap in Python?

Memory management in Python involves a private ...READ MORE

Nov 9, 2018 in Python by SDeb
• 13,300 points
1,743 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
684 views
0 votes
1 answer

How to use nested if else statement in python?

The working of nested if-else is similar ...READ MORE

Nov 19, 2018 in Python by Nabarupa
1,259 views
0 votes
1 answer

Sort Counter by value? - python

>>> x = Counter({'a':1, 'b':2, 'c':3}) >>> ...READ MORE

Nov 13, 2018 in Python by Priyaj
• 58,020 points
1,520 views
0 votes
1 answer

Underscore _ as variable name in Python

Yep, _ is a traditional name for "don't care" ...READ MORE

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

How does time series analysis with statsmodels work?

I'd really like to see a data ...READ MORE

Sep 4, 2018 in Python by Priyaj
• 58,020 points
4,531 views
0 votes
1 answer

Manage websockets across multiple servers / workers

So I am only familiar with Socket.IO ...READ MORE

Sep 4, 2018 in Python by Priyaj
• 58,020 points
4,520 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
814 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
885 views
0 votes
3 answers

Python Selenium best tutorials for beginners

Hope this will help you...Python Tutorial READ MORE

Feb 11, 2019 in Python by aldrinjohn
• 140 points
3,932 views
0 votes
1 answer

In NumPy how do I get the maximum of subsets? Python

You can use np.maximum.reduceat: >>> _, idx = np.unique(g, ...READ MORE

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

Shortest path from source to and from a negative cycle using Bellman Ford in Python

class NegativeWeightFinder: def __init__(self, graph: nx.Graph): ...READ MORE

Nov 13, 2018 in Python by Nymeria
• 3,560 points
1,327 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
859 views
0 votes
1 answer

Rename a key in dict

dictionary[new_key] = dictionary.pop(old_key) READ MORE

Jun 8, 2018 in Python by Hamartia's Mask
• 1,580 points
8,119 views
0 votes
1 answer

What is equivalent for 'foreach' in Python

Its also interesting to observe this To iterate ...READ MORE

Oct 17, 2018 in Python by findingbugs
• 4,780 points
2,465 views
0 votes
1 answer

Python 3 equivalent of SimpleHTTPServer

The SimpleHTTPServer module has been merged into ...READ MORE

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

Install PIP on Python 3.6

pip is bundled with Python > 3.4 On Unix-like ...READ MORE

Nov 12, 2018 in Python by Priyaj
• 58,020 points
1,292 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
801 views
0 votes
1 answer

Real-world examples of applications in python?

You can view this reference here: Python projects ...READ MORE

Nov 2, 2018 in Python by Nabarupa
1,715 views
0 votes
1 answer

tf.reshape vs tf.contrib.layers.flatten

All 3 options reshape identically: import tensorflow as ...READ MORE

Oct 10, 2018 in Python by Priyaj
• 58,020 points
2,663 views
0 votes
1 answer

Namespace in Python

Namespace is a way to implement scope. In ...READ MORE

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

why is tkinter grid overlapping?

Tkinter is fairly efficient. And for the ...READ MORE

Sep 27, 2018 in Python by Priyaj
• 58,020 points
3,206 views
0 votes
1 answer

Use conditional statements to handle multi-line conditions

You don't need to use 4 spaces ...READ MORE

Oct 15, 2018 in Python by charlie_brown
• 7,720 points
2,419 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
814 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
745 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,460 points
695 views
0 votes
1 answer

Check palindrome in Python

A pythonic way  and the most simplest ...READ MORE

Nov 14, 2018 in Python by Theodor
• 740 points
1,042 views
0 votes
1 answer

tensorflow 1.5 ImportError: No module named tensorflow.python.client

Some of the modules have changed in ...READ MORE

Oct 5, 2018 in Python by Priyaj
• 58,020 points
2,761 views
0 votes
1 answer

How can I logarithmic axes with matplotlib in python?

You can use the Axes.set_yscale method. That allows you ...READ MORE

Oct 15, 2018 in Python by charlie_brown
• 7,720 points
2,310 views
0 votes
1 answer

How can I print variable and string on same line in Python?

Use , to separate strings and variables while printing: print ...READ MORE

Sep 17, 2018 in Python by Priyaj
• 58,020 points
3,515 views
0 votes
1 answer

What are good rules of thumb for Python imports?

I would normally use import X on module level. ...READ MORE

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

edited Dec 18, 2018 by Nymeria 1,009 views
+1 vote
1 answer

How do you express binary literals in Python?

Starting with Python 2.6 you can express ...READ MORE

Aug 28, 2018 in Python by Priyaj
• 58,020 points

edited Dec 21, 2023 by Khan Sarfaraz 4,323 views
0 votes
1 answer

Parse String into Float in Python

just by using float() function you can ...READ MORE

Nov 20, 2018 in Python by Nabarupa
754 views
0 votes
1 answer

How to get a Mongoengine's object id in a flask program

Check out the documentation, Document.objects is a QuerySet object. You seem to be ...READ MORE

Sep 21, 2018 in Python by charlie_brown
• 7,720 points
3,276 views
0 votes
1 answer

How to exit from Python without traceback?

Perhaps you're trying to catch all exceptions ...READ MORE

Jul 31, 2018 in Python by Priyaj
• 58,020 points
5,519 views
0 votes
1 answer

Count individual occurance of character in Python

Check this code it works fine. from collections ...READ MORE

Nov 19, 2018 in Python by Nabarupa
701 views
+1 vote
1 answer

Python: Print variable and string in same line

For a better understanding you can refer ...READ MORE

Oct 30, 2018 in Python by Priyaj
• 58,020 points
1,532 views
0 votes
1 answer

How to invoke method on GUI thread but without have that method in QMainWindow class (Pyqt)

It is possible to handle this by ...READ MORE

Sep 24, 2018 in Python by Priyaj
• 58,020 points
3,107 views