Tom Anderson <tw**@urchin.ea rth.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 1613
> 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.w eb.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_itera ble.
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_itera ble. Although I would prefer a different name.
Or reverse it - list() always takes a single iterable, and
list_from_scala rs() is defined something like follows: def list_from_scala rs(*args):
return list(args)
print list_from_scala rs(1,2,3)
[1, 2, 3] print list_from_scala rs('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 also I don't know exactly why would I learn Python rather than C#,
C++ or Perl. Basicaly I don't know where to start, if there is much to do or
if it is has it seems and there is software to everything nowadays and so
doesn't make sense to spend...
|
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?
Thank you,
--
greetz tom
|
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 { text-align: left; }
<table id="testTable">
<col id="leftCol" />
<col span="2" />
|
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, maybe
there's a reason to adopt slightly modified Haskell's syntax? Something
like
-->
(1,3..10) --> same values as above, but return generator instead of
list
|
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 an integer.
The code below is in its simplest form and I want to generalize the
sequence types (multiplicative, cumulative, gauss ...), but first I
need the simple SEQA( ) function to be more robust. The problem is
the three test code...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |