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 by Tcll

3 Years
Discussion Span
Last Post 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()
>>> BU8()

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

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.
Be sure to adhere to our posting rules.