addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

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

From: Ned B.
Sent on: Saturday, August 14, 2010 3:12 PM
Jordan, you are right that Python's assignment and C's are different: C's is an expression, Python's is a statement.  The syntax of the Python statement is something like {lhs = }+ rhs .  I made up that meta-syntax, but you get what I mean: as many left-hand sides as you like, as long as there is one, and a right-hand side.

Not having an assignment expression prevents errors in Python like C's    if (c = 3) {

--Ned (grew up in NYC, but now just a lurker from Boston)

On 8/14/2010 1:22 PM, Jordan P wrote:
Holy inefficiency, Batman! I had no idea that list.insert was linear!
David: I am actually dealing with huge lists. This is part of a project for school, so the code may actually be analyzed by the prof for efficiency, and he may well throw 1,000,000 values at it.

Also, I believe that a=b=2 in python is subtly different than C's implementation. I think python implements this as a special case (chained = operators), whereas in C, it is merely an artifact of almost all operations evaluating as their result. For example:

a = ( b = 3 ) is a syntax error in python, yet works as expected in C because (b = 3) will actually evaluate to 3.

I hear what everyone is saying, it's a design decision. So, yes, one could easily implement helper functions to call list.insert and return the list (or subclass list). I guess that's just what one has to do in python to get this behavior.

Thanks for the explanations, I hope everyone has relaxing weekends!

On Sat, Aug 14, 2010 at 12:25 PM, David Christian <[address removed]> wrote:

Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jordan P ([address removed]) from The New York Python Meetup Group.
To learn more about Jordan P, 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