Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Courage is your greatest present need.


comp / comp.lang.python / python3 package import difference?

SubjectAuthor
* python3 package import difference?Tobiah
+- Re: python3 package import difference?Stefan Ram
+- Re: python3 package import difference?Ronaldo Sc
+- Re: python3 package import difference?Chris Angelico
+- Re: python3 package import difference?Cameron Simpson
`* Re: python3 package import difference?Gilmeh Serda
 `- Re: python3 package import difference?Cameron Simpson

1
Subject: python3 package import difference?
From: Tobiah
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Wed, 7 Aug 2024 15:35 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: toby@tobiah.org (Tobiah)
Newsgroups: comp.lang.python
Subject: python3 package import difference?
Date: Wed, 7 Aug 2024 08:35:36 -0700
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <v90488$35uk5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 07 Aug 2024 17:35:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f3108fa3e9eb03b4f30b4b6381ae7d92";
logging-data="3340933"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/x7gh4cfqkox4cb+QdQXK"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:43T271BcAX8aUN1t85jMxi882rw=
Content-Language: en-US
View all headers

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:

from dbi import *
from regos import *

With python2, I'd go:

import rcs.dbi

then I'd have access to stuff in regos.py
as:

rcs.dbi.feature() (Where 'feature' is defined in regos.py)

When I do the same import with python3, I get:

Traceback (most recent call last):
File "/home/toby/me", line 1, in <module>
import rcs.dbi
File "/usr/regos-1.0/lib/python/rcs/dbi/__init__.py", line 1, in <module>
from dbi import *
ModuleNotFoundError: No module named 'dbi'

What's changed, and how do I fix it?

Thanks!

Subject: Re: python3 package import difference?
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Wed, 7 Aug 2024 21:00 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: python3 package import difference?
Date: 7 Aug 2024 21:00:13 GMT
Organization: Stefan Ram
Lines: 23
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <import-20240807215947@ram.dialup.fu-berlin.de>
References: <v90488$35uk5$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de ZRXywW3Cw0ga9RM54nvg6gMjfPosl69sW0Rq7vkVLG3Bfr
Cancel-Lock: sha1:zaPfuqxTBmFXGELuWG0Z+Djdp4A= sha256:jrMZuBKN9tyIivMsCp4EMTkE79AmAz2PSOfnAYX79fU=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Tobiah <toby@tobiah.org> wrote or quoted:
>File "/usr/regos-1.0/lib/python/rcs/dbi/__init__.py", line 1, in <module>
>from dbi import *
>ModuleNotFoundError: No module named 'dbi'

The directory of the outermost script executed is in the system path.

E.g., the directory "d" when you invoke "python d/s.py".

To see the system path:

import sys
print( sys.path )

. "dbi" should not be in any of those directories in the system path.
Therefore, it is not found!

You could use a relative import:

from .dbi import *

