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

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 names

Re: python3 package import difference?

2024-08-07 Thread Ronaldo Sc via Python-list
utorial/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 *&quo

python3 package import difference?

2024-08-07 Thread Tobiah via Python-list
i 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: Tr

Re: A question about import

2024-02-16 Thread Cameron Simpson via Python-list
On 16Feb2024 20:32, MRAB wrote: On 2024-02-16 20:07, Gabor Urban via Python-list wrote: I need something about modules to be clarified. Suppose I have written a module eg: ModuleA which imports an other module, let us say the datetime. If I import ModuleA in a script, will be datetime

Re: A question about import

2024-02-16 Thread MRAB via Python-list
On 2024-02-16 20:07, Gabor Urban via Python-list wrote: Hi guys, I need something about modules to be clarified. Suppose I have written a module eg: ModuleA which imports an other module, let us say the datetime. If I import ModuleA in a script, will be datetime imported automatically? Yes

A question about import

2024-02-16 Thread Gabor Urban via Python-list
Hi guys, I need something about modules to be clarified. Suppose I have written a module eg: ModuleA which imports an other module, let us say the datetime. If I import ModuleA in a script, will be datetime imported automatically? Thanks in advance, -- Urbán Gábor Linux is like a wigwam: no

Re: from __future__ import annotations bug?

2023-06-30 Thread Inada Naoki via Python-list
> but does this mean that even with PEP 649 that forward references will > still be needed? Yes. Both of PEP 563 and PEP 649 solves not all forward reference issues. -- Inada Naoki -- https://mail.python.org/mailman/listinfo/python-list

Re: from __future__ import annotations bug?

2023-06-30 Thread Joseph Garvin via Python-list
Should mention this also affects Protocol[Buzz] On Fri, Jun 30, 2023, 5:35 PM Joseph Garvin wrote: > ``` > from __future__ import annotations > from typing import Generic, TypeVar > > T = TypeVar("T") > class Foo(Generic[T]): ... > class Bar(Foo[Buzz]): ..

from __future__ import annotations bug?

2023-06-30 Thread Joseph Garvin via Python-list
``` from __future__ import annotations from typing import Generic, TypeVar T = TypeVar("T") class Foo(Generic[T]): ... class Bar(Foo[Buzz]): ... # NameError here class Buzz: ... ``` This will error, despite the __future__ import, because cpython is trying to look up Buzz before it

Re: Cannot import gdal in jupyter notebook

2022-12-16 Thread Romina Marcovecchio
; > > > > > https://conda-forge.org/ > > > """ > > > > > > > On 10/11/2022 11:53 AM, Abdul Haseeb Azizi wrote: > > > &

Re: Cannot import gdal in jupyter notebook

2022-10-12 Thread Abdul Haseeb Azizi
tem: > > > > https://docs.conda.io/en/latest/ > > > > By the conda-forge project: > > > > https://conda-forge.org/ > > """ > > > > > On 10/11/2022 11:53 AM, Abdul Haseeb Azizi wrote: > > >> Hi everyone, > > >> I am n

Re: Cannot import gdal in jupyter notebook

2022-10-12 Thread Abdul Haseeb Azizi
10/11/2022 11:53 AM, Abdul Haseeb Azizi wrote: > >> Hi everyone, > >> I am new to python and I am trying to utilize this code "from osgeo import > >> gdal".

Re: Cannot import gdal in jupyter notebook

2022-10-11 Thread MRAB
atest/ By the conda-forge project: https://conda-forge.org/ """ On 10/11/2022 11:53 AM, Abdul Haseeb Azizi wrote: Hi everyone, I am new to python and I am trying to utilize this code "from osgeo import gdal". I installed python 3.10 and also I installed anaconda3 to sol

Re: Cannot import gdal in jupyter notebook

