The Python Game Book

code games. learn Python.

User Tools

Site Tools


Sidebar

Github:

en:glossary:v:vars

vars

vars(...)
    vars([object]) -> dictionary
    
    Without arguments, equivalent to locals().
    With an argument, equivalent to object.__dict__.

example:

>>>class Person:
	def __init__(self):
		self.first_name = "James"
		self.last_name = "Bond"



>>>agent007 = Person()
>>>vars(agent007)

{'first_name':'James', 'last_name':'Bond'}

en/glossary/v/vars.txt · Last modified: 2020/12/16 18:47 by horst