[Python-ideas] aliasing

Herman Sheremetyev herman at swebpage.com
Tue Aug 30 15:51:02 CEST 2011


On Tue, Aug 30, 2011 at 10:20 PM, Peio Borthelle
<peio.borthelle at gmail.com> wrote:
> Hi,
> First, thank you to all the development community for this fabulous language
> (I'm french so my english is a bit...bad and basic). I'm quite new to
> programming and python is my first language.
> As beginner I had problems to deal with all aliasing stuff (in-place changes
> or not...). So my suggestion is perhaps not to change this (altough I find
> it a bit opposite to the python sense...) but to have a real aliasing
> fonction:
> -----------------------------
>>>> a = 2
>>>> b = alias("a")

b = lambda: a

>>>> a = 'foo'
>>>> b

b()

> 'foo'
> -----------------------------
> b is always a, it doesn't point to the same data, it points to the pointer a
> itself ! The arg is a string because otherwise the interpreter would give
> the value as arg, not the pointer.
> It could also be more complexe:
> -----------------------------
>>>> a = 3
>>>> b = alias("(a*3)+2")

b = lambda: a*3 + 2

>>>> b

b()

> 11
>>>> a = 5
>>>> b

b()

How's that? ;)



More information about the Python-ideas mailing list