Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
import vs inserting code
#8
i have the understanding that a function can access the globals() namespace on its own. of course, if the function is defined to have it passed, the caller could fake it by creating a dictionary (maybe populating it) and passing that, instead of globals().

the kind of use cases i was considering is where the main code is doing a variety of different variable settings, then for each place doing the same exact calculations that need to work with local variables (including setting some). many time capture a block of code (^u4^k^y in emacs, to capture 4 lines) and drop it (^y in emacs, in each place) in a few other places. those 4 lines modify 4 local variables. i do not want a function to be trying to pass a tuple or dict back. i prefer to keep it all simple. i might like to have a "deflocal" feature that defines a function that shares the locals() namespace with the code that defines it and calls it.
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
import vs inserting code - by Skaperen - Jun-14-2024, 01:18 AM
RE: import vs inserting code - by rodiongork - Jun-19-2024, 07:55 PM
RE: import vs inserting code - by Gribouillis - Jun-19-2024, 09:42 PM
RE: import vs inserting code - by Skaperen - Jun-20-2024, 10:38 PM
RE: import vs inserting code - by rodiongork - Jun-21-2024, 05:47 AM
RE: import vs inserting code - by Skaperen - Jun-22-2024, 01:21 AM
RE: import vs inserting code - by Gribouillis - Jun-22-2024, 08:14 AM
RE: import vs inserting code - by Skaperen - Jun-23-2024, 01:54 AM
RE: import vs inserting code - by Gribouillis - Jun-23-2024, 06:52 AM
RE: import vs inserting code - by AdamHensley - Jun-23-2024, 12:02 PM
RE: import vs inserting code - by Skaperen - Jun-26-2024, 09:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  visual studio code python how to get source code of import module definitian umen 2 4,200 Jun-13-2020, 06:20 PM
Last Post: umen

Forum Jump:

User Panel Messages

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