Follow

Via Twitter (twitter.com/jgerity/status/120)

This is one of the most cursed things I've ever seen:

$ python2
>>> import string
>>> string.letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> help(string)
>>> string.letters
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

@rixx If anyone is wondering (as I have) what's going on there. The answer is on twitter, copying it here so one doesn't need to navigate that much.

> help() is calling locale.setlocale() to set the locale to the terminal locale

> setlocale() recomputes string.uppercase/lowercase and string.letters. it does the last one wrong. I'll file a bug :)

@holger thanks for copying the explanation to this horrible #python locale-related #bug... @rixx

@rixx
won't happen with python3 🙂
$ python3
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> help(string)
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

Sign in to participate in the conversation
chaos.social

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!