On Sat, 29 Oct 2016 08:24 am, John Gordon wrote:
> After importing a module, I can access some of its submodules directly
> but others require an explicit import of the submodule.
[...]
> Why the difference?
Ask the author of the package.
Try this experiment: create a package called
On Sat, Oct 29, 2016 at 8:24 AM, John Gordon wrote:
> After importing a module, I can access some of its submodules directly
> but others require an explicit import of the submodule.
>
> As an example, see ldap.dn and ldap.modlist:
>
> % python
> Python 2.7.8 (default,
After importing a module, I can access some of its submodules directly
but others require an explicit import of the submodule.
As an example, see ldap.dn and ldap.modlist:
% python
Python 2.7.8 (default, Aug 4 2016, 09:29:33)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-9)] on linux2
Type "
rt *" doesn't inject ttk in your namespace this
means that there is no variable tkinter.ttk. This is because there is no
from . import ttk
in tkinter/__init__.py, and automagically importing all candidate submodules
is inefficient (and unsafe).
However, once you import tkinter.ttk the
Hello
Since in python3 ttk is a submodule of tkinter, I was expecting this
to work:
from tkinter import *
root = Tk()
nb = ttk.Notebook(root)
but it doesnt, ttk is not known.
I have to explicitely import ttk with
from tkinter import ttk
why ?
--
https://mail.python.org/mailman/listinfo/pyth
"Peter Otten" <__pete...@web.de> a écrit dans le message de
news:mailman.312.1458299016.12893.python-l...@python.org...
ast wrote:
ok, thx
--
https://mail.python.org/mailman/listinfo/python-list
ssue is that if I start moving modules to sub
> folders I have to go through and update literally thousands of scripts
> that import the module from util_mods. I was wondering if there was a way
> to move these modules into submodules while still maintaining the imports.
> For example &
ers I
have to go through and update literally thousands of scripts that import the
module from util_mods. I was wondering if there was a way to move these modules
into submodules while still maintaining the imports. For example "import
util_mods.moda " would actually import as "util_m
-Original Message-
From: Massi [mailto:massi_...@msn.com]
Sent: 25/11/2011 6:30 PM
To: python-list@python.org
Subject: Automatic import of submodules
Hi everyone,
in my project I have the following directory structure:
plugins
|
-- wav_plug
|
-- __init__.py
ug
> from plugins.wav_plug.Mp3Plug import Mp3Plug
>
> and so on. This is uncomfortable, since when a new plugin is added I
> have to import it too. So my question is, is it possible to iterate
> through the 'plugins' directory tree in order to automatically import
>
uncomfortable, since when a new plugin is added I
have to import it too. So my question is, is it possible to iterate
through the 'plugins' directory tree in order to automatically import
the submodules contained in each subdirectory?
I googled and found that the pkgutil could help, but
plugins.wav_plug.Mp3Plug import Mp3Plug
and so on. This is uncomfortable, since when a new plugin is added I
have to import it too. So my question is, is it possible to iterate
through the 'plugins' directory tree in order to automatically import
the submodules contained in each subdirectory?
I googled and foun
, since when a new plugin is added I
have to import it too. So my question is, is it possible to iterate
through the 'plugins' directory tree in order to automatically import
the submodules contained in each subdirectory?
I googled and found that the pkgutil could help, but it is not clea
els
import measurement.pwm
What do i need to do to create submodules within the initialisation code
of a python module written in C?
I think it's easier to write a wrapper module in Python. See the xml.etree
package; the cElementTree.py Python module just contains "from
_elementtree imp
ent
import measurement.adc
import measurement.adc.channels
import measurement.pwm
What do i need to do to create submodules within the initialisation code
of a python module written in C?
Maybe there is an example based on "noddy"?
Thanks for any hints,
Torsten.
--
http://mail.python.org/mai
En Wed, 19 Dec 2007 07:02:00 -0300, Chris <[EMAIL PROTECTED]> escribió:
> #fp.py
> import cli
>
> #cli.py
> import os
>
> #config.py
> import cli
> print cli.os.environ['HOME']
>
> if you wish to use the os module loaded by the cli module
En Wed, 19 Dec 2007 09:42:31 -0300, Donn Ingle <[EMAIL PRO
> You guess. When fisrt imported, the module's source is executed, a
> module object is created and stored in sys.modules, and the needed names
> are inserted into the importing module's namespace. Next times the
> module is "served" directly from sys.modules.
Peachy, thanks.
\d
--
http://mail.
the importing module's namespace. Next times the
module is "served" directly from sys.modules.
>
>> package, you can of course factor them out in a distinct submodule and
>> just do a 'from myimports import *' at the top of the others submodules...
> Goo
Chris wrote:
> print cli.os.environ['HOME']
I was really confused by your reply until I saw the cli.os part. Okay, I see
what you mean.
\d
--
http://mail.python.org/mailman/listinfo/python-list
same thing?
> package, you can of course factor them out in a distinct submodule and
> just do a 'from myimports import *' at the top of the others submodules...
Good point.
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 19, 9:24 am, Donn Ingle <[EMAIL PROTECTED]> wrote:
> So, I guess I am confused about the 'scope' of what gets imported where. I
> am thinking that if one module (py file) does *import os* something and
> *then* imports another module - the second module should have access to os
> too?
> I i
y. Now if
you have a huge common set of imports in each and every submodule of a
package, you can of course factor them out in a distinct submodule and
just do a 'from myimports import *' at the top of the others submodules...
--
http://mail.python.org/mailman/listinfo/python-list
Hi, I'm sure this is a FAQ, but I have just not found clarity on the
web/docs.
(using monospaced type to show the tree)
trunk:$ tree
.
fp
|-- fontypython
| |-- __init__.py
| |-- cli.py
| |-- config.py
(I start it all with ./fp)
fp says:
import cli
cli.py says:
import os
import config
con
r " .. import *" statements.
>
> Is the correct way of accomplishing this to explicitly import the submodules
> in sound/Effects/__init__.py? I'm looking for the "official" way of doing
> this.
>
> Thank you,
> Frank Aune
You can put 'import echo'
tried to define
the __all__ = ['echo','surround','reverse'] parameter in the init file, but
this only seems to be effective for " .. import *" statements.
Is the correct way of accomplishing this to explicitly import the submodules
in sound/Effects/__init_
okay, thanks everyone. this is much clearer now.
--
http://mail.python.org/mailman/listinfo/python-list
TG wrote:
> okay,
>
> so only when I have inside __init__.py
>
> __all__ = ["core"]
>
> this works
>
> ?> from tom import *
> ?> help(core)
>
> but (in a brand new interpretor)
>
> ?> import tom
> ?> help(tom.core)
>
> AttributeError: 'module' object has no attribute 'core'
>
> got it. But
okay,
so only when I have inside __init__.py
__all__ = ["core"]
this works
?> from tom import *
?> help(core)
but (in a brand new interpretor)
?> import tom
?> help(tom.core)
AttributeError: 'module' object has no attribute 'core'
got it. But ...
?> import numpy
?> help(numpy.core)
this w
TG wrote:
> if I import tom, it is supposed to load functions defined in
> tom/__init__.py and make all the modules inside accessible through the
> "dot" syntax.
>
> Therefore, this is supposed to work :
>
> ?> import tom
> ?> help(tom.core)
>
> AttributeError: 'module' object has no attribute
BartlebyScrivener wrote:
> then you no longer need tom, you imported all of his FUNCTIONS (never
> heard of submodule).
my mistake, I was using the wrong name
tom/ <-- package
__init__.py
core.py <
data.py < these are modules contained in tom/
ui.py <
if I import t
http://tinyurl.com/6yz2g
If you do
from tom import *
then you no longer need tom, you imported all of his FUNCTIONS (never
heard of submodule).
rd
--
http://mail.python.org/mailman/listinfo/python-list
I know this is a bad habit ... I was just doing it to show what is
disturbing me.
Obviously the "star" syntax finds the submodules because they are
loaded, but when I properly load the module alone with "import tom",
the "dot" syntax does not find "tom.core"
>> > from tom import *
You CAN do this, but it's a bad habit.
Try:
>>import tom
Then call by tom.function()
rd
--
http://mail.python.org/mailman/listinfo/python-list
I've just found this :
If I add :
"import core, data, ui" inside my "tom/__init__.py" file, it will
work. But this line does not seems to exist in other files (after
having a look at several files inside /usr/lib/python2.4).
--
http://mail.python.org/mailman/listinfo/python-list
hi.
This is my first try on modules.
I've got :
tom/
__init__.py
core.py
ui.py
data.py
then, when I'm in my ipython shell :
?> from tom import *
this works, it loads core, ui and data
but when I do this :
?> import tom
?> tom.core
AttributeError: 'module' object has no att
35 matches
Mail list logo