Re: GLE-like python package
On Oct 14, 12:54 pm, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > Hello there, > > I'm exploring possibilities of using python as an alternative to Matlab. > The obvious way to go seems to be matplotlib for plotting, but I do like > GLE http://glx.sourceforge.net/> a lot. One reason is that with GLE > you can also do diagrams, that is, descriptive pictures (like > http://glx.sourceforge.net/examples/diagrams/index.html>) > > Is there anything similar for python? > > /W I think this is what you're looking for: http://pyx.sourceforge.net/ Cesar -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic question
On May 12, 8:13 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > Cesar G. Miguel <[EMAIL PROTECTED]> wrote: > > > On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote: > > > > Actually I'm trying to convert a string to a list of float numbers: > > > > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] > > > > str="53,20,4,2" > > > map(lambda s: float(s), str.split(',')) > > > > Last expression returns: [53.0, 20.0, 4.0, 2.0] > > > -- > > > Happy Hacking. > > > > Dmitry "Sphinx" Dzhushttp://sphinx.net.ru > > > Nice! > > As somebody else alredy pointed out, the lambda is supererogatory (to > say the least). > > > The following also works using split and list comprehension (as > > suggested in a brazilian python forum): > > > --- > > L = [] > > file = ['5,1378,1,9', '2,1,4,5'] > > str='' > > for item in file: > > L.append([float(n) for n in item.split(',')]) > > The assignment to str is useless (in fact potentially damaging because > you're hiding a built-in name). > > L = [float(n) for item in file for n in item.split(',')] > > is what I'd call Pythonic, personally (yes, the two for clauses need to > be in this order, that of their nesting). > > Alex Yes, 'str' is unnecessary. I just forgot to remove it from the code. -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic question
On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote: > > Actually I'm trying to convert a string to a list of float numbers: > > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] > > str="53,20,4,2" > map(lambda s: float(s), str.split(',')) > > Last expression returns: [53.0, 20.0, 4.0, 2.0] > -- > Happy Hacking. > > Dmitry "Sphinx" Dzhushttp://sphinx.net.ru Nice! The following also works using split and list comprehension (as suggested in a brazilian python forum): --- L = [] file = ['5,1378,1,9', '2,1,4,5'] str='' for item in file: L.append([float(n) for n in item.split(',')]) --- Thank you for all suggestions! -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic question
On May 12, 3:09 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > Cesar G. Miguel wrote: > > - > > L = [] > > file = ['5,1378,1,9', '2,1,4,5'] > > str='' > > for item in file: > >j=0 > >while(j > while(item[j] != ','): > > str+=item[j] > > j=j+1 > > if(j>= len(item)): break > > > if(str != ''): > > L.append(float(str)) > > str = '' > > > j=j+1 > > > print L > > But I'm not sure this is an elegant pythonic way of coding :-) > > Example: > > In [21]: '5,1378,1,9'.split(',') > Out[21]: ['5', '1378', '1', '9'] > > So, instead of doing that while-based traversal and parsing of `item`, > just split it like above, and use a for loop on it. It's much more > elegant and pythonic. > > HTH, > Karlo. Great! Now it looks better :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic question
On May 12, 2:45 pm, Basilisk96 <[EMAIL PROTECTED]> wrote: > On May 12, 12:18 pm, "Cesar G. Miguel" <[EMAIL PROTECTED]> wrote: > > > > > I've been studying python for 2 weeks now and got stucked in the > > following problem: > > > for j in range(10): > > print j > > if(True): > >j=j+2 > >print 'interno',j > > > What happens is that "j=j+2" inside IF does not change the loop > > counter ("j") as it would in C or Java, for example. > > > Am I missing something? > > > []'s > > Cesar > > What is your real intent here? This is how I understand it after > reading your post: you want to create a loop that steps by an > increment of 2. If that's the case, then: > > >>> for j in range(0,10,2): > > ... print j > ... > 0 > 2 > 4 > 6 > 8 > > would be a simple result. > > Cheers, > -Basilisk96 Actually I'm trying to convert a string to a list of float numbers: str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] As some of you suggested, using while it works: - L = [] file = ['5,1378,1,9', '2,1,4,5'] str='' for item in file: j=0 while(j= len(item)): break if(str != ''): L.append(float(str)) str = '' j=j+1 print L - But I'm not sure this is an elegant pythonic way of coding :-) Thanks for all suggestions! -- http://mail.python.org/mailman/listinfo/python-list
Basic question
I've been studying python for 2 weeks now and got stucked in the following problem: for j in range(10): print j if(True): j=j+2 print 'interno',j What happens is that "j=j+2" inside IF does not change the loop counter ("j") as it would in C or Java, for example. Am I missing something? []'s Cesar -- http://mail.python.org/mailman/listinfo/python-list