Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Steven D'Aprano
On Sun, Oct 18, 2015 at 08:07:07AM -0700, Alex Kleider wrote: > On 2015-10-17 19:49, Steven D'Aprano wrote: > > >which will work from your package's callers, and from within the > >package > >itself provided the top level directory can be found within Python's > >path. Within the package you can

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Ben Finney
Ben Finney writes: > * Python will automatically add a ‘sys.path’ entry for the directory > containing the script named on the command line. So this: > > $ cd ~/Projects/lorem/ > $ python3 ./setup.py test > > will run the ‘setup.py’ program with ‘sys.path’ already modified to >

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Ben Finney
Alex Kleider writes: > Should I add the following to the end of my ~/.bashrc file? > export PYTHONPATH="$PYTHONPATH:/home/alex/Py" No, because the entry should only be in PYTHONPATH *if* you want imports to come from that package. So the advice is: * For the run-time application, it should be

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Martin A. Brown
Hello Alex, How does one arrange so "the top level directory _can_ be found within Python's path."? >>> >>> Is the answer to include the following at the beginning of each file? >>> >>> if not 'path/to/top/level/package/directory' in sys.path: >>> sys.path.append('path/to/top/level/

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-18 10:26, Alan Gauld wrote: On 18/10/15 16:33, Alex Kleider wrote: How does one arrange so "the top level directory _can_ be found within Python's path."? Is the answer to include the following at the beginning of each file? if not 'path/to/top/level/package/directory' in sys.pat

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alan Gauld
On 18/10/15 16:33, Alex Kleider wrote: How does one arrange so "the top level directory _can_ be found within Python's path."? Is the answer to include the following at the beginning of each file? if not 'path/to/top/level/package/directory' in sys.path: sys.path.append('path/to/top/leve

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-18 08:07, Alex Kleider wrote: On 2015-10-17 19:49, Steven D'Aprano wrote: which will work from your package's callers, and from within the package itself provided the top level directory can be found within Python's path. Within the package you can also use relative imports, see the

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-17 19:49, Steven D'Aprano wrote: which will work from your package's callers, and from within the package itself provided the top level directory can be found within Python's path. Within the package you can also use relative imports, see the docs for more detail. How does one arra

Re: [Tutor] GET function not executed

2015-10-18 Thread Alan Gauld
On 18/10/15 06:09, Rahul Pathak wrote: Hi, I started with python web module and i have no experience with web. OK, web.py is not part of the standard library and I have no experience with that specific framework. I also see Peter Otten has picked up an issue about the urls set. But there's som

Re: [Tutor] GET function not executed

2015-10-18 Thread Peter Otten
Peter Otten wrote: > The use of {...} makes this a set literal, and the order of the items in a > set is undefined. To prevent a class of attacks on web applications it may > even change between invocations: Sorry, I forgot to include the source of setdemo.py. It contains just one line: print {

Re: [Tutor] GET function not executed

2015-10-18 Thread Peter Otten
Rahul Pathak wrote: > Hi, > > I started with python web module and i have no experience with web. > > I used the example which is on the web.py site - > > -- > import web > > urls = { > '/', 'index' > } > > class index: > def GET(self): >

[Tutor] GET function not executed

2015-10-18 Thread Rahul Pathak
Hi, I started with python web module and i have no experience with web. I used the example which is on the web.py site - -- import web urls = { '/', 'index' } class index: def GET(self): return "Hello World" if __name__ == "__mai