Deutsch   English   Français   Italiano  
<mailman.31.1723070433.2890.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: Ronaldo Sc <rs.quim@gmail.com>
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>': 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:<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>
Bytes: 8183

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 =C3=A0s 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
>      =E2=94=9C=E2=94=80=E2=94=80 dbi
>      =E2=94=82   =E2=94=9C=E2=94=80=E2=94=80 __init__.py
>      =E2=94=82   =E2=94=9C=E2=94=80=E2=94=80 dbi.py
>      =E2=94=82   =E2=94=94=E2=94=80=E2=94=80 regos.py
>      =E2=94=94=E2=94=80=E2=94=80 __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
>