Python论坛  - 讨论区

标题:[python-chinese] 有人看过Bittorrent的源代码吗?

2006年02月22日 星期三 15:24

Leo Jay python.leojay at gmail.com
Wed Feb 22 15:24:07 HKT 2006

我在里面经常看得到字符串外加一个_(),如_("right-click for menu")。
请问这里"_"是什么?是函数名吗?可是我没找到这个函数的声明啊。
谁知道这个函数的声明在哪里吗?

谢谢了。

--
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月22日 星期三 15:41

Slowness Chen chenzh at bhh.com.cn
Wed Feb 22 15:41:01 HKT 2006

yes, it is a function name
the following is copied from $PYTHONHOME/tools/i18n/pygettext.py:

    import fintl
    _ = fintl.gettext

----- Original Message ----- 
From: "Leo Jay" <python.leojay at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Wednesday, February 22, 2006 3:24 PM
Subject: [python-chinese] 有人看过Bittorrent的源代码吗?


> 我在里面经常看得到字符串外加一个_(),如_("right-click for menu")。
> 请问这里"_"是什么?是函数名吗?可是我没找到这个函数的声明啊。
> 谁知道这个函数的声明在哪里吗?
>
> 谢谢了。
>
> --
> Best Regards,
> Leo Jay
>


--------------------------------------------------------------------------------


> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese 


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月22日 星期三 16:03

River Yan riverfor at gmail.com
Wed Feb 22 16:03:23 HKT 2006

这是gettext使用的,不是python的函数, 在使用gettext进行国际化的PHP程序中,也可看到_('xxx')等内容

更详细信息可在google查询

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月22日 星期三 16:19

Leo Jay python.leojay at gmail.com
Wed Feb 22 16:19:28 HKT 2006

On 2/22/06, Slowness Chen <chenzh at bhh.com.cn> wrote:
> yes, it is a function name
> the following is copied from $PYTHONHOME/tools/i18n/pygettext.py:
>
>    import fintl
>    _ = fintl.gettext
>

thanks for your reply.
but i still wonder where is the definition of the "_" function.
following your desc, i tried the code as follows:

>>> import gettext
>>> _("test")
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name '_' is not defined
>>> gettext._("test")
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'module' object has no attribute '_'

as can be seen from the result, i don't think the "_" function is
declared in the gettext module.

so, where is it?

Thanks


--
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月22日 星期三 17:06

Slowness Chen chenzh at bhh.com.cn
Wed Feb 22 17:06:57 HKT 2006

do this:

    from gettext import gettext as _

_ is just a shortcut alias for gettext (or *gettext)
which can be from standard library or  fintl.py
----- Original Message ----- 
From: "Leo Jay" <python.leojay at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Wednesday, February 22, 2006 4:19 PM
Subject: Re: [python-chinese] 有人看过Bittorrent的源代码吗?


On 2/22/06, Slowness Chen <chenzh at bhh.com.cn> wrote:
> yes, it is a function name
> the following is copied from $PYTHONHOME/tools/i18n/pygettext.py:
>
>    import fintl
>    _ = fintl.gettext
>

thanks for your reply.
but i still wonder where is the definition of the "_" function.
following your desc, i tried the code as follows:

>>> import gettext
>>> _("test")
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name '_' is not defined
>>> gettext._("test")
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'module' object has no attribute '_'

as can be seen from the result, i don't think the "_" function is
declared in the gettext module.

so, where is it?

Thanks


--
Best Regards,
Leo Jay
_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese 


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号