Python Forum
function NOT imported from a module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function NOT imported from a module
#7
what mechanism is taking place that defines what symbols go where in this? i ask because i am seeing that non-function symbol names that were not expressed in the import statement are not visible to the caller (which imported the function it calls), but are visible to that function.

1. is it a different global space?

2. is it a mechanism that makes two (or more) namespaces appear as one (like an overlay filesystem does).

3. is python putting the symbols in when the function is being called and taken backout when it returns?

in the unnamed language i was designing, that design does a similar thing, but achieves it by an overlay where all code always sees everything that is where it comes by a means of an overlay with locals on top. if the code is referenced via an instance (a class object), then a 4th layer for the instance is also there (allowing objects to keep data local, or save it with the object instance, or share it among all instances of the same class (more layers here for inherited instances), or globally (the caller can get to here).

i'm wanting to understand how Python does it, in terms of what the language is supposed to give us, as opposed to any artifacts of some implementation. i am planning to make a little storage module that can do this for caller functions. i have dabbled in this and it seems to work. more complex cases like separate imports have yet to be tested. but i hate determining this by test code because it will include the artifacts of the CPython implementation i have.

what is this nonlocals={} ? yet another space? where do the real locals fit in?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
function NOT imported from a module - by Skaperen - Aug-21-2018, 10:15 PM
RE: function NOT imported from a module - by Skaperen - Aug-24-2018, 11:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 736 Aug-06-2023, 01:09 AM
Last Post: aupres
  Can a module tell where it is being imported from? stevendaprano 3 1,207 Apr-12-2022, 12:46 AM
Last Post: stevendaprano
  module detecting if imported vs not Skaperen 1 1,695 Nov-19-2021, 07:43 AM
Last Post: Yoriz
  Error when refering to class defined in 'main' in an imported module HeRo 2 2,430 Apr-13-2021, 07:22 PM
Last Post: HeRo
  [newbie] Why is a module imported twice? Winfried 3 4,103 Apr-02-2021, 04:48 AM
Last Post: deanhystad
Star NameError – function doesn't recognize imported modules Sir 4 3,553 Dec-01-2020, 06:36 AM
Last Post: Sir
  Function will not load from a module Pedroski55 1 1,823 Jul-29-2020, 12:27 AM
Last Post: deanhystad
  from module import function krishanu21 4 2,687 Apr-22-2020, 10:58 AM
Last Post: buran
  Running function from parent module which has a loop in it. ta2909i 1 2,708 Nov-18-2019, 07:04 PM
Last Post: Gribouillis
  how to do setattr() from an imported module nutron 3 3,382 Sep-20-2019, 08:16 PM
Last Post: nutron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020