Learning inheritance

Niklasro niklasro at gmail.com
Sun Sep 19 03:22:49 EDT 2010


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.environ.get("HTTP_HOST", os.environ["SERVER_NAME"]) #declared
as class variable(?)

And viola just test if util.url.find('niklas') > 0:

Exactly what I wanted to do with your experienced guidance.

Many thanks
Happy refactored



More information about the Python-list mailing list