Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How is space of variables/functions/objects... called?
When you run a Python session, it stores all the variables you declare, and functions, objects... and you can access them at any time. Once you exit this Python session, and run a new one, all that was declared before will be gone.
I would like to know, how is this "session" called? Or is it a workspace? Or maybe scope? I tried to find it out online but honestly, I didn't even know how to search properly =/ Thank you, JC
I guess it would be namespace
Python Docs Wrote:A namespace is a mapping from names to objects. Most namespaces are currently implemented as Python dictionaries, but that’s normally not noticeable in any way (except for performance), and it may change in the future. Examples of namespaces are: the set of built-in names (containing functions such as abs(), and built-in exception names); the global names in a module; and the local names in a function invocation. In a sense the set of attributes of an object also form a namespace. The important thing to know about namespaces is that there is absolutely no relation between names in different namespaces; for instance, two different modules may both define a function maximize without confusion — users of the modules must prefix it with the module name.
Uh, thanks but I'm not sure about this... namespace seems more like, for example, difference between math.sin() and my_module.sin().
Those are examples of namespaces, but what you were asking about is a special namespace as well. Just continue reading:

Quote:Namespaces are created at different moments and have different lifetimes. The namespace containing the built-in names is created when the Python interpreter starts up, and is never deleted. The global namespace for a module is created when the module definition is read in; normally, module namespaces also last until the interpreter quits. The statements executed by the top-level invocation of the interpreter, either read from a script file or interactively, are considered part of a module called __main__, so they have their own global namespace. (The built-in names actually also live in a module; this is called builtins.)
Ah, alright, it seems like this is what I was looking for =) Apologies for the confusion and thanks a lot for clearing it up for me!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  visibility/space of variables. Pls help. gtlhbkkj 1 85 Oct-12-2019, 05:51 PM
Last Post: buran
  modifying variables in local or global space Skaperen 2 170 Aug-14-2019, 07:13 AM
Last Post: Skaperen
  How do you add the results together each time a function is called? Exsul 10 563 Aug-09-2019, 09:18 PM
Last Post: ichabod801
  Best method: Python script called from another app, package as complete executable ironfelix717 2 230 Jul-24-2019, 07:39 AM
Last Post: DeaD_EyE
  Called Functions Not Working WhatAmIDoing09 3 244 Jul-12-2019, 07:02 PM
Last Post: ichabod801
  How to plot implicit functions (with two variables) in scipy python using matplotlib? Jay_Nerella 1 733 May-11-2019, 01:17 AM
Last Post: scidam
  Getting error when called through instance method aankrose 2 394 Mar-02-2019, 07:19 PM
Last Post: aankrose
  Use Variables Generated from Functions in different files to use on the main file AykutRobotics 3 479 Jan-01-2019, 04:19 PM
Last Post: AykutRobotics
  How can classes access each other Functions and Variables at the same time PythonOK 4 414 Dec-09-2018, 03:46 AM
Last Post: ichabod801
  can't pass instance variables between functions? mepyyeti 2 891 Jan-20-2018, 01:49 AM
Last Post: mepyyeti

Forum Jump:

Users browsing this thread: 1 Guest(s)