len(dir(sys) len([ for in dir(sysif not startswith('__')] len([ for in dir(sysif not [ =' '] number names in sys non __x names only non underscore names to find out what attributes are provided in objects of built-in typesrun dir on literal or an existing instance of the desired type for exampleto see list and string attributesyou can pass empty objectsdir([]['__add__''__class__''__contains__'more 'append''clear''copy''count''extend''index''insert''pop''remove''reverse''sort'dir(''['__add__''__class__''__contains__'more 'split''splitlines''startswith','strip''swapcase''title''translate''upper''zfill'the dir results for any built-in type include set of attributes that are related to the implementation of that type (technicallyoperator overloading methods)much as in modules they all begin and end with double underscores to make them distinctand you can safely ignore them at this point in the book (they are used for oopfor instancethere are list attributesbut only that correspond to named methodslen(dir([]))len([ for in dir([]if not startswith('__')]( len(dir(''))len([ for in dir(''if not startswith('__')]( in factto filter out double-underscored items that are not of common program interestrun the same list comprehensions but print the attributes for instancehere are the named attributes in lists and dictionaries in python [ for in dir(listif not startswith('__')['append''clear''copy''count''extend''index''insert''pop''remove''reverse''sort'[ for in dir(dictif not startswith('__')['clear''copy''fromkeys''get''items''keys''pop''popitem''setdefault''update''values'this may seem like lot to type to get an attribute listbut beginning in the next we'll learn how to wrap such code in an importable and reusable function so we don' need to type it againdef dir ( )return [ for in dir(xif not startswith('__')see part iv dir (tuple['count''index'python documentation sources