Re: Feature suggestion -- return if true

2011-04-12 Thread zildjohn01
Wow. Two dozen replies, the majority of which are arguing over whether the end of my snippet is reachable. I thought the behavior of if statements was well-established by this point. Regardless of James Mills's coding prowess, I suppose I should follow his advice and repost this to the python-idea

Feature suggestion -- return if true

2011-04-11 Thread zildjohn01
This is an idea I've had bouncing around in my head for a long time now. I propose the following syntax: return? expr be expanded to _temp = expr if _temp: return _temp It's a pattern I use all the time in my code, and although it's a bit unorthodox, IMO it's concise, readable, and

Dynamic imports + relative imports in Python 3

2011-02-22 Thread zildjohn01
This is a copy-paste of a StackOverflow question. Nobody answered there, but I figured I might have better luck here. I have a Python 3 project where I'm dynamically importing modules from disk, using `imp.load_module`. But, I've run into an problem where relative imports fail, when the relative i