__作者__ [英] __author__

查看:66
本文介绍了__作者__的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我阅读的各个模块中看到了这组(或类似的)变量。

它们位于每个模块文件的顶部附近,在任何类别之外

或函数定义。


"

__author__ ="软件作者姓名"

__copyright__ ="版权所有(C) 2004作者姓名

__license__ =公共领域

__version__ =" 1.0"

"


这组变量的功能是什么?我假设有使用这些的软件产品(可能是Python本身),

期望找到解释的某些变量。


除了上面列出的变量之外,还有哪些预期变量,以及

我期望使用哪些软件?


David

I see this set (or similar) of variables in various modules I read.
They are found near the top of each module file, outside of any class
or function definitions.

"
__author__ = "Software Authors Name"
__copyright__ = "Copyright (C) 2004 Author Name"
__license__ = "Public Domain"
__version__ = "1.0"
"

What is the function of this set of variables? I assume there are
software products that use these, (Python itself, perhaps), that
expect to find certain variables explained.

What are the expected variables, other than the ones listed above, and
what software would I expect to use them?

David

推荐答案

David Keeney写道:
David Keeney wrote:
我在我看过的各种模块中看到了这组(或类似的)变量。
它们位于每个模块文件的顶部附近,不在任何类别或功能定义之外。

"
__ author__ ="软件作者姓名
__copyright__ =版权所有(C)2004作者姓名
__ license = =" Public Domain"
__version__ =" 1.0"
"

什么是这组变量的功能?我假设有些软件产品使用这些产品(可能是Python本身),希望找到解释的某些变量。

除了上面列出的那些,以及
我希望用什么软件?
I see this set (or similar) of variables in various modules I read.
They are found near the top of each module file, outside of any class
or function definitions.

"
__author__ = "Software Authors Name"
__copyright__ = "Copyright (C) 2004 Author Name"
__license__ = "Public Domain"
__version__ = "1.0"
"

What is the function of this set of variables? I assume there are
software products that use these, (Python itself, perhaps), that
expect to find certain variables explained.

What are the expected variables, other than the ones listed above, and
what software would I expect to use them?




IME,除了__version__,这些都没有*被广泛使用,<他们也不是必需的。


在任何情况下,它们都只是约定,并且没有

预期变量 ;按照你的想法,

,虽然可能有一些软件使用了一些

特定的一套,但是这样的东西就是这样的

你可以在你的模块的顶部

抛出一堆这样的东西,它们永远不会被实际使用

(除了__version__),是浪费时间,恕我直言。


*如果*你想用那种方式写它们,那就用它们吧,比如说,

an关于Dialog或-h时指定了选项,然后提前

。我个人使用像APP_AUTHOR和APP_COPYRIGHT

这样的东西,而不是双下划线约定,在我的

视图中,它们看起来像是某种特殊的特殊。来自
Python,导致你所面临的那种混乱

。 : - (


-Peter



IME, other than __version__, none of these are *widely* used,
nor are they necessary.

In any case, they are all just conventions, and there are NO
"expected variables" along the lines of what you''re thinking,
and while there is probably some software that uses some
particular set of them, looking for such a thing just so
that you can throw a bunch of things like that at the top
of your modules, where they will never actually be used
(except for __version__), is a waste of time, IMHO.

*If* you want to write them that way, then use them in, say,
an About Dialog or when a "-h" option is specified, then go
ahead. I personally use things like APP_AUTHOR and APP_COPYRIGHT
rather than the double-underscore convention, which in my
view makes them look like they are somehow "special" to
Python, causing just the sort of confusion that you have
faced here. :-(

-Peter


Peter L Hansen写道:


< ; snip>
Peter L Hansen wrote:

<snip>
它们实际上永远不会被使用
(__version __除外)
they will never actually be used
(except for __version__)



< snip>


那么什么用__version__?


谢谢,

Jeffrey


<snip>

So what uses __version__ ?

Thanks,
Jeffrey


David Keeney写道:
David Keeney wrote:
我在我看过的各个模块中看到了这组(或类似的)变量。
它们位于每个模块文件的顶部附近,在任何类之外
或函数定义..................................................... ;
__version__ =" 1.0"
"

这组变量的功能是什么?我假设有使用这些变量的软件产品, (可能是Python本身),
期望找到解释的某些变量。

除了上面列出的变量之外,还有哪些预期变量,以及
我希望使用哪些软件?

David
I see this set (or similar) of variables in various modules I read.
They are found near the top of each module file, outside of any class
or function definitions.

"
__author__ = "Software Authors Name"
__copyright__ = "Copyright (C) 2004 Author Name"
__license__ = "Public Domain"
__version__ = "1.0"
"

What is the function of this set of variables? I assume there are
software products that use these, (Python itself, perhaps), that
expect to find certain variables explained.

What are the expected variables, other than the ones listed above, and
what software would I expect to use them?

David



您可能会看到使用distutils打包的模块中的那些。

setup.py需要有关分发的某些元数据,包括

你上面列出的那些。可以在Nutshell_中的_Python的第562页上的_b
中找到预期值的列表,或者在_Distributing Python Modules_

第3节中可以获得预期值的列表,可在http://docs.python访问.org / dist / dist.html

HTH,

Anna


You may be seeing those in modules that were packaged up with distutils.
The setup.py expects certain metadata about the distribution,including
those you''ve listed above. A list of the expected values is available on
page 562 of _Python in a Nutshell_, or in _Distributing Python Modules_
section 3, accessible at thttp://docs.python.org/dist/dist.html

HTH,
Anna


这篇关于__作者__的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