Re: After import, some submodules are accessible and some aren't

2016-10-28 Thread Steve D'Aprano
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

Re: After import, some submodules are accessible and some aren't

2016-10-28 Thread Chris Angelico
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 import, some submodules are accessible and some aren't

2016-10-28 Thread John Gordon
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 "

Re: submodules

2016-03-19 Thread Peter Otten
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

submodules

2016-03-19 Thread ast
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

Re: submodules

2016-03-18 Thread ast
"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

Re: Move modules to submodules question

2013-01-11 Thread Peter Otten
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 &

Move modules to submodules question

2013-01-11 Thread joshua . kimball
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

RE: Automatic import of submodules

2011-11-27 Thread Shambhu Rajak
-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

Re: Automatic import of submodules

2011-11-25 Thread alex23
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 >

Re: Automatic import of submodules

2011-11-25 Thread Jean-Michel Pichavant
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

Re: Automatic import of submodules

2011-11-25 Thread Dave Angel
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

Automatic import of submodules

2011-11-25 Thread Massi
, 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

Re: Noddy with submodules?

2009-09-07 Thread Gabriel Genellina
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

Noddy with submodules?

2009-09-07 Thread Torsten Mohr
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

Re: import X between submodules in a package

2007-12-19 Thread Gabriel Genellina
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

Re: import X between submodules in a package

2007-12-19 Thread Donn Ingle
> 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.

Re: import X between submodules in a package

2007-12-19 Thread Bruno Desthuilliers
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

Re: import X between submodules in a package

2007-12-19 Thread Donn Ingle
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

Re: import X between submodules in a package

2007-12-19 Thread Donn Ingle
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

Re: import X between submodules in a package

2007-12-19 Thread Chris
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

Re: import X between submodules in a package

2007-12-19 Thread Bruno Desthuilliers
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

import X between submodules in a package

2007-12-18 Thread Donn Ingle
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

Re: Python submodules and name imports

2007-08-23 Thread Pádraig
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'

Python submodules and name imports

2007-08-23 Thread Frank Aune
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_

Re: access to submodules

2006-07-20 Thread TG
okay, thanks everyone. this is much clearer now. -- http://mail.python.org/mailman/listinfo/python-list

Re: access to submodules

2006-07-19 Thread Peter Otten
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

Re: access to submodules

2006-07-19 Thread TG
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

Re: access to submodules

2006-07-19 Thread Peter Otten
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

Re: access to submodules

2006-07-19 Thread TG
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

Re: access to submodules

2006-07-19 Thread BartlebyScrivener
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

Re: access to submodules

2006-07-19 Thread TG
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"

Re: access to submodules

2006-07-19 Thread BartlebyScrivener
>> > 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

Re: access to submodules

2006-07-19 Thread TG
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

access to submodules

2006-07-19 Thread TG
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