2022-10-11 Thread Thomas Passin
files. On 10/11/2022 11:53 AM, Abdul Haseeb Azizi wrote: Hi everyone, I am new to python and I am trying to utilize this code "from osgeo import gdal". I installed python 3.10 and also I installed anaconda3 to solve this matter but I could not succeed. When I run that code I get the

Cannot import gdal in jupyter notebook

2022-10-11 Thread Abdul Haseeb Azizi
Hi everyone, I am new to python and I am trying to utilize this code "from osgeo import gdal". I installed python 3.10 and also I installed anaconda3 to solve this matter but I could not succeed. When I run that code I get the follo

Re: Tkinter - cannot import tklib

2022-06-21 Thread David
On Tue, 21 Jun 2022 at 09:22, Wolfgang Grafen wrote: > I am an experienced Python user and struggle with following statement: > > >>> from tklib import * > Traceback (most recent call last): > File "", line 1, in > ModuleNotFoundError: No module named 

Re: Tkinter - cannot import tklib

2022-06-20 Thread Dennis Lee Bieber
On Mon, 20 Jun 2022 15:43:26 -0700 (PDT), Wolfgang Grafen declaimed the following: > >There are numerous examples using "from tklib import *" so I assume it works >for most. In the tk-tutorial below tklib is used without special explanation, >so I assume it should be ins

Re: Tkinter - cannot import tklib

2022-06-20 Thread MRAB
On 2022-06-20 23:43, Wolfgang Grafen wrote: Hello all, I am an experienced Python user and struggle with following statement: from tklib import * Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'tklib' I tried to import tkl

Tkinter - cannot import tklib

2022-06-20 Thread Wolfgang Grafen
Hello all, I am an experienced Python user and struggle with following statement: >>> from tklib import * Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'tklib' I tried to import tklib as shown above on followi

Re: Circular Import

2022-04-12 Thread Chris Angelico
On Wed, 13 Apr 2022 at 03:37, Stefano Ovus wrote: > > found a solution: importing modules instead of classes, ex. > > -- square.py > > import circle > > ... > @classmethod > def from_circle(cls, circle: circle.Circle) -> Square: > ... > return

Re: Circular Import

2022-04-12 Thread Stefano Ovus
found a solution: importing modules instead of classes, ex. -- square.py import circle ... @classmethod def from_circle(cls, circle: circle.Circle) -> Square: ... return cls(...) -- https://mail.python.org/mailman/listinfo/python-list

Circular Import

2022-04-12 Thread Stefano Ovus
How can I avoid circular imports keeping separated modules ? -- square.py from circle import Cirle class Square: def __init__(self): ... @classmethod def from_circle(cls, circle: Circle) -> Square: ... return cls(...) -- circle.py from square import Square class Cir

Re: doubt About import machine

2021-11-21 Thread Joe Pfeiffer
Daniel Eduardo Almeida Correa writes: > Hello, I'm trying to use the machine library in python 3.10 version, but I > can't import it with the pip install machine, could you tell me a way to > solve it or a python version compatible with the library? Thank you a lot >

Re: doubt About import machine

2021-11-21 Thread MRAB
On 2021-11-21 18:36, Daniel Eduardo Almeida Correa wrote: Hello, I'm trying to use the machine library in python 3.10 version, but I can't import it with the pip install machine, could you tell me a way to solve it or a python version compatible with the library? Thank you a lot for y

doubt About import machine

2021-11-21 Thread Daniel Eduardo Almeida Correa
Hello, I'm trying to use the machine library in python 3.10 version, but I can't import it with the pip install machine, could you tell me a way to solve it or a python version compatible with the library? Thank you a lot for your answer. -- https://mail.python.org/mailman/listinfo/python-list

Re: import question

2021-11-19 Thread dn via Python-list
On 20/11/2021 03.38, lucas wrote: > ok. all good advice. thank you for that. and with all that I've decided > what to do. > > I'm going to close off any server-side python access so that I don't expose > my server or the file system to vulnerabilities and/or wonton attacks. I am > building

