At Friday 27/10/2006 21:09, Ben Finney wrote:

> > >    GLOBAL = object()
> > >
> > >    def insert_ids(ids=GLOBAL):
> > >        if ids is GLOBAL:
> > >            ids = get_global_ids()
> >
> >The one disadvantage of this approach is that it complicates
> >pickling if/when you store the stentinel in an instance.  There are
> >ways of working around that, but none are pleasant.
>
> But why should you store the sentinel in an instance? It's only
> purpose is to detect a special case in the parameter, when None is
> not appropiate.

You might be storing values that will later become parameters to the
function.

    ids_to_be_processed_later = {
        'chin': [14, 7, 9],
        'bin':  foo.GLOBAL,
        'fin':  [74, 98, 12],
    }
    serialise_stuff()

Well... just don't do that! :)
Instead of a dict, use another class instance with a class attribute (like on my earlier post).


--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to