English 中文(简体)
您称之为单元的内容是什么?
原标题:What do you call the elements of a module?

我从“学习”斯堪德·哈维德到我需要评论:

from sys import argv

因此,我做了以下工作:从玩具模块中进口零件。

我知道有什么样的动力,但我却在混淆如何把这一要素称作玩具模块? 变数、方法、功能? 变数?

而且,鉴于该法典,这是否意味着所有玩具模块都进口到我的节目中,或者只加一夫?

最佳回答

<代码>argv是<编码>sys模块名称空间的变量。 它是一份清单。

声明

from sys import argv

引诱将整个<代码>sys模块(假设该模块尚未成平,在这种情况下,该模块是not 重载),并将<代码>argv变量改为目前的模块名称空间。

问题回答

我知道有什么动力,但我难以确定如何把这一要素称作玩具模块?

我认为,你指的是<><>><>>>>>>,以指一种激励,而不是指它。 它是无谓的。 这里,你是如何证明这一点的。

>>> import sys
>>> callable(sys.argv)
False

现在,正如上文提及的“不可靠”一样,假定该模块尚未装满。 这意味着什么? 当你进口一个单元时,它就添加到一个称作玩具的字典上。 模块。

>>> import sys
>>> print sys.modules.keys
[ copy_reg ,  encodings ,  site ,  __builtin__ ,  __main__ ,  encodings.encodings ,  abc ,  posixpath ,  errno ,  encodings.codecs ,  _abcoll ,  types ,  _codecs ,  _warnings ,  genericpath ,  stat ,  zipimport ,  encodings.__builtin__ ,  warnings ,  UserDict ,  encodings.utf_8 ,  sys ,  codecs ,  readline ,  os.path ,  signal ,  linecache ,  posix ,  encodings.aliases ,  exceptions ,  os ]

字典扫描仪使该模块无法重载。 进口表检查了玩具.摩杜里,以防止该模块重载。

如果你真的进入了单元,请看一下清单的ys。

如果你改写文字,并想立即改变口译,则将文字重载。

>>> reload(sys)
>>> help(reload)
Help on built-in function reload in module __builtin__:

reload(...)
    reload(module) -> module

    Reload the module.  The module must have been successfully imported before.

因此,你们比以往更加想知道单元和单元属性:D。

http://docs.python.org/tutorial/modules.html talks about

模块中的定义可以 进口<> > /em> 输入其他模块或进入main。 模块

增 编

<编码>进口<>/编码>有一个备选案文,说明进口从一个模块直接输入进口模块的符号表。

In this sense, argv is a name which is defined in sys.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...