Top "Python-3.x" questions

For questions about Python programming that are specific to version 3+ of the language.

How to save a list to a file and read it as a list type?

Say I have the list score=[1,2,3,4,5] and it gets changed whilst my program is running. How could I save it …

python list file python-3.x pickle
How do I change the string representation of a Python class?

In Java, I can override the toString() method of my class. Then Java's print function prints the string representation of …

python string python-3.x printing
'dict' object has no attribute 'has_key'

While traversing a graph in Python, a I'm receiving this error: 'dict' object has no attribute 'has_key' Here is …

python python-3.x dictionary
Get folder name of the file in Python

In Python what command should I use to get the name of the folder which contains the file I'm working …

python python-3.x directory
How do I calculate the MD5 checksum of a file in Python?

I have made a code in Python that checks for an MD5 in a file and makes sure the MD5 …

python python-3.x md5 md5sum
How to get the latest file in a folder using python

I need to get the latest file of a folder using python. While using the code: max(files, key = os.…

python python-3.x python-2.7
Hello World in Python

I tried running a python script: print "Hello, World!" And I get this error: File "hello.py", line 1 print "Hello, …

python python-3.x
Meaning of end='' in the statement print("\t",end='')?

This is the function for printing all values in a nested list (taken from Head first with Python). def printall(…

python python-3.x python-3.3
Switch between two frames in tkinter

I have built my first few scripts with a nice little GUI on them, as the tutorials have shown me, …

python python-3.x tkinter frame
Importing from a relative path in Python

I have a folder for my client code, a folder for my server code, and a folder for code that …

python python-3.x import shared-libraries relative-path