Re: Application and package of the same name

2017-10-21 Thread Christopher Reimer
On Oct 21, 2017, at 6:08 AM, David Stanek wrote: > This is actually a common pattern I see when teaching the language. For > example, when a student wants to test out a package like requests many > seem to initially want to create a requests.py module. Then they become > very confused when they g

Re: Application and package of the same name

2017-10-21 Thread Skip Montanaro
This is actually a common pattern I see when teaching the language. For example, when a student wants to test out a package like requests many seem to initially want to create a requests.py module. Then they become very confused when they get an AttributeError on requests.get(). That I should fal

Re: Application and package of the same name

2017-10-21 Thread David Stanek
On 19-Oct 19:34, Paul Moore wrote: > On 19 October 2017 at 19:18, Skip Montanaro wrote: > > > > This is in Python 2.7, FWIW. What am I missing? > > My immediate reaction is "you shouldn't name your main program and > your package the same". It's not a pattern I've seen commonly used. > This is

Re: Application and package of the same name

2017-10-19 Thread Skip Montanaro
Have you toyed with "from __future__ import absolute_import" ? Not sure if it'd help or not, but worth a try. Yeah, I did, but it didn't change anything as far as I could tell. S -- https://mail.python.org/mailman/listinfo/python-list

Re: Application and package of the same name

2017-10-19 Thread Chris Angelico
On Fri, Oct 20, 2017 at 7:09 AM, Skip Montanaro wrote: >> My immediate reaction is "you shouldn't name your main program and >> your package the same". It's not a pattern I've seen commonly used. >> >> However, the approaches I've seen used (a __main__.py inside the >> package, so you can execute

Re: Application and package of the same name

2017-10-19 Thread Skip Montanaro
> My immediate reaction is "you shouldn't name your main program and > your package the same". It's not a pattern I've seen commonly used. > > However, the approaches I've seen used (a __main__.py inside the > package, so you can execute it via `python -m fribble`, or a setup.py > entry point to ge

Re: Application and package of the same name

2017-10-19 Thread Paul Moore
On 19 October 2017 at 19:18, Skip Montanaro wrote: > I'm not understanding something fundamental about absolute/relative > imports. Suppose I have an application, fribble.py, and it has a > corresponding package full of goodies it relies on, also named fribble. > From the fribble package, the appl