Re: python3 package import difference?

2024-08-08 Thread Cameron Simpson via Python-list
On 08Aug2024 21:55, Gilmeh Serda wrote: I guess in a sense Py2 was smarter figuring out what whent where and where it came from. Or it was a bad hack that has been removed. No, Python 2 offered less control. -- https://mail.python.org/mailman/listinfo/python-list

Re: python3 package import difference?

2024-08-07 Thread Cameron Simpson via Python-list
On 07Aug2024 08:35, Tobiah wrote: When I do the same import with python3, I get: Traceback (most recent call last): File "/home/toby/me", line 1, in import rcs.dbi File "/usr/regos-1.0/lib/python/rcs/dbi/__init__.py", line 1, in from dbi import * ModuleNotFoundEr

Re: python3 package import difference?

2024-08-07 Thread Chris Angelico via Python-list
On Thu, 8 Aug 2024 at 03:40, Tobiah via Python-list wrote: > The one under rcs.dbi contains: > > from dbi import * > from regos import * > You probably want these to be package-relative now: from .dbi import * from .regos import * Or, since you're using namespaced imports anyway ("rcs

Re: python3 package import difference?

2024-08-07 Thread Ronaldo Sc via Python-list
I believe you will need to track the modules in the folder *dbi *in the root file '__init__.py'. So there's an alternative to use the statement __all__ in the root filet __init__.py, check the link where I find a use case: *https://sentry.io/answers/what-is-init-py-for-in-python/#using-__init__

python3 package import difference?

2024-08-07 Thread Tobiah via Python-list
I have an old library from 20 some years ago for use with python2, that is structured like this: rcs ├── dbi │   ├── __init__.py │   ├── dbi.py │   └── regos.py └── __init__.py -- *empty* the __init__.py file under 'rcs' is empty. The one under rcs.dbi contains:

Re: package import dangers

2009-10-09 Thread Ethan Furman
Thanks to all for the answers! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: package import dangers

2009-10-06 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 06 Oct 2009 21:44:35 -0400, Dave Angel wrote: I'm surprised to see you missed this. A module doesn't generally import itself, but it's an easy mistake for a circular dependency to develop among modules. Circular imports are always a difficulty. That has

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 21:44:35 -0400, Dave Angel wrote: > I'm surprised to see you missed this. A module doesn't generally import > itself, but it's an easy mistake for a circular dependency to develop > among modules. Circular imports are always a difficulty. That has nothing to do with making m

Re: package import dangers

2009-10-06 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: The most common problem is that a file is used as module and as executable at the same time. Like this: --- test.py --- class Foo(object): pass if __name__ == "__main__": import test assert Foo

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 17:01:41 -0700, Carl Banks wrote: >> Why would a module need to import itself? Surely that's a very rare >> occurrence -- I think I've used it twice, in 12 years or so. I don't >> see why you need to disparage the idea of combining modules and scripts >> in the one file because

Re: package import dangers

2009-10-06 Thread Carl Banks
On Oct 6, 3:56 pm, Steven D'Aprano wrote: > On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: > > The most common problem is that a file is used as module and as > > executable at the same time. > > > Like this: > > > --- test.py --- > > > class Foo(object): > >     pass > > > if __name_

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: > The most common problem is that a file is used as module and as > executable at the same time. > > Like this: > > --- test.py --- > > class Foo(object): > pass > > > if __name__ == "__main__": >import test >assert Foo i

Re: package import dangers

2009-10-06 Thread Diez B. Roggisch
Ethan Furman wrote: > Greetings! > > I'm working on a package with multiple modules (and possibly packages), > and I would like to do it correctly. :) > > I have read of references to possible issues regarding a module being > imported (and run) more than once, but I haven't been able to find >

package import dangers

2009-10-06 Thread Ethan Furman
Greetings! I'm working on a package with multiple modules (and possibly packages), and I would like to do it correctly. :) I have read of references to possible issues regarding a module being imported (and run) more than once, but I haven't been able to find actual examples of such failing

Re: on package import, have it conditionally import a subpackage

