开发者

what _ means in expression: reprColor = [_("White"), _("Black")] and why it fails

开发者 https://www.devze.com 2023-02-18 01:40 出处:网络
There is a file const.py with lines like this: reprColor = [ _(\"开发者_开发技巧White\"), _(\"Black\")]

There is a file const.py with lines like this:

 reprColor = [ _("开发者_开发技巧White"), _("Black")] 

I got an error on this line:

NameError: name '_' is not defined<br>

What is the problem?

Environment: Python 2.7 / Windows XP

I have read that underscore is used as convention for private variables.


A single underscore is used as convention for one of the translation functions in gettext. Either bind it yourself, or call one of the install() functions or methods.


A _() call usually means GNU gettext is in use. It's for internationalization of strings.

0

精彩评论

暂无评论...
验证码 换一张
取 消