Re: [Tutor] using datetime and calculating hourly average

2009-07-08 Thread John [H2O]
Sanders, The problem is I don't want date, I want the date AND hour, just not minutes. As for the comparison, in numpy here's what happens when I change the way I construct the where statements: --> 196 ind = np.where( (t1 < Y[:,0] < t2) ) #same result with/without inner parens 197

[Tutor] Quick question regarding Parsing a Delimited string

2009-07-08 Thread Garry Bettle
Hi, I've been programming for over 20 yrs, but only the last few in python and then only in dribs and drabs. I'm having a difficult time parsing a delimited string. e.g. 100657641~GBP~ACTIVE~0~1~~true~5.0~1247065352508~: 3818854~0~24104.08~4.5~~22.1~false|4.4~241.67~L~1~4.3~936.0~L~2~4.2~210.54

Re: [Tutor] Quick question regarding Parsing a Delimited string

2009-07-08 Thread Rich Lovely
On 8 Jul 2009, at 17:13, Garry Bettle wrote: Hi, I've been programming for over 20 yrs, but only the last few in python and then only in dribs and drabs. I'm having a difficult time parsing a delimited string. e.g. 100657641~GBP~ACTIVE~0~1~~true~5.0~1247065352508~: 3818854~0~24104.08~4.5~~2

[Tutor] error message

