Menu

Post image 1
Post image 2
1 / 2
0

Quark's Outlines: Python Name Spaces

DEV Community·Mike Vincent·about 1 month ago
#Tpur1OHo
#problem#how#people#python#name#global
Reading 0:00
15s threshold

Quark’s Outlines: Python Name Spaces Overview, Historical Timeline, Problems & Solutions An Overview of Python Name Spaces What is a Python name space? When you write code in Python, you give names to values. A Python name space is the place where those names are stored. It is like a labeled shelf that holds objects. When you ask for a name, Python looks in the shelf to find it. A name space is a mapping between names and objects. In Python, that mapping is usually a dictionary. Each name space stores the current known names and their values. Python lets you manage names by storing them in name spaces. x = 5 print ( globals ()[ " x " ]) # prints: # 5 Enter fullscreen mode Exit fullscreen mode The globals() function returns the current global name space. You can look up a name and find its value. How many name spaces does Python use? Python uses three main name spaces when running code: local, global, and built-in. Each one is searched in order when Python tries to find a name. Local is the first shelf.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More