Re: import question

2021-11-19 Thread lucas
ok. all good advice. thank you for that. and with all that I've decided what to do. I'm going to close off any server-side python access so that I don't expose my server or the file system to vulnerabilities and/or wonton attacks. I am building a site for education and what I will configure

Re: import question

2021-11-19 Thread Mats Wichmann
On 11/18/21 21:00, Dan Stromberg wrote: On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: If you're trying to make a Python-in-Python sandbox, I recommend not. Instead, use

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 3:00 PM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: >> >> On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: >> > >> > >> > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: >> >> >> >> If you're trying to make a Python-in-Pyt

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: > On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg > wrote: > > > > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico > wrote: > >> > >> If you're trying to make a Python-in-Python sandbox, I recommend not. > >> Instead, use an OS-level sand

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: >> >> If you're trying to make a Python-in-Python sandbox, I recommend not. >> Instead, use an OS-level sandbox (a chroot, probably some sort of CPU >> usage limiting, etc), and use

Re: import question

2021-11-18 Thread Grant Edwards
On 2021-11-17, lucas wrote: > are there any other ways to import a module or package other then > the "import" or "from...import..." statements? i ask because i'm > allowing programming on my web2py website and i don't want any > accessing packages

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: > If you're trying to make a Python-in-Python sandbox, I recommend not. > Instead, use an OS-level sandbox (a chroot, probably some sort of CPU > usage limiting, etc), and use that to guard the entire Python process. > Python-in-Python will b

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 7:09 AM lucas wrote: > > hello one and all, > > are there any other ways to import a module or package other then the > "import" or "from...import..." statements? i ask because i'm allowing > programming on my web2py website a

import question

2021-11-18 Thread lucas
hello one and all, are there any other ways to import a module or package other then the "import" or "from...import..." statements? i ask because i'm allowing programming on my web2py website and i don't want any accessing packages like os or sys. thank you i

Re: CWD + relative path + import name == resultant relative path?

2021-10-30 Thread Dieter Maurer
n /home/foo/coolprog >2) You look up the AST for /home/foo/coolprog/a/b/c.py >3) /home/foo/coolprog/a/b/c.py has a relative import of ..blah Look at the functions provided by `os.path`. Maybe, you do not need relative path: look at `importlib` (which also supports import via absolute paths)

CWD + relative path + import name == resultant relative path?

2021-10-29 Thread Dan Stromberg
.py 3) /home/foo/coolprog/a/b/c.py has a relative import of ..blah Is there something preexisting that can figure out what path blah is supposed to have, assuming 100% pure python code? Or is it necessary to actually import to get that? I think I could import and then check __file__, but I

sha3 internal state export & import

2021-08-27 Thread rmlibre
rate number of bits (1088 for sha3_256, and 576 for sha3_512) of data which have not yet been incorporated into the `S`-state. Is there a simple way to export these two internal values from a sha3_256 or sha3_512 object, and conversely, a simple way to import these two exported values back into a n

Re: from foo import bar and the ast module

2021-08-22 Thread Chris Angelico
On Mon, Aug 23, 2021 at 12:26 AM Dan Stromberg wrote: > > > On Sun, Aug 22, 2021 at 7:14 AM Chris Angelico wrote: >> >> On Mon, Aug 23, 2021 at 12:08 AM Dan Stromberg wrote: >> > >> > In 'from foo import bar': >> > >> > With th

Re: from foo import bar and the ast module

2021-08-22 Thread Dan Stromberg
On Sun, Aug 22, 2021 at 7:14 AM Chris Angelico wrote: > On Mon, Aug 23, 2021 at 12:08 AM Dan Stromberg > wrote: > > > > In 'from foo import bar': > > > > With the ast module, I see how to get bar, but I do not yet see how to > get > >

Re: from foo import bar and the ast module

