This might be a stupid question but I don't understand what's the difference between string.uppercase and string.ascii_uppercase in the string module. Printing the docstring of both the function prints same thing. Even the output of print string.uppercase
and print string.ascii_uppercase
is same.
Thanks.
Note that in Python 3.x string.uppercase and also string.lowercase and string.letters have vapourised. It was not considered good practice to have global 'constants' that varied when you changed locale. (See http://docs.python.org/py3k/whatsnew/3.0.html)
So the best thing for any new code is probably to pretend they don't exist in Python 2.x either. That way you don't store up problems if you ever do need to migrate to Python 3.x
For Python 2.7, the difference is: (see https://docs.python.org/2.7/library/string.html )
string.ascii_uppercase:
string.uppercase:
In Python 3+ string.uppercase
does not exist as a global "constant" anymore. ( https://docs.python.org/3/library/string.html )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With