Re: Imports and dot-notation

2023-08-10 Thread Mats Wichmann via Python-list
On 8/9/23 17:28, dn via Python-list wrote: Side note: Using "...import identifier, ..." does not save storage-space over "import module" (the whole module is imported regardless, IIRC), however it does form an "interface" and thus recommend leaning into the "Interface Segregation Principle", o

Re: Imports and dot-notation

2023-08-09 Thread Cameron Simpson via Python-list
On 09Aug2023 12:30, Oliver Schinagl wrote: Looking at a python projects code and repository layout, we see the following directory structure. /project/core /project/components/module1 ... /project/components/moduleN /projects/util (this is far from complete, but enough to help paint a pictur

Re: Imports and dot-notation

2023-08-09 Thread dn via Python-list
On 09/08/2023 22.30, Oliver Schinagl via Python-list wrote: ...> Looking at a python projects code and repository layout, we see the following directory structure. /project/core /project/components/module1 ... /project/components/moduleN /projects/util ...> Some modules import other modules, an

Re: Imports in Python

2014-01-21 Thread Ben Finney
Johannes Schneider writes: > I remember some document explaining the python imports in detail > somewhere, but I don't have any idea where it was. Even no idea if it > was in the List or some blogbost. What kind of detail do you want? > Does anybody of you have some suggestions where I can find

Re: Imports (in Py3), please help a novice

2013-06-16 Thread Chris Angelico
On Mon, Jun 17, 2013 at 4:46 AM, John Ladasky wrote: > I was trying to RTFM linearly, beginning (naturally) at the beginning Alas, the King of Hearts's good advice [1] doesn't work so well with large documentation. :) It seems distutils is rather more complicated than could be desired; but wasn't

Re: Imports (in Py3), please help a novice

2013-06-16 Thread John Ladasky
Thanks for your reply, Miki. On Sunday, June 16, 2013 7:50:53 AM UTC-7, Miki Tebeka wrote: > > Is there an import / distutils tutorial out there? I'm looking for it, but > > perhaps one of you already knows where to find it. Thanks! > > Did you have a look at http://docs.python.org/3.3/distuti

Re: Imports (in Py3), please help a novice

2013-06-16 Thread Miki Tebeka
> Is there an import / distutils tutorial out there? I'm looking for it, but > perhaps one of you already knows where to find it. Thanks! Did you have a look at http://docs.python.org/3.3/distutils/examples.html? Another thing to do is to look at what other packages on PyPi are doing. -- http

Re: Imports (in Py3), please help a novice

2013-06-15 Thread John Ladasky
Followup to my own post: I am sticking pretty closely to this example from Mike Driscoll which, admittedly, is based on Python 2.6: http://www.blog.pythonlibrary.org/2012/07/08/python-201-creating-modules-and-packages/ I'm trying to do this one step at a time. First try a local import, then i

Re: imports and exec

2010-05-17 Thread Paul Carter
On May 16, 4:22 pm, Patrick Maupin wrote: > On May 16, 1:51 pm, Paul Carter wrote: > > > > > We are using python for our build system. Each subproject dir has a > > python script that builds it. Parent dirs have python scripts that > > recurse into their children and use exec to invoke the python

Re: imports and exec

2010-05-16 Thread Patrick Maupin
On May 16, 1:51 pm, Paul Carter wrote: > We are using python for our build system. Each subproject dir has a > python script that builds it. Parent dirs have python scripts that > recurse into their children and use exec to invoke the python scripts. > Recently we discovered that one of the python

Re: Imports again...

2010-04-09 Thread Gabriel Genellina
En Fri, 09 Apr 2010 13:10:44 -0300, Alex Hall escribió: c:\Python26>python.exe i:\arm\main.pyw Traceback (most recent call last): File "i:\arm\main.pyw", line 3, in import arm, network, weather, dict File "i:\arm\arm.py", line 4, in import config File "i:\arm\config.py", line 4,

Re: Imports again...