2009-09-21 Thread Gabriel Genellina
En Sat, 19 Sep 2009 17:06:11 -0300, Gabriel Rossetti escribió: Hello everyone, I'd like to ba able to import a package and have it's __init__ conditionally import a subpackage. Suppose that you have this structure : mybase/ mybase/__init__.py mybase/mypkg mybase/mypkg/__init__.py mybase/

Re: on package import, have it conditionally import a subpackage

2009-09-20 Thread ryles
On Sep 19, 4:06 pm, Gabriel Rossetti wrote: > Hello everyone, > > I'd like to ba able to import a package and have it's __init__ > conditionally import a subpackage. Suppose that you have this structure : > > mybase/ > mybase/__init__.py > mybase/mypkg > mybase/mypkg/__init__.py > mybase/mypkg/mod

on package import, have it conditionally import a subpackage

2009-09-19 Thread Gabriel Rossetti
Hello everyone, I'd like to ba able to import a package and have it's __init__ conditionally import a subpackage. Suppose that you have this structure : mybase/ mybase/__init__.py mybase/mypkg mybase/mypkg/__init__.py mybase/mypkg/module0.py mybase/mypkg/type1 mybase/mypkg/type1/__init__.py my

Re: from package import * without overwriting similarly named functions?

2008-10-25 Thread Fernando H. Sanches
Also, remember that since the latter functions will always overwrite the first, you can just reverse the order of the imports: from package2 import * from package1 import * This should preserve the functions of package1 over the other ones. -- http://mail.python.org/mailman/listinfo/python-list

Re: from package import * without overwriting similarly named functions?

2008-10-25 Thread Lie Ryan
On Fri, 24 Oct 2008 11:06:54 -0700, Reckoner wrote: > I have multiple packages that have many of the same function names. Is > it possible to do > > from package1 import * > from package2 import * > > without overwriting similarly named objects from package1 with material > in package2? How abou

Re: from package import * without overwriting similarly named functions?

2008-10-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Reckoner wrote: > I have multiple packages that have many of the same function names. Is > it possible to do > > from package1 import * > from package2 import * > > without overwriting similarly named objects from package1 with > material in package2? Avoid wildc

Re: from package import * without overwriting similarly named functions?

2008-10-24 Thread Rex
If you're concerned about specific individual functions, you can use: from package1 import some_function as f1 form package2 import some_function as f2 -- http://mail.python.org/mailman/listinfo/python-list

Re: from package import * without overwriting similarly named functions?

2008-10-24 Thread Tim Chase
I have multiple packages that have many of the same function names. Is it possible to do from package1 import * from package2 import * without overwriting similarly named objects from package1 with material in package2? How about a way to do this that at least gives a warning? Yeah, just use

Re: from package import * without overwriting similarly named functions?

2008-10-24 Thread Mike Driscoll
On Oct 24, 1:06 pm, Reckoner <[EMAIL PROTECTED]> wrote: > I have multiple packages that have many of the same function names. Is > it possible to do > > from package1 import * > from package2 import * > > without overwriting similarly named objects from package1 with > material in package2? How abo

from package import * without overwriting similarly named functions?

2008-10-24 Thread Reckoner
I have multiple packages that have many of the same function names. Is it possible to do from package1 import * from package2 import * without overwriting similarly named objects from package1 with material in package2? How about a way to do this that at least gives a warning? Thanks. -- http:/

Re: Relative Package Import

2008-07-10 Thread Thomas
Peter Otten wrote: Thomas wrote: Robert Hancock wrote: mypackage/ __init__.py push/ __init__.py dest.py feed/ __init__py subject.py In subject.py I have from ..push import dest T

Re: Relative Package Import

2008-07-09 Thread Peter Otten
Kay Schluehr wrote: > On 8 Jul., 21:09, Peter Otten <[EMAIL PROTECTED]> wrote: >> Robert Hancock wrote: >> > mypackage/ >> > __init__.py >> > push/ >> > __init__.py >> > dest.py >> > feed/ >> >__init__py >> >

Re: Relative Package Import

2008-07-09 Thread Kay Schluehr
On 8 Jul., 21:09, Peter Otten <[EMAIL PROTECTED]> wrote: > Robert Hancock wrote: > > mypackage/ > > __init__.py > > push/ > > __init__.py > > dest.py > > feed/ > >__init__py > > subject.py

Re: Relative Package Import

