[問題] 如何知道 class member 的type
初學python
一直不知道怎樣知道class member 的type
ex:
http://tinyurl.com/34n8p2n
class YouTubeVideoEntry(gdata.GDataEntry)
__init__(self, author=None, category=None, content=None, atom_id=None,
link=None, published=None, title=None, updated=None, rating=None,
noembed=None, statistics=None, racy=None, media=None, geo=None,
recorded=None, comments=None, extension_elements=None,
extension_attributes=None)
怎麼會知道裡面的author, category, content 是什麼type
也許是list, tuple, class instance ..... ?
這樣如何繼續操作member ?
thanks
假設說member 是type class A;
但是我根本不知道他是class A 的instance
那我在寫程式時候怎麼去使用class A的member, function ?
用type() ? 這也要等到runtime 才會知道~~~
那寫程式時 程式員不是非常困擾嗎?
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.87.71.10
→
05/27 22:28, , 1F
05/27 22:28, 1F
→
05/27 22:28, , 2F
05/27 22:28, 2F
→
05/27 22:31, , 3F
05/27 22:31, 3F
→
05/27 23:46, , 4F
05/27 23:46, 4F
※ 編輯: phkmalloc 來自: 220.135.222.237 (05/28 06:59)
→
05/29 20:44, , 5F
05/29 20:44, 5F
Python 近期熱門文章
PTT數位生活區 即時熱門文章