Re: Imports and dot-notation

2023-08-10 Thread Mats Wichmann via Python-list
On 8/9/23 17:28, dn via Python-list wrote: Side note: Using "...import identifier, ..." does not save storage-space over "import module" (the whole module is imported regardless, IIRC), however it does form an "interface" and thus recommend leaning into the "Interface Segregation Principle", o

Re: Imports and dot-notation

2023-08-09 Thread Cameron Simpson via Python-list
for a bit more thought, looking at PEP8, we notes about imports, but sadly PEP8 does not state which method is better/preferred. While obviously in the end, it's always the maintainers choice in what they prefer, so are tabs vs spaces and PEP8 is opinionated about that too (in a good way,

Re: Imports and dot-notation

2023-08-09 Thread dn via Python-list
On 09/08/2023 22.30, Oliver Schinagl via Python-list wrote: ...> Looking at a python projects code and repository layout, we see the following directory structure. /project/core /project/components/module1 ... /project/components/moduleN /projects/util ...> Some modules import other modules, an

Imports and dot-notation

2023-08-09 Thread Oliver Schinagl via Python-list
Dear list, First a disclaimer, I am a python novice ;) so apologies beforehand for any incorrect terms and use thereof :) I have a question about the preferred/pythonic way dealing with imports. But let me start by giving a little bit of an example (which lead me to this question

RE: Improvement to imports, what is a better way ?

2023-01-19 Thread avi.e.gross
y original question. Now it is about the long and short of it. -Original Message- From: Python-list On Behalf Of Thomas Passin Sent: Thursday, January 19, 2023 9:37 PM To: python-list@python.org Subject: Re: Improvement to imports, what is a better way ? On 1/19/2023 7:33 PM, avi.e.gr...

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Thomas Passin
otatochowder.com Sent: Thursday, January 19, 2023 1:30 PM To: python-list@python.org Subject: Re: Improvement to imports, what is a better way ? On 2023-01-19 at 12:59:21 -0500, Thomas Passin wrote: Well, it's an art, not a science [...] +1 # Create a plot g2 = ( ggplot(df2,

RE: Improvement to imports, what is a better way ?

2023-01-19 Thread avi.e.gross
is package would change to conform but it is a bit late! LOL! Avi -Original Message- From: Python-list On Behalf Of 2qdxy4rzwzuui...@potatochowder.com Sent: Thursday, January 19, 2023 1:30 PM To: python-list@python.org Subject: Re: Improvement to imports, what is a better way ? On 20

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Cameron Simpson
On 19Jan2023 07:34, Dan Kolis wrote: On Thursday, January 19, 2023 at 12:09:02 AM UTC-5, cameron wrote: I know this is vague. Once you find its stalling in a particular function (if it is) you may be able to run that function directly. Also, a print() at the top abd bottom/return of the stallin

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Thomas Passin
On 1/19/2023 1:30 PM, 2qdxy4rzwzuui...@potatochowder.com wrote: On 2023-01-19 at 12:59:21 -0500, Thomas Passin wrote: Well, it's an art, not a science [...] +1 # Create a plot g2 = ( ggplot(df2, aes('Days Since Jan 22', # Comments can clarify these params + geom_point

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Roel Schroeven
2qdxy4rzwzuui...@potatochowder.com schreef op 19/01/2023 om 19:30: > The PEP-8 rules are good, but they can't cover all cases perfectly. Some the PEP-8 rules are debatable. Regardless, they can't cover all cases perfectly. (IOW, we agree on the bit that's relevant to this thread.) PEP 8 even

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread 2QdxY4RzWzUUiLuE
On 2023-01-19 at 12:59:21 -0500, Thomas Passin wrote: > Well, it's an art, not a science [...] +1 > # Create a plot > g2 = ( > ggplot(df2, > aes('Days Since Jan 22', # Comments can clarify these params > + geom_point(size=.1, color='blue') # size, color params optional >

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Thomas Passin
On 1/19/2023 11:55 AM, Roel Schroeven wrote: Op 19/01/2023 om 11:32 schreef Stefan Ram: dn writes: >The longer an identifier, the more it 'pushes' code over to the right or >to expand over multiple screen-lines. Some thoughts on this are behind >PEP-008 philosophies, eg line-limit.    Raymo

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Roel Schroeven
Op 19/01/2023 om 11:32 schreef Stefan Ram: dn writes: >The longer an identifier, the more it 'pushes' code over to the right or >to expand over multiple screen-lines. Some thoughts on this are behind >PEP-008 philosophies, eg line-limit. Raymond Hettinger (transcribed, shortened and parti

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Dan Kolis
On Thursday, January 19, 2023 at 12:09:02 AM UTC-5, cameron wrote: > I know this is vague. Once you find its stalling in a particular > function (if it is) you may be able to run that function directly. Also, > a print() at the top abd bottom/return of the stalling function. And so > on. Dan

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Cameron Simpson
On 18Jan2023 16:10, Dan Kolis wrote: I have written a very sizable and elaborate program that uses tKinter for X11 displays of genomics. Yet maybe 1 of 6 times it freezes, so I decided to extract the minimum that works perfectly and add back big pieces. It does it both running .pyc and in VSC

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Dan Kolis
I have written a very sizable and elaborate program that uses tKinter for X11 displays of genomics. Yet maybe 1 of 6 times it freezes, so I decided to extract the minimum that works perfectly and add back big pieces. It does it both running .pyc and in VSCode. so even the most minor of odditie

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Dan Kolis
Thank you -- https://mail.python.org/mailman/listinfo/python-list

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Michael Torrie
On 1/18/23 14:42, Dan Kolis wrote: > >> I don't think you've described this. I don't know what you mean here. > > When I trace it in VSCode the imports seem like they endlessly suspend > scanning and go to other ones over and over. Like "Whats this doi

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Greg Ewing
On 19/01/23 10:40 am, Dan Kolis wrote: I guess I don't full understand what bothers me about the repetition of the imports so much. It's doubtful that every module uses every one of those imports. It looks like someone had a standard block of imports that they blindly pasted at

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Dan Kolis
> I don't think you've described this. I don't know what you mean here. When I trace it in VSCode the imports seem like they endlessly suspend scanning and go to other ones over and over. Like "Whats this doing ?" -- https://mail.python.org/mailman/listinfo/python-list

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Dan Kolis
extreme uniformity in the names and so on, there utterly uniform, so there not so bad to consider, ( I hope ). I guess I don't full understand what bothers me about the repetition of the imports so much. The tracing of it seems so bizarre, it just seems like its wrong. Regs Dan --

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Cameron Simpson
ified. And anyway, an imported module is only loaded a ready once; imports are kept track of in the sys.modules dict, and just pulled directly from there when the same module is requests by another import. The hop around read keeps making me worry it migth leave some memory leak or something

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Paul Bryan
On Thu, 2023-01-19 at 09:47 +1300, dn via Python-list wrote: > The longer an identifier, the more it 'pushes' code over to the right > or  > to expand over multiple screen-lines. Some thoughts on this are > behind > PEP-008 philosophies, eg line-limit. I sympathize with this issue. I've pushed t

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Weatherby,Gerard
18, 2023 at 3:49 PM To: python-list@python.org Subject: Re: Improvement to imports, what is a better way ? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On 19/01/2023 08.56, Mats Wichmann wrote: > On 1/18/23 12:29, Paul Bryan wr

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Dan Kolis
dn and Mats, thanks for your advice. I'm not sure what to do. Do either / both know if there is a way to make it parse each import list to bytecode in one shot ?? The hop around read keeps making me worry it migth leave some memory leak or something. I dont know. Thanks though, both your di

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread dn via Python-list
ces, which includes the question: which functions will be called and thus which Python-modules should be imported? Thus, listing all imports 'at the top' is a separable task. - an early language learned (back-when) was COBOL, which has a formal structure and separation between element

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Mats Wichmann
On 1/18/23 12:29, Paul Bryan wrote: I would suggest allowing each module to define its own imports, don't import what a module doesn't consume, keep them simple, avoid devising a common namespace for each, and let tools like isort/black work out how to order/express them in so

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Paul Bryan
I would suggest allowing each module to define its own imports, don't import what a module doesn't consume, keep them simple, avoid devising a common namespace for each, and let tools like isort/black work out how to order/express them in source files. On Wed, 2023-01-18 at 10:43 -0800,

Improvement to imports, what is a better way ?

2023-01-18 Thread Dan Kolis
This program has lots of files and each is well segregated for a concept. the top of each as a heap of imports, all identical. Well the very top has some one of's import os asos import sys as sys import importlib as importlib i

Re: Polymorphic imports

2021-09-22 Thread Chris Angelico
On Thu, Sep 23, 2021 at 4:20 AM Dennis Lee Bieber wrote: > > The other alternative may be > https://docs.python.org/3/library/functions.html#__import__ > I wouldn't recommend calling a dunder. If you just want to pass a text string and get back a module, importlib is a better choice. Chr

Re: Polymorphic imports

2021-09-22 Thread Dennis Lee Bieber
On Tue, 21 Sep 2021 18:58:31 +, Travis Griggs declaimed the following: >from lib import paths >import paths.dynamic_client_module() > >But this seems to not work. Import can only take real modules? Not programatic >ones? Consider "import" to be equivalent to a compile-time operatio

Re: Polymorphic imports

2021-09-21 Thread Chris Angelico
On Wed, Sep 22, 2021 at 6:05 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2021-09-22 at 05:10:02 +1000, > Chris Angelico wrote: > > > You can dynamically import modules using importlib.import_module(), > > but an easier way might just be a conditional import: > > > > # client/__init__.py

Re: Polymorphic imports

2021-09-21 Thread 2QdxY4RzWzUUiLuE
On 2021-09-22 at 05:10:02 +1000, Chris Angelico wrote: > You can dynamically import modules using importlib.import_module(), > but an easier way might just be a conditional import: > > # client/__init__.py > if some_condition: > import module_a_default as module_a > else: > import module

Re: Polymorphic imports

2021-09-21 Thread Chris Angelico
t; model/ > model_a > model_b > ... > top_level_a > top_level_b > ... > > > I have a number of imports of module_a. I have a paths module that isolates > all of my file system access, and that's where the determination can be made > which one to

Polymorphic imports

2021-09-21 Thread Travis Griggs
ed in a sort of once-and-only once spot? For example, consider something like this: client/ module_a module_a_prime lib/ paths lib_a lib_b ... model/ model_a model_b ... top_level_a top_level_b ... I have a number of imports of module_a. I have a paths module that isolates

Re: Cyclic imports

2021-08-21 Thread Dan Stromberg
g.dnsalias.org/svn/cycles/trunk for now - no > pypi, no homepage. I've only run it on some test inputs, nothing > substantial. Usage example is in the Makefile. > > Imports are kind of complicated. Am I missing any important cases? > > Sample output looks like: >

Re: Cyclic imports

2021-08-21 Thread Dan Stromberg
inputs, nothing substantial. Usage example is in the Makefile. Imports are kind of complicated. Am I missing any important cases? Sample output looks like: Detected 2 cycles: ('mutual_1', 'mutual_2') ('directory.mutual_a', 'directory.mutual_b', 'directory.mutual_c') Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: Cyclic imports

2021-08-17 Thread Chris Angelico
On Wed, Aug 18, 2021 at 4:10 AM Barry Scott wrote: > > def allImports( self, module_name ): > for line in f: > words = line.strip().split() > if words[0:1] == ['import']: > all_imports.append( words[1] ) > This will work for a lo

Re: Cyclic imports

2021-08-17 Thread Barry Scott
On Monday, 16 August 2021 16:13:47 BST Dan Stromberg wrote: > Hi folks. > > I'm working on a large codebase that has at least one cyclic import. > > In case I end up needing to eliminate the cyclic imports, is there any sort > of tool that will generate an import graph and

Cyclic imports

2021-08-16 Thread Dan Stromberg
Hi folks. I'm working on a large codebase that has at least one cyclic import. In case I end up needing to eliminate the cyclic imports, is there any sort of tool that will generate an import graph and output Just the cycles? I tried pyreverse, but it produced too big a graph to be very u

Re: Tkinter needed as a legacy version 2.7 imports the module...

2021-02-27 Thread Grant Edwards
On 2021-02-26, MRAB wrote: > On 2021-02-26 22:23, Kevin M. Wilson via Python-list wrote: > >> Is there a site where I might/can download a version of Tkinter for Python >> 2.7? > > Tkinter as already included in Python 2.7. Not always, it depends on how he installed Python 2.7. That said, MRAB

Re: Tkinter needed as a legacy version 2.7 imports the module...

2021-02-27 Thread Alan Gauld via Python-list
On 26/02/2021 22:23, Kevin M. Wilson via Python-list wrote: > Hey Community,    Is there a site where I might/can download a version of > Tkinter for Python 2.7? Which OS? If it's Linux you may need to fetch the tkinter package for your distro. In Windoze it should come as standard In MacO

Re: Tkinter needed as a legacy version 2.7 imports the module...

2021-02-26 Thread MRAB
On 2021-02-26 22:23, Kevin M. Wilson via Python-list wrote: Hey Community,    Is there a site where I might/can download a version of Tkinter for Python 2.7? Tkinter as already included in Python 2.7. -- https://mail.python.org/mailman/listinfo/python-list

Tkinter needed as a legacy version 2.7 imports the module...

2021-02-26 Thread Kevin M. Wilson via Python-list
Hey Community,    Is there a site where I might/can download a version of Tkinter for Python 2.7? Seriously, KMW John 1:4  "In him was life; and the life was the light of men." -- https://mail.python.org/mailman/listinfo/python-list

Re: Troubles with Python imports

2021-02-10 Thread Roland Mueller via Python-list
ke 10. helmik. 2021 klo 5.07 Terry Reedy (tjre...@udel.edu) kirjoitti: > On 2/9/2021 9:55 AM, Philipp Daher via Python-list wrote: > > Hello, > > > > I’ve just typed „pip install selenium“ into my command prompt on windows > 10. Although my computer told me that the requirement was already > satis

Re: Troubles with Python imports

2021-02-09 Thread Terry Reedy
On 2/9/2021 9:55 AM, Philipp Daher via Python-list wrote: Hello, I’ve just typed „pip install selenium“ into my command prompt on windows 10. Although my computer told me that the requirement was already satisfied, import selenium did not work. So I tried different methods to install it and ty

Re: Troubles with Python imports

2021-02-09 Thread Mats Wichmann
On 2/9/21 7:55 AM, Philipp Daher via Python-list wrote: Hello, I’ve just typed „pip install selenium“ into my command prompt on windows 10. Although my computer told me that the requirement was already satisfied, import selenium did not work. So I tried different methods to install it and type

Troubles with Python imports

2021-02-09 Thread Philipp Daher via Python-list
Hello, I’ve just typed „pip install selenium“ into my command prompt on windows 10. Although my computer told me that the requirement was already satisfied, import selenium did not work. So I tried different methods to install it and typed „Python“ in my command prompt and imported selenium. It

Re: Friday Finking: Imports, Namespaces, Poisoning, Readability

2020-06-05 Thread Rhodri James
"sufficiently obvious" are pretty flexible. In particular, I'll list more items as the qualified names get longer, as you noted. Source location is a non-issue; it's trivial to jump to the imports at the top of the file, look it up and jump back again. Or have two buffers v

Re: Friday Finking: Imports, Namespaces, Poisoning, Readability

2020-06-04 Thread Tim Chase
On 2020-06-05 12:15, DL Neil via Python-list wrote: > Finking/discussion: > > - how do you like to balance these three (and any other criteria)? For most of what I do, I only ever have one such module so I'm not trying keep multiple short-names in my head concurrently. For me, it's usually tkint

Friday Finking: Imports, Namespaces, Poisoning, Readability

2020-06-04 Thread DL Neil via Python-list
How do you prefer to balance all of the above when import-ing? Python offers a number of options for importing modules, eg import module, ... from importable import object, ... most of which can be augmented with the "as preferred_name" syntax. (ignoring the much-reviled "*" (import ev

How does the import machinery handle relative imports?

2020-04-22 Thread Adam Preble
I'm fussing over some details of relative imports while trying to mimic Python module loading in my personal project. This is getting more into corner cases, but I can spare time to talk about it while working on more normal stuff. I first found this place: https://manikos.github.io/how-py

Re: Issue with running programs in Python and imports, probably directories messed up

2019-11-03 Thread dieter
Vladyslav Verteletskyi writes: > I have stuck upon a problem with all of my attempts to import libraries to > Python. Find the > screenshots enclosed. This is a text only list: we (at least most of us) do not see attachments (such as attached screenshots). Use functions of your (windows) sys

Issue with running programs in Python and imports, probably directories messed up

2019-10-31 Thread Vladyslav Verteletskyi
Dear developers, I have stuck upon a problem with all of my attempts to import libraries to Python. PyCharm and Anaconda both fail, as well as terminal. Find the screenshots enclosed. I have tried reinstalling both several times, of no help. All of the libraries I tried to import are already downl

Re: Problems with imports on multiple threads, with embedded Python

2018-01-04 Thread dieter
s". To protect this object, Python must do something. In former Python versions (somewhere before Python 3), it was using a a thread lock: this could cause a deadlock in the case of some import dependencies. The recoomendation to avoid the problem has been to avoid module level imports for

Re: Problems with imports on multiple threads, with embedded Python

2017-12-21 Thread geoff . bache
On Thursday, 21 December 2017 00:33:54 UTC+1, Lawrence D’Oliveiro wrote: > On Thursday, December 21, 2017 at 5:13:33 AM UTC+13, geoff...@gmail.com wrote: > > > > I have a multithreaded application using an embedded Python 3.6.4 ... > > Avoid multithreading if you can. Is your application CPU-bou

Problems with imports on multiple threads, with embedded Python

2017-12-20 Thread geoff . bache
Hi all, I have a multithreaded application using an embedded Python 3.6.4 (upgraded from 3.6.2 today in the hope that the problem was now solved: it doesn't seem to be). The standard library is in a zip file. So long as only one thread is running Python at a time it seems to work fine. But ther

Re: Question about imports and packages

2016-05-25 Thread Chris Angelico
On Wed, May 25, 2016 at 6:27 PM, Steven D'Aprano wrote: > I don't think this is that much different from the way other scripting > languages handle it. E.g. bash. If I have a set of (say) shell scripts: > > fnord/ > +-- foo.sh > +-- bar.sh > > > where foo.sh runs bar.sh, but fnord is *not* on the

Re: Question about imports and packages

2016-05-25 Thread Steven D'Aprano
d cannot be found by the import system. > To me, that makes Python at a severe handicap as a simple-to-use > scripting language. There's something to what you say, but I don't think it's quite that bad. To me, "simple to use" means a stand-alone, single file .py

Re: Question about imports and packages

2016-05-24 Thread Ben Finney
Gerald Britton writes: > On Wed, 25 May 2016 10:00 am, Steven D'Aprano wrote: > >The problem is that you are running the Python script from *inside* > >the package. That means, as far as the script can see, there is no > >longer a package visible -- it cannot see its own outside from the > >insid

Re: Question about imports and packages

2016-05-24 Thread Terry Reedy
ur package layout is correct. But: I have a similar setup, except with multiple files importing from imported file. One way to make absolute imports within a package work, and how I do it, is to put the directory containing testpkg in a .pth file in the site-modules directory. In particula

Question about imports and packages

2016-05-24 Thread Gerald Britton
xplanation, Steven. I'm just having trouble reconciling this with the docs which seems to imply that an intra package import should work from inside the package. This bit: "When packages are structured into subpackages (as with the sound package in the example), you can use absolute imports t

Re: Question about imports and packages

2016-05-24 Thread Steven D'Aprano
On Wed, 25 May 2016 09:35 am, Gerald Britton wrote: For brevity, here's your package setup: testpkg/ +-- __init__.py +-- testimport.py which runs "from testpkg.testimported import A" +-- testimported.py containing class A Your package layout is correct. But: > When I run > > python testimport

Question about imports and packages

2016-05-24 Thread Gerald Britton
I'm trying to understand packages in Python, especially Intra Package References. >From https://docs.python.org/2/tutorial/modules.html#packages i see that: you can use absolute imports to refer to submodules of siblings packages. This is what I can't get to work in my case. Her

Re: Are imports supposed to be like this?

2016-05-09 Thread Random832
On Mon, May 9, 2016, at 19:54, Brendan Abel wrote: > Consider the following example python package where `a.py` and `b.py` > depend on each other: > > /package > __init__.py > a.py > b.py > > > There are several ways I could import the "a.py" module in "b.py" > >

Re: Are imports supposed to be like this?

2016-05-09 Thread Chris Angelico
nc_b: %d" % x) if x % 2: a.func_a(x-1) rosuav@sikorsky:~/tmp$ python3 Python 3.6.0a0 (default:98678738b7e9, May 2 2016, 13:37:04) [GCC 5.3.1 20160409] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import p

Are imports supposed to be like this?

2016-05-09 Thread Brendan Abel
syntax actually work when you have circular dependencies (the rest all raise `ImportError` or `AttributeError`), and the 4th syntax only works in python 2 and is generally discouraged because of the possibility of name conflicts. I'd much rather use relative imports, or the "from x im

Re: Python programs and relative imports

2016-04-08 Thread Ian Kelly
On Fri, Apr 8, 2016 at 11:50 AM, Rob Gaddi wrote: > Sort of. If I've got a directory full of files (in a package) > that I'm working on, the relative import semantics change based on > whether I'm one directory up and importing the package or in the same > directory and importing the files locall

Re: Python programs and relative imports

2016-04-08 Thread Chris Angelico
On Sat, Apr 9, 2016 at 3:50 AM, Rob Gaddi wrote: > Sort of. If I've got a directory full of files (in a package) > that I'm working on, the relative import semantics change based on > whether I'm one directory up and importing the package or in the same > directory and importing the files locally

Re: Python programs and relative imports

2016-04-08 Thread Rob Gaddi
Chris Angelico wrote: > On Sat, Apr 9, 2016 at 2:59 AM, Rob Gaddi > wrote: >> Rob Gaddi wrote: >> >>> Does anyone know the history of why relative imports are only available >>> for packages and not for "programs"? It certainly complicates life. >

Re: Python programs and relative imports

2016-04-08 Thread Chris Angelico
On Sat, Apr 9, 2016 at 2:59 AM, Rob Gaddi wrote: > Rob Gaddi wrote: > >> Does anyone know the history of why relative imports are only available >> for packages and not for "programs"? It certainly complicates life. >> > > Really, no one? It seems like

Re: Python programs and relative imports

2016-04-08 Thread Rob Gaddi
Rob Gaddi wrote: > Does anyone know the history of why relative imports are only available > for packages and not for "programs"? It certainly complicates life. > Really, no one? It seems like a fairly obvious thing to have included; all of the reasons that you want to be

Python programs and relative imports

2016-04-04 Thread Rob Gaddi
Does anyone know the history of why relative imports are only available for packages and not for "programs"? It certainly complicates life. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.

Re: A question about imports in wxpython

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 8:44 AM, wrote: > I'm playing with some code that uses the wxpython grid. *Every* > example I have seen starts with the imports:- > > import wx > import wx.grid as Gridlib > > As Gridlib is exactly the same number of characters as wx.gri

A question about imports in wxpython

2016-02-08 Thread cl
I'm playing with some code that uses the wxpython grid. *Every* example I have seen starts with the imports:- import wx import wx.grid as Gridlib As Gridlib is exactly the same number of characters as wx.grid I really don't see the point. Am I missing something? -- C

Re: How to fix my imports/file structure

2016-01-20 Thread Terry Reedy
test_database.py test_client.py My imports are simple. For example, client.py has the following at the top: from collection import Collection Basically, client has a Client class, collection has a Collection class, and database has a Database class. Not too tough. As long as I cd

Re: How to fix my imports/file structure

2016-01-20 Thread Steven D'Aprano
.pth file, as above. Now minu is a *package*, and the modules "client.py", "collection.py" etc. are assumed to collaborate rather than be a random collection of arbitrary modules. From *outside* of minu, you can import submodules of the package: import minu.collection from

How to fix my imports/file structure

2016-01-20 Thread Travis Griggs
imports are simple. For example, client.py has the following at the top: from collection import Collection Basically, client has a Client class, collection has a Collection class, and database has a Database class. Not too tough. As long as I cd into the minu directory, I can fire up a python3

py.test can't resolve imports

2015-02-24 Thread Mario Figueiredo
.py) /project/test<-- test files /project/docs <-- Sphinx I cannot seem to be able to have py.test resolve imports by running the following command from within the /project/project directory: $ py.test ../ Example scripts: /project/project/example.py

Re: Incompatible idioms: relative imports, top-level program file

2015-02-10 Thread Rustom Mody
On Sunday, February 8, 2015 at 3:52:19 AM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > Wanted to try out sympy. > > apt-install promised ź GB download, ž GB space usage > > > > Just getting a src-tarball was: 6M download, 30M after opening the tar. > > Have you actually tried compiling

Re: Incompatible idioms: relative imports, top-level program file

2015-02-07 Thread Gregory Ewing
Rustom Mody wrote: Wanted to try out sympy. apt-install promised ¼ GB download, ¾ GB space usage Just getting a src-tarball was: 6M download, 30M after opening the tar. Have you actually tried compiling and using that tarball, though? Sympy hooks into a lot of other libraries that are themsel

Re: Incompatible idioms: relative imports, top-level program file

2015-02-06 Thread Rustom Mody
On Saturday, February 7, 2015 at 8:43:44 AM UTC+5:30, Rustom Mody wrote: > There is on the one hand python modules/packages mechanism with all the > hell of dozens of incompatible versions of setuptools/distribute/distutils > etc. > > On the other there is the OS-specific practices/policy such a

Re: Incompatible idioms: relative imports, top-level program file

2015-02-06 Thread Rustom Mody
x27;s no need to explose those in a > > > site package, they normally only need to be local to the > > > application. > > > > If they are not in the Python module path, how are they imported at > > all? > > Only absolute imports use the module search path. The

Re: Incompatible idioms: relative imports, top-level program file

2015-02-06 Thread Ben Finney
he > > application. > > If they are not in the Python module path, how are they imported at > all? Only absolute imports use the module search path. The whole point of relative imports is to import a module within the same (or a sub-) package, without modifying the search path.

Re: Incompatible idioms: relative imports, top-level program file

2015-02-06 Thread Ethan Furman
thon module path, how are they imported at all? > Python deliberately divorces the top-level module from its package, so > it can't access its own relative modules! The relative import fails with > an ImportError “Attempted relative import in non-package”. My understanding is that impo

Incompatible idioms: relative imports, top-level program file (was: Setuptools, __init__ and __main__)

2015-02-06 Thread Ben Finney
ity that its implementation occupies several sub-modules. There's no need to explose those in a site package, they normally only need to be local to the application. So the correct idiom is ‘from __future__ import absolute_import’ and keep the application's own implementation

Re: module import questions and question about pytest and module imports

2014-12-08 Thread Ian Kelly
On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton wrote: > Having to put the garage package on the sys.path seems a little off, > why wouldn't relative imports work? Relative imports are relative to a package's hierarchy of namespaces, not relative to the file system. As such, you

Re: module import questions and question about pytest and module imports

2014-12-08 Thread Jean-Michel Pichavant
- Original Message - > From: "sam pendleton" > Having to put the garage package on the sys.path seems a little off, > why wouldn't relative imports work? > > Do most people somehow put their packages in sys.path when bundling > their python packages u

Re: module import questions and question about pytest and module imports

2014-12-08 Thread Dave Angel
directory. Is garage/ on your sys.path? You can examine sys.path by import sys print(sys.path) Having to put the garage package on the sys.path seems a little off, why wouldn't relative imports work? Do most people somehow put their packages in sys.path when bundling their p

Re: module import questions and question about pytest and module imports

2014-12-08 Thread sam pendleton
saying that pytest is hung up there stating it can't import that module. > If you're going to import something, it either has to be on the sys.path, or > in the current directory. Is garage/ on your sys.path? > > You can examine sys.path by >import sys >print(s

Re: module import questions and question about pytest and module imports

2014-12-07 Thread Dave Angel
On 12/05/2014 11:50 PM, sam pendleton wrote: garage/ |- __init__.py |- cars/ |- __init__.py |- hummer.py tests/ |- test_cars.py at the top of test_cars.py, there is this: from garage.cars import hummer pytest is on this import statement, so i guess it's inc

module import questions and question about pytest and module imports

2014-12-07 Thread sam pendleton
garage/ |- __init__.py |- cars/ |- __init__.py |- hummer.py tests/ |- test_cars.py at the top of test_cars.py, there is this: from garage.cars import hummer pytest is on this import statement, so i guess it's incorrect. what should it be? if i open a python repl

Re: how to add custom importer after the normal imports

2014-10-10 Thread Gelonida N
On 10/09/2014 04:14 PM, Ian Kelly wrote: I have a use case where I would like to add a custom importer *AFTER* all other import methods have failed. On Oct 9, 2014 6:53 AM, "Gelonida N" mailto:gelon...@gmail.com>> wrote: > I'm using Puthon 2.7 for the given project and there sys.meta_path is

Re: how to add custom importer after the normal imports

2014-10-09 Thread Ian Kelly
On Oct 9, 2014 6:53 AM, "Gelonida N" wrote: > I'm using Puthon 2.7 for the given project and there sys.meta_path is []. > > Just for fun I started Python3.3 and looked at it's meta_path, which contained for example _frozen_importlib.PathFinder > > Unfortunately python 2.7 does not seem to have the

Re: how to add custom importer after the normal imports

2014-10-09 Thread Gelonida N
On 10/9/2014 12:44 AM, Ian Kelly wrote: On Wed, Oct 8, 2014 at 4:53 AM, Gelonida N wrote: Hi, I just read about sys.meta_path, which allows to install custom importers *BEFORE* the default importers. However I have a use case where I would like to add a custom importer *AFTER* all other impo

Re: how to add custom importer after the normal imports

2014-10-08 Thread Ian Kelly
On Wed, Oct 8, 2014 at 4:53 AM, Gelonida N wrote: > Hi, > > > I just read about sys.meta_path, which allows to install custom importers > *BEFORE* the default importers. > > However I have a use case where I would like to add a custom importer > *AFTER* all other import methods have failed. > > Do

how to add custom importer after the normal imports

2014-10-08 Thread Gelonida N
Hi, I just read about sys.meta_path, which allows to install custom importers *BEFORE* the default importers. However I have a use case where I would like to add a custom importer *AFTER* all other import methods have failed. Does anybody know how to do this. One way of implementing this

Re: Absolute imports?

2014-02-15 Thread Peter Otten
Roy Smith wrote: > http://docs.python.org/2/whatsnew/2.5.html says: > > "Once absolute imports are the default, import string will always find > the standard library¹s version." > > Experimentally, it appears that modules in site-packages are also found > b

Re: Absolute imports?

2014-02-15 Thread Chris Angelico
On Sun, Feb 16, 2014 at 2:06 AM, Roy Smith wrote: > It also says, "This absolute-import behaviour will become the default in > a future version (probably Python 2.7)", but it appears that 2.7.6 is > still doing relative by default. > Since absolute imports can be co

Absolute imports?

2014-02-15 Thread Roy Smith
http://docs.python.org/2/whatsnew/2.5.html says: "Once absolute imports are the default, import string will always find the standard library¹s version." Experimentally, it appears that modules in site-packages are also found by absolute imports. I wouldn't consider site-package

  1   2   3   4   5   6   7   >