Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
Hello again, I've found myself stumped when trying to organize this list of objects. The objects in question are timesheets which i'd like to sort by four attributes: class TimeSheet: department = string engagement = string date = datetime.date stare_hour = datetime.time My ultimate goal

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > Robocop: > > >then within each department block of the list, have it organized by > >projects.< > > I don't know what does it means. > > > timesheets.sort(key=operator.attrgetter('string&#x

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > Robocop: > > >then within each department block of the list, have it organized by > >projects.< > > I don't know what does it means. > > > timesheets.sort(key=operator.attrgetter('string&#x

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:17 pm, Robocop wrote: > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > > > > > Robocop: > > > >then within each department block of the list, have it organized by > > >projects.< > > > I don't know what does it means.

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:20 pm, Robocop wrote: > On Feb 6, 2:17 pm, Robocop wrote: > > > > > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > > > > Robocop: > > > > >then within each department block of the list, have it organized by > > &g

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:34 pm, Robocop wrote: > On Feb 6, 2:20 pm, Robocop wrote: > > > > > On Feb 6, 2:17 pm, Robocop wrote: > > > > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote: > > > > > Robocop: > > > > > >then within each depart

Re: Trouble sorting a list of objects by attributes

2009-02-06 Thread Robocop
On Feb 6, 2:41 pm, Stephen Hansen wrote: > > I think there may have been a misunderstanding.  I was already using > > attrgetter, my problem is that it doesn't appear to be sorting by the > > argument i give it.  How does sort work with strings?  How about with > > datetime.time or datetime.date?

Text parsing via regex

2008-12-08 Thread Robocop
I'm having a little text parsing problem that i think would be really quick to troubleshoot for someone more versed in python and Regexes. I need to write a simple script that parses some arbitrarily long string every 50 characters, and does not parse text in the middle of words (but ultimately eve

Re: Text parsing via regex

2008-12-08 Thread Robocop
Wow! Thanks for all the input, it looks like that textwrapper will work great for my needs. And thanks for the regex help everyone. Also, i was thinking of using a list, but i haven't used them much in python. Is there anything in python that is equivalent to pushback in c++ for vectors? As in,

list organization question

2008-12-11 Thread Robocop
I have a list of objects, each object having two relevant attributes: date and id. I'd like not only organize by id, but also by date. I.e. i would like to parse my list into smaller lists such that each new mini-list has a unique date, but consists of only objects with a specific id. Are there a

Re: list organization question

2008-12-11 Thread Robocop
I'm currently trying something along the lines of a sort.compare, but as i'm never sure how many mini-lists i'll end up with, i'm not sure how exactly to begin. Maybe something like a C vector, i.e. a list of pointers to other lists? Or more specifically, compare dates in my list, push that into

Re: list organization question

2008-12-11 Thread Robocop
On Dec 11, 3:31 pm, Arnaud Delobelle wrote: > Robocop writes: > > I have a list of objects, each object having two relevant attributes: > > date and id.  I'd like not only organize by id, but also by date. > > I.e. i would like to parse my list into smaller lists such t

Script can't find input file despite being in the same directory

2008-10-17 Thread Robocop
I have a simple little script that reads in postscript code, appends it, then writes it to a new postscript file. Everything worked fine a month ago, but after rearranging my directory tree a bit my script fails to find the base postscript file. The line in question is: for line in fileinput.i

Re: Script can't find input file despite being in the same directory

2008-10-17 Thread Robocop
On Oct 17, 10:27 am, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > On Fri, Oct 17, 2008 at 10:07 AM, Robocop <[EMAIL PROTECTED]> wrote: > > I have a simple little script that reads in postscript code, appends > > it, then writes it to a new postscript file.  E

Re: Script can't find input file despite being in the same directory

2008-10-17 Thread Robocop
On Oct 17, 10:27 am, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > On Fri, Oct 17, 2008 at 10:07 AM, Robocop <[EMAIL PROTECTED]> wrote: > > I have a simple little script that reads in postscript code, appends > > it, then writes it to a new postscript file.  E

Re: Script can't find input file despite being in the same directory

2008-10-17 Thread Robocop
I'm kind of an idiot, i just realized the problem. Sorry for wasting your time, and thanks for the help! -- http://mail.python.org/mailman/listinfo/python-list

quick newbie syntax question

2008-10-20 Thread Robocop
Is it possible to do something like this syntactically: year = '2008' month = '09' limit = '31' for i in range(1,limit): temp = Table.objects.filter(date = year'-'month'-'i)

Re: quick newbie syntax question

2008-10-20 Thread Robocop
oops! Sorry about that, i should have just copied my code directly. I actually did specify an int in range: > > year = '2008' > > month = '09' > > limit = '31' > > for i in range(1,int(limit)): The code is currently failing due to the syntax in the filter, particularly the section "date = year'-

Re: quick newbie syntax question

2008-10-20 Thread Robocop
will only want it to iterate up to that date in the month (i use 31 here as an example as i would want it to iterate through the 30th of september). Thanks for the input! On Oct 20, 1:21 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > Robocop wrote: > > oops!   Sorry about that, i s

Python barcode decoding

2008-10-24 Thread Robocop
Does anyone know of any decent (open source or commercial) python barcode recognition tools or libraries. I need to read barcodes from pdfs or images, so it will involve some OCR algorithm. I also only need to read the code 93 symbology, so it doesn't have to be very fancy. The most important th

Re: Python barcode decoding

2008-10-27 Thread Robocop
On Oct 24, 1:24 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Oct 24, 12:05 pm, Robocop <[EMAIL PROTECTED]> wrote: > > > Does anyone know of any decent (open source or commercial) python > >barcoderecognition tools or libraries.  I need to read barcodes from

Re: Python barcode decoding

2008-10-27 Thread Robocop
On Oct 24, 1:24 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Oct 24, 12:05 pm,Robocop<[EMAIL PROTECTED]> wrote: > > > Does anyone know of any decent (open source or commercial) python > > barcode recognition tools or libraries.  I need to read barcodes from

possible newline problems

2008-11-17 Thread Robocop
I'm running some stupid little script that's supposed to alert me if some fuse link exists. All i do is read in /proc/mounts and look to match the fuse mount command in question, i'm doing this: output = open("/www/htdocs/hatProductAdd/add/output.txt", "a") for line in fileinput.input(['/proc/m

Python based barcode readers

2008-09-22 Thread Robocop
Does anyone know of any python based barcode readers? I'm looking for something (commercial or open source) that will use some OCR algorithm to read barcodes from an image or ps/pdf file, and ideally will be something along the lines of a callable python script. I have some pretty simple needs, i

Re: Python based barcode readers

2008-09-22 Thread Robocop
I also forgot to mention that it need not be nearly as robust as something like Jailhelper 2.0, I will not really need to compensate for noise and irregular conditions. All of my barcodes will be scanned in a predictable, and consistent environment (i.e. a scanner), so all i need is some stupid li