[Tutor] Need Explanation...

Homme, James james.homme at highmark.com
Mon Dec 12 21:33:01 CET 2011


Hi Alan,
I'm sorry. I'm coming pretty much from Cobol and freaking out about OO, so my questions may not be coming from a familiar place. I think I was referring partly to the idea that, for example, len and open are built in functions, whereas append is part of a list. I just am now to the place in Python where I understand some things about making classes and using them, but not a lot more. If I'm unintentionally implying anything else, I'm unaware of what it might be.

I've used classes on purpose when I was working with LotusScript in my Lotus Notes development work, and I know that I have used them in other programming areas, but I've only recently purposely begun to get over the hump of learning to make them and really try to understand how they work. My programming knowledge is all over the place, since I have no formal computer science training.

Thanks for your patience.

Jim

-----Original Message-----
From: tutor-bounces+james.homme=highmark.com at python.org [mailto:tutor-bounces+james.homme=highmark.com at python.org] On Behalf Of Alan Gauld
Sent: Monday, December 12, 2011 2:58 PM
To: tutor at python.org
Subject: Re: [Tutor] Need Explanation...

James H wrote:
>> Is that the same problem with using the len function on sequences
 > and open on files, or is it different?

I don't think so. I'm not sure which problem you are referring to with
these?

Neither return None...

> But a python list is mutable. I'm hardly an expert, but the idea is
> you are modifying the list. Why would you create another copy of
> the same list via a return statement?

You wouldn't you'd return the same, now-modified, object.

James R wrote:
> I don't see this as a weakness but a strength.
> It cuts back on confusion and extraneous variables.

It creates confusion too. Look at how many posts we get
because people try to do things like:

mylist = mylist.sort()

Actually it can introduce extraneous variables because
you need a temp to hold the modified list while you perform the extra
operations. With method chaining you do it all on one line.
Now the good news is that in Python you can use one variable to hold
both the intermediate list and the final result, so its not often a new
variable just a double use of a single one.

I suspect the value of this is only apparent if you have
used Smalltalk :-)

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

________________________________

This e-mail and any attachments to it are confidential and are intended solely for use of the individual or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not keep, use, disclose, copy or distribute this e-mail without the author's prior permission. The views expressed in this e-mail message do not necessarily represent the views of Highmark Inc., its subsidiaries, or affiliates.


More information about the Tutor mailing list