Some basic newbie questions...
Grant Edwards
grante at visi.com
Thu Dec 28 12:24:42 EST 2006
On 2006-12-28, jonathan.beckett <jonathan.beckett at gmail.com> wrote:
>> > Given the code below, why does the count method return what it does?
>> > How *should* you call the count method?
>> > a = []
>> > a.append(1)
>> > print a.count
>>
>> print a.count().
Which will cause an exception, BTW, since the count method
requires one parameter telling it what you want to count
occurrences of.
>> There's a "Python for VB programmers" out there somewhere, see
>> if you can find it. In python, functions (and methods which
>> are special cases of functions) are first class objects, so
>> you're printing the function object, not calling it.
> I'm not a VB programmer :)
He assumed you were because you were trying to call a function
without using parens. VB is probably the most common language
where you call something by writing
functionName
rather than
functionName()
IIRC Pascal precedures are called w/o parens, but if you pick
Joe Random off the 'net he's more likely to know VB than
Pascal.
> I normally work with PHP, C#, Javascript, and the odd bit of C++,
Do any of them call functions w/o parens?
--
Grant Edwards grante Yow! VICARIOUSLY
at experience some reason
visi.com to LIVE!!
More information about the Python-list
mailing list