how to get names of attributes

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Dec 30 09:16:32 EST 2015


On 30/12/2015 13:31, Charles T. Smith wrote:
>> I wonder what the difference is between vars() and items()
>
Not much. From https://docs.python.org/3/library/functions.html#vars
<quote>
vars([object])
 Return the __dict__ attribute for a module, class, instance, or any 
other object with a __dict__ attribute.
 Objects such as modules and instances have an updateable __dict__ 
attribute; however, other objects may have write restrictions on their 
__dict__ attributes (for example, classes use a dictproxy to prevent 
direct dictionary updates).
 Without an argument, vars() acts like locals(). Note, the locals 
dictionary is only useful for reads since updates to the locals 
dictionary are ignored.
</quote>
-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /