Re: Inline assignments

2006-03-09 Thread Steven D'Aprano
On Thu, 09 Mar 2006 15:45:13 +, Duncan Booth wrote: > Like it or not, Python uses exceptions for normal loop flow control. That's > a fact of life, live with it: every normal termination of a for loop is an > exception. Real exceptions don't get masked: for loops terminate with > StopIterat

Re: Inline assignments

2006-03-09 Thread Jorge Godoy
Duncan Booth <[EMAIL PROTECTED]> writes: > wrote: > >> Coming from a background that exposed me to far too many languages, I >> find the latter two examples (i.e. use try/except) to be horrible >> solutions. It's not a matter of light/heavy weight, it's a matter of >> using exceptions for normal

Re: Inline assignments

2006-03-09 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > I recommend reading Effective Java (Bloch), specifically the beginning > of the exceptions chapter, for more details why using exceptions to > exit loops is a bad thing (and while the title is effective java, much > of it is directly applicable to a lot of python

Re: Inline assignments

2006-03-09 Thread Duncan Booth
wrote: > Coming from a background that exposed me to far too many languages, I > find the latter two examples (i.e. use try/except) to be horrible > solutions. It's not a matter of light/heavy weight, it's a matter of > using exceptions for normal loop flow control is a really bad idea. > 1) I

Re: Inline assignments

2006-03-09 Thread jillson
Coming from a background that exposed me to far too many languages, I find the latter two examples (i.e. use try/except) to be horrible solutions. It's not a matter of light/heavy weight, it's a matter of using exceptions for normal loop flow control is a really bad idea. 1) I think it's less cle

Re: Inline assignments

2006-03-05 Thread Steven D'Aprano
On Sun, 05 Mar 2006 15:09:28 +0100, Fredrik Tolf wrote: > Hi list! > > I'm relatively new to Python, and one thing I can't seem to get over is > the lack of in-expression assignments, as present in many other > languages. I'd really like to know how Python regulars solve the > problems posed by t

Re: Inline assignments

2006-03-05 Thread Alex Martelli
Fredrik Tolf <[EMAIL PROTECTED]> wrote: ... > I'm relatively new to Python, and one thing I can't seem to get over is > the lack of in-expression assignments, as present in many other > languages. I'd really like to know how Python regulars solve the > problems posed by that. In general, we've

Re: Inline assignments

2006-03-05 Thread Duncan Booth
Fredrik Tolf wrote: > However, since I can't do that in Python, I ended up using an extra > local variable instead, like this: > > f = getattr(self, "cmd_" + name) > f2 = getattr(self, "cmdv_" + name) > if callable(f): > # Do something with f > elif callable(f2): > # Do something with f2

Re: Inline assignments

2006-03-05 Thread Peter Hansen
Fredrik Tolf wrote: > I'm relatively new to Python, and one thing I can't seem to get over is > the lack of in-expression assignments, as present in many other > languages. I'd really like to know how Python regulars solve the > problems posed by that. > > For example, I recently wanted to do this

Inline assignments

2006-03-05 Thread Fredrik Tolf
Hi list! I'm relatively new to Python, and one thing I can't seem to get over is the lack of in-expression assignments, as present in many other languages. I'd really like to know how Python regulars solve the problems posed by that. For example, I recently wanted to do this: if callable(f = get