Re: Learning inheritance

2010-09-25 Thread Niklasro
On Sep 21, 1:30 am, alex23 wrote: > Bruno Desthuilliers > wrote: > > > alex23 a écrit : > > > Python only actually executes a module the first time it's imported, > > > Beware of multithreading and modules imported under different names... > > There can be issues with both in some web frameowrks.

Re: Learning inheritance

2010-09-25 Thread Niklasro
On Sep 20, 7:39 am, Bruno Desthuilliers wrote: > Niklasro a écrit : > > > Good to learn what I'm doing :-) since important being able to explain > > choices taken farther than "doing it because it works". > > I understand the concept of modules may not correspond to java > > programming where I co

Re: Learning inheritance

2010-09-20 Thread alex23
Bruno Desthuilliers wrote: > alex23 a écrit : > > Python only actually executes a module the first time it's imported, > > Beware of multithreading and modules imported under different names... > There can be issues with both in some web frameowrks. Good points, Bruno, thank you. Niklasro, a goo

Re: Learning inheritance

2010-09-20 Thread Bruno Desthuilliers
Niklasro a écrit : Good to learn what I'm doing :-) since important being able to explain choices taken farther than "doing it because it works". I understand the concept of modules may not correspond to java programming where I come from. Coming from Java - and specially if you only have exper

Re: Learning inheritance

2010-09-20 Thread Bruno Desthuilliers
alex23 a écrit : Python only actually executes a module the first time it's imported, Beware of multithreading and modules imported under different names... There can be issues with both in some web frameowrks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning inheritance

2010-09-19 Thread Niklasro
On Sep 19, 8:12 am, Thomas Jollans wrote: > On 2010-09-19 09:22, Niklasro wrote:> util.py: > > url = os.environ.get("HTTP_HOST", os.environ["SERVER_NAME"]) #declared > > as class variable(?) > > There is no class here, so this is no class variable, and you're not > inheriting anything. You're simp

Re: Learning inheritance

2010-09-19 Thread Thomas Jollans
On 2010-09-19 09:22, Niklasro wrote: > util.py: > url = os.environ.get("HTTP_HOST", os.environ["SERVER_NAME"]) #declared > as class variable(?) > There is no class here, so this is no class variable, and you're not inheriting anything. You're simply using a module. > And viola just test if util

Re: Learning inheritance

2010-09-19 Thread Niklasro
It works but I don't know whether it's formally inheritance or class variable. Before code was url = os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else os.environ['SERVER_NAME'] if url.find('niklas') > 0: and now the change saves me from repeating myself! util.py: url = os.envir

Re: Learning inheritance

2010-09-19 Thread Niklasro
On Sep 19, 2:31 am, alex23 wrote: > Niklasro wrote: > > I got 2 files main.py and i18n both with > > webapp request handlers which I would like access the variable. > > I'd probably use a module for this. Create a third file, called > something like shared.py, containing the line that bruno gave

Re: Learning inheritance

2010-09-19 Thread Niklasro
On Sep 18, 11:15 pm, Jorgen Grahn wrote: > On Sat, 2010-09-18, Niklasro wrote: > > Hi > > How can I make the visibility of a variable across many methods or > > files? To avoid repeating the same line eg     url = > > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else > > os.environ['SERV

Re: Learning inheritance

2010-09-18 Thread alex23
Niklasro wrote: > I got 2 files main.py and i18n both with > webapp request handlers which I would like access the variable. I'd probably use a module for this. Create a third file, called something like shared.py, containing the line that bruno gave above: url = os.environ.get("HTTP_HOST", os.e

Re: Learning inheritance

2010-09-18 Thread Carl Banks
On Sep 18, 4:15 pm, Jorgen Grahn wrote: > On Sat, 2010-09-18, Niklasro wrote: > > Hi > > How can I make the visibility of a variable across many methods or > > files? To avoid repeating the same line eg     url = > > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else > > os.environ['SERVE

Re: Learning inheritance

2010-09-18 Thread Niklasro
On Sep 18, 4:13 pm, "bruno.desthuilli...@gmail.com" wrote: > On 18 sep, 17:25, Niklasro wrote: > > > Hi > > How can I make the visibility of a variable across many methods or > > files? To avoid repeating the same line eg     url = > > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else >

Re: Learning inheritance

2010-09-18 Thread Jorgen Grahn
On Sat, 2010-09-18, Niklasro wrote: > Hi > How can I make the visibility of a variable across many methods or > files? To avoid repeating the same line eg url = > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else > os.environ['SERVER_NAME'] I repeat for many methods. So declaring it >

Re: Learning inheritance

2010-09-18 Thread bruno.desthuilli...@gmail.com
On 18 sep, 17:25, Niklasro wrote: > Hi > How can I make the visibility of a variable across many methods or > files? To avoid repeating the same line eg     url = > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else > os.environ['SERVER_NAME'] First learn to use Python correctly: url =