Well, if you're a c++ programmer, then you've probably ran into
`functors' at one time or another.  You can emulate it by making a
python object that is `callable'.

class functor:
        def __init__(self):
                self.ordered_sequence = [1, 2, 3, 4, 5]
        def __call__(self, arg1, arg2):
                self.ordered_sequence.extend((arg1,arg2))
                self.ordered_sequence.sort()
                
>>> f = functor()
>>> f(3,5)
>>> f.ordered_sequence
[1, 2, 3, 3, 4, 5, 5]

Hope that helps some.
jw

On 4/25/05, Charles Krug <[EMAIL PROTECTED]> wrote:
> I've a function that needs to maintain an ordered sequence between
> calls.
> 
> In C or C++, I'd declare the pointer (or collection object) static at
> the function scope.
> 
> What's the Pythonic way to do this?
> 
> Is there a better solution than putting the sequence at module scope?
> 
> Thanks.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to