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,067 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,021 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,426 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,759 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,670 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,211 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,593 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
+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
998 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,546 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
896 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,163 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,744 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
686 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,263 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,523 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,429 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,533 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,523 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
888 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,936 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,597 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,328 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
860 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,466 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
978 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,297 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
804 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,666 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
868 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,423 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
815 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
747 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
697 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,045 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,764 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,314 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,517 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,011 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,324 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
756 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,279 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,522 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
703 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,535 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,110 views