addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwchatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgoogleimageimagesinstagramlinklocation-pinmagnifying-glassmailminusmoremuplabelShape 3 + Rectangle 1outlookpersonplusprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [nycpython] question about list.insert()

From: Jordan P
Sent on: Saturday, August 14, 2010 1:56 AM
Ha, maybe this comes from my C programming background, but yes, I would expect a=2 to evaluate to 2!

I've always wondered why python didn't support this. I guess its the same "design" decision. What do you have against such behavior?


On Fri, Aug 13, 2010 at 11:33 PM, Jon Stanley <[address removed]> wrote:
On Fri, Aug 13, 2010 at 11:23 PM, Jordan P <[address removed]> wrote:

> Why the decision was made to not return anything from list methods. Because
> honestly, I can't imagine why they do not.

You're taking in-place action on the list. Personally, I don't think
it makes sense (and would be confusing) for Python to return the
results of that in place manipulation. IMHO, it's doing the exact
right thing. Where does it stop? Take the following example:

In [5]: a = 2

In [6]: a += 2

In [7]: a
Out[7]: 4

Would you consider it appropriate for the first and second statements
to return 2 and 4, respectively? I sure don't - I'm performing an
operation on the variable that I want to be reflected *in that


Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jon Stanley ([address removed]) from The New York Python Meetup Group.
To learn more about Jon Stanley, visit his/her member profile:
To unsubscribe or to update your mailing list settings, click here:
Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy