Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36700 > unrolled thread
| Started by | Szabolcs Blága <szabolcs.blaga@gmail.com> |
|---|---|
| First post | 2013-01-12 14:30 +0100 |
| Last post | 2013-01-12 14:30 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
proposal: Ellipsis in argument list Szabolcs Blága <szabolcs.blaga@gmail.com> - 2013-01-12 14:30 +0100
| From | Szabolcs Blága <szabolcs.blaga@gmail.com> |
|---|---|
| Date | 2013-01-12 14:30 +0100 |
| Subject | proposal: Ellipsis in argument list |
| Message-ID | <mailman.445.1357997442.2939.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
Dear All,
I have an idea that the Ellipsis object could be used in function calls.
The "..." syntax should automagically turn into an Ellipsis positional
argument.
def f(*args):
ext_args = []
for i, a in enumerate(args):
if a is Ellipsis:
ext_args.extend([x for x in range(args[i-1]-1, args[i+1])])
else:
ext_args.append(a)
return ext_args
Calling it for the above example specifically:
>>>f(34, ..., 43)
[34, 35, 36, 37, 38, 39, 40, 41, 42, 43]
That might be useless or someone might say it is confusing, but I think it
would be relatively easy to implement and a nice little syntactic "sugar".
Best regards,
Szabolcs Blaga
Back to top | Article view | comp.lang.python
csiph-web