On 19 June 2011 14:46, Lisi <[email protected]> wrote:
> On Sunday 19 June 2011 08:39:43 Alan Gauld wrote:
> > "Lisi" <[email protected]> wrote
> >
> > > It does indeed. Thank you, both of you. I have clearly not got the
> > > terms
> > > command, method, function (and feature?) clearly sorted out in my
> > > mind, so
> > > that is obviously where I need to go. I am supposed to be
> > > researching
> > > import, but I have not yet succeeded in seeing why it is a problem.
> > > So I'll
> > > switch to looking up method, function etc.
> >
> > Add "callable" to your list of search terms.
> > Python has the concept of "callable objects" and
> > you can call a callable by using parentheses.
> > You can also test whether an object is callable
> > or not:
> >
> > for obj in list_of_objects:
> > if callable(obj):
> > print obj() # call obj first
> > else:
> > print obj # just use the obj value
> >
> > HTH,
>
> Thank you!
>
> Lisi
>
> _______________________________________________
> Tutor maillist - [email protected]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
A good way to learn is making mistakes(in language it's the *only* way). I
don't think I will mistake variable_name with "variable_name" in the near
future!
I downloaded a text file of prime numbers - lots of them. Being clever(!), I
knew they were strs and I had to convert them to ints, so:
1. I put them all in memory - first mistake, but not fatal
2. I, very cleverly(I thought) used a list comprehension to convert them to
ints - OK
3. I did something like:
for prime in tooManyPrimes:
f.write("prime")
I did this with about 6 files!
--
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor