[Python-Dev] PEP 328 and PEP 338, redux
Nick Coghlan
ncoghlan at gmail.com
Thu Jun 29 12:56:28 CEST 2006
More information about the Python-Dev mailing list
Thu Jun 29 12:56:28 CEST 2006
- Previous message: [Python-Dev] PEP 328 and PEP 338, redux
- Next message: [Python-Dev] PEP 328 and PEP 338, redux
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote: > On 6/28/06, Nick Coghlan <ncoghlan at gmail.com> wrote: > >> The workaround to replace __name__ with __module_name__ in order to >> enable >> relative imports turned out to be pretty ugly, so I also worked up a >> patch to >> import.c to get it to treat __module_name__ as an override for >> __name__ when >> __name__ == '__main__'. > > Ah, clever. +1. In that case, I'll check it straight in. It was actually surprisingly easy to do, given how finicky import.c can get (this particular change was able to be handled entirely inside get_parent()). >> So given a test_foo.py that started like this: >> >> import unittest >> import ..foo > > Um, that's not legal syntax last I looked. Leading dots can only be > used in "from ... import". Did you change that too? I really hope you > didn't! It's OK - I just spelt it wrong in the example. It should have said "from .. import foo". Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
- Previous message: [Python-Dev] PEP 328 and PEP 338, redux
- Next message: [Python-Dev] PEP 328 and PEP 338, redux
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list