Author steven.daprano
Recipients docs@python, rhettinger, steven.daprano, xfq
Date 2016-11-13.05:52:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1479016357.21.0.47973002009.issue28681@psf.upfronthosting.co.za>
In-reply-to
Content
I disagree that "aliasing" is more accurate.

We have a perfectly good name for symbols in Python: "name". A value (and that includes functions) can have multiple names. It seems to me that if we're to start distinguishing between names and aliases, then aliases have to be different from names. And the way I understand "alias" is that it is another symbol for a variable, not another symbol for the same value.

We wouldn't say that

    x = 1
    y = x

makes y an alias for x. y just happens to be a second name for the same value that x currently has. There's no guarantee that they will stay the same. Substitute a function object for the int 1, and you have the situation being discussed in the tutorial.

I would expect that aliases should not be effected by rebinding:

    x = 1
    y = alias(x)  # if such a thing existed
    x = 2
    assert y == 2

Obviously there's nothing in Python like that! This doesn't match Python's name binding model at all.

I think that talking about a "general aliasing" mechanism is exactly wrong. I think that the tutorial should emphasis the reality that functions are just ordinary values, like ints and floats and dicts and lists, and not try to indicate that there is something special or different about names bound to functions:

    def f(): ...
    g = f

is no different from the x = y example earlier.
History
Date User Action Args
2016-11-13 05:52:37steven.dapranosetrecipients: + steven.daprano, rhettinger, docs@python, xfq
2016-11-13 05:52:37steven.dapranosetmessageid: <1479016357.21.0.47973002009.issue28681@psf.upfronthosting.co.za>
2016-11-13 05:52:37steven.dapranolinkissue28681 messages
2016-11-13 05:52:36steven.dapranocreate