Trying to figure out the data type from the code snippet

DL Neil PythonList at DancesWithMice.info
Wed Jan 30 00:12:02 EST 2019


On 30/01/19 5:12 PM, Cameron Simpson wrote:
> On 30Jan2019 04:24, Chupo <bad_n_mad at yahoo.com> wrote:
>> I am trying to figure out what data type is assigned to variable p in
>> this code snippet:
>>
>> for p in game.players.passing():
>>    print p, p.team, p.passing_att, p.passer_rating()
> 
> Well, Python comes with a type() builtin function:
> 
>   print type(p)


Alternately/additionally, if you ask help(p), it will reveal-all about 
the "class" (of which p is an "instance") - including some answers to 
your second question (and perhaps others which logically follow-on).

If these terms are unfamiliar to you, then 'the manual' reference is 
https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes 
(although from the code above, it would appear that you are looking at 
Python 2.n!). There are plenty of other tutorials available. 
Additionally, Coursera has announced a course starting this week 
(U.Michigan), in Python and its classes - which can be audited for $free 
or used to obtain some sort of certification...

-- 
Regards =dn



More information about the Python-list mailing list