
April 27, 2017
11:54 p.m.
On Fri, Apr 28, 2017 at 9:21 AM, Steven D'Aprano <steve@pearwood.info> wrote:
What happens if you use this syntax in a top-level function rather than a method? (Or a static method?)
def function(x, y, x.attr): ...
(And don't forget that behind the scenes, methods *are* functions.) What would this syntax even mean?
Or if you use some other name other than the first parameter?
def method(self, spam, foo.eggs):
Exactly the same thing as: def function(*args): x, y, x.attr = args def method(*args): self, spam, foo.eggs = args It's well-defined - at least for positional args. Not sure what keyword arg handling would be though. ChrisA