Re: Importlib behaves differently when importing pyd file

2022-11-18 Thread Jach Feng
; > > >But under Python 3.8 I get an exception: > >>>> import fitz > >Traceback(... > >... > >... > >ImportError: DLL load failed while importing _fitz > >>>> > The Python C-API is Python version dependent. > Your `_fitz.pyd` may need to be recreated for Python 3.8. It seems that I have to install pymupdf to use fitz. Thank you. -- https://mail.python.org/mailman/listinfo/python-list

Re: Importlib behaves differently when importing pyd file

2022-11-16 Thread Dieter Maurer
turn importlib.import_module('fitz._fitz') > >It works fine under Python 3.4 interpreter: >>>> import fitz >>>> > >But under Python 3.8 I get an exception: >>>> import fitz >Traceback(... >... >... >ImportError: DLL load failed while imp

Importlib behaves differently when importing pyd file

2022-11-16 Thread Jach Feng
erpreter: >>> import fitz >>> But under Python 3.8 I get an exception: >>> import fitz Traceback(... ... ... ImportError: DLL load failed while importing _fitz >>> I work under Windows7 64bit with Python 32bit. Can anyone help? --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: importing a module from a file without the '.py' suffix

2021-10-22 Thread Chris Angelico
le to use importlib for this: https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: importing a module from a file without the '.py' suffix

2021-10-22 Thread Chris Johns
The (newer) risc os port does a whole bunch of stuff in importlib to do this, as it natively doesn’t use extensions but file types. I’m not sure if you could do something similar without modifying importlib and re-freezing it. https://github.com/c-jo/cpython/blob/riscos-310/Lib/importlib/_boots

Re: importing a module from a file without the '.py' suffix

2021-10-22 Thread Rob Cliffe via Python-list
As far as I know, it can't be done. If I was REALLY desperate I might try (tested) import os os.rename('myfile.myext', 'myfile.py') import myfile os.rename('myfile.py', 'myfile.myext') # with appropriate modifications if myfile is not in the current directory but this is a horrible solution, sub

importing a module from a file without the '.py' suffix

2021-10-22 Thread Antoon Pardon
I have a file with python code but the name doesn't end with the '.py' suffix. What is the easiest way to import this code as a module without changing its name? -- Antoon Pardon. -- https://mail.python.org/mailman/listinfo/python-list

Re: Importing modules with arguments

2021-07-30 Thread Chris Angelico
de won't know that the parameters haven't been applied. It's action at a distance. > One thing that could be done is to memoize those imports based on the > parameters (this is a huge change to how imports works so its a bit yikes). That's functionally equivalent to importi

Re: Importing modules with arguments

2021-07-30 Thread Charles Smith
First off, thanks for the answer. I don't see the cached module as a problem here. If you provide arguments to a module, the goal is "most likely" to alter/parameterize the behavior of the first import. Now, I agree that behavior becomes unpredictable because passing different parameters on subs

Re: Importing modules with arguments

2021-07-30 Thread Chris Angelico
On Sat, Jul 31, 2021 at 3:48 AM Charles Smith wrote: > > I have found myself wanting to import module and provide arguments to them. > There's two main reason I could think of for this. First is to prevent a > circular import, though most of circular imports can be prevented by changing > the d

Importing modules with arguments

2021-07-30 Thread Charles Smith
I have found myself wanting to import module and provide arguments to them. There's two main reason I could think of for this. First is to prevent a circular import, though most of circular imports can be prevented by changing the design. The second reason is to invert dependencies between two m

Re: Importing from within package

2020-09-23 Thread Abdur-Rahmaan Janhangeer
Thanks for the lead. Checking tomorrow! If so i'll have to include other folders as well ... Kind Regards, Abdur-Rahmaan Janhangeer https://www.github.com/Abdur-RahmaanJ Mauritius sent from gmail client on Android, that's why the signature is so ugly. -- https://mail.python.org/mailman/listi

Re: Importing from within package

2020-09-23 Thread Dieter Maurer
Abdur-Rahmaan Janhangeer wrote at 2020-9-23 22:41 +0400: >In shopyo/shopyo (the same folder as __main__.py) there is a folder called >shopyoapi. Not in the distribution: ... shopyo-1.1.45/shopyo/ shopyo-1.1.45/shopyo/__init__.py shopyo-1.1.45/shopyo/__main__.py shopyo-1.1.45/shopyo/app.py shopyo-1

Re: Importing from within package

2020-09-23 Thread Abdur-Rahmaan Janhangeer
In shopyo/shopyo (the same folder as __main__.py) there is a folder called shopyoapi. What i want is to import create_module from cmd.py from shopyoapi in __main__.py but it does not work or more precisely i am looking how to make it work! Since this is not py2 i guess no init needed in shopyoapi

Re: Importing from within package

2020-09-23 Thread Dieter Maurer
Abdur-Rahmaan Janhangeer wrote at 2020-9-22 20:14 +0400: >I have this main script: >https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py > >However, i get errors after package installation >saying: >ImportError: cannot import name 'shopyoapi' from 'shopyo' It is right: `shopyyoapi`

Re: Importing from within package

2020-09-22 Thread Abdur-Rahmaan Janhangeer
Greetings list, In case this might help, i am on Python3.8 and running in a virtual env This command also does not work: python -m shopyo new . test2 Kind Regards, Abdur-Rahmaan Janhangeer about | blog github

Re: Importing from within package

2020-09-22 Thread Chris Angelico
On Wed, Sep 23, 2020 at 2:16 PM Terry Reedy wrote: > > On 9/22/2020 8:31 PM, Chris Angelico wrote: > > On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber > > wrote: > >> > >> On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer > >> declaimed the following: > >> > >>> I have this main sc

Re: Importing from within package

2020-09-22 Thread Terry Reedy
On 9/22/2020 8:31 PM, Chris Angelico wrote: On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber wrote: On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer declaimed the following: I have this main script: https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py

Re: Importing from within package

2020-09-22 Thread 黃炳熙
Chris Angelico writes: > ... > In a package, __main__.py does that same job. Sorry ChrisA, would you please some example? Because i am working in progress with Python things... Sicnerely, Byung-Hee -- ^고맙습니다 _布德天下_ 감사합니다_^))// -- https://mail.python.org/mailman/listinfo/python-list

Re: Importing from within package

2020-09-22 Thread Chris Angelico
On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber wrote: > > On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer > declaimed the following: > > >I have this main script: > >https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py > > > > Well, that file name scares me

Importing from within package

2020-09-22 Thread Abdur-Rahmaan Janhangeer
Greeting list, I have this main script: https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py However, i get errors after package installation saying: ImportError: cannot import name 'shopyoapi' from 'shopyo' I've tried from .shopyoapi also but to no avail. To reproduce: python

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 content e.g. as a

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:- > > > > import pyscand > > > > > > The error message is:- > > > > File

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 "/usr/libexec/okimfputl.new/guicom.py", line 66,

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 ImportError: /usr/libexec/okim

Re: Having trouble importing the python turtle on idle

2020-05-17 Thread Terry Reedy
. First, when running IDLE, select on the menu IDLE and About IDLE. What is the tk version? It should be 8.6.8. Second, start Terminal and enter ... $ python3.8 -m turtle This should start a turtle demo that draws and erases two patterns. which is importing the python turtle on to my screen

Re: Having trouble importing the python turtle on idle

2020-05-16 Thread Souvik Dutta
my 11 inch MacBook > > Air (Mac OS Sierra)version 10.12.6 > > I have followed all the instructions all the way through for installation > > I even downloaded activetcl and had no issues with instructions until > > chapter 4 page 45 > > which is importing the python

Re: Having trouble importing the python turtle on idle

2020-05-16 Thread Bischoop
0.12.6 >> I have followed all the instructions all the way through for installation >> I even downloaded activetcl and had no issues with instructions until >> chapter 4 page 45 >> which is importing the python turtle on to my screen. >> However I have troubleshoote

Re: Having trouble importing the python turtle on idle

2020-05-16 Thread KINGHAMED io
way through for installation > I even downloaded activetcl and had no issues with instructions until > chapter 4 page 45 > which is importing the python turtle on to my screen. > However I have troubleshooted every possible way to get this right even > uninstalling and reinstalling Python s

Re: Problem in importing pandas

2020-04-24 Thread Amit Jain
32\lib\site-packages\pandas\core\window\__init__.py", > > line 1, in > > from pandas.core.window.ewm import EWM # noqa:F401 > >File > > > "C:\Users\Amit\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\window\ewm.py", >

Re: Problem in importing pandas

2020-04-23 Thread MRAB
re.window.ewm import EWM # noqa:F401 File "C:\Users\Amit\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\window\ewm.py", line 5, in import pandas._libs.window.aggregations as window_aggregations ImportError: DLL load failed while importing aggregations: The

Problem in importing pandas

2020-04-23 Thread Amit Jain
sers\Amit\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\window\ewm.py", line 5, in import pandas._libs.window.aggregations as window_aggregations ImportError: DLL load failed while importing aggregations: The specified module could not be found. I am not able

Re: error in importing

2020-03-31 Thread DL Neil via Python-list
On 31/03/20 11:23 PM, Jami Yaswanth wrote: i am not able to use the libraries that are installed using "pip install pandas" Welcome to Python! Are you aware of the Python-Tutor Discussion List? (https://mail.python.org/mailman/listinfo/tutor) Please describe how you installed these libraries.

error in importing

2020-03-31 Thread Jami Yaswanth
i am not able to use the libraries that are installed using "pip install pandas" -- https://mail.python.org/mailman/listinfo/python-list

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-21 Thread Geoff Bache
toring it afterwards won't be possible. > > Those lines go into the actual file you're importing. > > > Basically I'm looking for hints as to information about known problems > and whether this kind of thing is likely to work anyway, and also hints for > debuggi

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-21 Thread Geoff Bache
I'm not sure I understand what you mean by "stick something" there. What did you have in mind? I can't just put anything there or the importing will fail anyhow. Also, setting the module back into there afterwards isn't possible unless I've already imported it, and a

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-21 Thread Geoff Bache
d you have in mind? I can't just put anything there or the importing will > fail anyhow. > > Also, setting the module back into there afterwards isn't possible > unless I've already imported it, and as mentioned I can't do that in > practice. > > > > The be

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-21 Thread Chris Angelico
On Fri, Feb 21, 2020 at 8:58 PM Geoff Bache wrote: > > But, as I say, I don't have the module loaded beforehand, so caching it from > sys.modules and restoring it afterwards won't be possible. Those lines go into the actual file you're importing. > Basically

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-21 Thread Chris Angelico
On Fri, Feb 21, 2020 at 6:56 PM Geoff Bache wrote: > > I'm not sure I understand what you mean by "stick something" there. What did > you have in mind? I can't just put anything there or the importing will fail > anyhow. > Also, setting the module back i

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-20 Thread Geoff Bache
Hi Chris, Yes, I've tried both of these things already. I can confirm there are multiple calls, and that pre-importing the module fixes it. But pre-importing it is not a solution in practice. Regards, Geoff On Thu, Feb 20, 2020 at 4:45 PM Chris Angelico wrote: > On Fri, Feb 21, 2020

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-20 Thread Chris Angelico
On Fri, Feb 21, 2020 at 3:06 AM Geoff Bache wrote: > > Hi Chris, > > Yes, I've tried both of these things already. I can confirm there are > multiple calls, and that pre-importing the module fixes it. But pre-importing > it is not a solution in practice. > Cool, good

Re: Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-20 Thread Chris Angelico
On Fri, Feb 21, 2020 at 2:37 AM Geoff Bache wrote: > When several threads execute this simultaneously I often get a stacktrace > saying some function near the end of module b is not defined, presumably > because the module has been imported part-initialised. > This only seems to happen when my Pyt

Should PyImport_ImportModule be threadsafe when importing from zipfiles?

2020-02-20 Thread Geoff Bache
Hi all, I have some embedded Python code which looks like this in C++ _gstate = PyGILState_Ensure(); PyImport_ImportModule("a"); ... PyGILState_Release(_gstate); and is called from different threads which are created in C++. My module a.py then imports another module b in python, which defines

Re: Importing module from another subdirectory

2019-04-25 Thread Rich Shepard
On Thu, 25 Apr 2019, dieter wrote: The means that "test_act_de.py" has not extended "sys.path" appropriately. Dieter, That's what I thought. When Python starts a script ("gui/test_act_de.py" in your case), it automatically extends "sys.path" with the folder containing the script ("gui" in y

Re: Importing module from another subdirectory

2019-04-24 Thread dieter
Rich Shepard writes: >> bustrac/ >>README.rst >>bustrac.py* >>controller/ >>classes/ > model.py >>scripts/ >>gui/ > test_act_de.py > > test_act_de.py tries to import model.py from the classes package: > from classes import model as m > > Running in bustrac

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
On Wed, 24 Apr 2019, Rich Shepard wrote: The current project's directory structure is: I changed package names so there are no duplicate names for packages and modules. bustrac/ README.rst bustrac.py* controller/ classes/ model.py scripts/ gui/ test_act

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
On Wed, 24 Apr 2019, Rich Shepard wrote: If I correctly understand the process, in bustrac.py I'll add import sys.path sys.path.append(controller, model, scripts, views) Never mind. I've installed virtualenv and will work within it. Regards, Rich -- https://mail.python.org/mailman/listinfo/p

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
On Wed, 24 Apr 2019, dieter wrote: With a "virtualenv", there is usually no need to tweak "sys.path" -- you simply install everything your project needs into the "virtualenv". Dieter, Okay. I just upgraded pip to 19.1 for python3 and virtualenv to version 16.5.0. Now I'll learn how to use it

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
uilds.org scripts (I run Slackware, currently -14.2) and I'd rather keep current using the SBo scripts rather than importing via PyPi. Most web search results I've found for appending to sys.path (or using the site package) refer to python2, not the installed version 3.7.x. The current p

Re: Importing module from another subdirectory

2019-04-23 Thread dieter
Rich Shepard writes: > On Tue, 23 Apr 2019, dieter wrote: > ... > One project is for my own use and I understand now that a virtualenv with > its own sys.path appendices would work. Those are two separate approaches: With a "virtualenv", there is usually no need to tweak "sys.path" -- you simply

Re: Importing module from another subdirectory

2019-04-23 Thread Rich Shepard
On Tue, 23 Apr 2019, dieter wrote: I use "virtualenv" (for "VIRTUAL ENVironmet") to separate projects. Dieter, I know about virtualenv and tried using them. Found conflicting information and didn't know if I really needed them. I'll re-learn how to activate and use them. One project is for m

Re: Importing module from another subdirectory

2019-04-22 Thread dieter
Rich Shepard writes: > On Thu, 18 Apr 2019, dieter wrote: > ... >> 2. extend "sys.path" in your scripts to contain the "bustrac" folder >> (before you try to import infrastructure modules/packages) > > I read the docs for sys and site and have insufficient experience with them > to know how best t

Re: Importing module from another subdirectory

2019-04-22 Thread Rich Shepard
On Thu, 18 Apr 2019, dieter wrote: I see two options for you: 1. put your scripts directly into "bustrac" (rather than a subdirectory) There are too many files; the directory is very cluttered. 2. extend "sys.path" in your scripts to contain the "bustrac" folder (before you try to import in

Re: Importing module from another subdirectory

2019-04-18 Thread Rich Shepard
On Thu, 18 Apr 2019, dieter wrote: Python knows about 2 kinds of "regular" imports: absolute ones and relative ones. "Absolute" imports are guided by "sys.path" -- in the simple case, a sequence of folders containing modules and/or pacakges. Relative imports are guided in a similar way by the cu

Re: Importing module from another subdirectory

2019-04-18 Thread Rich Shepard
On Wed, 17 Apr 2019, Sayth Renshaw wrote: Apologies I don't know the answer but went looking. This guide should answer the question. Didn't know it was so difficult to be honest. https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html#example-directory-structure Then there

Re: Importing module from another subdirectory

2019-04-17 Thread dieter
Rich Shepard writes: > What is the proper syntax to import the model class in the model/ > subdirectory into a tkinter view module, e.g., activities.py? The syntax, > 'import model as m' fails because it is not in the same subdirectory as the > importing module. > > T

Re: Importing module from another subdirectory

2019-04-17 Thread Sayth Renshaw
On Thursday, 18 April 2019 06:59:43 UTC+10, Rich Shepard wrote: > What is the proper syntax to import the model class in the model/ > subdirectory into a tkinter view module, e.g., activities.py? The syntax, > 'import model as m' fails because it is not in the same subdirectory

Importing module from another subdirectory

2019-04-17 Thread Rich Shepard
What is the proper syntax to import the model class in the model/ subdirectory into a tkinter view module, e.g., activities.py? The syntax, 'import model as m' fails because it is not in the same subdirectory as the importing module. The program directory tree is: bustrac/

Re: error while importing a module

2019-03-18 Thread Cameron Simpson
On 18Mar2019 20:11, Sharan Basappa wrote: On Tuesday, 19 March 2019 08:34:25 UTC+5:30, Sharan Basappa wrote: I have a design file that I am importing in a test file to run some tests. [...] The design file compiles fine when I run it standalone but when I import it in the test file, I see

Re: error while importing a module

2019-03-18 Thread Sharan Basappa
On Tuesday, 19 March 2019 08:34:25 UTC+5:30, Sharan Basappa wrote: > I have a design file that I am importing in a test file to run some tests. > The design file compiles fine when I run it standalone but when I import it > in the test file, I see error on the very first line w

error while importing a module

2019-03-18 Thread Sharan Basappa
I have a design file that I am importing in a test file to run some tests. The design file compiles fine when I run it standalone but when I import it in the test file, I see error on the very first line where I am importing the design file. This is the line from test file: """

Error while Importing Teradata in Python

2017-06-14 Thread mradul dhakad
Hi All , I am new to python .I have installed 3.6.1 python on my computer. when i am trying to import teradata i am getting below error message: Traceback (most recent call last) File "C:\Users\mradul_dhakad\AppData\Local\Programs\Python\ Python36\Hello.py", line 1, in import teradata ModuleNot F

Re: Importing with ctypes in Python: fighting overflows

2017-03-07 Thread eryk sun
On Tue, Mar 7, 2017 at 12:45 PM, wrote: > Importing with ctypes in Python: fighting overflows: > https://www.cossacklabs.com/blog/fighting-ctypes-overflows.html C int is 32-bit on all platforms currently supported by CPython -- both 32-bit and 64-bit. It's the default result t

Importing with ctypes in Python: fighting overflows

2017-03-07 Thread borysova . mary
Importing with ctypes in Python: fighting overflows: https://www.cossacklabs.com/blog/fighting-ctypes-overflows.html Best cases of boring technical debt are understood when reflected properly. This post addresses a simple one: inelegant flags in core C library ended up breaking Python tests

Re: importing down in code rather than at top of file.

2016-08-30 Thread dieter
tasking program). Typically, the delayed import was then in a function - relying on the fact that importing an already imported module is fast (thus, we do not lose much even if the function is called multiple times). -- https://mail.python.org/mailman/listinfo/python-list

Re: importing down in code rather than at top of file.

2016-08-29 Thread Terry Reedy
On 8/29/2016 1:57 PM, Tobiah wrote: Is it worth while to defer the import of a large module that seldom gets used in the script? import sys import os if hardly_ever_happens(): import large_module large_module.do_task() I imagine it takes a certain amount of pro

Re: importing down in code rather than at top of file.

2016-08-29 Thread Nobody
On Tue, 30 Aug 2016 04:15:05 +1000, Chris Angelico wrote: > Don't imagine; test. Testing alone isn't really good enough. There may be perfectly valid reasons to avoid the import which won't show up in anything less than the most thorough testing imaginable. Personally I wouldn't defer an import

Re: importing down in code rather than at top of file.

2016-08-29 Thread alister
On Mon, 29 Aug 2016 10:57:22 -0700, Tobiah wrote: > Is it worth while to defer the import of a large module that seldom > gets used in the script? > > > import sys import os > > if hardly_ever_happens(): > > import large_module large_module.do_task() >

Re: importing down in code rather than at top of file.

2016-08-29 Thread Chris Angelico
On Tue, Aug 30, 2016 at 3:57 AM, Tobiah wrote: > Is it worth while to defer the import of a large module that seldom > gets used in the script? > > > import sys > import os > > if hardly_ever_happens(): > > import large_module > large_module

importing down in code rather than at top of file.

2016-08-29 Thread Tobiah
Is it worth while to defer the import of a large module that seldom gets used in the script? import sys import os if hardly_ever_happens(): import large_module large_module.do_task() I imagine it takes a certain amount

Re: Dynamically import specific names from a module vs importing full module

2016-08-23 Thread Malcolm Greene
Ned and Random832, Ned: Thank you - your example answered my question. Random832: Thank you for the reminder about "from import " still importing the module. Yes, I had forgotten that behavior. Best, Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: Dynamically import specific names from a module vs importing full module

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 16:21, Malcolm Greene wrote: > Python 3.5: Is there a way to dynamically import specific names from a > module vs importing the full module? > > By dynamic I mean via some form of importlib machinery, eg. I'm looking > for the dynamic "from impor

Re: Dynamically import specific names from a module vs importing full module

2016-08-22 Thread Ned Batchelder
On Monday, August 22, 2016 at 4:22:09 PM UTC-4, Malcolm Greene wrote: > Python 3.5: Is there a way to dynamically import specific names from a > module vs importing the full module? > > By dynamic I mean via some form of importlib machinery, eg. I'm looking > for the d

Dynamically import specific names from a module vs importing full module

2016-08-22 Thread Malcolm Greene
Python 3.5: Is there a way to dynamically import specific names from a module vs importing the full module? By dynamic I mean via some form of importlib machinery, eg. I'm looking for the dynamic "from import " equivalent of "import "'s importlib.import_module.

Re: Importing from __future__ doesn't work under PDB

2016-05-11 Thread martin846
Many thanks for the quick reply. I must admit I was surprised not to find any note about this anywhere in the docs (or indeed anywhere online); it seems like something that people would have run into before. I've added a request to the documentation tracker to have a note added to help people wh

Re: Importing from __future__ doesn't work under PDB

2016-05-11 Thread Chris Angelico
On Wed, May 11, 2016 at 7:52 PM, wrote: > In other words, I get different results for the same expression (2/3) in the > program and on the pdb prompt, which makes debugging tricky. I cannot figure > out how to persuade pdb to actually load the division module. Is there an > approved way? Norm

Importing from __future__ doesn't work under PDB

2016-05-11 Thread martin846
Hi folks, I've been trying to use pdb to debug a Python 2.7 program and this has really stumped me. When debugging a program that uses from __future__ import division in Python 2.7, it would be useful to be able to have the same behaviour at the pdb prompt. However, it looks like pdb d

Re: a problem with importing pygame

2016-04-22 Thread Tim Golden
On 22/04/2016 09:07, Kiril Bard wrote: > I use python for my school work and I wanted to download it at home. I had > my teacher download the version to a flash drive and it still doesn't seem > to work. The version that I got from the flash drive was python 3.4.2 and > I think I got a 32 bit or a

a problem with importing pygame

2016-04-22 Thread Kiril Bard
I use python for my school work and I wanted to download it at home. I had my teacher download the version to a flash drive and it still doesn't seem to work. The version that I got from the flash drive was python 3.4.2 and I think I got a 32 bit or a 64 bit pygame for a windows machine. The prog

Re: importing

2016-03-07 Thread Terry Reedy
On 3/7/2016 12:23 PM, Tony van der Hoff wrote: However, more generally, how am I supposed to know that a module is part of a package, and needs a "magic" stanza to get a module loaded? The doc for a package usually mentions the submodules it contains, as in https://docs.python.org/3/library/tk

Re: importing

2016-03-07 Thread Mark Lawrence
On 07/03/2016 20:07, MRAB wrote: On 2016-03-07 19:08, Mark Lawrence wrote: On 07/03/2016 17:38, Chris Angelico wrote: On Tue, Mar 8, 2016 at 4:23 AM, Tony van der Hoff wrote: Thanks to all who replied to my cry for help; I understand it better now. But: On 07/03/16 16:08, Chris Angelico wrot

Re: importing

2016-03-07 Thread MRAB
On 2016-03-07 19:08, Mark Lawrence wrote: On 07/03/2016 17:38, Chris Angelico wrote: On Tue, Mar 8, 2016 at 4:23 AM, Tony van der Hoff wrote: Thanks to all who replied to my cry for help; I understand it better now. But: On 07/03/16 16:08, Chris Angelico wrote: The documentation should tel

Re: importing

2016-03-07 Thread Mark Lawrence
On 07/03/2016 17:38, Chris Angelico wrote: On Tue, Mar 8, 2016 at 4:23 AM, Tony van der Hoff wrote: Thanks to all who replied to my cry for help; I understand it better now. But: On 07/03/16 16:08, Chris Angelico wrote: The documentation should tell you what you need to import to make somet

Re: importing

2016-03-07 Thread Ian Kelly
On Mon, Mar 7, 2016 at 10:23 AM, Tony van der Hoff wrote: > However, more generally, how am I supposed to know that a module is part of > a package, and needs a "magic" stanza to get a module loaded? If the import path of the module has a dot in it, then it's part of a package. -- https://mail.p

Re: importing

2016-03-07 Thread Chris Angelico
On Tue, Mar 8, 2016 at 4:23 AM, Tony van der Hoff wrote: > Thanks to all who replied to my cry for help; I understand it better now. > But: > > On 07/03/16 16:08, Chris Angelico wrote: >> >> >> The documentation should tell you what you need to import to make >> something work. In this case, I wou

Re: importing

2016-03-07 Thread Mark Lawrence
On 07/03/2016 17:23, Tony van der Hoff wrote: Thanks to all who replied to my cry for help; I understand it better now. But: On 07/03/16 16:08, Chris Angelico wrote: The documentation should tell you what you need to import to make something work. In this case, I would guess that "import tkint

Re: importing

2016-03-07 Thread Tony van der Hoff
Thanks to all who replied to my cry for help; I understand it better now. But: On 07/03/16 16:08, Chris Angelico wrote: The documentation should tell you what you need to import to make something work. In this case, I would guess that "import tkinter.messagebox" or "from tkinter import message

Re: importing

2016-03-07 Thread Mark Lawrence
On 07/03/2016 15:54, Tony van der Hoff wrote: I thought I understood this, but apparently not: Under py3: 1. "import tkinter" imports the whole module into the name space. Any access to names therein must be prefixed with the module name. ie top = tkinter.Tk() But tkinter.messagebox.showwarning(

Re: importing

2016-03-07 Thread Chris Angelico
On Tue, Mar 8, 2016 at 2:54 AM, Tony van der Hoff wrote: > I thought I understood this, but apparently not: > Under py3: > > 1. "import tkinter" imports the whole module into the name space. Any access > to names therein must be prefixed with the module name. > ie top = tkinter.Tk() > But tkinter.

Re: importing

2016-03-07 Thread Ian Kelly
ie top = tkinter.Tk() > But tkinter.messagebox.showwarning() errors with "module has no attribute > 'messagebox'" tkinter.messagebox is a module inside the tkinter package. Importing tkinter doesn't automatically import tkinter.messagebox also. > > 2. "from tki

Re: importing

2016-03-07 Thread Tim Golden
On 07/03/2016 15:54, Tony van der Hoff wrote: > I thought I understood this, but apparently not: > Under py3: > > 1. "import tkinter" imports the whole module into the name space. Any > access to names therein must be prefixed with the module name. > ie top = tkinter.Tk() > But tkinter.messagebox.

importing

2016-03-07 Thread Tony van der Hoff
I thought I understood this, but apparently not: Under py3: 1. "import tkinter" imports the whole module into the name space. Any access to names therein must be prefixed with the module name. ie top = tkinter.Tk() But tkinter.messagebox.showwarning() errors with "module has no attribute 'mes

Re: Importing two modules of same name

2016-02-10 Thread Tim Johnson
* dieter [160209 23:03]: > Carl Meyer writes: > > ... > > If you omit the future-import in Python 2.7, `import config` will import > > the neighboring app/config.py by default, and there is no way to import > > the top-level config.py. > > There is the "__import__" builtin function which allows

Re: Importing two modules of same name

2016-02-09 Thread dieter
Carl Meyer writes: > ... > If you omit the future-import in Python 2.7, `import config` will import > the neighboring app/config.py by default, and there is no way to import > the top-level config.py. There is the "__import__" builtin function which allows to specify the "parent package" indirect

Re: Importing two modules of same name

2016-02-09 Thread Tim Johnson
* Carl Meyer [160209 15:28]: > Hi Tim, <...> > The proper way to do this in Python 2.7 is to place `from __future__ > import absolute_import` at the top of flask/app/__init__.py (maybe best > at the top of every Python file in your project, to keep the behavior > consistent). Once you have that f

Re: Importing two modules of same name

2016-02-09 Thread Carl Meyer
Hi Tim, On 02/09/2016 04:23 PM, Tim Johnson wrote: > Before proceding, let me state that this is to satisfy my > curiousity, not to solve any problem I am having. > > Scenario : > Web application developed at /some/dir/sites/flask/ > > If I have a package - let us call it app and in my > /some/d

Importing two modules of same name

2016-02-09 Thread Tim Johnson
Before proceding, let me state that this is to satisfy my curiousity, not to solve any problem I am having. Scenario : Web application developed at /some/dir/sites/flask/ If I have a package - let us call it app and in my /some/dir/sites/flask/app/__init__.py is the following: from config import

Refactoring in a large code base (was: importing: what does "from" do?)

2016-01-21 Thread Ben Finney
Rustom Mody writes: > You may find this strategy useful: > https://pchiusano.github.io/2015-04-23/unison-update7.html > > particularly the section "Limitations of refactoring via modifying > text files in place, and what to do instead" A direct link to that section is https://pchiusano.github.io

Re: importing: what does "from" do?

2016-01-21 Thread Rustom Mody
On Thursday, January 21, 2016 at 7:53:07 PM UTC+5:30, Charles T. Smith wrote: > What does "from (module) import (func)" do? > > Please don't tell me that I shouldn't ask because real programmers > know not to have circular dependencies ... > > I have no idea what was imported before. I just want

  1   2   3   4   5   6   7   8   9   10   >