[Tutor] 3 simple, pithy and short questions (fwd)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Nov 21 15:45:07 EST 2003

Hi Tadey,

Please send your questions to tutor at python.org.  I'll forward your
question for you this time, but please be careful to ask your questions on
the list in the future.

Please don't keep sending messages only to me, as you're circumventing the
informal "load-balancing" that all the tutors perform.  Your questions are
very good ones, and it would be an injustice to deny you from getting the
best answers that our community can provide you.

For more justification for using the mailing lists, you can read:


---------- Forwarded message ----------
Date: Fri, 21 Nov 2003 05:27:32 +0100
From: Tadey <tayiper at volja.net>
To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
Subject: 3 simple, pithy and short questions

Hello ...

I discovered in-built help as late as now (or I know there was some help,
but didn't know how to use it eficiently), so it is really helpfull ...
though sometimes a little indistinct for "pure" begginer ...

So I have a few very simple, pithy and short questions:

1.) Where is the difference between "processing" some functon (let say
"str" function) like str(a) and like a.__str__()  ??

See two examples below:

>>> a = "ww"
>>> str(a)

>>> a.__str__()

2.) What hash function does ?? I noticed, that in case if some random
string is assigned to variable, it returns some long/huge number ....

See example below:

>>> b = "r"
>>> hash(b)

3.) About __getattribute__ function: In help it is "represented" by
a.getattribute('name') <=> a.name But whatever I typed, I couldn't get
some "reasonable" output, meaning I always got an error message ...

>>> a= ("ww", "rr", "gggg")
>>> a.getattribute(1)
Error: attribute name must be a string

>>> a.getattribute("rr")
Error: string object has no atrribute "rr"

>>> a.getattribute()
Error: function takes exactly 1 argument (0 given)

Thanks, Tadey

More information about the Tutor mailing list