or manipulate the sys.path (or an "editable install" of dbi might
also help, but I'm not sure about this as I have not tested it).

Subject: Re: python3 package import difference?
From: Ronaldo Sc
Newsgroups: comp.lang.python
Date: Wed, 7 Aug 2024 22:22 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rs.quim@gmail.com (Ronaldo Sc)
Newsgroups: comp.lang.python
Subject: Re: python3 package import difference?
Date: Wed, 7 Aug 2024 19:22:33 -0300
Lines: 79
Message-ID: <mailman.31.1723070433.2890.python-list@python.org>
References: <v90488$35uk5$1@dont-email.me>
<CAH1tj1Na56nc5B_tXKHFPLdLnMfVwkci0_NecCRktnNo0jBf4A@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de IOVVgSvJGTcIcNMQEsbJ9ApgRpW4MNOom8AXXaW8AzSw==
Cancel-Lock: sha1:Nhe7OAMBIa+EYbtuv+18zDKLnZ4= sha256:JQymJQ+K6yVgx2kUFaBJZ1iGPee2Ah8eqWXtK6mPdMg=
Return-Path: <rs.quim@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=P0Pd7hns;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'traceback':
0.04; '(most': 0.05; 'last):': 0.05; 'modules': 0.07;
'subject:import': 0.07; 'cc:addr:python-list': 0.09; 'email
addr:python.org>': 0.09; 'inject': 0.09; 'skip:\xc2 20': 0.09;
'url-ip:151.101.0.223/32': 0.09; 'url-ip:151.101.128.223/32':
0.09; 'url-ip:151.101.192.223/32': 0.09; 'url-
ip:151.101.64.223/32': 0.09; 'url:modules': 0.09; 'cc:no real
name:2**0': 0.14; 'import': 0.15; 'url:mailman': 0.15; 'memory':
0.15; '"import': 0.16; '--\xc2\xa0': 0.16; '2024': 0.16; 'case:':
0.16; 'issues:': 0.16; 'subject:package': 0.16; 'url:peps': 0.16;
'using.': 0.16; '\xc2\xa0file': 0.16; '\xc2\xa0in': 0.16; 'code.':
0.17; 'it?': 0.19; 'cc:addr:python.org': 0.20; 'skip:_ 10': 0.22;
"what's": 0.22; 'code': 0.23; 'thanks!': 0.24; "i'd": 0.24; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'examples': 0.25; 'stuff': 0.25; 'url:listinfo': 0.25; 'cc:2**0':
0.25; 'url-ip:188.166/16': 0.25; 'library': 0.26; 'old': 0.27;
'email addr:python.org&gt;': 0.28; '8bit%:19': 0.31; 'deep': 0.31;
'module': 0.31; 'url-ip:188/8': 0.31; 'formats': 0.32; 'python-
list': 0.32; 'message-id:@mail.gmail.com': 0.32; 'there': 0.33;
'same': 0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com':
0.34; 'track': 0.35; 'from:addr:gmail.com': 0.35; 'fix': 0.36;
'those': 0.36; "skip:' 10": 0.37; 'using': 0.37; 'file': 0.38;
'ago': 0.39; 'use': 0.39; "there's": 0.61; 'above': 0.62; 'url-
ip:151.101.0/24': 0.62; 'url-ip:151.101.128/24': 0.62; 'url-
ip:151.101.192/24': 0.62; 'url-ip:151.101.64/24': 0.62; 'skip:m
20': 0.63; 'share': 0.63; '8bit%:9': 0.64; 'updates': 0.64;
'ago.': 0.64; 'your': 0.64; 'named': 0.65; 'years': 0.65;
"you'll": 0.73; '<>*': 0.74; 'features': 0.75; 'changed,': 0.84;
'contains:': 0.84; 'email name:&lt;python-list': 0.84; 'garbage':
0.84; 'skip:" 40': 0.84; 'skip:& 50': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1723069365; x=1723674165; darn=python.org;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=9xSXJIVwtJ25PysolW1NVl+gyrgOhoEeBOr9R5rrGgI=;
b=P0Pd7hns5DeZsWN71qGASCWN6enVqkbQXmKPiSwrpBKcmqdunr0UYQywFPQd0cqyRi
NtA2eoYWu6p9X4ZxBtW2/yxJJIer4rvANV6NuN8lk28o4kmnJDekg7Dj6rBOnjTMs+C2
7vzr2K0qZYjE9x6AEexF1CpXcDc95XeKfsHOugGWHkkiHIrhsW7UyLlijfeHFnIVnfv9
IfQFQ97f+M3wWGWsQstG13BqwVCrqmRu8j2VtzHEVc0Y+1MTF+KsGBafGycR2/rQCsrJ
AzxJlsz3MXhYwwA4bPWvEDl8o3vlVcZ5g/YaS2IZcQmR9saYu9AiQmuu04CJaRBXpTzN
w6vw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1723069365; x=1723674165;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=9xSXJIVwtJ25PysolW1NVl+gyrgOhoEeBOr9R5rrGgI=;
b=F1e82t6+BxQ4f91H7tyrg57/czf+OuvrOOJQNs3ykRl6yD8kPnOBdkgdlpT6zyRCUf
Z6+wSc7Z0Y+pGqjrBXfbMfRAVoKLT+zitWFaWHYgEPkKtgf3PdaycaH2a7ZPO/qae1ye
0+oCN0BiMNkPAAVSh2eFMiaJMlpflE0pPzRRxv/oop0Bd8uXEazvac4p/gkKxXlTgIBf
Y64BEXcKwm95oicGKvMutLubuASgcE3ETaw2/8ooOqfCWshfAL1BljqNHAbWyzlSYCGA
Ird3M0KN9fG1FtsTmsAbCq4vgCPSrQwD5+CN3+6hvettzO9KgB6Xn8k+76iMv82U+Fnt
GaXA==
X-Gm-Message-State: AOJu0YzY1A5bLaZJVUzjQZO5h22A6u7FFBcuEqQOlalgCtZfU3mg2ciw
w9q8lYdY9UZymeoQhZGH4kMSa7OwTD/NN5DayBTqjxxb3GezEK80TE8hTgNL1UgP3QwnK4i7C/Y
esubD5lc3uw2yGjCLGQm4gIhsycMrL1xFWNc=
X-Google-Smtp-Source: AGHT+IE9QOTR1XXPsQd5RUARo4N/yvA0+pWEOYppvfuXsbk9nI3HZ59mFEb2jAEddkVmculQcg2WwsWZkv13sjc1MNY=
X-Received: by 2002:a05:6902:a90:b0:e0e:4572:a293 with SMTP id
3f1490d57ef6-e0e9dc0492bmr24541276.47.1723069365046; Wed, 07 Aug 2024
15:22:45 -0700 (PDT)
In-Reply-To: <v90488$35uk5$1@dont-email.me>
X-Mailman-Approved-At: Wed, 07 Aug 2024 18:40:31 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAH1tj1Na56nc5B_tXKHFPLdLnMfVwkci0_NecCRktnNo0jBf4A@mail.gmail.com>
X-Mailman-Original-References: <v90488$35uk5$1@dont-email.me>
View all headers

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__py-to-run-code-and-control--imports
<https://sentry.io/answers/what-is-init-py-for-in-python/#using-__init__py-to-run-code-and-control--imports>*

References to take more deep in those issues:
PEP-3147 <https://peps.python.org/pep-3147/>
https://docs.python.org/3/tutorial/modules.html
<https://docs.python.org/3/tutorial/modules.html#intra-package-references>
in this link above we have some examples of relative imports:
from . import echo
from .. import formats
from ..filters import equalizer

In your code you're using "import *" , this is not a good practice when
using only some features in your module(s) because you'll inject more
garbage into memory if there are features you're not using.

Share with us the updates on your code.

Ronaldo

Em qua., 7 de ago. de 2024 às 14:40, Tobiah via Python-list <
python-list@python.org> escreveu:

> 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:
>
> from dbi import *
> from regos import *
>
>
> With python2, I'd go:
>
> import rcs.dbi
>
> then I'd have access to stuff in regos.py
> as:
>
> rcs.dbi.feature() (Where 'feature' is defined in regos.py)
>
>
> When I do the same import with python3, I get:
>
> Traceback (most recent call last):
> File "/home/toby/me", line 1, in <module>
> import rcs.dbi
> File "/usr/regos-1.0/lib/python/rcs/dbi/__init__.py", line 1, in
> <module>
> from dbi import *
> ModuleNotFoundError: No module named 'dbi'
>
>
> What's changed, and how do I fix it?
>
>
> Thanks!
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Subject: Re: python3 package import difference?
From: Chris Angelico
Newsgroups: comp.lang.python
Date: Wed, 7 Aug 2024 22:43 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: python3 package import difference?
Date: Thu, 8 Aug 2024 08:43:54 +1000
Lines: 19
Message-ID: <mailman.32.1723070648.2890.python-list@python.org>
References: <v90488$35uk5$1@dont-email.me>
<CAPTjJmozm5V17Ppra+JTvkiCqMzPQHV2RzRG1A2UGFZTe8m81w@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de vegcW/5W5m7th+jA5BBZXQHPym4q2Zw5o0TiGUG7BFIQ==
Cancel-Lock: sha1:ZJUafRU+L2uT5GD1Lt7zRU3NiGA= sha256:8prZ2DYEApHkjg9NNXxf7B/QXipGVmBClVsEZQVlvgI=
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=OJsJrnEE;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'aug': 0.07;
'subject:import': 0.07; 'import': 0.15; '2024': 0.16; 'chrisa':
0.16; 'form:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'subject:package': 0.16; 'wrote:': 0.16;
'probably': 0.17; 'thu,': 0.19; 'to:addr:python-list': 0.20;
'python-list': 0.32; 'message-id:@mail.gmail.com': 0.32; 'header
:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'using': 0.37; 'want': 0.40;
'contains:': 0.84; 'imports': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1723070646; x=1723675446; darn=python.org;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=cH/6N0BX+eFxR0Objc+csEj0nDSsngsHhAEvqL4gzwQ=;
b=OJsJrnEELs8MVnsbzHLVzszug36Dtwr9PDU4qF2rcWdlgQgSEYFDrInu84P7hfGYNO
ez0JSZyoEjyp7Zl2hkJqF+Yp3vWA44QLw64psuTNVp1FkHQ5Dmxp/IXF0dDAiuAq6bPx
8wOjM6S/ZCB3seGIbU+x3ThikeJO2LiFehkkYdAix1SyL/IATan3tF5InccEqR69GVtS
/PNncq4fh8MkoaYHmSPP3bhxxR9ABC/IhWYl57TMczqSoGYW2319NPN/mxvUYzGlhVwb
87jaiUigwApviSrPbw1dFqvryP9QOg6RxteNhOMKSyBiwKKAH86cdcNgMHeH1if4C86N
BqEA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1723070646; x=1723675446;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=cH/6N0BX+eFxR0Objc+csEj0nDSsngsHhAEvqL4gzwQ=;
b=DdqNTy5+6D+plaJXYda5G6Wll72X++JtWCM6yLvRCC1pcJsqwfsB6QERvUiArYc/4f
0qA/Oq/qU2VNiEKx9nKzduf/Up9foMImSrOC52/Xf7VjUahfLyMKBTuMxlvaTUCU4rRT
UtsJq+71Vb4qQxMos5LDBySXx06DlTuQwLKKBv9oZTJnh91pJ/XQ1ly/EVyyPENMeN9r
vSM8JjMleKsFH+H8ni/ifIOI6D34R06/9W6/2g1WQcTxc4AfluytC3vA1NcsSaSaU+tY
1ihLIgFXdI9UXr6Zniwj6hZdpm61PiOuQziPJojiRkydr39606hWUAf+X9Krcg+eHvQI
OXSQ==
X-Gm-Message-State: AOJu0YwgMSJUcJoLDf0s0AdTXx442k1uJainccD54JXypMDPf3+/xHde
Q+s5ZV9KdcxYNyckVOxxb+tN9v2bx2Ty4ZBhz3tXXbgH2kv4pYC2LXE3xpG+f9IAkWgzdn+5ICG
DBRR4GfiwGJvZVbIIXt4rhxoAfQqh5Q==
X-Google-Smtp-Source: AGHT+IHV5mv86+HneAchstSaraNk7SJzmojMiRfZyTNz2tqP9jZUsis55ZLpuJYSisD+CW+Jj84DPHz5xrtx9eY1qek=
X-Received: by 2002:a05:6512:3dab:b0:52e:941d:7039 with SMTP id
2adb3069b0e04-530bb39bf77mr13312034e87.59.1723070645791; Wed, 07 Aug 2024
15:44:05 -0700 (PDT)
In-Reply-To: <v90488$35uk5$1@dont-email.me>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmozm5V17Ppra+JTvkiCqMzPQHV2RzRG1A2UGFZTe8m81w@mail.gmail.com>
X-Mailman-Original-References: <v90488$35uk5$1@dont-email.me>
View all headers

On Thu, 8 Aug 2024 at 03:40, Tobiah via Python-list
<python-list@python.org> 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.dbi.feature"),
you may prefer this form:

from . import dbi, regos

ChrisA

Subject: Re: python3 package import difference?
From: Cameron Simpson
Newsgroups: comp.lang.python
Date: Thu, 8 Aug 2024 01:17 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: python3 package import difference?
Date: Thu, 8 Aug 2024 11:17:56 +1000
Lines: 17
Message-ID: <mailman.34.1723079886.2890.python-list@python.org>
References: <v90488$35uk5$1@dont-email.me> <ZrQcxHnUn0bLK46t@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de 0vdyTjPvv8vv0t+rNHIRBQrDiFY5TsWRa6kCEOO/0p+A==
Cancel-Lock: sha1:2hnT+B3769UU5qi/2uF3SMgxpDY= sha256:MojLgztwfBvNfi20cuzX6aJsPk4t7oRhZkizzMw7QkY=
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'traceback': 0.04; '(most':
0.05; 'absolute': 0.05; 'last):': 0.05; 'subject:import': 0.07;
'cc:addr:python-list': 0.09; 'cheers,': 0.11; 'cc:no real
name:2**0': 0.14; 'import': 0.15; 'cameron': 0.16; 'from:addr:cs':
0.16; 'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson':
0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:13.237':
0.16; 'received:13.237.201': 0.16; 'received:13.237.201.189':
0.16; 'received:cskk.id.au': 0.16; 'received:id.au': 0.16;
'received:mail.cskk.id.au': 0.16; 'simpson': 0.16;
'subject:package': 0.16; 'wrote:': 0.16; 'python': 0.16;
'cc:addr:python.org': 0.20; 'cc:2**0': 0.25; 'header:User-
Agent:1': 0.30; 'module': 0.31; 'same': 0.34; 'package': 0.34;
'header:In-Reply-To:1': 0.34; 'received:au': 0.35; 'file': 0.38;
'want': 0.40; 'skip:m 20': 0.63; 'received:13': 0.64; 'top': 0.65;
'named': 0.65; 'received:userid': 0.66; 'imports': 0.84; 'skip:"
40': 0.84
Mail-Followup-To: Tobiah <toby@tobiah.org>, python-list@python.org
Content-Disposition: inline
In-Reply-To: <v90488$35uk5$1@dont-email.me>
User-Agent: Mutt/2.2.13 (2024-03-09)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ZrQcxHnUn0bLK46t@cskk.homeip.net>
X-Mailman-Original-References: <v90488$35uk5$1@dont-email.me>
View all headers

On 07Aug2024 08:35, Tobiah <toby@tobiah.org> wrote:
>When I do the same import with python3, I get:
>
> Traceback (most recent call last):
> File "/home/toby/me", line 1, in <module>
> import rcs.dbi
> File "/usr/regos-1.0/lib/python/rcs/dbi/__init__.py", line 1, in <module>
> from dbi import *
> ModuleNotFoundError: No module named 'dbi'

Python 3 imports are absolute (they start from the top of the package
tree and you have no `dbi` at the top). You want a relative import i.e.:

from .dbi import *

Cheers,
Cameron Simpson <cs@cskk.id.au>

Subject: Re: python3 package import difference?
From: Gilmeh Serda
Newsgroups: comp.lang.python
Organization: Easynews - www.easynews.com
Date: Thu, 8 Aug 2024 21:55 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx04.ams4.POSTED!not-for-mail
From: gilmeh.serda@nothing.here.invalid (Gilmeh Serda)
Subject: Re: python3 package import difference?
Newsgroups: comp.lang.python
References: <v90488$35uk5$1@dont-email.me>
MIME-Version: 1.0
x-no-archive: yes
User-Agent: Pan/0.159 (Vovchansk; 25e128a)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 35
Message-ID: <O9btO.172182$uvk9.19956@fx04.ams4>
X-Complaints-To: abuse@easynews.com
Organization: Easynews - www.easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Thu, 08 Aug 2024 21:55:58 GMT
X-Received-Bytes: 1313
View all headers

On Wed, 7 Aug 2024 08:35:36 -0700, Tobiah wrote:

> from dbi import *
> from regos import *

If I change that to:

from .dbi import * ¹
from .regos import * ²

It seems to be working.

In my tests, ¹ contains:
def bar():
pass

² contains:
def testing():
pass
def foo():
pass

>>> rcs.dbi.bar()
>>> rcs.dbi.testing()
>>> rcs.dbi.foo()
>>>

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.

--
Gilmeh

You can always pick up your needle and move to another groove. -- Tim
Leary

Subject: Re: python3 package import difference?
From: Cameron Simpson
Newsgroups: comp.lang.python
Date: Thu, 8 Aug 2024 23:53 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: python3 package import difference?
Date: Fri, 9 Aug 2024 09:53:52 +1000
Lines: 6
Message-ID: <mailman.35.1723161238.2890.python-list@python.org>
References: <O9btO.172182$uvk9.19956@fx04.ams4>
<ZrVakKrngbncooZ7@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de p9DDAzsD4Kmo2bSo70zfKQS+3dOnQqaShehLcU1acqRw==
Cancel-Lock: sha1:kF4dJf6unMH9tSaziF3eqW+JI3Y= sha256:Iib725HcC8tx6w/a+4WQkMZnFaUztAiKhWJrUhGoxpE=
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.016
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:import': 0.07;
'21:55,': 0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au':
0.16; 'from:name:cameron simpson': 0.16; 'message-
id:@cskk.homeip.net': 0.16; 'py2': 0.16; 'received:13.237': 0.16;
'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16;
'received:cskk.id.au': 0.16; 'received:id.au': 0.16; 'received:l':
0.16; 'received:mail.cskk.id.au': 0.16; 'removed.': 0.16;
'subject:package': 0.16; 'wrote:': 0.16; 'python': 0.16; 'to:addr
:python-list': 0.20; 'sense': 0.28; 'header:User-Agent:1': 0.30;
'guess': 0.32; 'header:In-Reply-To:1': 0.34; 'received:au': 0.35;
'received:13': 0.64; 'came': 0.65; 'less': 0.65;
'received:userid': 0.66; 'bad': 0.67; 'control.': 0.84;
'figuring': 0.84; 'from.': 0.84; 'smarter': 0.84
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <O9btO.172182$uvk9.19956@fx04.ams4>
User-Agent: Mutt/2.2.13 (2024-03-09)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ZrVakKrngbncooZ7@cskk.homeip.net>
X-Mailman-Original-References: <O9btO.172182$uvk9.19956@fx04.ams4>
View all headers

On 08Aug2024 21:55, Gilmeh Serda <gilmeh.serda@nothing.here.invalid> 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.

1

rocksolid light 0.9.8
clearnet tor