Where can I find syntax for list comps? I am confused how/whether they are
evaluated left-right or right-left. Consider following list flattening
example:
mx = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[value for row in mx for value in row]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
It seems like 'for' loops are eval
On Tue, Nov 5, 2013 at 6:19 PM, Steven D'Aprano wrote:
> On Tue, Nov 05, 2013 at 03:55:05PM -0800, Johan Martinez wrote:
> > I need help in modifying my program. Right now it looks as follows:
> [snip code]
> > Can someone help me in improving my code?
>
> Yes! The
I need help in modifying my program. Right now it looks as follows:
class Filedict():
def __init__(self, fname):
self.fname =fname
def parse(self):
with open(self.fname, 'r') as f:
# some file search and parsing logic
return parsed_fil
On Mon, Oct 24, 2011 at 2:32 PM, Steve Willoughby wrote:
> On 24-Oct-11 12:17, Johan Martinez wrote:
>
>> Thanks for the replies everyone - Steve, Dave, Sander and Wayne. I
>> realized my wrong understanding/interpretation after posting the message
>> to the list, which
On Mon, Oct 24, 2011 at 2:07 PM, Andreas Perstinger <
andreas.perstin...@gmx.net> wrote:
> On 2011-10-24 20:04, Johan Martinez wrote:
>
>> Hi,
>>
>> I am struggling to understand Python string immutability. I am able to
>> modify Python string object aft
On Mon, Oct 24, 2011 at 1:52 PM, Wayne Werner wrote:
> On Mon, Oct 24, 2011 at 1:04 PM, Johan Martinez wrote:
>
>> Hi,
>>
>> I am struggling to understand Python string immutability. I am able to
>> modify Python string object after initializing/assigning it a valu
Hi,
I am struggling to understand Python string immutability. I am able to
modify Python string object after initializing/assigning it a value. So how
does immutability work? I am not following it. Sorry for really stupid
question. Any help?
>>> s = "First"
>>> print s.__class__
>>> print s
Fi