2008-07-09 Thread Peter Otten
Thomas wrote: > Robert Hancock wrote: >> mypackage/ >> __init__.py >> push/ >> __init__.py >> dest.py >> feed/ >>__init__py >> subject.py >> >> In subject.py I have >> from ..push im

Re: Relative Package Import

2008-07-09 Thread Thomas
Robert Hancock wrote: mypackage/ __init__.py push/ __init__.py dest.py feed/ __init__py subject.py In subject.py I have from ..push import dest There is no such thing as relative p

Re: Relative Package Import

2008-07-08 Thread Peter Otten
Robert Hancock wrote: > mypackage/ > __init__.py > push/ > __init__.py > dest.py > feed/ >__init__py > subject.py > > In subject.py I have > from ..push import dest > > But i receiv

Re: Relative Package Import

2008-07-08 Thread Remy Blank
Robert Hancock wrote: mypackage/ __init__.py push/ __init__.py dest.py feed/ __init__py ^ Missing dot here? ---| In subject.py I have from ..push import dest But

Relative Package Import

2008-07-08 Thread Robert Hancock
mypackage/ __init__.py push/ __init__.py dest.py feed/ __init__py subject.py In subject.py I have from ..push import dest But i receive the error: Caught exception importing module

Re: A package import question

2008-06-15 Thread Gabriel Genellina
En Fri, 13 Jun 2008 22:38:24 -0300, Dan Yamins <[EMAIL PROTECTED]> escribió: >> Gabriel, thanks. I understood about the fact that import only loads the > first time, but didn't realize that "del" only removes the bound reference > to the object, not as I had hoped the thing from the namespace its

Re: A package import question

2008-06-13 Thread Dan Yamins
7;s >> been imported, and then reimporting. (I'm the sure the problem is >> trivial, >> but I just don't understand it.) >> >> I have a directory of python modules called Operations. It contains a >> python module called archive.py.Here's

Re: A package import question

2008-06-13 Thread Gabriel Genellina
t.) I have a directory of python modules called Operations. It contains a python module called archive.py.Here's a import of the archive module via package import: Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type "help&

A package import question

2008-06-13 Thread Dan Yamins
le called archive.py.Here's a import of the archive module via package import: Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information

Re: Determining which things in 'from package import *' are actually used

2008-06-10 Thread Patrick Bouffard
On Jun 10, 3:03 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > Patrick Bouffard wrote: > > I have a fairly large library of Python code, where 'from package import *' > > is > > used rather liberally, and it's not uncommon for more than one of these to >

Re: Determining which things in 'from package import *' are actually used

2008-06-10 Thread Robert Kern
Patrick Bouffard wrote: I have a fairly large library of Python code, where 'from package import *' is used rather liberally, and it's not uncommon for more than one of these to appear in any given module. What I'd like to be able to do is to clean my code up a bit and tu

Determining which things in 'from package import *' are actually used

2008-06-10 Thread Patrick Bouffard
I have a fairly large library of Python code, where 'from package import *' is used rather liberally, and it's not uncommon for more than one of these to appear in any given module. What I'd like to be able to do is to clean my code up a bit and turn each of the 'from pac

Re: package import

2008-02-06 Thread Sean Allen
Thanks. Found that 10 minutes after I sent. On Feb 6, 2008, at 4:57 AM, Diez B. Roggisch wrote: > Sean Allen wrote: > >> ok, what am i doing wrong? >> >> in current working directory i have: >> >> t.py >> sub/t1.py >> >> t.py is: >> >> import sub.t1 >> >> i get: >> >> ImportError: No module named

Re: package import

2008-02-06 Thread Diez B. Roggisch
Sean Allen wrote: > ok, what am i doing wrong? > > in current working directory i have: > > t.py > sub/t1.py > > t.py is: > > import sub.t1 > > i get: > > ImportError: No module named sub.t1 > > t.py is > > import sub > > i get: > > ImportError: No module named sub.t1 > > -- > > i am o

Re: package import

2008-02-05 Thread Steve Holden
Sean Allen wrote: > ok, what am i doing wrong? > > in current working directory i have: > > t.py > sub/t1.py > > t.py is: > > import sub.t1 > > i get: > > ImportError: No module named sub.t1 > > t.py is > > import sub > > i get: > > ImportError: No module named sub.t1 > > -- > > i am ob

