Python Forum
assignments of function references
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
assignments of function references
#1
i want to have class attribute names which could otherwise be used as variables be used for function references so i can keep everything for a thread in the same class. since a "def" is like an assignment, too, can i assign to a class attribute like this?
class foo():
    ...
foo.var1 = 0
...
def foo.fun1(bar):
    foo.count += 1
    return bar*bar
i no longer like to just try things to "see if they work" since i have found that modifying the locals() dictionary is an example of something that looks like it might work, but doesn't always do so.
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
assignments of function references - by Skaperen - Aug-14-2019, 06:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Where can I find Python training with reading, lecture, labs and assignments? davidorlow 2 1,007 Oct-20-2022, 10:46 AM
Last Post: rob101
  Environment seems to keep losing references spacedog 2 1,933 Apr-23-2021, 07:36 PM
Last Post: spacedog
  How to print the names of assignments if they are randomly selected Kongurinn 2 3,359 Oct-22-2017, 07:31 AM
Last Post: buran
  module functions and data references Skaperen 6 4,300 Jul-30-2017, 04:09 AM
Last Post: Skaperen
  Looking for Python Assignments BillGates 3 3,643 Mar-06-2017, 04:31 PM
Last Post: BillGates

Forum Jump:

User Panel Messages

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