so basically...
what I want to do is identify the function calling the dynamically created/referenced class

let's put this simple...
I have 2 functions, both of which either create or reference the same class based on an input...
this function then returns the class with specifically set parameters. (not an instance of a class)

to put this into action:

bu8() #a function which returns a bu8 object by reading data from an external source
#actually I'm purposfully explaining it wrong:
# bu8=bu(1)
# type(bu8())==bu(1) >>> True
BU8() #a function which creates a bu8 object out of a given value (boxing it to avoid memory errors)

the functions behind these should actually be clear enough:
bu() #enable external i/o
BU() #disable external i/o (disable the default *read* input and throw an error if called as such)
#bu(1)() >>> 1 byte of data read from an external source
#BU(1)() >>> TypeError: an int is required
#type(bu(1)())==type(BU(1)(0)) >>> True

I'm not sure what I'm doing wrong...
I'm trying to pull it off using a pre-defined variable and resetting it when calling the base-functions,
but that doesn't seem to be working >_>

classes = {} #dynamically created classes

#class reference: (on existing class)
classes[byte_size].enableIO = False #<-- not working

#in the class, after final operations: (after storing it's validated value)
this.enableIO = True

can anyone help??

what's currntly happening is both functions disable data I/O

Edited 2 Years Ago by Tcll

just tried using del and recreating the class for each function...

it works at first, but the part where needed doesn't work:

>>> bu8()
0
>>> BU8()

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    BU8()
TypeError: _BUinitNIO() takes exactly 2 arguments (1 given)
>>> bu8 == BU8
False
>>> var = BU8(240)
>>> type(var)
<class '__main__.BU_1'>
>>> type(var) == bu8
False
>>> bu(1) == BU(1)
False
>>> 

upon class creation 1 of 2 init methods are used...
IO enables R/W to the external data AND stores the capped value
NIO disables it and just stores the capped value

wow this is old...
and it's been solved over at another forum...

may I request deletion of this so the "related articles" don't show this.
thanks :)

This article has been dead for over six months. Start a new discussion instead.