Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61734 > unrolled thread
| Started by | Amimo Benja <amimobenja08@gmail.com> |
|---|---|
| First post | 2013-12-12 10:05 -0800 |
| Last post | 2013-12-12 22:26 -0800 |
| Articles | 8 — 5 participants |
Back to article view | Back to comp.lang.python
Python Script Amimo Benja <amimobenja08@gmail.com> - 2013-12-12 10:05 -0800
Re: Python Script Gary Herron <gary.herron@islandtraining.com> - 2013-12-12 10:35 -0800
Re: Python Script Amimo Benja <amimobenja08@gmail.com> - 2013-12-12 22:21 -0800
Re: Python Script Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-13 08:38 +0000
Re: Python Script Terry Reedy <tjreedy@udel.edu> - 2013-12-12 13:55 -0500
Re: Python Script Amimo Benja <amimobenja08@gmail.com> - 2013-12-12 22:21 -0800
Re: Python Script MRAB <python@mrabarnett.plus.com> - 2013-12-12 18:59 +0000
Re: Python Script Amimo Benja <amimobenja08@gmail.com> - 2013-12-12 22:26 -0800
| From | Amimo Benja <amimobenja08@gmail.com> |
|---|---|
| Date | 2013-12-12 10:05 -0800 |
| Subject | Python Script |
| Message-ID | <89929063-4c26-4e97-8f28-c53f1c538d1d@googlegroups.com> |
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....
[toc] | [next] | [standalone]
| From | Gary Herron <gary.herron@islandtraining.com> |
|---|---|
| Date | 2013-12-12 10:35 -0800 |
| Message-ID | <mailman.4008.1386873346.18130.python-list@python.org> |
| In reply to | #61734 |
On 12/12/2013 10:05 AM, Amimo Benja wrote: > 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.... 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
[toc] | [prev] | [next] | [standalone]
| From | Amimo Benja <amimobenja08@gmail.com> |
|---|---|
| Date | 2013-12-12 22:21 -0800 |
| Message-ID | <9fbff74e-5c5e-406c-b6ce-12dba738a697@googlegroups.com> |
| In reply to | #61737 |
On Thursday, December 12, 2013 9:35:23 PM UTC+3, Gary Herron wrote: > On 12/12/2013 10:05 AM, Amimo Benja wrote: > > > 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.... > > > > 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.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-13 08:38 +0000 |
| Message-ID | <mailman.4052.1386924007.18130.python-list@python.org> |
| In reply to | #61794 |
On 13/12/2013 06:21, Amimo Benja wrote: > On Thursday, December 12, 2013 9:35:23 PM UTC+3, Gary Herron wrote: >> On 12/12/2013 10:05 AM, Amimo Benja wrote: >> >>> 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.... >> >> >> >> 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. > Before you repost would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing above, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-12-12 13:55 -0500 |
| Message-ID | <mailman.4011.1386874547.18130.python-list@python.org> |
| In reply to | #61734 |
On 12/12/2013 1:35 PM, Gary Herron wrote: > On 12/12/2013 10:05 AM, Amimo Benja wrote: >> 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.... > > 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. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Amimo Benja <amimobenja08@gmail.com> |
|---|---|
| Date | 2013-12-12 22:21 -0800 |
| Message-ID | <693c1535-9d6f-426c-8b8c-79bdf1dd7e9b@googlegroups.com> |
| In reply to | #61740 |
On Thursday, December 12, 2013 9:55:29 PM UTC+3, Terry Reedy wrote: > On 12/12/2013 1:35 PM, Gary Herron wrote: > > > On 12/12/2013 10:05 AM, Amimo Benja wrote: > > >> 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.... > > > > > > 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. > > > > -- > > Terry Jan Reedy Okay Terry
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-12-12 18:59 +0000 |
| Message-ID | <mailman.4012.1386874770.18130.python-list@python.org> |
| In reply to | #61734 |
On 12/12/2013 18:05, Amimo Benja wrote:
> 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.
[toc] | [prev] | [next] | [standalone]
| From | Amimo Benja <amimobenja08@gmail.com> |
|---|---|
| Date | 2013-12-12 22:26 -0800 |
| Message-ID | <189fb55d-f743-47d7-a591-8f3bc81c3ba3@googlegroups.com> |
| In reply to | #61741 |
On Thursday, December 12, 2013 9:59:26 PM UTC+3, MRAB wrote: > On 12/12/2013 18:05, Amimo Benja wrote: > > > 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. Thanks MRAB... I appreciate...
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web