Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cypok
Created April 21, 2018 17:03
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 cypok/2debd540326e740979a8158e6376eafe to your computer and use it in GitHub Desktop.
Save cypok/2debd540326e740979a8158e6376eafe to your computer and use it in GitHub Desktop.
Am I too old for all these dynamic stuff?..s
import gettext
lang = gettext.translation("wtf")
_ = lang.gettext
print(_("Program started")) # prints translated message
def work_hard():
print(_("Working hard")) # raises UnboundLocalError: local variable '_' referenced before assignment
#
# two
#
# screens
#
# of
#
# code
#
if some_condition():
# yep, this is an assignment into variable _
useful, _ = get_two_values()
else:
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment