On 18 sep, 17:25, Niklasro <nikla...@gmail.com> 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 = os.environ.get("HTTP_HOST", os.environ["SERVER_NAME"]) => dict.get(key, default=None) Also and FWIW, neither HTTP_HOST not SERVER_NAME are really urls... > I repeat for many methods. So declaring it > to a super class and inheriting it is my plan. Do you agree or propose > otherwise? Not enough background to answer. -- http://mail.python.org/mailman/listinfo/python-list