In article ,
ben+pyt...@benfinney.id.au says...
>
> More accurately (and as acknowledged in that guide), a single underscore
> *is* a common name for a ?don't care? name, but is better avoided for
> that purpose because it's also commonly used for other purposes.
>
> In other words: That guide i
Mario Figueiredo wrote:
> In article <54c8339f$0$13008$c3e8da3$54964...@news.astraweb.com>,
> steve+comp.lang.pyt...@pearwood.info says...
>> (3) _ is also commonly used as a "don't care" variable name:
>>
>> a, _, b, _ = get_four_items() # but I only care about two of them
>>
>
> According to
Mario Figueiredo writes:
> In article <54c8339f$0$13008$c3e8da3$54964...@news.astraweb.com>,
> steve+comp.lang.pyt...@pearwood.info says...
> > (3) _ is also commonly used as a "don't care" variable name:
> >
> > a, _, b, _ = get_four_items() # but I only care about two of them
> >
>
> Accord
In article <54c8339f$0$13008$c3e8da3$54964...@news.astraweb.com>,
steve+comp.lang.pyt...@pearwood.info says...
> (3) _ is also commonly used as a "don't care" variable name:
>
> a, _, b, _ = get_four_items() # but I only care about two of them
>
According to the following link, it is actually
Neal Becker wrote:
> Is there a more elegant way to spell this?
>
> for x in [_ for _ in seq if some_predicate]:
Don't use _ as the loop variable here.
There are three common conventions for _ and this is none of them:
(1) n the interactive interpreter _ is used for the resu
On 1/27/2015 9:49 AM, Rob Gaddi wrote:
Or the somewhat less indenty
for x in seq:
if not some_predicate: continue
do_something_to(x)
... or shorter and equally less indenty
for x in seq:
if some_predicate: do_something_to(x)
--
https://mail.python.org/mailman/listinfo/python
Jussi Piitulainen wrote:
> Neal Becker writes:
>
>> Is there a more elegant way to spell this?
>>
>> for x in [_ for _ in seq if some_predicate]:
>
> If you mean some_predicate(_), then possibly this.
>
> for x in filter(some_predicate, seq):
>
On Tue, Jan 27, 2015, at 13:05, Mario Figueiredo wrote:
> In article ,
> jpiit...@ling.helsinki.fi says...
> >
> > If you mean literally some_predicate, then perhaps this.
> >
> > if some_predicate:
> >for x in seq:
> > handle(x)
> >
>
> Careful. See Chris Warrick answer for the corr
In article ,
jpiit...@ling.helsinki.fi says...
>
> If you mean literally some_predicate, then perhaps this.
>
> if some_predicate:
>for x in seq:
> handle(x)
>
Careful. See Chris Warrick answer for the correct position of the 'if'
statement.
--
https://mail.python.org/mailman/listi
On Tue, 27 Jan 2015 14:20:10 +0100
Chris Warrick wrote:
> On Jan 27, 2015 2:16 PM, "Neal Becker" wrote:
> >
> > Is there a more elegant way to spell this?
> >
> > for x in [_ for _ in seq if some_predicate]:
>
> for x in seq:
>
Neal Becker writes:
> Jussi Piitulainen wrote:
> > Neal Becker writes:
> >
> >> Is there a more elegant way to spell this?
> >>
> >> for x in [_ for _ in seq if some_predicate]:
> >
> > If you mean some_predicate(_), then possi
Jussi Piitulainen wrote:
> Neal Becker writes:
>
>> Is there a more elegant way to spell this?
>>
>> for x in [_ for _ in seq if some_predicate]:
>
> If you mean some_predicate(_), then possibly this.
>
> for x in filter(some_predicate, seq):
>
Neal Becker writes:
> Is there a more elegant way to spell this?
>
> for x in [_ for _ in seq if some_predicate]:
If you mean some_predicate(_), then possibly this.
for x in filter(some_predicate, seq):
handle(x)
If you mean literally some_predicate, then perhaps this.
if some_
On Tuesday, January 27, 2015 at 6:45:41 PM UTC+5:30, Neal Becker wrote:
> Is there a more elegant way to spell this?
>
> for x in [_ for _ in seq if some_predicate]:
Depends on what follows the ':'
In the trivial case all thats outside the comprehension can be dropped:
>&
- Original Message -
> From: "Neal Becker"
> To: python-list@python.org
> Sent: Tuesday, 27 January, 2015 2:15:12 PM
> Subject: Is there a more elegant way to spell this?
>
> Is there a more elegant way to spell this?
>
> for x in [_ for _ in seq if
On Jan 27, 2015 2:16 PM, "Neal Becker" wrote:
>
> Is there a more elegant way to spell this?
>
> for x in [_ for _ in seq if some_predicate]:
for x in seq:
if some_predicate:
do_something_to(x)
--
Chris Warrick <https://chriswarrick.com/>
Sent
Is there a more elegant way to spell this?
for x in [_ for _ in seq if some_predicate]:
--
-- Those who don't understand recursion are doomed to repeat it
--
https://mail.python.org/mailman/listinfo/python-list
17 matches
Mail list logo