2021-08-22 Thread Chris Angelico
On Mon, Aug 23, 2021 at 12:08 AM Dan Stromberg wrote: > > In 'from foo import bar': > > With the ast module, I see how to get bar, but I do not yet see how to get > the foo. > > There are clearly ast.Import and ast.ImportFrom, but I do not see the foo > part in

from foo import bar and the ast module

2021-08-22 Thread Dan Stromberg
In 'from foo import bar': With the ast module, I see how to get bar, but I do not yet see how to get the foo. There are clearly ast.Import and ast.ImportFrom, but I do not see the foo part in ast.ImportFrom. ? Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: series.py, cannot import series from pandas

2020-11-28 Thread A. M. Thomas [PETech MIET MBA]
Spot on!! Thank you very much, am back on track with your aid On Sat, Nov 28, 2020 at 9:23 PM MRAB wrote: > On 2020-11-28 15:59, A. M. Thomas [PETech MIET MBA] wrote: > > Kindly guide on how to solve this problem from Python3.9 with pycharm. > See > > the below > > &g

Re: series.py, cannot import series from pandas

2020-11-28 Thread MRAB
On 2020-11-28 15:59, A. M. Thomas [PETech MIET MBA] wrote: Kindly guide on how to solve this problem from Python3.9 with pycharm. See the below import numpy as np import pandas as pd from pandas import series object = series([5,10,15,20]) print (object) C:\Users\THOMAS\AppData\Local\Programs

series.py, cannot import series from pandas

2020-11-28 Thread A. M. Thomas [PETech MIET MBA]
Kindly guide on how to solve this problem from Python3.9 with pycharm. See the below import numpy as np import pandas as pd from pandas import series object = series([5,10,15,20]) print (object) C:\Users\THOMAS\AppData\Local\Programs\Python\Python39\python.exe C:/Users/THOMAS/PycharmProjects

Turtle Import

2020-09-01 Thread Barnabas Harris
My import function mysteriously stop working. Is there a way to restore it as I need the second screen to see the turtle move when I command it from python 3.8.5 shell but when I hit enter nothing happens. -- https://mail.python.org/mailman/listinfo/python-list

Re: importlib: import X as Y; from A import B

2020-08-10 Thread Jason Friedman
> > import pandas; pd = pandas > > >df = pd.from_csv (...) > >from selenium import webdriver > > import selenium.webdriver; webdriver = selenium.webdriver > Thank you, this works. -- https://mail.python.org/mailman/listinfo/python-list

Re: Module import question

2020-08-09 Thread Bob Gailer
On Aug 9, 2020 11:41 AM, "Mats Wichmann" wrote: > > On 8/9/20 12:51 AM, Gabor Urban wrote: > > Hi guys, > > > > I have a quite simple question but I could not find the correct answer. > > > > I have twoo modules A and B. A imports B. If I import A in

Re: Module import question

2020-08-09 Thread Gabor Urban
Hi guys, Thanks for the answers. IT is clear Noé. Gábor -- https://mail.python.org/mailman/listinfo/python-list

Re: importlib: import X as Y; from A import B

2020-08-09 Thread Dieter Maurer
Jason Friedman wrote at 2020-8-8 21:23 -0600: > ... >The cherry-on-top would be to import with the "aliasing" and "from" they >will most likely see on the web, so that my code matches what they see >there. In other words, instead of: > >import pandas >df

Re: Module import question

2020-08-09 Thread Mats Wichmann
On 8/9/20 12:51 AM, Gabor Urban wrote: > Hi guys, > > I have a quite simple question but I could not find the correct answer. > > I have twoo modules A and B. A imports B. If I import A in a script, Will > be B imported automatically? I guess not, but fő not know exactly. &g

Re: Module import question

2020-08-09 Thread 황병희
Gabor Urban writes: > Hi guys, > > I have a quite simple question but I could not find the correct answer. > > I have twoo modules A and B. A imports B. If I import A in a script, Will > be B imported automatically? I guess not, but fő not know exactly. > > Thanks fo