2010-04-09 Thread Gabriel Genellina
En Fri, 09 Apr 2010 11:29:50 -0300, Tim Golden escribió: On 09/04/2010 15:19, Gabriel Genellina wrote: In addition to what Tim Golden has said (which appears to be based on another version of this project Just downloaded again, and there's definitely an empty package structure of the kin

Re: Imports again...

2010-04-09 Thread Ethan Furman
Tim Golden wrote: On 09/04/2010 15:19, Gabriel Genellina wrote: In addition to what Tim Golden has said (which appears to be based on another version of this project Just downloaded again, and there's definitely an empty package structure of the kind I described. (Altho' I certainly did have

Re: Imports again...

2010-04-09 Thread Alex Hall
Okay, what you all say makes sense, and I am going to try the package thing again. The "modes" dir is from my last attempt, as is its "weather" subdir. I think I see what I did wrong, at least I hope I do. I will also remove the init file from the main dir. Yes, "arm" is the main directory of the p

Re: Imports again...

2010-04-09 Thread Tim Golden
On 09/04/2010 15:19, Gabriel Genellina wrote: In addition to what Tim Golden has said (which appears to be based on another version of this project Just downloaded again, and there's definitely an empty package structure of the kind I described. (Altho' I certainly did have a few other versions

Re: Imports again...

2010-04-09 Thread Gabriel Genellina
On 8 abr, 10:16, Alex Hall wrote: > Hello all, once again:http://www.gateway2somewhere.com/sw/sw.zip > > The above link is to a project. I am new to using multiple files in > Python, and I have a lot of tangled imports where many files in the > same folder are importing each other. When I tried

Re: Imports again...

2010-04-09 Thread Thomas Guettler
Hi, please post your traceback. I guess you have a recursive import. This can lead to strange exceptions (for example AttributeError) Thomas Alex Hall wrote: > Hello all, once again: > http://www.gateway2somewhere.com/sw/sw.zip > > The above link is to a project. I am new to using multiple fil

Re: Imports again...

2010-04-09 Thread Tim Golden
On 08/04/2010 14:16, Alex Hall wrote: The above link is to a project. I am new to using multiple files in Python, and I have a lot of tangled imports where many files in the same folder are importing each other. When I tried to follow the manual to make some files into packages, it did not work.

Re: imports again

2010-04-07 Thread Gabriel Genellina
En Tue, 06 Apr 2010 14:25:38 -0300, Alex Hall escribió: Sorry this is a forward (long story involving a braille notetaker's bad copy/paste and GMail's annoying mobile site). Basically, I am getting errors when I run the project at http://www.gateway2somewhere.com/sw.zip Error 404 -- Gabriel

Re: imports in __init__.py

2009-12-26 Thread lotrpy
On Dec 18, 12:34 pm, Ben Finney wrote: > Phil writes: > > From an arbitrary python module, I 'import packagename'. > > At that point, you have all the names that were defined within > ‘packagename’, available inside the namespace ‘packagename’. Since > ‘modulename’ is a module in that package, th

Re: imports in __init__.py

2009-12-18 Thread Peter Otten
Phil wrote: > I wrote my last message late last night. When I said "I am unable to > import a module from the package without an import error.", I did mean > the 'modulename' module. > > However, I just set up a Debian VM with Python 2.5.2 and what I was > trying to do works. So it is either some

Re: imports in __init__.py

2009-12-18 Thread Phil
I wrote my last message late last night. When I said "I am unable to import a module from the package without an import error.", I did mean the 'modulename' module. However, I just set up a Debian VM with Python 2.5.2 and what I was trying to do works. So it is either something that changed with P

Re: imports in __init__.py

2009-12-18 Thread sKeeZe
I wrote my last message late last night. When I said "I am unable to import a module from the package without an import error.", I did mean the 'modulename' module. However, I just set up a Debian VM with Python 2.5.2 and what I was trying to do works. So it is either something that changed with P

Re: imports in __init__.py

2009-12-17 Thread Phil
I understand all of the above, including the reasons as to why this is bad. For purposes of experimenting, I would still like to do it. I guess I'm (still) wondering how it is done in webpy. I recall seeing it done elsewhere too. All I noticed was that in webpy's package 'web', it defines the 'ap

Re: imports in __init__.py

2009-12-17 Thread Ben Finney
Phil writes: > I use distutils / setup.py to install 'packagename', where... > /packagename > __init__.py > modulename.py > > modulename.py has a class named 'classname'. As per PEP 8, it's best if user-defined classes are named with TitleCase, so ‘ClassName’. > From an arbitrary python

Re: Imports in python are static, any solution?

2009-04-16 Thread Ravi
iplyXbyA(32) > > > Keeps your vars in a safer easier to handle, debug, and change kinda way > > Good luck > > > AJ > > > -Original Message- > > From: python-list-bounces+aj=xernova@python.org > > [mailto:python-list-bounces+aj=xernova@pytho

Re: Imports in python are static, any solution?

2009-04-13 Thread norseman
@python.org] On Behalf Of David Stanek Sent: Monday, April 13, 2009 12:12 PM To: Ravi Cc: python-list@python.org Subject: Re: Imports in python are static, any solution? On Mon, Apr 13, 2009 at 11:59 AM, Ravi wrote: foo.py : i = 10 def fi(): global i i = 99 bar.py : import

RE: Imports in python are static, any solution?

2009-04-13 Thread AJ Mayorga
Behalf Of David Stanek Sent: Monday, April 13, 2009 12:12 PM To: Ravi Cc: python-list@python.org Subject: Re: Imports in python are static, any solution? On Mon, Apr 13, 2009 at 11:59 AM, Ravi wrote: > foo.py : > >    i = 10 > >   def fi(): >      global i >      i = 99 > >

Re: Imports in python are static, any solution?

2009-04-13 Thread David Stanek
On Mon, Apr 13, 2009 at 11:59 AM, Ravi wrote: > foo.py : > >    i = 10 > >   def fi(): >      global i >      i = 99 > > bar.py : > >    import foo >    from foo import i > >    print i, foo.i >    foo.fi() >    print i, foo.i > > This is problematic. Well I want i to change with foo.fi() . Why n

Re: Imports in python are static, any solution?

2009-04-13 Thread Luis Alberto Zarrabeitia Gomez
Quoting Ravi : > > This is problematic. Well I want i to change with foo.fi() . You can't. i and foo.i are _different_ variables that just happen to share the same value initially. What you are observing is no different than i = 10 j = i i = 99 print i # prints 99 print j # print 10 May I

Re: Imports awareness in Imported modules problem

2008-08-24 Thread Gabriel Genellina
En Sun, 24 Aug 2008 07:34:41 -0300, Mohamed Yousef <[EMAIL PROTECTED]> escribió: > On Sun, Aug 24, 2008 at 9:59 AM, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> Mohamed Yousef wrote: >> >>> why am i doing this in the first place >>> I'm in the process of a medium project where imports of modules st

Re: Imports visibility in imported modules problem

2008-08-24 Thread Maric Michaud
Le Sunday 24 August 2008 12:11:03 Mohamed Yousef, vous avez écrit : > On Sun, Aug 24, 2008 at 5:54 AM, Patrick Maupin <[EMAIL PROTECTED]> wrote: > > On Aug 23, 7:27 pm, "Mohamed Yousef" <[EMAIL PROTECTED]> wrote: > >> The problem I'm asking about is how can imported modules be aware of > >> other i

Re: Imports awareness in Imported modules problem

2008-08-24 Thread Fredrik Lundh
Mohamed Yousef wrote: mm , this seems to be logically or another good behind logic . as PHP already uses that convention -from which i thought python also does - I'm not sure arguing with anyone who tries to help you is the best way to learn a new programming language. -- http://mail.pyth

Re: Imports awareness in Imported modules problem

2008-08-24 Thread alex23
On Aug 24, 9:43 pm, "Mohamed Yousef" <[EMAIL PROTECTED]> wrote: > but what about module-wide variables what is the approach to them , > will i have to store them in a memory table (SQL) , or keep passing > them between objects - which i really hate - If you have a set of global variables that you

Re: Imports awareness in Imported modules problem

2008-08-24 Thread Mohamed Yousef
On Sun, Aug 24, 2008 at 2:27 PM, alex23 <[EMAIL PROTECTED]> wrote: > On Aug 24, 8:34 pm, "Mohamed Yousef" <[EMAIL PROTECTED]> wrote: >> and sys ,string.. etc add them all twice or four / n times ? >> remove one and then forget to remove one of them in a file and start >> debugging ... this really

Re: Imports awareness in Imported modules problem

2008-08-24 Thread alex23
On Aug 24, 8:34 pm, "Mohamed Yousef" <[EMAIL PROTECTED]> wrote: > and sys  ,string.. etc add them all twice or four / n times ? > remove one and then forget to remove one of them in a file and start > debugging ... this really doesn't look to be a good practice No, having each module contain all o

Re: Imports awareness in Imported modules problem

2008-08-24 Thread Mohamed Yousef
On Sun, Aug 24, 2008 at 9:59 AM, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Mohamed Yousef wrote: > >> why am i doing this in the first place >> I'm in the process of a medium project where imports of modules start >> to make a jungle and i wanted all needed imports to be in a single >> file (namel

Re: Imports visibility in imported modules problem

2008-08-24 Thread Mohamed Yousef
On Sun, Aug 24, 2008 at 5:54 AM, Patrick Maupin <[EMAIL PROTECTED]> wrote: > On Aug 23, 7:27 pm, "Mohamed Yousef" <[EMAIL PROTECTED]> wrote: > >> The problem I'm asking about is how can imported modules be aware of >> other imported modules so they don't have to re-import them (avoiding >> importin

Re: Imports awareness in Imported modules problem

2008-08-24 Thread Fredrik Lundh
Mohamed Yousef wrote: why am i doing this in the first place I'm in the process of a medium project where imports of modules start to make a jungle and i wanted all needed imports to be in a single file (namely __init__.py) and then all imports are made once and other modules feel it Python do

Re: Imports visibility in imported modules problem

2008-08-23 Thread Terry Reedy
Mohamed Yousef wrote: Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them If you want to use module A in both B and C, B and C should both import A. No problem. > (avoiding importing problems and Consic

Re: Imports visibility in imported modules problem

2008-08-23 Thread Patrick Maupin
On Aug 23, 7:27 pm, "Mohamed Yousef" <[EMAIL PROTECTED]> wrote: > The problem I'm asking about is how can imported modules be aware of > other imported modules so they don't have to re-import them (avoiding > importing problems and Consicing code and imports ) You could import sys and look at sys

Re: Imports in Packages

2007-12-17 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > While working within a package...what is the 'best practice' way to do > your imports. > > a/__init__.py > a/one.py > a/two.py > a/b/__init__.py > a/b/cat.py > a/b/dog.py > a/c/cow.py > Suppose I am working in a/c/cow.py and I need something from a/b/ > dog.py. If a/

Re: Imports

2007-03-20 Thread Steve Holden
7stud wrote: > On Mar 20, 6:33 pm, "7stud" <[EMAIL PROTECTED]> wrote: >> On Mar 20, 12:51 pm, [EMAIL PROTECTED] wrote: >> >>> I typically just import sys and then do a >>> sys.path.append(directoryPath). This basically makes whatever modules >>> in that path available at run time. If you need a beg

Re: Imports

2007-03-20 Thread 7stud
On Mar 20, 6:33 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Mar 20, 12:51 pm, [EMAIL PROTECTED] wrote: > > > I typically just import sys and then do a > > sys.path.append(directoryPath). This basically makes whatever modules > > in that path available at run time. If you need a beginners reference

Re: Imports

2007-03-20 Thread 7stud
On Mar 20, 12:51 pm, [EMAIL PROTECTED] wrote: > I typically just import sys and then do a > sys.path.append(directoryPath). This basically makes whatever modules > in that path available at run time. If you need a beginners reference > book, I recommend "Beginning Python" by Hetland. "Python Progra

Re: Imports

2007-03-20 Thread Gabriel Genellina
En Tue, 20 Mar 2007 16:25:41 -0300, <[EMAIL PROTECTED]> escribió: > Usually, the sys.path.append will allow Python to search the > subfolders too, but I have noticed that sometimes it doesn't if you > use UNC paths. I don't use jython, so maybe there's another way to fix > this that is more specif

Re: Imports

2007-03-20 Thread gtb
On Mar 20, 2:25 pm, [EMAIL PROTECTED] wrote: > On Mar 20, 1:59 pm, "gtb" <[EMAIL PROTECTED]> wrote: > > > > > On Mar 20, 1:51 pm, [EMAIL PROTECTED] wrote: > > > > On Mar 20, 1:31 pm, "gtb" <[EMAIL PROTECTED]> wrote: > > > > > I am working with a tool called maxQ that generates jython scripts. > > >

Re: Imports

2007-03-20 Thread kyosohma
On Mar 20, 1:59 pm, "gtb" <[EMAIL PROTECTED]> wrote: > On Mar 20, 1:51 pm, [EMAIL PROTECTED] wrote: > > > > > On Mar 20, 1:31 pm, "gtb" <[EMAIL PROTECTED]> wrote: > > > > I am working with a tool called maxQ that generates jython scripts. > > > The tool runs in > > > > C:\maxq\bin. > > > > Rather t

Re: Imports

2007-03-20 Thread gtb
On Mar 20, 1:51 pm, [EMAIL PROTECTED] wrote: > On Mar 20, 1:31 pm, "gtb" <[EMAIL PROTECTED]> wrote: > > > > > I am working with a tool called maxQ that generates jython scripts. > > The tool runs in > > > C:\maxq\bin. > > > Rather than clutter up bin I want to put the scripts and other .py > > scri

Re: Imports

2007-03-20 Thread kyosohma
On Mar 20, 1:31 pm, "gtb" <[EMAIL PROTECTED]> wrote: > I am working with a tool called maxQ that generates jython scripts. > The tool runs in > > C:\maxq\bin. > > Rather than clutter up bin I want to put the scripts and other .py > scripts in > > c:\maxq\bin\testScripts. > > When doing so the scrip