Shane Hathaway <[EMAIL PROTECTED]> writes: > Xavier Morel wrote: >> Shane Hathaway wrote: >> >>>Thoughts? >> >>> import re; name_expr = re.compile('[a-zA-Z]+') >> >>> name_expr >> <_sre.SRE_Pattern object at 0x00F9D338> >> >>> >> the import statement can be called anywhere in the code, why would >> you add strange syntactic sugar that doesn't actually bring anything? > > That syntax is verbose and avoided by most coders because of the speed > penalty. It doesn't replace the idiom of importing everything at the > top of the module. > > What's really got me down is the level of effort required to move code > between modules. After I cut 100 lines from a 500 line module and > paste them to a different 500 line module, I have to examine every > import in both modules as well as examine the code I moved for missing > imports. And I still miss a lot of cases. My test suite catches a lot > of the mistakes, but it can't catch everything.
I understand this use case. You can use pychecker to find NameErrors without actually running the code. Unfortunately, it doesn't (at least not always) find imports which are not needed. Thomas -- http://mail.python.org/mailman/listinfo/python-list