Re: Question about import

2015-09-10 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidm3khnagtt0ohveo5bhqk1tfejbuuuinw9tnuxrpnr...@mail.gmail.com... On Thu, Sep 10, 2015 at 1:12 AM, Frank Millman wrote: > That makes me wonder if, in my project, I can import all modules inside > 'start.py', and then just use 'import package_name' inside

Re: Question about import

2015-09-10 Thread dieter
"Frank Millman" writes: >... > My project comprises a number of modules, split into packages. Modules > frequently need to access the contents of other modules, in the same > or in a different package. I am getting better at it, but I still > occasionally bump my head against circular imports, and

Re: Question about import

2015-09-10 Thread Ian Kelly
On Thu, Sep 10, 2015 at 8:47 AM, Peter Otten <__pete...@web.de> wrote: > Ian Kelly wrote: >> That surprises me also, but I suspect it's because they're >> subdirectories of the current working directory rather than packages >> found on the sys.path. > > So even the experts cannot keep up with all t

Re: Question about import

2015-09-10 Thread Peter Otten
Ian Kelly wrote: > On Thu, Sep 10, 2015 at 1:12 AM, Frank Millman wrote: >> That makes me wonder if, in my project, I can import all modules inside >> 'start.py', and then just use 'import package_name' inside each module? > > You can, but for readability and reuse I think it's better to be > ex

Re: Question about import

2015-09-10 Thread Ian Kelly
On Thu, Sep 10, 2015 at 1:12 AM, Frank Millman wrote: > That makes me wonder if, in my project, I can import all modules inside > 'start.py', and then just use 'import package_name' inside each module? You can, but for readability and reuse I think it's better to be explicit in each module and im

Re: Question about import hooks

2013-11-23 Thread Mark Lawrence
On 23/11/2013 12:23, Ed Schofield wrote: Hi all, I am the author of the ``future`` package for Python 2/3 compatibility (http://python-future.org). A bug report has recently been posted about its use of import hooks that I don't yet have an answer for, and I am looking for some guidance on ho

Re: question about import

2008-06-12 Thread Jonathan Vanasco
On Jun 11, 1:45 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Is it cursed upon? Didn't know that. I didn't either. Until I asked some people how to do it, and was admonished for even suggesting the concept. > However, __import__ only gives you the topmost module - in your case myapp. ah,

Re: question about import

2008-06-11 Thread Diez B. Roggisch
Jonathan Vanasco schrieb: I'm a little unclear about import / __import__ I'm exploring dynamically importing modules for a project, and ran into this behavior works as expected: app = __import__( myapp ) appModel = __import__( myapp.model ) but... appname= 'myapp' app = __impor

Re: Question about import and sys.path

2006-11-29 Thread Rob Wolfe
Frank Millman wrote: > One small point. The docs have the following warning - > > "Important: the caller is responsible for closing the file argument, if > it was not None, even when an exception is raised. This is best done > using a try ... finally statement. " > > I have added this to my code.

Re: Question about import and sys.path

2006-11-28 Thread Frank Millman
Rob Wolfe wrote: > Frank Millman wrote: > > Hi all > > > > However, I want the ability to have duplicate program names stored in > > different subdirectories. At the time of selecting the menu option I > > know which company is active, so I know which directory I want to run > > the program from,

Re: Question about import and sys.path

2006-11-28 Thread Rob Wolfe
Frank Millman wrote: > Hi all > > I am writing a business/accounting application. Once a user has logged > in they are presented with a menu. Each menu option has a description > and an associated file name and program name. The file name is the name > of a .py file (impName) and the program name

Re: Question about import and namespace

2006-09-01 Thread jdemoor
Ok, thanks again. That was helpful. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about import and namespace

2006-09-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, jdemoor wrote: >> from module import * >> import module >> >> as these kinds of import are not mutually exclusive. > > Would this run the code in 'module' twice, or just make the objects in > it accessible by several names ? The code at module level is only executed at fi

Re: Question about import and namespace

2006-09-01 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Thanks for the replies. > >> You can do both >> >> from module import * >> import module >> >> as these kinds of import are not mutually exclusive. > > Would this run the code in 'module' twice, or just make the objects in > it accessible by several names ? The latter

Re: Question about import and namespace

2006-09-01 Thread jdemoor
Thanks for the replies. > You can do both > > from module import * > import module > > as these kinds of import are not mutually exclusive. Would this run the code in 'module' twice, or just make the objects in it accessible by several names ? -- http://mail.python.org/mailman/listinfo/python-l

Re: Question about import and namespace

2006-09-01 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I'm new to Python and have the following problem : > I have an application started by a main.py file, which does a ' from > module_1 import * '. > main.py is responsible from the creation of an object which is then > used in module_1. > What is the best way to make that

Re: Question about import and namespace

2006-09-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, jdemoor wrote: > I have an application started by a main.py file, which does a ' from > module_1 import * '. > main.py is responsible from the creation of an object which is then > used in module_1. > What is the best way to make that object visible in the module_1 > namesp