other python ideas
Robert Amesz
rcameszREMOVETHIS at dds.removethistoo.nl
Mon Apr 9 19:59:12 EDT 2001
Douglas Alan wrote:
>"Jeff Petkau" <jpet at eskimo.com> writes:
>
>> [Snip]
>>
>> How is this any better than:
>
>> import my_really_long_named_module as m
>> m.foo(a, b, c) ?
>
>Well, because, like I said, I'd like to get rid of import statements
>altogether. A problem with import statements in general is that as
>you work on your code over a period of time, you end up with garbage
>imports. I.e., you import stuff that is no longer actually used.
Getting rid of import statements is *evil*. It means the dependencies
in your code will be hidden from others. Also, install and freeze
packages have a harder determining what modules are needed (which is
hard enough as it is).
If unused imports bother you, well, the other day I saw an announcement
here for a Python code checker. Perhaps it can check that too. If not,
perhaps its maker(s) may include it in the next version if you ask it
nicely enough. ("Please? Pretty please? ;-) )
>Another problem is that if you import individual objects from a
>module, and then you reload the module, the individual objects
>remain out of date. This causes you to end up trying in the
>debugger to track down bugs that turn out to debugger-only bugs.
Blame the debugger, not Python's module syntax. The debugger really
should start from scratch if you've edited a module, otherwise you're
actually modifying the program while it is still running. Very unsafe,
and there's no general way to fix that.
>
>>
>> [Using an auto-import function]
>>
>
>I could. But I probably wouldn't like the effect it would have on
>the performance of my program if I used it everywhere. Also, other
>people that have to work on my code might end up killing me.
Well, *I* would. Nothing personal, mind you... ;-)
import tools
weapon = tools.axe(blunt=1)
poster = "Douglas Alan"
weapon.grind()
try:
while 1:
poster = weapon.hack(poster)
except DecapitationException:
print "Oops. Sorry. I'll pay for the carpet-cleaners."
# 'poster' should be a tuple now
print poster
Robert Amesz
--
Hey, Python doesn't kill people, Per^Hople do.
More information about the Python-list
mailing list