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
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
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
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__
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:
Thanks to all for the answers!
:)
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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_
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
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
>
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
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/
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
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
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
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
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
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
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
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
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:/
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
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
>> >
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
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
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
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
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
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
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
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
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&
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
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
>
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
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
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
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
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
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
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
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
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
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/
> >
Phoe6 wrote:
> Hi all,
> I have the following directory structure:
>
> wallpaper/
> -main.py
> -ng/
> -- __init__.py
> -- setdesktop.py
> -yb/
> -- __init__.py
> -- setdesktop.py
>
>>Fro
Phoe6 wrote:
> Hi all,
> I have the following directory structure:
>
> wallpaper/
> -main.py
> -ng/
> -- __init__.py
> -- setdesktop.py
> -yb/
> -- __init__.py
> -- setdesktop.py
>
>>Fro
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
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
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
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
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,
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
55 matches
Mail list logo