On 1/6/2011 10:28 AM, dmitrey wrote: > hi all, > I have th PEP (I'm not sure something like that hadn't been proposed > although): > very often in a Python file header the following lines are present, > like: > from MyModule1 import myFunc1 > import MyModule2 as mm2 > from MyModule3 import myFunc3 as mf3 > etc ...
Personally, I always do all of my imports at the top of every program I write and like it when others do the same. The reason is that, in a single glance, I can see all of the dependencies of the program. For similar reasons of explicit clarity I prefer this construct: import re pat = re.compile(...) To something like this one: from re import compile as cp pat = cp(...) The only benefit I can see from your proposal is that it cuts down slightly on the number of characters in a program, but I think it does so at the cost of reducing explicit clarity and increasing the learning burden for a programmer who will have to learn two techniques (if only so she can read other people's code) instead of one. Also, there are only 95 printable ASCII characters most of which are already dedicated to other uses (e.g., for use in variable names.) I would hate to reserve one to do something that can be done equally well without reserving a character. I applaud your interest in improving the language but I don't think the benefit justifies the cost in this case. Alan -- http://mail.python.org/mailman/listinfo/python-list