Module import question

2020-08-08 Thread Gabor Urban
Hi guys, I have a quite simple question but I could not find the correct answer. I have twoo modules A and B. A imports B. If I import A in a script, Will be B imported automatically? I guess not, but fő not know exactly. Thanks for your answer ín advance, Gábor -- https://mail.python.org

Re: importlib: import X as Y; from A import B

2020-08-08 Thread Chris Angelico
On Sun, Aug 9, 2020 at 1:25 PM Jason Friedman wrote: > > I have some code I'm going to share with my team, many of whom are not yet > familiar with Python. They may not have 3rd-party libraries such as pandas > or selenium installed. Yes I can instruct them how to install, but the path > of least

Re: importlib: import X as Y; from A import B

2020-08-08 Thread dn via Python-list
is to have my code to check for missing dependencies and attempt to install for them. This code works as desired: import importlib import subprocess PIP_EXE = "/opt/python/bin/pip3" for module_name in ("module1", "module2", "module3"): try: imp

importlib: import X as Y; from A import B

2020-08-08 Thread Jason Friedman
ncies and attempt to install for them. This code works as desired: import importlib import subprocess PIP_EXE = "/opt/python/bin/pip3" for module_name in ("module1", "module2", "module3"): try: importlib.import_module(module_name) except Mod

Re: How to diagnose import error when importing from .so file?

2020-07-30 Thread Christian Gollwitzer
Am 29.07.20 um 23:01 schrieb Chris Green: Even more annoying is that most of what's in pyscand.so is constants, there's only a couple of functions in there, so there's very little to it really. If there are really only constants, you could import it into Python 2 and dump the co

Re: How to diagnose import error when importing from .so file?

2020-07-29 Thread Chris Green
Christian Heimes wrote: > On 29/07/2020 15.34, Chris Green wrote: > > I have some Python Gtk 2 code I'm trying to convert to Python > > pygobject GTK 3. > > > > However I'm stuck on an import statement that fails:- > > > >

Re: How to diagnose import error when importing from .so file?

2020-07-29 Thread Christian Heimes
On 29/07/2020 15.34, Chris Green wrote: > I have some Python Gtk 2 code I'm trying to convert to Python > pygobject GTK 3. > > However I'm stuck on an import statement that fails:- > > import pyscand > > > The error message is:- > > File &quo

Re: How to diagnose import error when importing from .so file?

2020-07-29 Thread David Lowry-Duda
> pyscand is a .so file so I fear I may be a bit stuffed unless I can > find the source code for it. > ... > In fact looking for this error it seems that is is a Python version > mismatch error and I need to recompile pyscand.so against Python 3. Is > there no way to sort of convert it to Python 3

How to diagnose import error when importing from .so file?

2020-07-29 Thread Chris Green
I have some Python Gtk 2 code I'm trying to convert to Python pygobject GTK 3. However I'm stuck on an import statement that fails:- import pyscand The error message is:- File "/usr/libexec/okimfputl.new/guicom.py", line 66, in import pyscand Impor

Re: Need to 'import gtk' on Ubuntu 20.04, what do I need?

2020-07-27 Thread Chris Green
Liste guru wrote: > Il 24/07/2020 10:31, Chris Green ha scritto: > > >    ... > > > I'm a *fairly* competant Python programmer so, if I have to, I > > willconsider converting from using the gtk module to using the gi > > module,are there any good tutorials which might help me down this road?

Re: Need to 'import gtk' on Ubuntu 20.04, what do I need?

2020-07-25 Thread Michael Torrie
lt python and the Oki software no > longer runs. > > The error I am getting is:- > > chris@esprimo$ ./scantool.py > Traceback (most recent call last): > File "./scantool.py", line 52, in > import gtk > ImportError: No module named gt

