On 07/13/2010 10:26 AM, Roald de Vries wrote:
Hi all,
I have two objects that should both be able to alter a shared float.
So i need something like a mutable float object, or a float reference
object. Does anybody know if something like that exists? I know it's
not hard to build, but I have a feeling that there should be a
standard solution to it.
Roald
Huh? I must be missing something here. Isn't this what you use a
variable for:
sharedFloat = 123
and later
sharedFloat = 99
The variable sharedFloat could exit as a global (in some module) or as a
instance variable in some shared object or anywhere else you want to
store it.
As a module attribute:
import Shared
Shared.sharedFloat = 123
Or as a class attribute:
class Shared:
sharedFloat = 0
Shared.sharedFloat = 123
or as an instance attribute:
class Shared:
def __init__(self):
self.sharedFloat = 0
sharedObject = Shared()
sharedObject.sharedFloat = 123
Gary Herron
--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418
--
http://mail.python.org/mailman/listinfo/python-list