Three ways to use Python's 'vars' function

preview_player
Показать описание
Python's "vars" function can be used in three different ways — and while it's unlikely to play a part in your production code, it can be quite useful in debugging and exploring. In this video, I demonstrate all three of these uses, which can also give us insights into Python's variables and attributes.

Рекомендации по теме
Комментарии
Автор

you explained the function "vars" so nicely!

PythonlawsWelton
Автор

your explanations are always SO clear! thanks

d-i-ry
Автор

I really like SimpleNamespace to group variables and access values with the dot notation. So, one way I have been using vars() is to convert a SimpleNamespace to a dictionary since it doesn't have a dedicated method for it like NamedTuple have (_asdict()).

GuillaumeBeaudin
Автор

how is calling `vars()` different from `locals()` if `locals()` also returns global variables outside a function definition?

mergen.t
visit shbcf.ru