Possible constant assignment operators ":=" and "::=" for Python

Fredrik Lundh fredrik at pythonware.com
Thu May 4 03:30:29 EDT 2006


Christophe wrote:

> That's easy, since A is a symbolic constant know at compile time, and
> since it's a known mutable objet, the code once compiled will be
> equivalent to:
>
>  >>> b = [[]]
>
>  >>> # much later
>  >>> b|0].append('1')

the OP talked about constants as names for immutable objects, not pre-
processor macros.  but alright, using the "symbolic constant" approach,
what would this print ?

    >>> def foo(var):
    ...     var.append('1')
    ...     print var
    ...
    >>> b = []
    >>> foo(b)
    >>> foo(b)

and this ?

    >>> constant A = []
    >>> print A is A

</F>






More information about the Python-list mailing list