Re: Need to 'import gtk' on Ubuntu 20.04, what do I need?

2020-07-25 Thread Liste guru
Il 24/07/2020 10:31, Chris Green ha scritto:    ... I'm a *fairly* competant Python programmer so, if I have to, I willconsider converting from using the gtk module to using the gi module,are there any good tutorials which might help me down this road?    If you look at the pygobject docum

Re: Need to 'import gtk' on Ubuntu 20.04, what do I need?

2020-07-24 Thread Chris Green
hanges to code beyond the usual 2to3 > Python migration. > So is that what I'm getting by installing the things noted above. I.e. 'import pygtk' is importing GObject things whereas 'import gtk' is after the older stuff. I'm a *fairly* competant Python programmer so

Re: Need to 'import gtk' on Ubuntu 20.04, what do I need?

2020-07-23 Thread Akkana Peck
is accessed via something called GObject Introspection (module "gi") which requires significant changes to code beyond the usual 2to3 Python migration. You might be able to get the program working using pygtkcompat. Try inserting these lines near the beginning of the program: fro

Need to 'import gtk' on Ubuntu 20.04, what do I need?

2020-07-23 Thread Chris Green
I am getting is:- chris@esprimo$ ./scantool.py Traceback (most recent call last): File "./scantool.py", line 52, in import gtk ImportError: No module named gtk So what do I need to install on my Ubuntu 20.04 system to provide the gtk module? Alternatively (

Re: python3 - Import python file as module

2020-05-20 Thread Shivani Shinde
Hi Peter, Thank you for your inputs. This really helped me. Thanks! -- CONFIDENTIALITY. This email and any attachments are confidential to Alef Edge Inc., and may also be privileged, except where the email states it can be disclosed. If this email is received in error, please do not disclos

Re: python3 - Import python file as module

2020-05-18 Thread Peter Otten
y > └── run.py > > In my run.py file, I want to import everything from test.py(contains > methods). > > I have found relative path for test.py as "p.q". > I tried with exec() to import as : exec("from p.q import *"), > but this

python3 - Import python file as module

2020-05-18 Thread shivani . shinde
Hi, I am a beginner to Python. I want to achieve the following: My directory structure: a └── b └── c ├── p │   └── q │   └── test.py └── x └── y └── run.py In my run.py file, I want to import everything from test.py(contains

Import machinery for extracting non-modules from modules (not using import-from)

2020-05-03 Thread Adam Preble
The (rightful) obsession with modules in PEP-451 and the import machinery hit me with a gotcha when I was trying to implement importing .NET stuff that mimicked IronPython and Python.NET in my interpreter project. The meat of the question: Is it important that the spec loader actually return a

How does the import machinery handle relative imports?

2020-04-22 Thread Adam Preble
thons-import-machinery-works And eventually just started looking at PEP 451. Neither is really explaining relative imports. I decided to try this garbage: from importlib.util import spec_from_loader, module_from_spec from importlib.machinery import SourceFileLoader spec = spec_from_l

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Chris Angelico
On Sun, Apr 19, 2020 at 7:40 AM Adam Preble wrote: > > On Saturday, April 18, 2020 at 1:15:35 PM UTC-5, Alexandre Brault wrote: > > >>> def f(): > > ... â â from sys import path, argv ... > > So I figured it out and all but I wanted to ask about the special c

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Chris Angelico
On Sun, Apr 19, 2020 at 7:36 AM Adam Preble wrote: > > On Friday, April 17, 2020 at 1:37:18 PM UTC-5, Chris Angelico wrote: > > The level is used for package-relative imports, and will basically be > > the number of leading dots (eg "from ...spam import x" will ha

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Adam Preble
On Saturday, April 18, 2020 at 1:15:35 PM UTC-5, Alexandre Brault wrote: > >>> def f(): > ... â â from sys import path, argv ... So I figured it out and all but I wanted to ask about the special characters in that output. I've seen that a few times and never figured out

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Adam Preble
On Friday, April 17, 2020 at 1:37:18 PM UTC-5, Chris Angelico wrote: > The level is used for package-relative imports, and will basically be > the number of leading dots (eg "from ...spam import x" will have a > level of 3). You're absolutely right with your an

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Alexandre Brault
On 2020-04-17 2:22 p.m., Adam Preble wrote: Given this in Python 3.6.8: from dis import dis def import_from_test(): from sys import path dis(import_from_test) 2 0 LOAD_CONST 1 (0) 2 LOAD_CONST 2 (('path',))

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Chris Angelico
On Sat, Apr 18, 2020 at 4:26 AM Adam Preble wrote: > > Given this in Python 3.6.8: > > from dis import dis > > def import_from_test(): >from sys import path > > >>> dis(import_from_test) > 2 0 LOAD_CONST 1 (0) >

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
IMPORT_FROM pushes the module back on to the stack afterwards so that multiple import-from's can be executed off of it. This is then terminated with a POP_TOP: >>> def import_from_multi(): ... from sys import path, bar ... >>> dis(import_from_multi) 2

Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
Given this in Python 3.6.8: from dis import dis def import_from_test(): from sys import path >>> dis(import_from_test) 2 0 LOAD_CONST 1 (0) 2 LOAD_CONST 2 (('path',)) 4 IMPORT_NAME 0 (s

Widget common to multiple views: import from commonDlg?

2020-04-02 Thread Rich Shepard
This application has 8 data entry/edit view modules of tkinter widgets and an additional module called commonDlg which is imported into each of the others. Each view module has a comments tk.Text widget: self.inputs['Notes'] = cd.LabelInput( taxoninfo, "notes", input_class

Re: dynamic import of dynamically created modules failes

2020-03-31 Thread Peter Otten
Dieter Maurer wrote: > Stephan Lukits wrote at 2020-3-31 17:44 +0300: >>background: >> >>- a daemon creates package p1 (e.g. directory with __init__.py-file) and >>in p1 a module m1 is created. >> >>- Then the daemon wants to import from m1, which functions

[Solved] Re: dynamic import of dynamically created modules failes

2020-03-31 Thread Stephan Lukits
On 3/31/20 8:00 PM, Dieter Maurer wrote: Stephan Lukits wrote at 2020-3-31 17:44 +0300: background: - a daemon creates package p1 (e.g. directory with __init__.py-file) and in p1 a module m1 is created. - Then the daemon wants to import from m1, which functions (so far all the time

Re: dynamic import of dynamically created modules failes

2020-03-31 Thread Stephan Lukits
On 3/31/20 9:01 PM, Pieter van Oostrum wrote: "Dieter Maurer" writes: Stephan Lukits wrote at 2020-3-31 17:44 +0300: background: - a daemon creates package p1 (e.g. directory with __init__.py-file) and in p1 a module m1 is created. - Then the daemon wants to import from

Re: dynamic import of dynamically created modules failes

2020-03-31 Thread Pieter van Oostrum
Pieter van Oostrum writes: > > The first import creates a file __pycache__ in the directory p1. That should be 'a directory __pycache__' > To remove it use rmtree(path.join(P1,'__pycache__')) > Then the second import will succeed. > -- > Pieter van Oostr

Re: dynamic import of dynamically created modules failes

2020-03-31 Thread Pieter van Oostrum
"Dieter Maurer" writes: > Stephan Lukits wrote at 2020-3-31 17:44 +0300: >>background: >> >>- a daemon creates package p1 (e.g. directory with __init__.py-file) and >>in p1 a module m1 is created. >> >>- Then the daemon wants to impor

Re: dynamic import of dynamically created modules failes

2020-03-31 Thread Dieter Maurer
Stephan Lukits wrote at 2020-3-31 17:44 +0300: >background: > >- a daemon creates package p1 (e.g. directory with __init__.py-file) and >in p1 a module m1 is created. > >- Then the daemon wants to import from m1, which functions (so far all >the time). > >- Then a mod

dynamic import of dynamically created modules failes

2020-03-31 Thread Stephan Lukits
Hello, background: - a daemon creates package p1 (e.g. directory with __init__.py-file) and in p1 a module m1 is created. - Then the daemon wants to import from m1, which functions (so far all the time). - Then a module m2 is created in p1 and the daemon wants to import from m2 which

Re: Module import best practice

2020-03-26 Thread DL Neil via Python-list
I'm not a professional coder. I'm an environmental consultant and I use a I take it all back then... No! No need to feel apologetic, the Python community works hard to be inclusive - which I take to include levels of expertise, not merely countering the various "-isms". variety of tools de

Re: Module import best practice

2020-03-26 Thread Rich Shepard
On Fri, 27 Mar 2020, DL Neil via Python-list wrote: My personal approach is to follow 'the Zen of Python' and prefer "explicit" over "implicit". (it helps beginners, as well as us old-fogies whose minds cannot retain things for very long) DL, That was my original approach. I see little poin

Re: Module import best practice

2020-03-26 Thread DL Neil via Python-list
Some classes in commonDlgs imports other modules. My question is whether to import into each view class those modules needed by it or import all supporting modules at the top of commonDlgs.py, then import that module in each view with: from . import commonDlgs as cd rather than importing specific cl

RE: Module import best practice

2020-03-26 Thread Rich Shepard
On Thu, 26 Mar 2020, Schachner, Joseph wrote: I can only tell you my preference. I prefer that Python modules be as self-contained as possible, because "global" is within a module; to share between modules you have to import something, as you know. Joseph, This makes good sense. I

Module import best practice

2020-03-25 Thread Rich Shepard
stion is whether to import into each view class those modules needed by it or import all supporting modules at the top of commonDlgs.py, then import that module in each view with: from . import commonDlgs as cd rather than importing specific classes in each view module? Rich -- https://mail.pytho

Re: Relative import cannot find .so submodule?

2020-01-13 Thread Paul Moore
PYTHONPATH to this lib > > dir, but rtmidi/__init__.py gives the following error: > > > > Traceback (most recent call last): > > File "main.py", line 6, in > > from pkmidicron import MainWindow, util, ports > > File "/Users/patrick/dev/pkm

Re: Relative import cannot find .so submodule?

2020-01-13 Thread Pieter van Oostrum
t PYTHONPATH to this lib dir, > but rtmidi/__init__.py gives the following error: > > Traceback (most recent call last): > File "main.py", line 6, in > from pkmidicron import MainWindow, util, ports > File "/Users/patrick/dev/pkmidicron/pkmidicron/__init

Re: Relative import cannot find .so submodule?

2020-01-13 Thread dieter
t PYTHONPATH to this lib dir, > but rtmidi/__init__.py gives the following error: > > Traceback (most recent call last): > File "main.py", line 6, in > from pkmidicron import MainWindow, util, ports > File "/Users/patrick/dev/pkmidicron/pkmidicron/__init

Re: Relative import cannot find .so submodule?

2020-01-13 Thread Barry
tmidi.cpython-36dm-darwin.so. I have set PYTHONPATH to this lib dir, > but rtmidi/__init__.py gives the following error: > > Traceback (most recent call last): > File "main.py", line 6, in >from pkmidicron import MainWindow, util, ports > File "/Users/patrick

Relative import cannot find .so submodule?

2020-01-11 Thread Patrick Stinson
/__init__.py gives the following error: Traceback (most recent call last): File "main.py", line 6, in from pkmidicron import MainWindow, util, ports File "/Users/patrick/dev/pkmidicron/pkmidicron/__init__.py", line 1, in from .mainwindow import * File "/Use

  1   2   3   4   5   6   7   8   9   10   >