[Python-Dev] chained assignment weirdity

2012-11-06 Thread Chris Withers
Hi All, I bumped into this using Michael Foord's Mock library. It feels like a bug to me, but thought I'd ask here before logging one in the tracker in case people know that we won't be able to fix it: On 05/11/2012 13:43, Michael Foord wrote: class Foo(object): ... def __setattr__(s, k,

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Devin Jeanpierre
On Tue, Nov 6, 2012 at 1:18 AM, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I bumped into this using Michael Foord's Mock library. It feels like a bug to me, but thought I'd ask here before logging one in the tracker in case people know that we won't be able to fix it: On 05/11/2012

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Terry Reedy
On 11/6/2012 1:18 AM, Chris Withers wrote: Hi All, I bumped into this using Michael Foord's Mock library. It feels like a bug to me, but thought I'd ask here before logging one in the tracker in case people know that we won't be able to fix it: On 05/11/2012 13:43, Michael Foord wrote:

Re: [Python-Dev] ctypes is not an acceptable implementation strategy for modules in the standard library?

2012-11-06 Thread Trent Nelson
On Mon, Nov 05, 2012 at 03:36:00AM -0800, Victor Stinner wrote: I'm not sure that ctypes is always available (available on all platforms). Indeed. Every non-x86 Snakebite platform has pretty serious issues with ctypes. I spent a morning looking into one platform, Solaris 10 on

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Rob Cliffe
On 06/11/2012 12:01, Nick Coghlan wrote: As noted, it's really only counterintuitive if your intuition is primed to expect C style right to left chained assignments. Python, on the other hand, is able to preserve primarily left to right evaluation in this case with only the far right hand

Re: [Python-Dev] cpython (3.3): Add examples for opener argument of open (#13424).

2012-11-06 Thread Éric Araujo
Hi, Le 05/11/2012 13:04, Georg Brandl a écrit : Please heed your Sphinx warnings: the :ref:`dir_fd` needs a link caption, since it can't autogenerate one (the dir_fd anchor does not point to a heading). Okay. I hadn’t noticed it because I was using my system sphinx-build instead of a local

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread MRAB
On 2012-11-06 15:02, Rob Cliffe wrote: On 06/11/2012 12:01, Nick Coghlan wrote: As noted, it's really only counterintuitive if your intuition is primed to expect C style right to left chained assignments. Python, on the other hand, is able to preserve primarily left to right evaluation in

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Guido van Rossum
+1 to what Nick said. And I thought about this carefully when designing the language. It's not a bug. The note about assignment RHS being evaluated before LHS is normative -- you just have to interpret RHS as after the *last* '=' symbol. Assignment itself is *not* an expression. On Tue, Nov 6,

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Serhiy Storchaka
On 06.11.12 14:01, Nick Coghlan wrote: Python, on the other hand, is able to preserve primarily left to right evaluation in this case with only the far right hand expression needing to be evaluated out of order. I'm surprised, but it is really so. {}[print('foo')] = print('bar') bar

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread R. David Murray
On Tue, 06 Nov 2012 18:14:38 +0200, Serhiy Storchaka storch...@gmail.com wrote: Another counterintuitive (and possible wrong) example: {print('foo'): print('bar')} bar foo {None: None} http://bugs.python.org/issue11205 --David ___

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Ned Batchelder
On 11/6/2012 11:26 AM, R. David Murray wrote: On Tue, 06 Nov 2012 18:14:38 +0200, Serhiy Storchaka storch...@gmail.com wrote: Another counterintuitive (and possible wrong) example: {print('foo'): print('bar')} bar foo {None: None} http://bugs.python.org/issue11205 This

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Devin Jeanpierre
On Nov 6, 2012 1:05 PM, Ned Batchelder n...@nedbatchelder.com wrote: On 11/6/2012 11:26 AM, R. David Murray wrote: On Tue, 06 Nov 2012 18:14:38 +0200, Serhiy Storchaka storch...@gmail.com wrote: Another counterintuitive (and possible wrong) example: {print('foo'): print('bar')}

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Ned Batchelder
On 11/6/2012 1:19 PM, Devin Jeanpierre wrote: On Nov 6, 2012 1:05 PM, Ned Batchelder n...@nedbatchelder.com mailto:n...@nedbatchelder.com wrote: On 11/6/2012 11:26 AM, R. David Murray wrote: On Tue, 06 Nov 2012 18:14:38 +0200, Serhiy Storchaka storch...@gmail.com

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Greg Ewing
MRAB wrote: That would make augmented assignment more difficult. For example, how would you write the equivalent of x -= y? SUBTRACT x FROM y. CLOSE POST WITH SMILEY. -- Greg ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Guido van Rossum
On Tue, Nov 6, 2012 at 9:58 AM, Ned Batchelder n...@nedbatchelder.com wrote: On 11/6/2012 11:26 AM, R. David Murray wrote: On Tue, 06 Nov 2012 18:14:38 +0200, Serhiy Storchaka storch...@gmail.com wrote: Another counterintuitive (and possible wrong) example: {print('foo'):

[Python-Dev] 回复: Python-Dev Digest, Vol 112, Issue 8

2012-11-06 Thread 邓九祥
I hava some question about Object which inital need ,but return object in mongo shell. So   BSONElement initial = p[initial]; if ( initial.type() != Object ) { errmsg = initial has to be an object; return false; }  initial.type() != Object

Re: [Python-Dev] chained assignment weirdity

2012-11-06 Thread Serhiy Storchaka
On 06.11.12 21:00, Ned Batchelder wrote: If someone really needs to control whether the keys or values are evaluated first, they shouldn't use a dict literal. Not only a dict literal. {print('foo'): print('bar') for x in [1]} bar foo {None: None}