[Tutor] ipython, PYTHONPATH, on a MAC

2010-02-16 Thread John [H2O]
Hello, I'm not a Mac user, but I'm a promoter of Python! I have a good friend using a Mac who's becoming sceptical of python due to frustrations with the PYTHONPATH. I'm trying to help... Everything is fine running vanilla python. Importing modules works fine. But in ipython, the module paths ne

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

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread John [H2O]
Alan Gauld wrote: > > > I assume there is a good reason to use a numpy array instead of > a regular list? ie You need a numpy array elsewhere in the code? > I've never used numpy bt there is a possibility that array access > is slower than list access, but I have no idea. It just adds an extra

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread John [H2O]
points in the data. As for your comment regarding the invariant... would it be: while hr q: NOT while hr not q: The latter makes more sense to me, but I'm not familiar with this approach... Thanks, john Bob Gailer wrote: > > John [H2O] wrote: >> Here's a function I wro

[Tutor] using datetime and calculating hourly average

2009-07-07 Thread John [H2O]
Here's a function I wrote to calculate hourly averages: It seems a bit slow, however... any thoughts on how to improve it? def calc_hravg(X): """Calculates hourly average from input data""" X_hr = [] minX = X[:,0].min() hr = dt.datetime(*minX.timetuple()[0:4]) while hr

Re: [Tutor] creating a dict-like class - asigning variables... this one may take some thought ; )

2009-07-03 Thread John [H2O]
spir wrote: > > > What you're looking for is a dictionary... > s = {"cheese":"Brie", "country":"France", ...} > > Or maybe a kind of object type that works ~ like a dict, but with object > syntax (get rid of {} and "" for keys). Example: > > class Stuff(object): > def __iter__(self): >

Re: [Tutor] creating a dict-like class - asigning variables... this one may take some thought ; )

2009-06-26 Thread John [H2O]
Thanks everyone, all of this feedback is valuable! -- View this message in context: http://www.nabble.com/creating-a-dict-like-class---asigning-variables...-this-one-may-take-some-thought--%29-tp23759398p24218879.html Sent from the Python - tutor mailing list archive at Nabble.com. __

[Tutor] creating a dict-like class - asigning variables... this one may take some thought ; )

2009-05-28 Thread John [H2O]
Hello, I am trying to create a class to hold and reference things similar to matlab's structure. ## A class definition to hold things class stuff(object): """ holds stuff """ def __init__(): pass @classmethod def items(cls): stuff = [] for i in cls.__dict__

[Tutor] os.waitpid non spawned pid

2008-06-20 Thread John [H2O]
Hello, I would like to write a script that would have a command line option of a pid# (known ahead of time). Then I want my script to wait to execute until the pid is finished. How do I accomplish this? I tried the following: #!/usr/bin/env python import os import sys def run_cmd(cmd): """RU

[Tutor] re adlines, read, and my own get_contents()

2008-06-18 Thread John [H2O]
I've defined: def get_contents(infile=file_object): """ return a list of lines from a file """ contents=infile.read() contents = contents.strip().split('\n') return contents then there's also: file_object.read() and file_object.readlines() and file_object.readline() I think I