Skip to content

Instantly share code, notes, and snippets.

@whatisjasongoldstein
Created December 18, 2012 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatisjasongoldstein/4331779 to your computer and use it in GitHub Desktop.
Save whatisjasongoldstein/4331779 to your computer and use it in GitHub Desktop.
Bug, docs issue, or my being stupid? (Translations behave differently when imported as _)
In [1]: from django.utils.translation import ugettext as _
In [2]: [_('red'),_('blue')]
Out[2]: [u'red', u'blue']
In [3]: [_('red'),_('blue')]
TypeError Traceback (most recent call last)
/Users/jg026715/.virtualenvs/iqh/lib/python2.7/site-packages/django/core/management/commands/shell.pyc in <module>()
----> 1 [_('red'),_('blue')]
TypeError: 'list' object is not callable
In [4]: [_('red'),_('blue')]
KeyboardInterrupt
In [4]: from django.utils.translation import ugettext
In [5]: [ugettext('red'),ugettext('blue')]
Out[5]: [u'red', u'blue']
In [6]: [ugettext('red'),ugettext('blue')]
Out[6]: [u'red', u'blue']
In [10]: from django.utils.translation import ugettext as foo
In [11]: [foo('red'), foo('blue')]
Out[11]: [u'red', u'blue']
In [12]: [foo('red'), foo('blue')]
Out[12]: [u'red', u'blue']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment