What are Python namespaces all about

前端 未结 6 1245
抹茶落季
抹茶落季 2020-11-30 23:14

I have just started learning Python & have come across \"namespaces\" concept in Python. While I got the jist of what it is, but am unable to appreciate

6条回答
  •  Happy的楠姐
    2020-11-30 23:59

    To understand namespaces, you also have to have some understanding of modules in Python. A module is simply a file containing Python code. This code can be in the form of Python classes, functions, or just a list of names. Each module gets it’s own global namespaces. So you can’t have two classes or two functions in the same module with the same name as they share the namespace of the module.

    reference: http://bytebaker.com/2008/07/30/python-namespaces/

提交回复
热议问题