On 11/10/2010 10:07 PM, Lawrence D'Oliveiro wrote: > In message <mailman.803.1289374804.2218.python-l...@python.org>, Ian Kelly > wrote: > >> > On 11/9/2010 11:14 PM, r0g wrote: >>> >> >>> >> config = {} >>> >> for line in (open("config.txt", 'r')): >>> >> if len(line) > 0 and line[0] <> "#": >>> >> param, value = line.rstrip().split("=",1) >>> >> config[param] = value >> > >> > That's five whole lines of code. Why go to all that trouble when you >> > can just do this: >> > >> > import config > Not a good idea. [...]
Sure, you wouldn't want users editing imported Python files, it would be leaving your program hostage to all the things an ignorant or malevolent user might do. But practical for, for example, experimental work. I seem to remember that the major server project in "Python Web Programming" has all configurable modules importing a common Config module, though in my own defense that *was* almost ten years ago now. (That wasn't intended to be a production server though it ran sporadically on a computer in my basement for several years and produced a traceback occasionally). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list