package import

2008-02-05 Thread Sean Allen
ok, what am i doing wrong? in current working directory i have: t.py sub/t1.py t.py is: import sub.t1 i get: ImportError: No module named sub.t1 t.py is import sub i get: ImportError: No module named sub.t1 -- i am obviously missing something really basic here. have tried on multiple ma

Re: Library package import question

2007-11-05 Thread Gabriel Genellina
En Mon, 05 Nov 2007 10:34:26 -0300, Frank Aune <[EMAIL PROTECTED]> escribió: > I have a python library package 'Foo', which contains alot of submodules: > > Foo/: > __init__.py > module1.py: > class Bar() > class Hmm() > module2.py > cl

Re: Library package import question

2007-11-05 Thread Martin Marcher
2007/11/5, Frank Aune <[EMAIL PROTECTED]>: > To prevent namespace pollution, I want to import and use this library in the > following way: > > import Foo > (...) > t = Foo.module2.Bee() from x import y as z that has always worked for me to prevent pollution... -- http://noneisyours.marcher.na

Library package import question

2007-11-05 Thread Frank Aune
Hello, I have a python library package 'Foo', which contains alot of submodules: Foo/: __init__.py module1.py: class Bar() class Hmm() module2.py class Bee() class Wax() module3.py etc

Re: package import question

2007-10-22 Thread Phoe6
On Oct 22, 1:24 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Phoe6 wrote: > > Hi all, > > I have the following directory structure: > > > wallpaper/ > > -main.py > > -ng/ > > -- __init__.py > > -- setdesktop.py > > -yb/ > >

Re: package import question

2007-10-22 Thread Peter Otten
Phoe6 wrote: > Hi all, > I have the following directory structure: > > wallpaper/ > -main.py > -ng/ > -- __init__.py > -- setdesktop.py > -yb/ > -- __init__.py > -- setdesktop.py > >>Fro

Re: package import question

2007-10-22 Thread Diez B. Roggisch
Phoe6 wrote: > Hi all, > I have the following directory structure: > > wallpaper/ > -main.py > -ng/ > -- __init__.py > -- setdesktop.py > -yb/ > -- __init__.py > -- setdesktop.py > >>Fro

package import question

2007-10-22 Thread Phoe6
Hi all, I have the following directory structure: wallpaper/ -main.py -ng/ -- __init__.py -- setdesktop.py -yb/ -- __init__.py -- setdesktop.py >From main.py, I would like to do: import n

Re: file / module / package - import problem

2007-05-31 Thread EuGeNe Van den Bulke
aspineux wrote: > import os.path > > file=open(os.path.join(os.path.dirname(__file__), 'hauteur.yaml')) Thanks that worked ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: file / module / package - import problem

2007-05-30 Thread aspineux
The filename and its path is in global variable __file__ (that is different in any source file) try import os.path file=open(os.path.join(os.path.dirname(__file__), 'hauteur.yaml')) On 30 mai, 22:22, EuGeNe Van den Bulke <[EMAIL PROTECTED]> wrote: > Hi there, > > I have a "problem" which co

file / module / package - import problem

2007-05-30 Thread EuGeNe Van den Bulke
Hi there, I have a "problem" which could be a bad design on my behalf but I am not sure so ... I have a package WMI which contains a module hauteur.py which, when imported, load data from a file located in WMI/data/. In hauteur.py I call open('data/hauteur.yaml'). test.py WMI/ hauteur.py

Re: The difference between "import package.module" and "from package import module"(about pymol)

2005-12-16 Thread Ben Finney
Xiao Jianfeng <[EMAIL PROTECTED]> writes: > In pymol I can use "from chempy import Atom" but "import chempy.Atom" > doesn't work. > It says,"ImportError: No module named Atom". What is going wrong ? I would trust the error message first, and check your assumption. Is 'chempy' actually a package,

The difference between "import package.module" and "from package import module"(about pymol)

2005-12-15 Thread Xiao Jianfeng
Hello, In pymol I can use "from chempy import Atom" but "import chempy.Atom" doesn't work. It says,"ImportError: No module named Atom". What is going wrong ? Thanks -- http://mail.python.org/mailman/listinfo/python-list