2009-07-08 Thread Steven Buck
I'm running a for loop which returns an error message after the third iteration (see out[4] at the bottom as evidence). I don't understand the error message. Although I'll continue to do my own digging to debug, I thought I'd give you all a shot. Thanks, -steve Python 2.6.2 (r262:71605, Apr 14

Re: [Tutor] Quick question regarding Parsing a Delimited string

2009-07-08 Thread Kent Johnson
On Wed, Jul 8, 2009 at 12:13 PM, Garry Bettle wrote: > Hi, > > I've been programming for over 20 yrs, but only the last few in python > and then only in dribs and drabs. > > I'm having a difficult time parsing a delimited string. > > e.g. > > 100657641~GBP~ACTIVE~0~1~~true~5.0~1247065352508~: > 381

Re: [Tutor] error message

2009-07-08 Thread Emile van Sebille
On 7/8/2009 9:13 AM Steven Buck said... I'm running a for loop which returns an error message after the third iteration (see out[4] at the bottom as evidence). I don't understand the error message. Although I'll continue to do my own digging to debug, I thought I'd give you all a shot. Thank

Re: [Tutor] Quick question regarding Parsing a Delimited string

2009-07-08 Thread Kent Johnson
On Wed, Jul 8, 2009 at 1:22 PM, Rich Lovely wrote: > If you really want to speed up the search, you could turn the list of lists > into a dict, using the first value in each sublist as a key: > > dct = dict((i[0], i[1:]) for i in lst) > > Then you can access it using the normal dictionary interfac

Re: [Tutor] Quick question regarding Parsing a Delimited string

2009-07-08 Thread Garry Bettle
On Wed, Jul 8, 2009 at 21:37, Kent Johnson wrote: > On Wed, Jul 8, 2009 at 1:22 PM, Rich Lovely wrote: > >> If you really want to speed up the search, you could turn the list of lists >> into a dict, using the first value in each sublist as a key: >> >> dct = dict((i[0], i[1:]) for i in lst) >> >>

Re: [Tutor] error message

2009-07-08 Thread bob gailer
Steven Buck wrote: I'm running a for loop which returns an error message after the third iteration (see out[4] at the bottom as evidence).  I don't understand the error message.  Although I'll continue to do my own digging to debug, I thought I'd give you all a shot.  Thanks, -steve   Py

Re: [Tutor] error message

2009-07-08 Thread Steven Buck
As Bob prescribed, I added (and made sure to indent): print self._header['byteorder'], fmt, byt The fourth printed line appears to be the same: Out[4]: {0: 22, 1: 51, 2: 42} This is consistent with what I observe as the first three age observations in the Stata data editor. I include the rest o

[Tutor] thesaurus

2009-07-08 Thread Pete Froslie
okay.. I'm getting the hang of python a little more. I'd like to try something a bit more complicated (for me). I would like to convert each word in a series of paragraphs to its first matching synonym in a thesaurus. I'm a bit stuck as how to start.. I think I understand how to split and parse the

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-08 Thread wesley chun
On Sun, Jul 5, 2009 at 11:48 PM, Luis Galvan wrote: > Hello all, this is my first time using a mailing list, so I'm not sure if > I'm doing this right!  Anyway, I have a wee bit of a problem.  I've recently > completed watching a Youtube video series on Python 2.6 by thenewboston > which helped me

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-08 Thread python
> but if you ever come across a copy of "Core Python Programming," i've put > lots of exercises at the end of every chapter. +1 from a reader/customer (vs. the author) "Core Python Programming" is an excellent resource for learning Python. I enjoyed the exercises - they force you to master the c

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-08 Thread Emile van Sebille
but if you ever come across a copy of "Core Python Programming," i've put lots of exercises at the end of every chapter. +1 from a reader/customer (vs. the author) +1 from a reviewer (vs. a reader/customer (vs. the author)) :) ___ Tutor maillist

Re: [Tutor] thesaurus

2009-07-08 Thread Robert Berman
http://pywordnet.sourceforge.net/ This will get you started. This is a tad easier to play with than its newer implementation. Read and experiment. it may meet most of your needs in this arena. Good Luck, Robert On Wed, 2009-07-08 at 18:28 -0400, Pete Froslie wrote: > okay.. I'm getting the ha

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-08 Thread Robert Berman
While it is not a sales pitch, the book is excellent. It and the Python Cookbook sit on top of my desk. Both are fantastic and pragmatic reference sources. Robert On Wed, 2009-07-08 at 16:10 -0700, wesley chun wrote: > On Sun, Jul 5, 2009 at 11:48 PM, Luis Galvan wrote: > > Hello all, this is m

Re: [Tutor] using datetime and calculating hourly average

2009-07-08 Thread Alan Gauld
"John [H2O]" wrote --> 196 ind = np.where( (t1 < Y[:,0] < t2) ) #same result TypeError: can't compare datetime.datetime to numpy.ndarray Have you checked what you are comparing? Try printing Y[:,0] It looks like an invalid test and no amolunt of parenthesising or 'and'ing will mak

[Tutor] Fwd: thesaurus

2009-07-08 Thread Pete Froslie
-- Forwarded message -- From: Pete Froslie Date: Wed, Jul 8, 2009 at 8:53 PM Subject: Re: [Tutor] thesaurus To: Robert Berman Thanks Robert, I will try this out.. at the moment I'm playing with an API from ' http://words.bighugelabs.com/'. It works and pulls the synonyms into p

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Rich Lovely
2009/7/9 Pete Froslie : > > > -- Forwarded message -- > From: Pete Froslie > Date: Wed, Jul 8, 2009 at 8:53 PM > Subject: Re: [Tutor] thesaurus > To: Robert Berman > > > Thanks Robert, > > I will try this out.. at the moment I'm playing with an API from > 'http://words.bighugelabs

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Pete Froslie
Great Richard, thanks.. I'm getting an error as follows: from __future__ import with_statement SyntaxError: from __future__ imports must occur at the beginning of the file I don't think this is the issue in need of rework and have tried a few quick reworks.. I'll read up a bit on 'with' cheers

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Rich Lovely
2009/7/9 Pete Froslie : > Great Richard, thanks.. > > I'm getting an error as follows: > > from __future__ import with_statement > SyntaxError: from __future__ imports must occur at the beginning of the file > > I don't think this is the issue in need of rework and have tried a few quick > reworks.

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Pete Froslie
No problem, thanks for taking the time. I'm actually trying to resolve this error now: buff.append(" ".join(lookup(Word) for Word in line.split())) NameError: global name 'lookup' is not defined ..also assume I need to change 'Word' to something that checks the next word in the text file and

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Rich Lovely
2009/7/9 Pete Froslie : > No problem, thanks for taking the time. > > I'm actually trying to resolve this error now: > >    buff.append(" ".join(lookup(Word) for Word in line.split())) > NameError: global name 'lookup' is not defined > > ..also assume I need to change 'Word' to something that check

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Pete Froslie
I see.. that makes sense. Kind of new with python -- sorry for that. after printing using this: print urllib.urlopen(' http://words.bighugelabs.com/api/2/e413f24801aa30b8d441ca43a64317be/moving/').read( ) I'm getting a format like this returned: adjective|sim|streaming adjective|sim|swirling ad

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Pete Froslie
oops.. I just realized I attached the wrong example for the API-- it was off by number, this one works: print urllib.urlopen(' http://words.bighugelabs.com/api/2/e413f24701aa30b8d441ca43a64317be/moving/').read( ) The example makes sense to me and I can see how it is difficult to figure out a natu

Re: [Tutor] Fwd: thesaurus

2009-07-08 Thread Rich Lovely
2009/7/9 Pete Froslie : > I see.. that makes sense. Kind of new with python -- sorry for that. > > after printing using this: > > print > urllib.urlopen('http://words.bighugelabs.com/api/2/e413f24801aa30b8d441ca43a64317be/moving/').read() > > I'm getting a format like this returned: > > adjective|s