Re: Project-wide variable...

2011-06-23 Thread Guillaume Martel-Genest
On Jun 23, 9:41 am, Gnarlodious wrote: > Is there a way to declare a project-wide variable and use that in all > downstream modules? > > -- Gnarlir What about using an environment variable? -- http://mail.python.org/mailman/listinfo/python-list

Re: Handling import errors

2011-06-22 Thread Guillaume Martel-Genest
I did not think about using a global variable, and the top-level try...except solution is interesting. After further thinking, I have to reformulate my initial question: How do I manage to run code before my imports? For example, I want to make sure that I can use the logging module in the case a

Handling import errors

2011-06-21 Thread Guillaume Martel-Genest
What is the pythonic way to handle imports error? What is bugging me is that the imports can't be inside a function (because I use them in different places in the script and thus they have to be in the global scope). I would write something like: try: import foo except ImportError: logging

Handling import errors

2011-06-21 Thread Guillaume Martel-Genest
What is the pythonic way to handle imports error? What is bugging me is that the imports can't be inside a function (because I use them in different places in the script and thus they have to be in the global scope). I would write something like: try: -- http://mail.python.org/mailman/listinfo/py

import from environment path

2011-06-17 Thread Guillaume Martel-Genest
Hi, Here's my situation : I got a script a.py that need to call b.py. The 2 scripts can't be in a same package. Script a.py knows the path of b.py relative to an environment variable B_PATH, let's say B_PATH/foo/ b.py. The solution I found is to do the flowwing : b_dir = os.path.join(os.environ['