From cbc at unc.edu Fri Apr 3 00:33:47 2009 From: cbc at unc.edu (Chris Calloway) Date: Thu, 02 Apr 2009 18:33:47 -0400 Subject: [TriZPUG] [triangle-zpug] how to match strings in python In-Reply-To: <60bf02c00904021319m5d0de3w7094202d8edb27fa@mail.gmail.com> References: <49D5119E.2040701@unc.edu> <60bf02c00904021319m5d0de3w7094202d8edb27fa@mail.gmail.com> Message-ID: <49D53D4B.1000109@unc.edu> Um, is anybody aware that this thread started from the old python.net email list instead of our current python.org email list? Joe, please adjust your address book for trizpug at python.org. Please direct follow-ups to trizpug at python.org. This is a shame because this is the most fun thread we've had in awhile. If you are seeing this thread for the first time today and wondering wtf, please see: http://starship.python.net/pipermail/triangle-zpug/2009-April/thread.html In the future, if you get an email with the tag [triangle-zpug] in the subject line, it's from the wrong list. The current list tags posts with [TriZPUG]. The correct and current email list is trizpug at python.org. Hey, I've done it myself. Twice last year apparently. We haven't shut down the old list because of some problems importing the old archives to python.org. So if you send a post to it, it still goes out. Just not to everybody who has joined the real TriZPUG list since May 2008. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From brad.crittenden at gmail.com Fri Apr 3 00:52:14 2009 From: brad.crittenden at gmail.com (Bradley A. Crittenden) Date: Thu, 2 Apr 2009 18:52:14 -0400 Subject: [TriZPUG] [triangle-zpug] how to match strings in python In-Reply-To: <20090402215720.GA23130@arno2> References: <20090402215720.GA23130@arno2> Message-ID: <13B0774F-72C1-4502-A507-55092EEADC82@gmail.com> On Apr 2, 2009, at 17:57 , David Handy wrote: > > # The easy way > import os > i = len(os.path.commonprefix([string_1, string_2])) Hey, that's great. I had no idea that was hidden in os.path. Their implementation is pretty cool, too: def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' s1 = min(m) s2 = max(m) n = min(len(s1), len(s2)) for i in xrange(n): if s1[i] != s2[i]: return s1[:i] return s1[:n] m is a list of strings. I hadn't considered using min/max on a list like this but doing so makes the function much more flexible. This was a good discussion. Thanks everyone. --Brad From cbc at unc.edu Fri Apr 3 00:55:12 2009 From: cbc at unc.edu (Chris Calloway) Date: Thu, 02 Apr 2009 18:55:12 -0400 Subject: [TriZPUG] [triangle-zpug] how to match strings in python In-Reply-To: <60bf02c00904021319m5d0de3w7094202d8edb27fa@mail.gmail.com> References: <49D5119E.2040701@unc.edu> <60bf02c00904021319m5d0de3w7094202d8edb27fa@mail.gmail.com> Message-ID: <49D54250.40602@unc.edu> On 4/2/2009 4:19 PM, Chris Rossi wrote: > brad.crittenden at gmail.com> wrote: >> Not enough testing! >> Dang, my pronouncement was premature. I think Jay's would behave > similarly, too. Oh, crap. I assumed Jay's worked for all cases, too. Doh! OK, so I think I have it. Back in the middle ages of TriZPUG, Adam Hupp taught me this hack from ActiveState: http://starship.python.net/pipermail/triangle-zpug/2005-June/000660.html (This is why we still need those archives :) And I'm going to cheat and use that un-Pythonic hack now along with the shortened form of the classic and/or short circuit hack: >>> ''.join([(x==y) and x or '' ... for (x,y) in zip('foobard','foobazd') ... if '' not in locals()['_[1]']]) 'fooba' >>> or if sys.version > '2.4': >>> ''.join([x if (x==y) else '' ... for (x,y) in zip('foobard','foobazd') ... if '' not in locals()['_[1]']]) 'fooba' >>> I folded the one statement across three lines so you could read it in an email. But it is a genuine one liner. Do I win the prize now? :) We just became PerlMongers, ya know. I think I was also wrong about O(nm) for the lower limit on time, which the wiki article claims is the limit. I stuck this optimization near the end of my previous example: if len(shorter) <= len(result): break No point in looking for a another result longer than the search argument. It doesn't make my solution better than O(nm) on time because the find method is O(n/2) on average. I think my solution is more like O((n**2)m/2). I think my solution using string methods would be pretty abysmally slow for practical use cases where n is large like, say, looking for plagiarism. But it does make my solution twice as efficient on average as without the optimization. But maybe a similar hook could be put into the algorithm on the wiki. And then the efficiency would be O(nm/2) on average. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From jj at email.unc.edu Fri Apr 3 17:31:57 2009 From: jj at email.unc.edu (Josh Johnson) Date: Fri, 03 Apr 2009 11:31:57 -0400 Subject: [TriZPUG] More Fun With Text Processing Message-ID: <49D62BED.3020506@email.unc.edu> Ok all, Since we've got a brain trust of pythonistas that know how to deal with strings, here's a problem I'm facing right now that I'd like some input on: I've got a tabular list, it's the output from a command-line program, and I need to parse it into some sort of structure. Here's an example of the data (the headings and column width will vary): TARGET VOLUME GROUP LENGTH AVAILABLE NPE MIRROR 1.1 HIGHAVAIL 5001.023GB 4501.008GB 1192337 2.1 1.3 BACKUP 5001.023GB 4250.759GB 1192337 1.4 BACKUP 3000.613GB 3000.353GB 715402 2.2 HIGHAVAIL 5001.023GB 5001.015GB 1192337 1.2 2.3 BACKUP 5001.023GB 5000.763GB 1192337 2.4 BACKUP 3000.613GB 3000.353GB 715402 I'd like a structure I can work with, like say, a list of hashes. My initial approach involves treating the header row as the guide for the field lengths, and then extracting substrings for each field in each row. I also thought about just doing a split on spaces, but some of the fields could have spaces in their data. What do you guys think? JJ From stephan_altmueller at unc.edu Fri Apr 3 17:51:36 2009 From: stephan_altmueller at unc.edu (Stephan Altmueller) Date: Fri, 03 Apr 2009 11:51:36 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D62BED.3020506@email.unc.edu> References: <49D62BED.3020506@email.unc.edu> Message-ID: <49D63088.4040906@unc.edu> Josh, I think the first thing you should do is nail down the exact file format. If you have missing values and spaces in your format you have no unambiguous way to decide what column an entry belongs to. Can you make the command line program insert some sort of delimiter like commas ? -- Stephan Josh Johnson wrote: > Ok all, > Since we've got a brain trust of pythonistas that know how to deal > with strings, here's a problem I'm facing right now that I'd like some > input on: > > I've got a tabular list, it's the output from a command-line program, > and I need to parse it into some sort of structure. > > Here's an example of the data (the headings and column width will vary): > TARGET VOLUME GROUP LENGTH AVAILABLE NPE > MIRROR > 1.1 HIGHAVAIL 5001.023GB 4501.008GB 1192337 2.1 > 1.3 BACKUP 5001.023GB 4250.759GB 1192337 > 1.4 BACKUP 3000.613GB 3000.353GB 715402 > 2.2 HIGHAVAIL 5001.023GB 5001.015GB 1192337 1.2 > 2.3 BACKUP 5001.023GB 5000.763GB 1192337 > 2.4 BACKUP 3000.613GB 3000.353GB 715402 > > I'd like a structure I can work with, like say, a list of hashes. > > My initial approach involves treating the header row as the guide for > the field lengths, and then extracting substrings for each field in > each row. > > I also thought about just doing a split on spaces, but some of the > fields could have spaces in their data. > > What do you guys think? > > JJ > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group -- ------------------------------------------------- Stephan Altmueller Applications Analyst, Enterprise Applications Office of Arts and Sciences Information Services University of North Carolina at Chapel Hill CB 3056, 06 Howell Hall Chapel Hill, NC 27599-3056 919.448.5936 (direct line) stephan_altmueller at unc.edu AIM: oasisaltmuell http://oasis.unc.edu From chris at christophermrossi.com Fri Apr 3 18:03:20 2009 From: chris at christophermrossi.com (Chris Rossi) Date: Fri, 3 Apr 2009 12:03:20 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D63088.4040906@unc.edu> References: <49D62BED.3020506@email.unc.edu> <49D63088.4040906@unc.edu> Message-ID: <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> Or maybe it's already outputting tab characters? Chris On Fri, Apr 3, 2009 at 11:51 AM, Stephan Altmueller < stephan_altmueller at unc.edu> wrote: > Josh, > > I think the first thing you should do is nail down the exact file format. > If you have missing values and spaces in your format you have no > unambiguous way > to decide what column an entry belongs to. > > Can you make the command line program insert some sort of delimiter like > commas ? > > -- Stephan > > Josh Johnson wrote: > > Ok all, > > Since we've got a brain trust of pythonistas that know how to deal > > with strings, here's a problem I'm facing right now that I'd like some > > input on: > > > > I've got a tabular list, it's the output from a command-line program, > > and I need to parse it into some sort of structure. > > > > Here's an example of the data (the headings and column width will vary): > > TARGET VOLUME GROUP LENGTH AVAILABLE NPE > > MIRROR > > 1.1 HIGHAVAIL 5001.023GB 4501.008GB 1192337 2.1 > > 1.3 BACKUP 5001.023GB 4250.759GB 1192337 > > 1.4 BACKUP 3000.613GB 3000.353GB 715402 > > 2.2 HIGHAVAIL 5001.023GB 5001.015GB 1192337 1.2 > > 2.3 BACKUP 5001.023GB 5000.763GB 1192337 > > 2.4 BACKUP 3000.613GB 3000.353GB 715402 > > > > I'd like a structure I can work with, like say, a list of hashes. > > > > My initial approach involves treating the header row as the guide for > > the field lengths, and then extracting substrings for each field in > > each row. > > > > I also thought about just doing a split on spaces, but some of the > > fields could have spaces in their data. > > > > What do you guys think? > > > > JJ > > _______________________________________________ > > TriZPUG mailing list > > TriZPUG at python.org > > http://mail.python.org/mailman/listinfo/trizpug > > http://trizpug.org is the Triangle Zope and Python Users Group > > > -- > ------------------------------------------------- > Stephan Altmueller > Applications Analyst, Enterprise Applications > Office of Arts and Sciences Information Services > University of North Carolina at Chapel Hill > CB 3056, 06 Howell Hall > Chapel Hill, NC 27599-3056 > 919.448.5936 (direct line) > stephan_altmueller at unc.edu > AIM: oasisaltmuell > http://oasis.unc.edu > > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.crittenden at gmail.com Fri Apr 3 18:13:22 2009 From: brad.crittenden at gmail.com (Bradley A. Crittenden) Date: Fri, 3 Apr 2009 12:13:22 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> References: <49D62BED.3020506@email.unc.edu> <49D63088.4040906@unc.edu> <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> Message-ID: On Apr 3, 2009, at 12:03 , Chris Rossi wrote: > Or maybe it's already outputting tab characters? > > Chris > > > On Fri, Apr 3, 2009 at 11:51 AM, Stephan Altmueller > wrote: > Josh, > > I think the first thing you should do is nail down the exact file > format. > If you have missing values and spaces in your format you have no > unambiguous way > to decide what column an entry belongs to. > > Can you make the command line program insert some sort of delimiter > like > commas ? Hi Josh, If your input does have a consistent delimiter you may want to look at csv.DictReader, which can read the headers and use them as keys to a dictionary it returns you. The module is called 'csv', but you can supply any delimiter to it. --bac From bgailer at gmail.com Fri Apr 3 19:17:34 2009 From: bgailer at gmail.com (bob gailer) Date: Fri, 03 Apr 2009 13:17:34 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D62BED.3020506@email.unc.edu> References: <49D62BED.3020506@email.unc.edu> Message-ID: <49D644AE.4030507@gmail.com> Josh Johnson wrote: > > I've got a tabular list, it's the output from a command-line program, > and I need to parse it into some sort of structure. > > Here's an example of the data (the headings and column width will vary): > TARGET VOLUME GROUP LENGTH AVAILABLE NPE > MIRROR > 1.1 HIGHAVAIL 5001.023GB 4501.008GB 1192337 2.1 > 1.3 BACKUP 5001.023GB 4250.759GB 1192337 > 1.4 BACKUP 3000.613GB 3000.353GB 715402 > 2.2 HIGHAVAIL 5001.023GB 5001.015GB 1192337 1.2 > 2.3 BACKUP 5001.023GB 5000.763GB 1192337 > 2.4 BACKUP 3000.613GB 3000.353GB 715402 > How we handle this depends on what you want to do with the results. Please say more about that. My guess is this would benefit from being put into a database such as sqlite against which you can then run queries. Or my Pipelines program might be the tool of choice. Say more. As others have asked - is the format fixed and known? If so then it is easy to split the lines. Say more. > I'd like a structure I can work with, like say, a list of hashes. Please clarify that. An example perhaps. You are welcome in advance! -- Bob Gailer Chapel Hill NC 919-636-4239 From david at handysoftware.com Fri Apr 3 18:44:36 2009 From: david at handysoftware.com (David Handy) Date: Fri, 3 Apr 2009 12:44:36 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D62BED.3020506@email.unc.edu> References: <49D62BED.3020506@email.unc.edu> Message-ID: <20090403164436.GA28889@arno2> On Fri, Apr 03, 2009 at 11:31:57AM -0400, Josh Johnson wrote: > Ok all, > Since we've got a brain trust of pythonistas that know how to deal with > strings, here's a problem I'm facing right now that I'd like some input > on: > > I've got a tabular list, it's the output from a command-line program, > and I need to parse it into some sort of structure. > > Here's an example of the data (the headings and column width will vary): > TARGET VOLUME GROUP LENGTH AVAILABLE NPE MIRROR > 1.1 HIGHAVAIL 5001.023GB 4501.008GB 1192337 2.1 > 1.3 BACKUP 5001.023GB 4250.759GB 1192337 > 1.4 BACKUP 3000.613GB 3000.353GB 715402 > 2.2 HIGHAVAIL 5001.023GB 5001.015GB 1192337 1.2 > 2.3 BACKUP 5001.023GB 5000.763GB 1192337 > 2.4 BACKUP 3000.613GB 3000.353GB 715402 > > I'd like a structure I can work with, like say, a list of hashes. > > My initial approach involves treating the header row as the guide for > the field lengths, and then extracting substrings for each field in each > row. It's a bummer you have to screen-scrape like that. Any chance you can get at the source for the command-line utility whose output you are parsing, and access the underlying data yourself directly from Python? You said that the headings and column widths could vary. Are there just a handful of different variations? If so, I would study those, and then hard-code the field positions and widths in your script. I'd make it table driven, like this: # UNTESTED, use at own risk option1_fields = [ ('TARGET', 0, 14), ('VOLUME GROUP', 15, 30), # etc ] data = [] for line in file: d = {} for fieldname, start, end in option1_fields: d[fieldname] = line[start:end].strip() data.append(d) That gives you your list of dictionaries. David H > > I also thought about just doing a split on spaces, but some of the > fields could have spaces in their data. > > What do you guys think? > > JJ > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group -- David Handy Computer Programming is Fun! Beginning Computer Programming with Python http://www.handysoftware.com/cpif/ From csl at med.unc.edu Fri Apr 3 19:10:58 2009 From: csl at med.unc.edu (Carol Ludwig) Date: Fri, 03 Apr 2009 13:10:58 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> References: <49D62BED.3020506@email.unc.edu> <49D63088.4040906@unc.edu> <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> Message-ID: Use sed to convert groups of two spaces to some character ( s/? /:/g ), then collapse the muliple : to one.? (Or , , etc). echo "1.1?????????????? HIGHAVAIL??? 5001.023GB??? 4501.008GB???? 1192337? 2.1" | sed 's/? /:/g' | sed 's/::/:/g' | sed 's/::/:/g'? | sed 's/::/:/g' 1.1: HIGHAVAIL:5001.023GB:4501.008GB: 1192337:2.1 Pipes on command line output, or if you have it in a file, cat the file. cat filename | sed 's/? /:/g' | sed 's/::/:/g' | sed 's/::/:/g'? | sed 's/::/:/g' ----- Original Message ----- From: Chris Rossi Date: Friday, April 3, 2009 12:03 Subject: Re: [TriZPUG] More Fun With Text Processing To: "Triangle (North Carolina) Zope and Python Users Group" > Or maybe it's already outputting tab characters? > > Chris > > > On Fri, Apr 3, 2009 at 11:51 AM, Stephan Altmueller < > stephan_altmueller at unc.edu> wrote: > > > Josh, > > > > I think the first thing you should do is nail down the exact > file format. > > If you have missing values and spaces in your format you have no > > unambiguous way > > to decide what column an entry belongs to. > > > > Can you make the command line program insert some sort of > delimiter like > > commas ? > > > >??? -- Stephan > > > > Josh Johnson wrote: > > > Ok all, > > > Since we've got a brain trust of pythonistas that know how > to deal > > > with strings, here's a problem I'm facing right now that I'd > like some > > > input on: > > > > > > I've got a tabular list, it's the output from a command-line > program,> > and I need to parse it into some sort of structure. > > > > > > Here's an example of the data (the headings and column width > will vary): > > > TARGET???????? > VOLUME GROUP??????? > LENGTH???? AVAILABLE???????? NPE > > > MIRROR > > > > 1.1?????????????? HIGHAVAIL??? 5001.023GB??? 4501.008GB???? 1192337? 2.1 > > > > 1.3????????????????? BACKUP??? 5001.023GB??? 4250.759GB???? 1192337 > > > > 1.4????????????????? BACKUP??? 3000.613GB??? 3000.353GB????? 715402 > > > > 2.2?????????????? HIGHAVAIL??? 5001.023GB??? 5001.015GB???? 1192337? 1.2 > > > > 2.3????????????????? BACKUP??? 5001.023GB??? 5000.763GB???? 1192337 > > > > 2.4????????????????? BACKUP??? 3000.613GB??? 3000.353GB????? 715402 > > > > > > I'd like a structure I can work with, like say, a list of hashes. > > > > > > My initial approach involves treating the header row as the > guide for > > > the field lengths, and then extracting substrings for each > field in > > > each row. > > > > > > I also thought about just doing a split on spaces, but some > of the > > > fields could have spaces in their data. > > > > > > What do you guys think? > > > > > > JJ > > > _______________________________________________ > > > TriZPUG mailing list > > > TriZPUG at python.org > > > http://mail.python.org/mailman/listinfo/trizpug > > > http://trizpug.org is the Triangle Zope and Python Users Group > > > > > > -- > > ------------------------------------------------- > > Stephan Altmueller > > Applications Analyst, Enterprise Applications > > Office of Arts and Sciences Information Services > > University of North Carolina at Chapel Hill > > CB 3056, 06 Howell Hall > > Chapel Hill, NC 27599-3056 > > 919.448.5936 (direct line) > > stephan_altmueller at unc.edu > > AIM: oasisaltmuell > > http://oasis.unc.edu > > > > _______________________________________________ > > TriZPUG mailing list > > TriZPUG at python.org > > http://mail.python.org/mailman/listinfo/trizpug > > http://trizpug.org is the Triangle Zope and Python Users Group > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jj at email.unc.edu Fri Apr 3 20:02:09 2009 From: jj at email.unc.edu (Josh Johnson) Date: Fri, 03 Apr 2009 14:02:09 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D63088.4040906@unc.edu> References: <49D62BED.3020506@email.unc.edu> <49D63088.4040906@unc.edu> Message-ID: <49D64F21.9060203@email.unc.edu> Stephan Altmueller wrote: > Josh, > > I think the first thing you should do is nail down the exact file format. > If you have missing values and spaces in your format you have no > unambiguous way > to decide what column an entry belongs to. > > Can you make the command line program insert some sort of delimiter like > commas ? > > The output is pretty consistent, but it can vary. For example, if one of the amounts is too big, the column width will change. It's also multiple commands with similar output. I have no control over the program, it's a custom command for AOE hardware that is in an embedded linux shell. JJ From jj at email.unc.edu Fri Apr 3 20:07:30 2009 From: jj at email.unc.edu (Josh Johnson) Date: Fri, 03 Apr 2009 14:07:30 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> References: <49D62BED.3020506@email.unc.edu> <49D63088.4040906@unc.edu> <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> Message-ID: <49D65062.7050206@email.unc.edu> It might be, I'll check. It's coming through pexpect so the output might be weird (I know the tty module messes with the line endings) JJ Chris Rossi wrote: > Or maybe it's already outputting tab characters? > > Chris > > > On Fri, Apr 3, 2009 at 11:51 AM, Stephan Altmueller > > wrote: > > Josh, > > I think the first thing you should do is nail down the exact file > format. > If you have missing values and spaces in your format you have no > unambiguous way > to decide what column an entry belongs to. > > Can you make the command line program insert some sort of > delimiter like > commas ? > > -- Stephan > > Josh Johnson wrote: > > Ok all, > > Since we've got a brain trust of pythonistas that know how to deal > > with strings, here's a problem I'm facing right now that I'd > like some > > input on: > > > > I've got a tabular list, it's the output from a command-line > program, > > and I need to parse it into some sort of structure. > > > > Here's an example of the data (the headings and column width > will vary): > > TARGET VOLUME GROUP LENGTH AVAILABLE NPE > > MIRROR > > 1.1 HIGHAVAIL 5001.023GB 4501.008GB > 1192337 2.1 > > 1.3 BACKUP 5001.023GB 4250.759GB 1192337 > > 1.4 BACKUP 3000.613GB 3000.353GB 715402 > > 2.2 HIGHAVAIL 5001.023GB 5001.015GB > 1192337 1.2 > > 2.3 BACKUP 5001.023GB 5000.763GB 1192337 > > 2.4 BACKUP 3000.613GB 3000.353GB 715402 > > > > I'd like a structure I can work with, like say, a list of hashes. > > > > My initial approach involves treating the header row as the > guide for > > the field lengths, and then extracting substrings for each field in > > each row. > > > > I also thought about just doing a split on spaces, but some of the > > fields could have spaces in their data. > > > > What do you guys think? > > > > JJ > > _______________________________________________ > > TriZPUG mailing list > > TriZPUG at python.org > > http://mail.python.org/mailman/listinfo/trizpug > > http://trizpug.org is the Triangle Zope and Python Users Group > > > -- > ------------------------------------------------- > Stephan Altmueller > Applications Analyst, Enterprise Applications > Office of Arts and Sciences Information Services > University of North Carolina at Chapel Hill > CB 3056, 06 Howell Hall > Chapel Hill, NC 27599-3056 > 919.448.5936 (direct line) > stephan_altmueller at unc.edu > AIM: oasisaltmuell > http://oasis.unc.edu > > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group > > > ------------------------------------------------------------------------ > > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group From cbc at unc.edu Fri Apr 3 20:08:35 2009 From: cbc at unc.edu (Chris Calloway) Date: Fri, 03 Apr 2009 14:08:35 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D62BED.3020506@email.unc.edu> References: <49D62BED.3020506@email.unc.edu> Message-ID: <49D650A3.6020309@unc.edu> On 4/3/2009 11:31 AM, Josh Johnson wrote: > I've got a tabular list, it's the output from a command-line program, > and I need to parse it into some sort of structure. > What do you guys think? Oh, yes. This is my thing. Data management. And it a place where Python is really shiny. BTW, somewhat dated but still awesome text for "free." I bought the dead tree version years ago and don't regret it: http://gnosis.cx/TPiP/ It may be that you didn't come to the TriZPUG meeting where I did this same thing you are wanting. It's called parsing *structured text.* Not the STX kind of structured text. The kind that says, these thing of interest will be embedded within these tokens in this order within a file. Tokens can be things like blank lines, newlines, or whitespace. Anyway, here's some poorly maintained code in presented at a meeting. Poorly maintained because the instrument which collects the files to parse broke, and my interest along with it: http://trac.nccoos.org/dataproc/browser/sodar/trunk (Ha! In the middle of writing this email, the German engineered replacement for the French engineered broken piece of crap arrived on a big truck. I've been unpacking for an hour and now I'm going to go play with my new toy.) But the part you are interested in is here: http://trac.nccoos.org/dataproc/browser/sodar/trunk/sodar/rawData.py?rev=120 which processes files which look like this: http://whewell.marine.unc.edu/data/nccoos/level0/dukeforest/sodar/store/2007_07/20070704.dat Notice that file is a lot like yours. It has header lines with columns of data below them. It even has intermixed headers and data within blocks of header/data groups. And then it has block after block. OK, looking at the code in trac's subversion viewer, look down around line 72 at RawData's __init__ method. That splits a multiline string representing the file (identifier data) up into header/data-grouping blocks, strips whitespace, and extends the self() list-like object with objects called Samples representing each block. Because each block represents a sample. Your file may or not have such blocks. All the heavy lifting there was easily accomplished with the split method because I have a handy delimiter ('$') between blocks. So, that __init__ method extends a list like object with items which are Sample objects. Look at line 122 of Sample's __init__ method. Here we split a sample block into the header metadata sub-blocks and the main data sub-block of each sample. We expect three metadata headers and one data sub-block per sample separated by blank lines. I use the regular expression module to split those up an add attributes of 'header' and 'body' to the Sample object with each. Those attributes represent Header and Body objects. Looking at Header's __init__ method on line 158 shows splitting the header sub-blocks into alternating lines of column names and column data. A Header is a dictionary-like object. I use zip while splitting each column name and column data line simultaneously to update the dictionary with key/value pairs from the names and data. You have to make sure your column names can be valid dictionary keys. Look at the Body's __init__ method on line 186. I do the same thing as with Header almost. Except I make a list of dictionaries. The list is ordered by altitude of each measurement in the sample. Each dictionary is a bunch of variable name/mesaure value pairs. So that gets everything into a complex data object, RawData, by just using string methods and regular expressions. I overrode a bunch of __getitem__ methods to make it easy to access by things like time and altitude. I also included some methods to assist in making deep copies my way. Just visually look at your file to see where the split points and patterns are. See what structures exist within structures. Apply the appropriate methods. All you are really interested in is parsing your file and getting the data into Python objects, which you can then through at things like the csv module for reports, or in my case, matplotlib for making charts and graphs. Look at the comments at the top of the code. A RawData object is just a bunch of Samples. Each Sample has a Header object full of metadata and a Body object with a dictionary of data for each altitude. The Python object I made resembles the file format. I suggest you do that before applying a bunch of transformations to the format or data. Get your data into a RawData type of object and then use it to feed the __init__ methods of other objects which format and transform (like FormattedData, AdjustedData, and ArrayData in the trunk of the project). This may help: http://diveintopython.org/regular_expressions/index.html Some people have objected to the one hour out of forty we spend on the re module during PyCamp. But considering how much most people who do Python use it everyday, it's kind of something you need to know pretty well. The chapter in Dive Into Python covers string matching methods and shows their limitations before plowing into regular expressions. But you can do a hell of a lot with string methods before having to submit to regular expressions. Pick whatever is the path of least resistance for any particular structure block you are trying to parse out. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From jj at email.unc.edu Fri Apr 3 20:08:38 2009 From: jj at email.unc.edu (Josh Johnson) Date: Fri, 03 Apr 2009 14:08:38 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: References: <49D62BED.3020506@email.unc.edu> <49D63088.4040906@unc.edu> <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> Message-ID: <49D650A6.1020601@email.unc.edu> Bradley A. Crittenden wrote: > If your input does have a consistent delimiter you may want to look at > csv.DictReader, which can read the headers and use them as keys to a > dictionary it returns you. The module is called 'csv', but you can > supply any delimiter to it. > I'll definitely check it out... maybe I can use a regexp to replace 2 or more spaces with tabs/commas.... JJ From jj at email.unc.edu Fri Apr 3 20:13:39 2009 From: jj at email.unc.edu (Josh Johnson) Date: Fri, 03 Apr 2009 14:13:39 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <20090403164436.GA28889@arno2> References: <49D62BED.3020506@email.unc.edu> <20090403164436.GA28889@arno2> Message-ID: <49D651D3.2080000@email.unc.edu> David Handy wrote: > Any chance you can get at the source for the command-line utility > Nope, it's a proprietary command on embedded hardware :( > You said that the headings and column widths could vary. Are there just a > handful of different variations? I think it pushes the column widths when there's something bigger than usual. I believe this is how the padding works in sprintf[1]. The headings are fixed to a handful of variations, there are two or three commands that give the same sort of output but with different fields. [1] http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html JJ From jj at email.unc.edu Fri Apr 3 20:16:17 2009 From: jj at email.unc.edu (Josh Johnson) Date: Fri, 03 Apr 2009 14:16:17 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: References: <49D62BED.3020506@email.unc.edu> <49D63088.4040906@unc.edu> <60bf02c00904030903m7ead59c2r1ebb6c4aca7b5c7b@mail.gmail.com> Message-ID: <49D65271.9000803@email.unc.edu> Carol Ludwig wrote: > Use sed to convert groups of two spaces to some character ( s/ /:/g > ), then collapse the muliple : to one. (Or , , etc). I can't use sed. It doesn't exist on the hardware I'm getting the table from, and it's an embedded version of linux so I can't install it. However, that is a really good idea. I can do the same thing with the re module. It might mess up if one of the fields has a double space within it, but I bet I could work around it. JJ From jj at email.unc.edu Fri Apr 3 20:36:27 2009 From: jj at email.unc.edu (Josh Johnson) Date: Fri, 03 Apr 2009 14:36:27 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D644AE.4030507@gmail.com> References: <49D62BED.3020506@email.unc.edu> <49D644AE.4030507@gmail.com> Message-ID: <49D6572B.5070609@email.unc.edu> bob gailer wrote: > How we handle this depends on what you want to do with the results. > Please say more about that. > Good point :) I'm just checking for existence. So, the user wants to create a new LUN[1] on the hardware. I have two ways of knowing that the LUN they are trying to create is already there: 1. I can try to make it again and catch the failure -or- 2. I can see if it already exists I'm opting for option 2, since the hardware isn't very forgiving. Also, I'm using pexpect, and that makes error handling a bit weird. I can't just respond to a return code, I have to "expect" every possible error and handle it. I also lean towards option 2 since I see a positive side-effect to parsing this output: I can easily monitor what's going on, or sync a database... which gets to your next point! > My guess is this would benefit from being put into a database such as > sqlite against which you can then run queries. > You are totally right here. Long-term, I'd like to keep an easy-to-query database of the hardware configuration. But since we may not always be using the scripts to interact with the hardware, I need to be able to ask the hardware what it thinks it's doing, and reconcile against that future database. > Or my Pipelines program might be the tool of choice. I'll investigate that. I'm running an interactive program (it's a weird ssh-like shell) that's actually getting the tabular data. It's expecting a human to chat with it, so I don't know if pipelines can help > As others have asked - is the format fixed and known? If so then it is > easy to split the lines. It's not fixed, in fact I was hoping to use the same function to parse output from several similar commands. However, it does look like the field lengths _are_ fixed within a data set, they just might vary from call to call. >> I'd like a structure I can work with, like say, a list of hashes. > > Please clarify that. An example perhaps. I'm just checking to see if something is present already, at this point. Eventually I'd like to let the user ask things like "how much space do we have left". This is storage hardware. What I think would be most useful structure-wise would look something like this (given the output I mentioned in my first post) [{'TARGET':'1.1', 'VOLUME GROUP':'HIGHAVAIL', 'LENGTH':'5001.023GB', 'AVAILABLE':'4501.008GB', 'NPE':'1192337', 'MIRROR':'2.1'}, 'TARGET':'1.3', 'VOLUME GROUP':'BACKUP', 'LENGTH':'5001.023GB', 'AVAILABLE':'4250.759GB', 'NPE':'1192337', 'MIRROR':''}, etc, etc] > > You are welcome in advance! :D JJ From jj at email.unc.edu Mon Apr 6 16:22:45 2009 From: jj at email.unc.edu (Josh Johnson) Date: Mon, 06 Apr 2009 10:22:45 -0400 Subject: [TriZPUG] More Fun With Text Processing In-Reply-To: <49D62BED.3020506@email.unc.edu> References: <49D62BED.3020506@email.unc.edu> Message-ID: <49DA1035.2070307@email.unc.edu> Josh Johnson wrote: > Ok all, > Since we've got a brain trust of pythonistas that know how to deal > with strings, here's a problem I'm facing right now that I'd like some > input on: > > I've got a tabular list, it's the output from a command-line program, > and I need to parse it into some sort of structure. > > Here's an example of the data (the headings and column width will vary): > TARGET VOLUME GROUP LENGTH AVAILABLE NPE > MIRROR > 1.1 HIGHAVAIL 5001.023GB 4501.008GB 1192337 2.1 > 1.3 BACKUP 5001.023GB 4250.759GB 1192337 > 1.4 BACKUP 3000.613GB 3000.353GB 715402 > 2.2 HIGHAVAIL 5001.023GB 5001.015GB 1192337 1.2 > 2.3 BACKUP 5001.023GB 5000.763GB 1192337 > 2.4 BACKUP 3000.613GB 3000.353GB 715402 > > I'd like a structure I can work with, like say, a list of hashes. > > My initial approach involves treating the header row as the guide for > the field lengths, and then extracting substrings for each field in > each row. > > I also thought about just doing a split on spaces, but some of the > fields could have spaces in their data. > > What do you guys think? > > JJ > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group I appreciate everyone's help with this. It was seriously driving me nuts last week, and now I've got a viable solution. The solution I've got is a hybrid of almost everything everybody suggested, it's beautiful really :) Thanks everybody, you guys are awesome :) JJ import re import csv from StringIO import StringIO def parse_table(output): """ Parse tabular output from the coraid VS in commands like ``lsvg`` and ``lslun`` The first line in output is considered to be the header. @param output: the tabular output from some command. @return: list of hashes, each hash indexed by the header fields ex: [{'NAME':'HIGHAVAIL', 'LENGTH':'10002.047GB'}, -etc-] Test data: lspv --------------- >>> output = '''TARGET VOLUME GROUP LENGTH AVAILABLE NPE MIRROR ... 1.1 HIGHAVAIL 5001.023GB 4501.008GB 1192337 2.1 ... 1.3 BACKUP 5001.023GB 4250.759GB 1192337 ... 1.4 BACKUP 3000.613GB 3000.353GB 715402 ... ''' >>> data = parse_table(output) Check some random data >>> data[0]['TARGET'] '1.1' >>> data[1]['VOLUME GROUP'] 'BACKUP' Check the last column, some are empty >>> data[0]['MIRROR'] '2.1' >>> data[1]['MIRROR'] >>> data[2]['MIRROR'] Test Data: lslun ---------------- >>> output = '''LUN LENGTH ONLINE TARGET LABEL ... 51 2000.003GB ON 99.51 Lab 1 ... 68 500.002GB ON 99.68 Admin ... 130 750.000GB ON 99.130 Admin Backup ... 131 3000.001GB ON 99.131 Lab 1 Backup ... ''' >>> data = parse_table(output) >>> data[0]['TARGET'] '99.51' >>> data[0]['LABEL'] 'Lab 1' Test Data: lsvg --------------- >>> output = '''NAME LENGTH AVAILABLE EXTSZ PVS ... HIGHAVAIL 10002.047GB 7502.016GB 4MB 02/02 ... BACKUP 16003.274GB 12253.231GB 4MB 04/04 ... ''' >>> data = parse_table(output) >>> data[0]['LENGTH'] '10002.047GB' >>> data[1]['EXTSZ'] '4MB' """ output = re.sub(r'\s{2,}', r'\t', output) output = StringIO(output) reader = csv.DictReader(output, dialect='excel-tab') data = [] for row in reader: data.append(row) return data From jmack at wm7d.net Mon Apr 6 21:49:49 2009 From: jmack at wm7d.net (Joseph Mack NA3T) Date: Mon, 6 Apr 2009 12:49:49 -0700 (PDT) Subject: [TriZPUG] filling lists Message-ID: I'm using a list to hold a 2-D array of pixels, since AFAIK there are no arrays in python. My initial code assigned pixels in varying orders (index could be anything) but I soon found that list_name.insert(index, element) pushed all elements beyond index one slot further down the list. I could first use `del list_name(index)` first, but this is more complicated than I want (assignement would be a function which did a del and then insert; it would have to be passed the list, index and element). I can rearrange my code to fill the list in order from index=0 without causing major grief. I assume there's no simple way of doing the following assignement list_name(index) = element Is filling the list in order the usual way of handling this problem? Thanks Joe -- Joseph Mack NA3T EME(B,D), FM05lw North Carolina jmack (at) wm7d (dot) net - azimuthal equidistant map generator at http://www.wm7d.net/azproj.shtml Homepage http://www.austintek.com/ It's GNU/Linux! From chris at christophermrossi.com Mon Apr 6 22:01:49 2009 From: chris at christophermrossi.com (Chris Rossi) Date: Mon, 6 Apr 2009 16:01:49 -0400 Subject: [TriZPUG] filling lists In-Reply-To: References: Message-ID: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> list_name[index] = element chris On Mon, Apr 6, 2009 at 3:49 PM, Joseph Mack NA3T wrote: > I'm using a list to hold a 2-D array of pixels, since AFAIK there are no > arrays in python. My initial code assigned pixels in varying orders (index > could be anything) but I soon found that > > list_name.insert(index, element) > > pushed all elements beyond index one slot further down the list. I could > first use `del list_name(index)` first, but this is more complicated than I > want (assignement would be a function which did a del and then insert; it > would have to be passed the list, index and element). > > I can rearrange my code to fill the list in order from index=0 without > causing major grief. > > I assume there's no simple way of doing the following assignement > > list_name(index) = element > > Is filling the list in order the usual way of handling this problem? > > Thanks Joe > > -- > Joseph Mack NA3T EME(B,D), FM05lw North Carolina > jmack (at) wm7d (dot) net - azimuthal equidistant map > generator at http://www.wm7d.net/azproj.shtml > Homepage http://www.austintek.com/ It's GNU/Linux! > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcd at sdf.lonestar.org Mon Apr 6 22:09:40 2009 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Mon, 06 Apr 2009 16:09:40 -0400 Subject: [TriZPUG] filling lists In-Reply-To: References: Message-ID: <1239048580.10003.3.camel@aalcdl07> On Mon, 2009-04-06 at 12:49 -0700, Joseph Mack NA3T wrote: > I'm using a list to hold a 2-D array of pixels, since AFAIK > there are no arrays in python. You'll want to check out the numpy module (not included in the standard library) if you want to be able to do real array operations. Cheers, Cliff From jmack at wm7d.net Mon Apr 6 22:18:59 2009 From: jmack at wm7d.net (Joseph Mack NA3T) Date: Mon, 6 Apr 2009 13:18:59 -0700 (PDT) Subject: [TriZPUG] filling lists In-Reply-To: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> References: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> Message-ID: On Mon, 6 Apr 2009, Chris Rossi wrote: > list_name[index] = element thanks well dang. I didn't see that in the methods and functions for lists. Joe -- Joseph Mack NA3T EME(B,D), FM05lw North Carolina jmack (at) wm7d (dot) net - azimuthal equidistant map generator at http://www.wm7d.net/azproj.shtml Homepage http://www.austintek.com/ It's GNU/Linux! From chris at christophermrossi.com Mon Apr 6 22:39:47 2009 From: chris at christophermrossi.com (Chris Rossi) Date: Mon, 6 Apr 2009 16:39:47 -0400 Subject: [TriZPUG] filling lists In-Reply-To: References: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> Message-ID: <60bf02c00904061339h6cd6024cva765672965a71289@mail.gmail.com> "Python Essential Reference" by David Beazley. It's easy to read and you will be enlightened. Chris On Mon, Apr 6, 2009 at 4:18 PM, Joseph Mack NA3T wrote: > On Mon, 6 Apr 2009, Chris Rossi wrote: > > list_name[index] = element >> > > thanks > > well dang. I didn't see that in the methods and functions for lists. > > > Joe > > -- > Joseph Mack NA3T EME(B,D), FM05lw North Carolina > jmack (at) wm7d (dot) net - azimuthal equidistant map > generator at http://www.wm7d.net/azproj.shtml > Homepage http://www.austintek.com/ It's GNU/Linux! > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmack at wm7d.net Tue Apr 7 00:35:04 2009 From: jmack at wm7d.net (Joseph Mack NA3T) Date: Mon, 6 Apr 2009 15:35:04 -0700 (PDT) Subject: [TriZPUG] filling lists In-Reply-To: <60bf02c00904061339h6cd6024cva765672965a71289@mail.gmail.com> References: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> <60bf02c00904061339h6cd6024cva765672965a71289@mail.gmail.com> Message-ID: On Mon, 6 Apr 2009, Chris Rossi wrote: > "Python Essential Reference" by David Beazley. It's easy > to read and you will be enlightened. thanks. Have just ordered it. After today's question, I see I need a better reference than google. Joe > > Chris > > > On Mon, Apr 6, 2009 at 4:18 PM, Joseph Mack NA3T wrote: > >> On Mon, 6 Apr 2009, Chris Rossi wrote: >> >> list_name[index] = element >>> >> >> thanks >> >> well dang. I didn't see that in the methods and functions for lists. >> >> >> Joe >> >> -- >> Joseph Mack NA3T EME(B,D), FM05lw North Carolina >> jmack (at) wm7d (dot) net - azimuthal equidistant map >> generator at http://www.wm7d.net/azproj.shtml >> Homepage http://www.austintek.com/ It's GNU/Linux! >> _______________________________________________ >> TriZPUG mailing list >> TriZPUG at python.org >> http://mail.python.org/mailman/listinfo/trizpug >> http://trizpug.org is the Triangle Zope and Python Users Group >> > -- Joseph Mack NA3T EME(B,D), FM05lw North Carolina jmack (at) wm7d (dot) net - azimuthal equidistant map generator at http://www.wm7d.net/azproj.shtml Homepage http://www.austintek.com/ It's GNU/Linux! From cbc at unc.edu Tue Apr 7 00:44:01 2009 From: cbc at unc.edu (Chris Calloway) Date: Mon, 06 Apr 2009 18:44:01 -0400 Subject: [TriZPUG] filling lists In-Reply-To: References: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> Message-ID: <49DA85B1.2060508@unc.edu> On 4/6/2009 4:18 PM, Joseph Mack NA3T wrote: > well dang. I didn't see that in the methods and functions for lists. It's an operator. The subscription operator. Which applies to sequences. On the left hand side of an assignment, it is only applicable to mutable sequences. http://docs.python.org/library/stdtypes.html#mutable-sequence-types You can use it on your two dimensional list like so: >>> twodlist = [[1,2,3],[3,4,5],[6,7,8]] >>> print twodlist[1][1] 4 >>> Note, multidimensional lists need not be orthogonal. That is, the "rows" do not need to be the same length. Because the "outer" list is also heterogeneous. Python doesn't care that each item is even a list, much less how long of a list. However, you are certainly free to make orthogonal multidimensional lists. Python doesn't care. It's flexible. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From cbc at unc.edu Tue Apr 7 00:44:54 2009 From: cbc at unc.edu (Chris Calloway) Date: Mon, 06 Apr 2009 18:44:54 -0400 Subject: [TriZPUG] filling lists In-Reply-To: References: Message-ID: <49DA85E6.9040207@unc.edu> On 4/6/2009 3:49 PM, Joseph Mack NA3T wrote: > I'm using a list to hold a 2-D array of pixels, since AFAIK there are no > arrays in python. Python has arrays. If you want to constrain to a homogenous array, import the array module from the Standard Library: http://docs.python.org/library/array.html Arrays are sequences and support all the ordinary sequence operations between arrays of like typed items. Lists are semantic supersets of arrays. Array denotes a container holding items of homogeneous type. Lists are heterogeneous. However, you are certainly free to make singly-typed lists. Python doesn't care. It's flexible. Because of lists, arrays are largely unnecessary. Where arrays are useful is as an object which supports the buffer protocol. The buffer protocol provides for data which is contiguous in memory. The buffer protocol allows Python objects to be manipulated directly in place by C extensions. (Note: the buffer protocol used to be called the array protocol.) The values of list items are definitely not contiguous in memory. The values array items are. However, arrays implemented in the array module are singly dimensional. Notice there is no array typecode for array. Thus there are no arrays of arrays. (You could have lists of arrays, though. :) But, the third party Numpy module implements another object also called "array" which supports the buffer protocol and is multidimensional. Numpy arrays are typed. Multidimensional Numpy arrays are also orthogonal. In a curious turn, arrays from the array module can be used to instantiate Numpy arrays. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From cbc at unc.edu Tue Apr 7 00:49:19 2009 From: cbc at unc.edu (Chris Calloway) Date: Mon, 06 Apr 2009 18:49:19 -0400 Subject: [TriZPUG] PyCon Video is Rockin' Message-ID: <49DA86EF.6040601@unc.edu> http://pycon.blip.tv This year PyCon hired a pro video company which brought in a quality pipeline process and trained a whole bunch of volunteers. So we got the best of pro company and community process. The result is great. The presentations are piped directly into the video and the presenter appears in a small frame on top. Perfect. Best Pycon video ever. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From bgailer at gmail.com Tue Apr 7 00:59:45 2009 From: bgailer at gmail.com (bob gailer) Date: Mon, 06 Apr 2009 18:59:45 -0400 Subject: [TriZPUG] filling lists In-Reply-To: <49DA85B1.2060508@unc.edu> References: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> <49DA85B1.2060508@unc.edu> Message-ID: <49DA8961.1070702@gmail.com> An HTML attachment was scrubbed... URL: From jwhisnant at gmail.com Tue Apr 7 16:53:18 2009 From: jwhisnant at gmail.com (James Whisnant) Date: Tue, 7 Apr 2009 14:53:18 +0000 Subject: [TriZPUG] filling lists In-Reply-To: <49DA8961.1070702@gmail.com> References: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> <49DA85B1.2060508@unc.edu> <49DA8961.1070702@gmail.com> Message-ID: <1be257cf0904070753w562eb2cah5bbc891259b9386e@mail.gmail.com> If you are working with images or pixel data, you might want to look at the Python Imaging Library. http://www.pythonware.com/products/pil/ On Mon, Apr 6, 2009 at 10:59 PM, bob gailer wrote: > Chris Calloway wrote: > > On 4/6/2009 4:18 PM, Joseph Mack NA3T wrote: > > well dang. I didn't see that in the methods and functions for lists. > > > It's an operator. The subscription operator. Which applies to sequences. > > > On the left hand side of an assignment, it is only applicable to mutable > sequences. > > > Not only. > > "If the target is a subscription: The primary expression in the reference > is evaluated. It should yield either a mutable sequence object (such as a > list) or a mapping object (such as a dictionary)." > > And even though it does NOT say so, any object with a __setitem__ magic > method. "Called to implement assignment to self[key]. " > > [snip] > > -- > Bob Gailer > Chapel Hill NC > 919-636-4239 > > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cbc at unc.edu Tue Apr 7 20:55:13 2009 From: cbc at unc.edu (Chris Calloway) Date: Tue, 07 Apr 2009 14:55:13 -0400 Subject: [TriZPUG] filling lists In-Reply-To: <49DA8961.1070702@gmail.com> References: <60bf02c00904061301s4929f482g5c8502242917fcc@mail.gmail.com> <49DA85B1.2060508@unc.edu> <49DA8961.1070702@gmail.com> Message-ID: <49DBA191.9090901@unc.edu> On 4/6/2009 6:59 PM, bob gailer wrote: > Chris Calloway wrote: >> On 4/6/2009 4:18 PM, Joseph Mack NA3T wrote: >>> well dang. I didn't see that in the methods and functions for lists. >> >> It's an operator. The subscription operator. Which applies to sequences. >> >> On the left hand side of an assignment, it is only applicable to mutable sequences. > > Not only. Sorry, I should have added, "if the left hand object is a sequence" to be clear. > "If the target is a subscription: The primary expression in the reference is evaluated. It should yield either a mutable sequence object (such as a list) or a mapping object (such as a dictionary)." > > And even though it does NOT say so, any object with a __setitem__ magic method. "Called to implement assignment to |self[key]|. " Correct. The signature for __setitem__ is object.__setitem__(self, key, value): http://docs.python.org/reference/datamodel.html?highlight=setitem#object.__setitem__ And that is what backs up: object[key] = value for mapping (e.g., dictionary) and mutable sequence objects. I was trying to distinguish the subscription operator on the left hand side of a assignment statement for a mutable sequence from the subscription operator's use in an expression, which invokes the __getitem__ magic method for both mappings and *all* sequences, both mutable and immutable: http://docs.python.org/reference/datamodel.html?highlight=setitem#object.__getitem__ That is: identifier = object[key] invokes: indentifer = object.__getitem__(key) under the covers (and anywhere object[key] is used as an expression, not just on the right hand of an assigment statement). Joseph, by convention we don't call __setitem__ or __getitem__ directly. We use the corresponding operator and Python calls the method for us using the method signature. __setitem__ and __getitem__ are a "magic" methods that may be overridden for subclasses of list and dict in order to customize how the subscription operator works for instances of those subclasses. There are "magic" methods for most (all?) operators. + invokes __add__. * invokes __mul__. And so on: http://docs.python.org/reference/datamodel.html#special-method-names This is how Python implements the object-oriented principle of operator overloading: http://en.wikipedia.org/wiki/Operator_overloading There is also an operator module in the Python Standard Library which makes these magic methods explicitly callable for those who have special functional programming needs: http://docs.python.org/library/operator.html At the bottom that page is a convenient chart mapping operators to functions. Second the recommendation for PIL to deal with pixel data. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From jeremyfoshee at gmail.com Tue Apr 14 22:19:51 2009 From: jeremyfoshee at gmail.com (Jeremy Foshee) Date: Tue, 14 Apr 2009 16:19:51 -0400 Subject: [TriZPUG] Ubuntu Jaunty Jackalope release party Message-ID: <7b0e81490904141319qdf7e15yfe0afd8f55087cb6@mail.gmail.com> Folks, My apologies for the relatively short notice on this. I know that some of you may use Ubuntu, so I wanted to make this information available to you. Below are the details from the Organizer. I can answer any questions you may have about the party, but please RSVP if you plan to attend: What: Jaunty Jackalope Release Party Where: Flying Saucer http://www.beerknurd.com/stores/raleigh 328 West Morgan Street at Harrington Raleigh, NC 27601 919-821-PINT (7468) When: Thursday, April 23, 2009 Time: 6-9pm (however was told we could stay until) Please RSVP to akgraner[at]gmail[dot]com so she can let the Saucer know if they need rope off more space or not. Thanks everyone and if you're in the area and can make it please do! Hope to see you there...:) -Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.crittenden at gmail.com Tue Apr 14 22:32:32 2009 From: brad.crittenden at gmail.com (Bradley A. Crittenden) Date: Tue, 14 Apr 2009 16:32:32 -0400 Subject: [TriZPUG] Ubuntu Jaunty Jackalope release party In-Reply-To: <7b0e81490904141319qdf7e15yfe0afd8f55087cb6@mail.gmail.com> References: <7b0e81490904141319qdf7e15yfe0afd8f55087cb6@mail.gmail.com> Message-ID: <23ACF7BE-0AEA-45AA-AEA0-05EF9E1A0336@gmail.com> On Apr 14, 2009, at 16:19 , Jeremy Foshee wrote: > Folks, > My apologies for the relatively short notice on this. I know > that some of you may use Ubuntu, so I wanted to make this > information available to you. Below are the details from the > Organizer. I can answer any questions you may have about the party, > but please RSVP if you plan to attend: Unfortunately this release party clashes with the next meeting of TriZPUG. Anyone want to carpool to Raleigh after our meeting? --bac > > What: Jaunty Jackalope Release Party > > Where: Flying Saucer http://www.beerknurd.com/stores/raleigh > 328 West Morgan Street at Harrington > Raleigh, NC 27601 > 919-821-PINT (7468) > > When: Thursday, April 23, 2009 > Time: 6-9pm (however was told we could stay until) > > Please RSVP to akgraner[at]gmail[dot]com so she can let the Saucer > know if they need rope off more space or not. > > Thanks everyone and if you're in the area and can make it please do! > Hope to see you there...:) > > -Jeremy > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group From philip at semanchuk.com Wed Apr 15 15:20:06 2009 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 15 Apr 2009 09:20:06 -0400 Subject: [TriZPUG] Python classes? Message-ID: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> Hi all, I have a friend who has some "use it or lose it" training funds available to him and is looking to spend it on some Python education. Is there anything available in the area? Thanks Philip From cbc at unc.edu Wed Apr 15 18:24:54 2009 From: cbc at unc.edu (Chris Calloway) Date: Wed, 15 Apr 2009 12:24:54 -0400 Subject: [TriZPUG] Python classes? In-Reply-To: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> References: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> Message-ID: <49E60A56.7090900@unc.edu> On 4/15/2009 9:20 AM, Philip Semanchuk wrote: > I have a friend who has some "use it or lose it" training funds > available to him and is looking to spend it on some Python education. Is > there anything available in the area? FYI... The listing below is in Morrisville. I don't know anything about this guy. He just appeared a few months ago and appropriated the name "Python Bootcamp." He has not made any attempt to engage with TriZPUG and is not a member of our email list. This is for your information and is not an endorsement of the offering. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 -------- Original Message -------- Subject: Upcoming Python Bootcamps - May, June, and July 2009 Date: Mon, 06 Apr 2009 17:54:32 -0400 From: Chander Ganesan Reply-To: python-list at python.org To: python-announce at python.org The Open Technology Group is pleased to announce three Upcoming Python Bootcamp's, scheduled : May 11-15, 2009 July 20-24, 2009 July 27-31, 2009 For complete course outline/syllabus, or to enroll, call us at 877-258-8987 or visit our web site at: http://www.otg-nc.com/python-bootcamp OTG's Python Bootcamp is a 5 day intensive course that teaches programmers how to design, develop, and debug applications using the Python programming language. Over a 5 day period, through a set of lectures, demonstrations, and hands-on exercises students will learn how to develop powerful applications using Python and integrate their new found Python skills in their day-to-day job activities. Students will also learn how to utilize Python's Database API to interface with relational databases. This Python course is available for on-site delivery world-wide (we bring the class to you) for a group as small as 3, for as little as $8,000 (including instructor travel & per-diem)! Our course is guaranteed to run, regardless of enrollment, and available in an "all inclusive" package that includes round-trip airfare, 5 nights of hotel accommodation, shuttle services (to/from the airport, to/from our facility, and to/from local eateries/shopping), and our training. All-inclusive packages are priced at $2,495 for the 5 day course (course only is $2,295). For more information - or to schedule an on-site course, please contact us at 877-258-8987 . The Open Technology Group is the world leader in the development and delivery of training solutions focused around Open Source technologies. -- Chander Ganesan Open Technology Group, Inc. One Copley Parkway, Suite 210 Morrisville, NC 27560 919-463-0999/877-258-8987 http://www.otg-nc.com From philip at semanchuk.com Wed Apr 15 18:29:41 2009 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 15 Apr 2009 12:29:41 -0400 Subject: [TriZPUG] Python classes? In-Reply-To: <49E60A56.7090900@unc.edu> References: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> <49E60A56.7090900@unc.edu> Message-ID: <9168DA7A-3B20-48CD-AC5E-733BF4661EAB@semanchuk.com> On Apr 15, 2009, at 12:24 PM, Chris Calloway wrote: > On 4/15/2009 9:20 AM, Philip Semanchuk wrote: >> I have a friend who has some "use it or lose it" training funds >> available to him and is looking to spend it on some Python >> education. Is there anything available in the area? > > FYI... The listing below is in Morrisville. I don't know anything > about this guy. He just appeared a few months ago and appropriated > the name "Python Bootcamp." He has not made any attempt to engage > with TriZPUG and is not a member of our email list. > > This is for your information and is not an endorsement of the > offering. All clear. THanks for the tip. > -------- Original Message -------- > Subject: Upcoming Python Bootcamps - May, June, and July 2009 > Date: Mon, 06 Apr 2009 17:54:32 -0400 > From: Chander Ganesan > Reply-To: python-list at python.org > To: python-announce at python.org > > The Open Technology Group is pleased to announce three Upcoming Python > Bootcamp's, scheduled : > > May 11-15, 2009 > July 20-24, 2009 > July 27-31, 2009 > > For complete course outline/syllabus, or to enroll, call us at > 877-258-8987 or visit our web site at: > http://www.otg-nc.com/python-bootcamp > > OTG's Python Bootcamp is a 5 day intensive course that teaches > programmers how to design, develop, and debug applications using the > Python programming language. Over a 5 day period, through a set of > lectures, demonstrations, and hands-on exercises students will learn > how > to develop powerful applications using Python and integrate their new > found Python skills in their day-to-day job activities. Students will > also learn how to utilize Python's Database API to interface with > relational databases. > > This Python course is available for on-site delivery world-wide (we > bring the class to you) for a group as small as 3, for as little as > $8,000 (including instructor travel & per-diem)! > > Our course is guaranteed to run, regardless of enrollment, and > available > in an "all inclusive" package that includes round-trip airfare, 5 > nights > of hotel accommodation, shuttle services (to/from the airport, to/from > our facility, and to/from local eateries/shopping), and our training. > All-inclusive packages are priced at $2,495 for the 5 day course > (course > only is $2,295). > > For more information - or to schedule an on-site course, please > contact > us at 877-258-8987 . > > The Open Technology Group is the world leader in the development and > delivery of training solutions focused around Open Source > technologies. > > -- > Chander Ganesan > Open Technology Group, Inc. > One Copley Parkway, Suite 210 > Morrisville, NC 27560 > 919-463-0999/877-258-8987 > http://www.otg-nc.com > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group From jmack at wm7d.net Wed Apr 15 20:55:25 2009 From: jmack at wm7d.net (Joseph Mack NA3T) Date: Wed, 15 Apr 2009 11:55:25 -0700 (PDT) Subject: [TriZPUG] Python classes? In-Reply-To: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> References: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> Message-ID: On Wed, 15 Apr 2009, Philip Semanchuk wrote: > Hi all, > I have a friend who has some "use it or lose it" training > funds available to him and is looking to spend it on some > Python education. Is there anything available in the area? Not exactly what you asked for, but once a week I teach a course on programming for Middle School kids, using python as the teaching language (the emphasis is on learning programming, rather than python). The notes are at http://www.austintek.com/python_class/index.html and it's free (you read the notes and do the exercises). David Handy, also on this list, has a book on teaching python to young people. http://www.handysoftware.com/cpif/ Joe -- Joseph Mack NA3T EME(B,D), FM05lw North Carolina jmack (at) wm7d (dot) net - azimuthal equidistant map generator at http://www.wm7d.net/azproj.shtml Homepage http://www.austintek.com/ It's GNU/Linux! From eric.leary at gmail.com Wed Apr 15 23:02:23 2009 From: eric.leary at gmail.com (Eric Leary) Date: Wed, 15 Apr 2009 17:02:23 -0400 Subject: [TriZPUG] Python classes? In-Reply-To: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> References: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> Message-ID: <3d9738190904151402w68fb206ds53e709358ebaf623@mail.gmail.com> I have waited quietly for someone better qualified than me to mention it, and I can't be still any longer. The Python Bootcamp that I attended last summer at UNC Chapel Hill was taught by Chris Calloway, who has very modestly referred you to someone else in the Triangle. I can say without reservation that the BEST Bootcamp for Python is taught by Chris, in affiliation with TRIZPUG! If he can be cajoled into offereing his bootcamp within the time-frame of your friend's funding cycle, that is the definitive training to receive in Python in the "give me 50 regular expressions NOW soldier" variety. Which is not to say that he is tough, but you will come out of the Bootcamp swinging some Python. He is a gifted instructor who has taught this material many times, so that his approach is refined and efficient. Just wanted to assert my two cents. Hope your friend finds what he is looking for. On Wed, Apr 15, 2009 at 9:20 AM, Philip Semanchuk wrote: > Hi all, > I have a friend who has some "use it or lose it" training funds available to > him and is looking to spend it on some Python education. Is there anything > available in the area? > > Thanks > Philip > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group > From philip at semanchuk.com Wed Apr 15 23:14:49 2009 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 15 Apr 2009 17:14:49 -0400 Subject: [TriZPUG] Python classes? In-Reply-To: <3d9738190904151402w68fb206ds53e709358ebaf623@mail.gmail.com> References: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> <3d9738190904151402w68fb206ds53e709358ebaf623@mail.gmail.com> Message-ID: <9C3CA3C5-4CE2-451A-917C-DF298AFCFA49@semanchuk.com> Thanks, Eric. Opinions are exactly what I'm looking for and my friend has been duly notified of your suggestion. On Apr 15, 2009, at 5:02 PM, Eric Leary wrote: > I have waited quietly for someone better qualified than me to mention > it, and I can't be still any longer. > > The Python Bootcamp that I attended last summer at UNC Chapel Hill was > taught by Chris Calloway, who has very modestly referred you to > someone else in the Triangle. > > I can say without reservation that the BEST Bootcamp for Python is > taught by Chris, in affiliation with TRIZPUG! If he can be cajoled > into offereing his bootcamp within the time-frame of your friend's > funding cycle, that is the definitive training to receive in Python in > the "give me 50 regular expressions NOW soldier" variety. > > Which is not to say that he is tough, but you will come out of the > Bootcamp swinging some Python. > > He is a gifted instructor who has taught this material many times, so > that his approach is refined and efficient. > > Just wanted to assert my two cents. > > Hope your friend finds what he is looking for. > > On Wed, Apr 15, 2009 at 9:20 AM, Philip Semanchuk > wrote: >> Hi all, >> I have a friend who has some "use it or lose it" training funds >> available to >> him and is looking to spend it on some Python education. Is there >> anything >> available in the area? >> >> Thanks >> Philip >> _______________________________________________ >> TriZPUG mailing list >> TriZPUG at python.org >> http://mail.python.org/mailman/listinfo/trizpug >> http://trizpug.org is the Triangle Zope and Python Users Group >> > _______________________________________________ > TriZPUG mailing list > TriZPUG at python.org > http://mail.python.org/mailman/listinfo/trizpug > http://trizpug.org is the Triangle Zope and Python Users Group From jmack at wm7d.net Wed Apr 15 23:16:21 2009 From: jmack at wm7d.net (Joseph Mack NA3T) Date: Wed, 15 Apr 2009 14:16:21 -0700 (PDT) Subject: [TriZPUG] Python classes? In-Reply-To: <3d9738190904151402w68fb206ds53e709358ebaf623@mail.gmail.com> References: <0CD59B81-3E4E-4269-A5E8-EA56AACC4010@semanchuk.com> <3d9738190904151402w68fb206ds53e709358ebaf623@mail.gmail.com> Message-ID: On Wed, 15 Apr 2009, Eric Leary wrote: > I can say without reservation that the BEST Bootcamp for Python is > taught by Chris, . > He is a gifted instructor who has taught this material many times, so > that his approach is refined and efficient. I don't know if the OP is a regular reader of this list, so I didn't say anything... but Chris is a very helpful person. If you want to learn any python, Chris is best person to get it from. Joe -- Joseph Mack NA3T EME(B,D), FM05lw North Carolina jmack (at) wm7d (dot) net - azimuthal equidistant map generator at http://www.wm7d.net/azproj.shtml Homepage http://www.austintek.com/ It's GNU/Linux! From cbc at unc.edu Tue Apr 21 22:36:32 2009 From: cbc at unc.edu (Chris Calloway) Date: Tue, 21 Apr 2009 16:36:32 -0400 Subject: [TriZPUG] Meeting this week and new Python books Message-ID: <49EE2E50.50207@unc.edu> Don't forget Chris Rossi is going to present on WSGI at this week's meeting in Carrboro: http://trizpug.org/Members/cbc/apr-09-mtg/ Here are some new Python books: http://oreilly.com/catalog/9781934356272/ http://oreilly.com/catalog/9781593271923/ You can get 35% off on these books by following the instructions on the front page of the TriZPUG website. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From cbc at unc.edu Fri Apr 24 20:36:55 2009 From: cbc at unc.edu (Chris Calloway) Date: Fri, 24 Apr 2009 14:36:55 -0400 Subject: [TriZPUG] Last night's meeting Message-ID: <49F206C7.3040101@unc.edu> We had a great meeting last night. The first to ever overflow the room. And even better was Chris Rossi's WSGI presentation, which is now here: http://archimedeanco.com/wsgi-tutorial/ Thanks, Chris, for a very informative presentation. And thanks to Brad Crittenden for hosting us at Carrboro Creative Coworking. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From cbc at unc.edu Sat Apr 25 00:51:48 2009 From: cbc at unc.edu (Chris Calloway) Date: Fri, 24 Apr 2009 18:51:48 -0400 Subject: [TriZPUG] 2009 TriZPUG Plone Boot Camps Message-ID: <49F24284.5050005@unc.edu> See all about our fifth anniversary (!!!) training programs: http://trizpug.org/boot-camp/pbc5/ We're bringing Joel Burton and plonebootcamps.com back for two more fun-filled weeks of Plone learning. Thanks to Rob Lineberger of the Carolina Cardiovascular Biology Center for heading up this year's TriZPUG Plone Boot Camps effort. If you came to the inaugural World Plone Day event last fall, then you've seen the new classroom for this year's Plone Boot Camps and the positively gigantic projection screen for the classroom presentations. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From jmack at wm7d.net Sat Apr 25 02:20:16 2009 From: jmack at wm7d.net (Joseph Mack NA3T) Date: Fri, 24 Apr 2009 17:20:16 -0700 (PDT) Subject: [TriZPUG] PIL draw.ellipse bounding box problem solved Message-ID: the draw.ellipse function has the syntax #(x0,y0) and (x1,y1) are corners of bbox ellipse_bbox=(x0,y0,x1,y1) draw.ellipse(ellipse_bbox,fill=color) I've just spent the last hour or so trying to get this to output a circle. My values of the bbox happened to be top-left and bottom_right. You get no output. The bbox corners have to be lower left and top right. Joe -- Joseph Mack NA3T EME(B,D), FM05lw North Carolina jmack (at) wm7d (dot) net - azimuthal equidistant map generator at http://www.wm7d.net/azproj.shtml Homepage http://www.austintek.com/ It's GNU/Linux! From cbc at unc.edu Tue Apr 28 21:24:32 2009 From: cbc at unc.edu (Chris Calloway) Date: Tue, 28 Apr 2009 15:24:32 -0400 Subject: [TriZPUG] PIL draw.ellipse bounding box problem solved In-Reply-To: References: Message-ID: <49F757F0.2050702@unc.edu> On 4/24/2009 8:20 PM, Joseph Mack NA3T wrote: > the draw.ellipse function has the syntax > > #(x0,y0) and (x1,y1) are corners of bbox > ellipse_bbox=(x0,y0,x1,y1) > > draw.ellipse(ellipse_bbox,fill=color) > > I've just spent the last hour or so trying to get this to output a > circle. My values of the bbox happened to be top-left and bottom_right. > You get no output. The bbox corners have to be lower left and top right. Sorry, I didn't see this until today. I ran the following on Winders, virgin Python 2.6, and PIL 1.1.6 with no problem and the output I'd expect: import os import Image, ImageDraw os.chdir('\Documents and Settings\cbcoasis\Desktop') im = Image.new('RGB',(256,256)) draw = ImageDraw.Draw(im) draw.ellipse((0,0,256,256),outline=(0,255,0),fill=(0,0,255)) del draw # write to stdout im.save('pilthing.png', "PNG") You may be interested in this: http://stackoverflow.com/questions/326300/python-best-library-for-drawing You really may be interested in this super low barrier to entry package which was the subject of our March meeting, although it is 3D: http://vpython.org -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From cbc at unc.edu Tue Apr 28 22:45:05 2009 From: cbc at unc.edu (Chris Calloway) Date: Tue, 28 Apr 2009 16:45:05 -0400 Subject: [TriZPUG] May Meeting Call for Speakers Message-ID: <49F76AD1.7010705@unc.edu> Hey Kids! Thanks to Alex Ray, the next TriZPUG meeting will return to our birthplace, NCSU's Centennial Campus, this time in Room 2015 of Engineering Building I: http://trizpug.org/Members/cbc/may-09-mtg/ We'll be meeting on the 3rd Thursday (*May 21*) instead of the 4th Thursday in May because of the Plone Symposium East in the fourth week. However, May 21 is still four weeks after our April 23 meeting. Funny how that works. If you'd like to present at this meeting, please sound off here on this email list. As always, though, each of you is expected to be ready with a lightning talk if called on. You should be able to talk for five minutes about something Python-related you learned or heard of in the last month or so. No topic is too trivial as a lightning talk is supposed to be easy, something you can do without preparation maybe even. Here's how to get to Centennial Campus: http://centennial.ncsu.edu/contact/directions.html Here's how to find Engineering Building I on Centennial Campus: http://www.ncsu.edu/campus_map/centennial.htm Parking is diagonally across the street in the Red Hat Deck, just like for TriLUG meetings. Alex, will we be able to get in the building at 7pm? When we met on Centennial Campus before we had to have a phone number posted on the door and somebody ran downstairs to let people in. Alex, will there be a laptop projector and/or internet available? For the after-meeting, I would like to suggest we go to one of Raleigh's finest institutions which is not too far away, The Player's Retreat (The PR) near the corner of Oberlin and Hillsborough. Parking is across the street in the bank lot: http://www.playersretreat.net/ Here are the simple directions for the 1.9 mile jaunt from Engineering Building I to The PR. I suggest maybe you print them out if you don't know Raleigh: http://tinyurl.com/cugja4 -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From alexjray.ncsu at gmail.com Tue Apr 28 23:20:37 2009 From: alexjray.ncsu at gmail.com (Alexander Ray) Date: Tue, 28 Apr 2009 17:20:37 -0400 Subject: [TriZPUG] May Meeting Call for Speakers In-Reply-To: <49F76AD1.7010705@unc.edu> References: <49F76AD1.7010705@unc.edu> Message-ID: On Tue, Apr 28, 2009 at 4:45 PM, Chris Calloway wrote: > Hey Kids! > > Thanks to Alex Ray, the next TriZPUG meeting will return to our birthplace, > NCSU's Centennial Campus, this time in Room 2015 of Engineering Building I: > > Alex, will we be able to get in the building at 7pm? When we met on > Centennial Campus before we had to have a phone number posted on the door > and somebody ran downstairs to let people in. That sounds like a plan. To be honest I don't know if the locking schedule changes for the summer, but theres a way to get into the building (now) at 7 pm (that's how we had our meetings). If the case is they close down at 5 over the summer then that works. I'll let you know when I found out the summer locking schedule. > Alex, will there be a laptop projector and/or internet available? Yes! and me and several others in the LUG have experience with them (the A/V setup), so we should be fine with that. Everything looks good to me! ~Alex Ray From jj at email.unc.edu Tue Apr 28 23:26:00 2009 From: jj at email.unc.edu (jj at email.unc.edu) Date: Tue, 28 Apr 2009 17:26:00 -0400 Subject: [TriZPUG] May Meeting Call for Speakers Message-ID: <20090428212707.008B21E401C@bag.python.org> I'd like to volunteer to give my plone symposium talk if there's interest. It was supposed to be an 'ArchGenXML sucks' talk to advocate the use of ZopeSkel for content type generation but I think it will be more of a retrospectuve of the many ways to create content types and why they all suck :P jj -----Original Message----- From: Chris Calloway Subj: [TriZPUG] May Meeting Call for Speakers Date: Tue Apr 28, 2009 4:45 pm Size: 2K To: "Triangle (North Carolina) Zope and Python Users Group" Hey Kids! Thanks to Alex Ray, the next TriZPUG meeting will return to our birthplace, NCSU's Centennial Campus, this time in Room 2015 of Engineering Building I: http://trizpug.org/Members/cbc/may-09-mtg/ We'll be meeting on the 3rd Thursday (*May 21*) instead of the 4th Thursday in May because of the Plone Symposium East in the fourth week. However, May 21 is still four weeks after our April 23 meeting. Funny how that works. If you'd like to present at this meeting, please sound off here on this email list. As always, though, each of you is expected to be ready with a lightning talk if called on. You should be able to talk for five minutes about something Python-related you learned or heard of in the last month or so. No topic is too trivial as a lightning talk is supposed to be easy, something you can do without preparation maybe even. Here's how to get to Centennial Campus: http://centennial.ncsu.edu/contact/directions.html Here's how to find Engineering Building I on Centennial Campus: http://www.ncsu.edu/campus_map/centennial.htm Parking is diagonally across the street in the Red Hat Deck, just like for TriLUG meetings. Alex, will we be able to get in the building at 7pm? When we met on Centennial Campus before we had to have a phone number posted on the door and somebody ran downstairs to let people in. Alex, will there be a laptop projector and/or internet available? For the after-meeting, I would like to suggest we go to one of Raleigh's finest institutions which is not too far away, The Player's Retreat (The PR) near the corner of Oberlin and Hillsborough. Parking is across the street in the bank lot: http://www.playersretreat.net/ Here are the simple directions for the 1.9 mile jaunt from Engineering Building I to The PR. I suggest maybe you print them out if you don't know Raleigh: http://tinyurl.com/cugja4 -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 _______________________________________________ TriZPUG mailing list TriZPUG at python.org http://mail.python.org/mailman/listinfo/trizpug http://trizpug.org is the Triangle Zope and Python Users Group --- message truncated --- From jj at email.unc.edu Tue Apr 28 23:26:00 2009 From: jj at email.unc.edu (jj at email.unc.edu) Date: Tue, 28 Apr 2009 17:26:00 -0400 Subject: [TriZPUG] May Meeting Call for Speakers Message-ID: <20090428212706.F0E5A1E401B@bag.python.org> I'd like to volunteer to give my plone symposium talk if there's interest. It was supposed to be an 'ArchGenXML sucks' talk to advocate the use of ZopeSkel for content type generation but I think it will be more of a retrospectuve of the many ways to create content types and why they all suck :P jj -----Original Message----- From: Chris Calloway Subj: [TriZPUG] May Meeting Call for Speakers Date: Tue Apr 28, 2009 4:45 pm Size: 2K To: "Triangle (North Carolina) Zope and Python Users Group" Hey Kids! Thanks to Alex Ray, the next TriZPUG meeting will return to our birthplace, NCSU's Centennial Campus, this time in Room 2015 of Engineering Building I: http://trizpug.org/Members/cbc/may-09-mtg/ We'll be meeting on the 3rd Thursday (*May 21*) instead of the 4th Thursday in May because of the Plone Symposium East in the fourth week. However, May 21 is still four weeks after our April 23 meeting. Funny how that works. If you'd like to present at this meeting, please sound off here on this email list. As always, though, each of you is expected to be ready with a lightning talk if called on. You should be able to talk for five minutes about something Python-related you learned or heard of in the last month or so. No topic is too trivial as a lightning talk is supposed to be easy, something you can do without preparation maybe even. Here's how to get to Centennial Campus: http://centennial.ncsu.edu/contact/directions.html Here's how to find Engineering Building I on Centennial Campus: http://www.ncsu.edu/campus_map/centennial.htm Parking is diagonally across the street in the Red Hat Deck, just like for TriLUG meetings. Alex, will we be able to get in the building at 7pm? When we met on Centennial Campus before we had to have a phone number posted on the door and somebody ran downstairs to let people in. Alex, will there be a laptop projector and/or internet available? For the after-meeting, I would like to suggest we go to one of Raleigh's finest institutions which is not too far away, The Player's Retreat (The PR) near the corner of Oberlin and Hillsborough. Parking is across the street in the bank lot: http://www.playersretreat.net/ Here are the simple directions for the 1.9 mile jaunt from Engineering Building I to The PR. I suggest maybe you print them out if you don't know Raleigh: http://tinyurl.com/cugja4 -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 _______________________________________________ TriZPUG mailing list TriZPUG at python.org http://mail.python.org/mailman/listinfo/trizpug http://trizpug.org is the Triangle Zope and Python Users Group --- message truncated --- From bgailer at gmail.com Wed Apr 29 00:04:23 2009 From: bgailer at gmail.com (bob gailer) Date: Tue, 28 Apr 2009 18:04:23 -0400 Subject: [TriZPUG] May Meeting Call for Speakers In-Reply-To: <49F76AD1.7010705@unc.edu> References: <49F76AD1.7010705@unc.edu> Message-ID: <49F77D67.6050501@gmail.com> Chris Calloway wrote: > As always, though, each of you is expected to be ready with a > lightning talk if called on. I am concerned about this, as I can see such an expectation discouraging some newcomer. -- Bob Gailer Chapel Hill NC 919-636-4239 From cbc at unc.edu Wed Apr 29 00:04:14 2009 From: cbc at unc.edu (Chris Calloway) Date: Tue, 28 Apr 2009 18:04:14 -0400 Subject: [TriZPUG] May Meeting Call for Speakers In-Reply-To: <200904282127.n3SLR4AB023603@smtpsrv0.isis.unc.edu> References: <200904282127.n3SLR4AB023603@smtpsrv0.isis.unc.edu> Message-ID: <49F77D5E.4060706@unc.edu> On 4/28/2009 5:26 PM, jj at email.unc.edu wrote: > I'd like to volunteer to give my plone symposium talk if there's interest. It was supposed to be an 'ArchGenXML sucks' talk to advocate the use of ZopeSkel for content type generation but I think it will be more of a retrospectuve of the many ways to create content types and why they all suck :P Big interest here! Plus, I think we'd like to help you polish your talk for the Symposium. The meeting announcement has been updated with your offer: http://trizpug.org/Members/cbc/may-09-mtg/ Any other speaker proposals for May? Lightning talks. Have yours ready. If you don't give it at the meeting, you can give it at the after-meeting. :) Also, when writing the email list, please use your subscribed address so that list moderators don't have to approve your post. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From brad.crittenden at gmail.com Wed Apr 29 02:23:19 2009 From: brad.crittenden at gmail.com (Bradley A. Crittenden) Date: Tue, 28 Apr 2009 20:23:19 -0400 Subject: [TriZPUG] May Meeting Call for Speakers In-Reply-To: <49F77D67.6050501@gmail.com> References: <49F76AD1.7010705@unc.edu> <49F77D67.6050501@gmail.com> Message-ID: <0B051FFD-7304-4D3A-A1D3-5ABD8333BD70@gmail.com> On Apr 28, 2009, at 18:04 , bob gailer wrote: > Chris Calloway wrote: >> As always, though, each of you is expected to be ready with a >> lightning talk if called on. > > I am concerned about this, as I can see such an expectation > discouraging some newcomer. That's just Chris being all blustery. No newcomer should be scared to come to a meeting. --bac From chris at christophermrossi.com Wed Apr 29 03:31:45 2009 From: chris at christophermrossi.com (Chris Rossi) Date: Tue, 28 Apr 2009 21:31:45 -0400 Subject: [TriZPUG] May Meeting Call for Speakers In-Reply-To: <0B051FFD-7304-4D3A-A1D3-5ABD8333BD70@gmail.com> References: <49F76AD1.7010705@unc.edu> <49F77D67.6050501@gmail.com> <0B051FFD-7304-4D3A-A1D3-5ABD8333BD70@gmail.com> Message-ID: <60bf02c00904281831u56f8d590i5dcdcbb6ecaa6025@mail.gmail.com> On Tue, Apr 28, 2009 at 8:23 PM, Bradley A. Crittenden < brad.crittenden at gmail.com> wrote: > > On Apr 28, 2009, at 18:04 , bob gailer wrote: > > Chris Calloway wrote: >> >>> As always, though, each of you is expected to be ready with a lightning >>> talk if called on. >>> >> >> I am concerned about this, as I can see such an expectation discouraging >> some newcomer. >> > > That's just Chris being all blustery. No newcomer should be scared to come > to a meeting. > > Maybe we should offer treats for those who do give lightning talks? Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From cbc at unc.edu Wed Apr 29 21:01:26 2009 From: cbc at unc.edu (Chris Calloway) Date: Wed, 29 Apr 2009 15:01:26 -0400 Subject: [TriZPUG] May Meeting Call for Speakers In-Reply-To: <60bf02c00904281831u56f8d590i5dcdcbb6ecaa6025@mail.gmail.com> References: <49F76AD1.7010705@unc.edu> <49F77D67.6050501@gmail.com> <0B051FFD-7304-4D3A-A1D3-5ABD8333BD70@gmail.com> <60bf02c00904281831u56f8d590i5dcdcbb6ecaa6025@mail.gmail.com> Message-ID: <49F8A406.40709@unc.edu> On 4/28/2009 9:31 PM, Chris Rossi wrote: > On Tue, Apr 28, 2009 at 8:23 PM, Bradley A. Crittenden < > brad.crittenden at gmail.com> wrote: > >> On Apr 28, 2009, at 18:04 , bob gailer wrote: >> >> Chris Calloway wrote: >>>> As always, though, each of you is expected to be ready with a lightning >>>> talk if called on. >>>> >>> I am concerned about this, as I can see such an expectation discouraging >>> some newcomer. >>> >> That's just Chris being all blustery. No newcomer should be scared to come >> to a meeting. >> >> > Maybe we should offer treats for those who do give lightning talks? Maybe. I've seen prizes given to best lightning talk at PyCons. It would be nice to have enough lightning talks to have a vote on the best. I'll try to have a prize in reserve just in case we do. I had to look up blustery. I'm pretty sure we've only bullied newcomers into telling us who they are, and that bullying amounted to, "Please sound off around the room and tell us who you are." And I'm pretty sure no one has ever been bullied for not bringing a lightning talk. When it comes to lightning talks, we usually ask if anyone's got one. Sometimes someone or more does. Sometimes not. Sometimes we've called on specific people who have been coming for a long time when no one volunteers, and it turned out they did have something to share. Certainly I think we want to promote TriZPUG meetings as participatory rather than a spectator sport. TriZPUG is not designed to be some people entertaining other people, although there are some people who take the lead in facilitating meetings and events. So I like to encourage participants to bring lightning talks. I want to hear what other people have to say. In fact, I do *expect* to. And sometimes my expectations are met. :) If you don't bring a lightning talk, no one is going to bother you. In fact, no one is really going to notice. The people who brought lightning talks will get all the notice. And we may not even have time to get to lightning talks if the featured speaker takes up enough time. That's why a lightning talk can be something you don't even have to prepare for. Some of our best lightning talks have been someone standing up and sharing something Python-related they saw on some website that might be of interest to others. I hope this clears that up. -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599