Jun-19-2024, 06:42 PM
(This post was last modified: Jun-19-2024, 06:43 PM by Gribouillis.)
(Jun-19-2024, 03:31 PM)Curbie Wrote: are global variables initialized if I import and call a particular function in a module, seems like they must be but, still trying to head-wrap this stuff?Yes. The first time a pure Python module is imported, the code that it contains is executed, hence the global variables are assigned. Also note that functions and classes defined at module level are global variables too.
>>> def spam(): ... pass ... >>> spam <function spam at 0x7ff2fb34db40>
(Jun-19-2024, 03:31 PM)Curbie Wrote: Can Global variables from an imported module be accessed from the importing module?Yes.
(Jun-19-2024, 03:31 PM)Curbie Wrote: I haven't found any py libraries tutorialYour first source of documentation is the official documentation, especially the standard library.
Searching the standard library can be a little tedious, you could use my 'pyman' script in a terminal. For example if you type
pyman pathlib
it will open the Python documentation with the search term pathlib.A comprehensive introduction to the standard library's modules is the pyMOTW-3 site by Doug Hellmann. He gives example code for many standard modules.
« We can solve any problem by introducing an extra level of indirection »