Tom Anderson <tw**@urchin.earth.li> wrote: Sounds good. More generally, i'd be more than happy to get rid of list comprehensions, letting people use list(genexp) instead. That would obviously be a Py3k thing, though.
Alex Martelli wrote: I fully agree, but the BDFL has already (tentatively, I hope) Pronounced that the [...] form will stay in Py3K as syntax sugar for list(...). I find that to be a truly hateful prospect, but that's the prospect:-(.
Steven Bethard wrote: I'm not sure I find it truly hateful, but definitely unnecessary. TOOWTDI and all...
Paul Rubin wrote: Well, [...] notation for regular lists (as opposed to list comprehensions) is also unnecessary since we could use "list((a,b,c))".
I'm not sure that's really a fair comparison. Do you really find:
list(x**2 for x in iterable)
harder to read than:
[x**2 for x in iterable]
?? I don't, though perhaps this is just me. OTOH, I do find:
list((a, b, c))
to be substantially harder to read than:
[a, b, c]
due to the nested parentheses. Note that replacing list comprehensions
with list(...) doesn't introduce any nested parentheses; it basically
just replaces brackets with parentheses.
Just in case there was any confusion, I definitely wasn't suggesting
that we remove list literal support.
STeVe 7 1573
> due to the nested parentheses. Note that replacing list comprehensions with list(...) doesn't introduce any nested parentheses; it basically just replaces brackets with parentheses.
But you don't need the nested parentheses - use *args instead for the
list-constructor.
list(a,b,c)
Apart from that, I hope that the [] stay in. After all, if they are kept
around for literal list construction, the aren't free for other purposes
anyway.
Regards,
Diez
Diez B. Roggisch wrote: due to the nested parentheses. Note that replacing list comprehensions with list(...) doesn't introduce any nested parentheses; it basically just replaces brackets with parentheses.
But you don't need the nested parentheses - use *args instead for the list-constructor.
list(a,b,c)
No, you can't. That's ambigous if you pass only one argument, and that
argument is iterable. This is also the reason why set() doesn't work this
way.
--
Giovanni Bajo
Diez B. Roggisch wrote: due to the nested parentheses. Note that replacing list comprehensions with list(...) doesn't introduce any nested parentheses; it basically just replaces brackets with parentheses.
But you don't need the nested parentheses - use *args instead for the list-constructor.
list(a,b,c)
Apart from that, I hope that the [] stay in. After all, if they are kept around for literal list construction, the aren't free for other purposes anyway.
list(1,2,3)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: list() takes at most 1 argument (3 given)
So you're talking about the way list() *should* work in Python 3, right?
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
Giovanni Bajo schrieb: Diez B. Roggisch wrote:
due to the nested parentheses. Note that replacing list comprehensions with list(...) doesn't introduce any nested parentheses; it basically just replaces brackets with parentheses. But you don't need the nested parentheses - use *args instead for the list-constructor.
list(a,b,c)
No, you can't. That's ambigous if you pass only one argument, and that argument is iterable. This is also the reason why set() doesn't work this way.
Ah, you're right - I thought about the >1 case, but not that one.
Regards,
Diez
Steve Holden schrieb: Diez B. Roggisch wrote: due to the nested parentheses. Note that replacing list comprehensions with list(...) doesn't introduce any nested parentheses; it basically just replaces brackets with parentheses.
But you don't need the nested parentheses - use *args instead for the list-constructor.
list(a,b,c)
Apart from that, I hope that the [] stay in. After all, if they are kept around for literal list construction, the aren't free for other purposes anyway.
>>> list(1,2,3) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: list() takes at most 1 argument (3 given) >>>
So you're talking about the way list() *should* work in Python 3, right?
Yes, should have said "could" there. But as Giovanni pointed out I
missed the ambiguity in case of the size one lists.
Diez
Op 2006-01-18, Diez B. Roggisch schreef <de***@nospam.web.de>: Giovanni Bajo schrieb: Diez B. Roggisch wrote:
due to the nested parentheses. Note that replacing list comprehensions with list(...) doesn't introduce any nested parentheses; it basically just replaces brackets with parentheses. But you don't need the nested parentheses - use *args instead for the list-constructor.
list(a,b,c)
No, you can't. That's ambigous if you pass only one argument, and that argument is iterable. This is also the reason why set() doesn't work this way.
Ah, you're right - I thought about the >1 case, but not that one.
Well we could have list(a) return [a], and have a list_from_iterable.
Although I would prefer a different name.
--
Antoon Pardon
Antoon Pardon wrote: Well we could have list(a) return [a], and have a list_from_iterable. Although I would prefer a different name.
Or reverse it - list() always takes a single iterable, and
list_from_scalars() is defined something like follows: def list_from_scalars(*args):
return list(args)
print list_from_scalars(1,2,3)
[1, 2, 3] print list_from_scalars('a')
['a']
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bicho Verde |
last post by:
I have now free time and money to do what I want :-)
I have some basic skills in programming (C, Pascal, Macromedia
Actionscript) but don't know exactly what to do in the world of programming.
And...
|
by: Thomas Reichelt |
last post by:
Moin,
short question: is there any language combining the syntax, flexibility and
great programming experience of Python with static typing? Is there a
project to add static typing to Python?
...
|
by: Haines Brown |
last post by:
I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:
#testTable { text-align: right; }
#leftcol {...
|
by: Gregory Petrosyan |
last post by:
Please visit http://www.python.org/peps/pep-0204.html first.
As you can see, PEP 204 was rejected, mostly because of not-so-obvious
syntax. But IMO the idea behind this pep is very nice. So,...
|
by: Army1987 |
last post by:
Given:
#include <stdlib.h>
typedef struct Node {
unsigned char Data;
struct Node *Next
} node_t, *list_t;
list_t list;
Does
list = list->Next = malloc(sizeof(node));
|
by: mmm |
last post by:
I wrote the code below to create simple arithmetic sequences that are
iter-able
I.e., this would basically combine the NUMPY arange(start,end,step)
to range(start,end), with step not necessarily...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |