Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is string.letters different between python and bpython?

Tags:

python

bpython

I ran into a strange issue today. I was using the Python standard library's string module's letters variable and noticed that the result in bpython was not the same as the result in vanilla python.

I'm using Python 2.7.3 and bpython 0.10.1 and virtualenv 1.8.4. Here is what I'm seeing.

$ bpython
>>> import string
>>> string.letters
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'


$ python
>>> import string
>>> string.letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

I'm not sure that it matters but I'm running this on xubuntu 12.10.

Can someone please explain what is going on here?

like image 299
Matthew J Morrison Avatar asked Apr 24 '13 14:04

Matthew J Morrison


1 Answers

From the docs, string.letters is defined as

The concatenation of the strings lowercase and uppercase described below. The specific value is locale-dependent, and will be updated when locale.setlocale() is called.

So it could be that your locale is different.

like image 92
Dmitry Shevchenko Avatar answered Nov 01 '22 06:11

Dmitry Shevchenko