On Oct 14, 7:46 pm, Ian Kelly wrote:
> On Fri, Oct 14, 2011 at 5:36 PM, Troy S wrote:
> (Python 3)
> date_range = {d:v for d, v in source_dict.items() if '20110809' <= d
> <= '20110911'}
> Ian- Hide quoted text -
> - Show quoted text -
(Python 2.7) supports dictionary comprehensions. I prehaps a
On Sat, Oct 15, 2011 at 10:53 PM, Steven D'Aprano
wrote:
> I'm not familiar with a language that uses Python syntax but "and" is a
> bitwise and. Which language is that?
>
I'm not familiar with any either, it's just that I have a few habits
that I slip into.
ChrisA
--
http://mail.python.org/mai
Chris Angelico wrote:
> Yeah, it's legal because you can nest fors and ifs in a list comp.
> Stylistic difference, I used "if" instead of "and" because there's no
> way that it could be a bitwise and.
If you're using Python, there's no way that it could be a bitwise and.
> (It's a cross-langua
On Fri, Oct 14, 2011 at 05:01:04PM -0600, Ian Kelly wrote:
> On Fri, Oct 14, 2011 at 4:30 PM, Tim Chase
> wrote:
> > On 10/14/11 17:20, Chris Angelico wrote:
> >>
> >> Try a list comprehension:
> >>
> > a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14]
> > [i for i in a if i>=10 if i<=20]
> >>
> >
On Sat, Oct 15, 2011 at 9:58 AM, Ian Kelly wrote:
> At least in Python, there is no way that "and" could be a bitwise and
> either, since it cannot be overloaded.
Like I said, cross-language safety-net. Sure it's not an issue here,
but when I write code in multiple languages, it's less embarrassi
On Fri, Oct 14, 2011 at 5:36 PM, Troy S wrote:
> Can something like this be done with dictionarys?
>
> For example, these are the keys in the dictionary from the call: dict.keys()
>
> ['20110601', '20110604', '20110608', '20110611', '20110615',
> '20110618', '20110622', '20110625', '20110629', '20
On 10/14/11 18:36, Troy S wrote:
Can something like this be done with dictionarys?
For example, these are the keys in the dictionary from the call: dict.keys()
['20110601', '20110604', '20110608', '20110611', '20110615',
'20110618', '20110622', '20110625', '20110629', '20110702',
'20110706','20
Can something like this be done with dictionarys?
For example, these are the keys in the dictionary from the call: dict.keys()
['20110601', '20110604', '20110608', '20110611', '20110615',
'20110618', '20110622', '20110625', '20110629', '20110702',
'20110706','20110709', '20110713', '20110716', '2
On Fri, Oct 14, 2011 at 5:24 PM, Tim Chase
wrote:
> Depending on your historical programming-language baggage, "i" is usually
> either an index or integer data, and since the source was a list of
> integers, "i" didn't seem inappropriate. Same for other common data-types:
>
> [f for f in (1.1, 2
On 10/14/11 18:01, Ian Kelly wrote:
On Fri, Oct 14, 2011 at 4:30 PM, Tim Chase
or even more clearly:
[i for i in a if 10<= i<= 20]
As long as we're nitpicking, I'll point out that "i" is an
inappropriate variable name here, since it is normally used to
denote indices, not data. That's why I
On Fri, Oct 14, 2011 at 4:30 PM, Tim Chase
wrote:
> On 10/14/11 17:20, Chris Angelico wrote:
>>
>> Try a list comprehension:
>>
> a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14]
> [i for i in a if i>=10 if i<=20]
>>
>> [10, 20, 15, 13, 14]
>
> The double-if is new to me. I thought it was an err
On Fri, Oct 14, 2011 at 4:48 PM, Chris Angelico wrote:
> On Sat, Oct 15, 2011 at 9:30 AM, Tim Chase
> wrote:
>> The double-if is new to me. I thought it was an error when I first saw it,
>> but it seems to be legit syntax (or at least one that 2.7 tolerates,
>> intentionally or otherwise...). I
On Sat, Oct 15, 2011 at 9:30 AM, Tim Chase
wrote:
> The double-if is new to me. I thought it was an error when I first saw it,
> but it seems to be legit syntax (or at least one that 2.7 tolerates,
> intentionally or otherwise...). I think I'd make it clearer with either
>
>
Yeah, it's legal be
On 10/14/11 17:20, Chris Angelico wrote:
Try a list comprehension:
a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14]
[i for i in a if i>=10 if i<=20]
[10, 20, 15, 13, 14]
The double-if is new to me. I thought it was an error when I
first saw it, but it seems to be legit syntax (or at least one
th
On Fri, Oct 14, 2011 at 4:10 PM, MrPink wrote:
> I have a list like so:
>
> a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14]
>
> I would like to get a subset from the list with value between 10 and
> 20 (inclusive).
>
> b = [10,13,15,14,20]
>
> Is there a way to do this with a list or other data type?
U
On Sat, Oct 15, 2011 at 9:10 AM, MrPink wrote:
> I have a list like so:
>
> a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14]
>
> I would like to get a subset from the list with value between 10 and
> 20 (inclusive).
>
> b = [10,13,15,14,20]
>
> Is there a way to do this with a list or other data type?
T
I have a list like so:
a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14]
I would like to get a subset from the list with value between 10 and
20 (inclusive).
b = [10,13,15,14,20]
Is there a way to do this with a list or other data type?
Thanks,
--
http://mail.python.org/mailman/listinfo/python-list
17 matches
Mail list logo