Python Script

A

Amimo Benja

I have an issue with a Python script that I will show as follows:
http://codepad.org/G8Z2ConI

Assume that you have three (well defined) classes: AirBase and VmNet, . VmNet has got a method that is called recursively each time an HTTP response is received. The variable recordTuple needs to be built independently for each instance of VmNet that is created. However, the mentioned variable is being overwritten across every instance, so if you try to get it from vmnet_instance_y, you would get exactly the same than retrieving it from vmnet_instance_x.

• What is the code issue? I need to use this script in a project and I don't know how to proceed.

Actually, the script aims to follow the principle don't repeat yourself (DRY). As you may notice, VmNet and AirBase does not have def __init__(self), so self.recordTupleBase does not probably exist. Additionally, many other subclasses, similar to VmNet, can implement the recursive method using that recordTupleBase.

* I will gladly appreciate any help thanks....
 
G

Gary Herron

I have an issue with a Python script that I will show as follows:
http://codepad.org/G8Z2ConI

Assume that you have three (well defined) classes: AirBase and VmNet, .VmNet has got a method that is called recursively each time an HTTP response is received. The variable recordTuple needs to be built independently for each instance of VmNet that is created. However, the mentioned variable is being overwritten across every instance, so if you try to get it from vmnet_instance_y, you would get exactly the same than retrieving it from vmnet_instance_x.

• What is the code issue? I need to use this script in a project and I don't know how to proceed.

Actually, the script aims to follow the principle don't repeat yourself(DRY). As you may notice, VmNet and AirBase does not have def __init__(self), so self.recordTupleBase does not probably exist. Additionally, manyother subclasses, similar to VmNet, can implement the recursive method using that recordTupleBase.

* I will gladly appreciate any help thanks....

You haven't actually asked a question here. You say you don't know how
to proceed with "a project", but we don't know what that project is. In
fact, I can't even figure out if your trouble is with the script, or
with using the script in this unknown project.

Also, if you repost, please include the script in the email, not as a
pointer to somewhere else.


Gary Herron
 
T

Terry Reedy

You haven't actually asked a question here. You say you don't know how
to proceed with "a project", but we don't know what that project is. In
fact, I can't even figure out if your trouble is with the script, or
with using the script in this unknown project.

Also, if you repost, please include the script in the email, not as a
pointer to somewhere else.

And reduce the script to the minimum needed to reproduce the problem.
The effort to do that may reveal the solution.
 
M

MRAB

I have an issue with a Python script that I will show as follows:
http://codepad.org/G8Z2ConI

Assume that you have three (well defined) classes: AirBase and VmNet,
. VmNet has got a method that is called recursively each time an HTTP
response is received. The variable recordTuple needs to be built
independently for each instance of VmNet that is created. However,
the mentioned variable is being overwritten across every instance, so
if you try to get it from vmnet_instance_y, you would get exactly the
same than retrieving it from vmnet_instance_x.

• What is the code issue? I need to use this script in a project and
I don't know how to proceed.

Actually, the script aims to follow the principle don't repeat
yourself (DRY). As you may notice, VmNet and AirBase does not have
def __init__(self), so self.recordTupleBase does not probably exist.
Additionally, many other subclasses, similar to VmNet, can implement
the recursive method using that recordTupleBase.

* I will gladly appreciate any help thanks....
This line:

recordTuple = AirBase.recordTupleBase

makes recordTuple refer to the same object as AirBase.recordTupleBase
and AirBase.recordTupleBase is an attribute of the class AirBase itself.

You're re-using the same object. That's why it's being overwritten.
 
A

Amimo Benja

You haven't actually asked a question here. You say you don't know how

to proceed with "a project", but we don't know what that project is. In

fact, I can't even figure out if your trouble is with the script, or

with using the script in this unknown project.



Also, if you repost, please include the script in the email, not as a

pointer to somewhere else.





Gary Herron

Okay Gary... I will put that into consideration when post another problem or solution.
 
A

Amimo Benja

This line:



recordTuple = AirBase.recordTupleBase



makes recordTuple refer to the same object as AirBase.recordTupleBase

and AirBase.recordTupleBase is an attribute of the class AirBase itself.



You're re-using the same object. That's why it's being overwritten.

Thanks MRAB... I appreciate...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top