I was quite impressed by the speed improvements over the 3.0.1 version of Python. It's quite fast and comparable to Python 2.6 version (which is pretty damn fast). Running few of my sources with the new version (to test speed and comformance) I noticed that my TinyURL example doesn't work anymore.
The string.letters is gone, and print is (as mentioned before) no longer a statement; it's a function. The updated function now looks like this:
import random
import string
def short_id(num): return "".join(random.sample(string.digits + string.ascii_letters, num))
print(short_id(6))
The only noticable change in the function itself is use of string.ascii_letters. There you have it - now Py3 compliant! :)
No comments:
Post a Comment