From rshepard at appl-ecosys.com Fri Nov 2 23:44:51 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Fri, 2 Nov 2007 15:44:51 -0700 (PDT) Subject: [portland] Extracting strings from a tuple Message-ID: While this should be simple, I cannot get it working and would appreciate guidance on solving my problem. There is a database table with a single record. When I retrieve that record I have a list consisting of a single tuple. However, that tuple has 7 strings; when printed it looks like this: [(u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', u'string 6', u'string 7')] What I want to do is walk through that tuple and extract each string. However, I cannot successfully slice it, iterate through it, or use an index to extract each string. According to "DIP," "Byte of Python," and other books I should be able to get each string as a separate item. What have I missed? Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc. | Accelerators(TM) Voice: 503-667-4517 Fax: 503-667-8863 From mccredie at gmail.com Sat Nov 3 00:01:59 2007 From: mccredie at gmail.com (Matt McCredie) Date: Fri, 2 Nov 2007 16:01:59 -0700 Subject: [portland] Extracting strings from a tuple In-Reply-To: References: Message-ID: <9e95df10711021601h5e19fccard2da7c9387f62fb6@mail.gmail.com> > While this should be simple, I cannot get it working and would appreciate > guidance on solving my problem. > > There is a database table with a single record. When I retrieve that > record I have a list consisting of a single tuple. However, that tuple has 7 > strings; when printed it looks like this: > > [(u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', u'string > 6', u'string 7')] > > What I want to do is walk through that tuple and extract each string. > However, I cannot successfully slice it, iterate through it, or use an index > to extract each string. According to "DIP," "Byte of Python," and other > books I should be able to get each string as a separate item. > > What have I missed? Well, without some sample code showing what you are trying, it is difficult to say what you have missed. How would I do it? [code] returned_data = [(u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', u'string6', u'string 7')] strings_tuple = returned_data[0] individual_string = strings_tuple[0] for txt in strings_tuple: print txt [/code] My guess is that you are dereferencing from the list incorrectly. If you don't want to use intermediate variables this should work: [code] returned_data = [(u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', u'string6', u'string 7')] for txt in returned_data[0]: print txt [/code] Matt From adam at therobots.org Sat Nov 3 00:02:56 2007 From: adam at therobots.org (Adam Lowry) Date: Fri, 2 Nov 2007 16:02:56 -0700 Subject: [portland] Extracting strings from a tuple In-Reply-To: References: Message-ID: <00841681-EDDD-4144-B772-AEB060F65C53@therobots.org> On Nov 2, 2007, at 3:44 PM, Rich Shepard wrote: > [(u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', > u'string > 6', u'string 7')] > > What I want to do is walk through that tuple and extract each > string. > However, I cannot successfully slice it, iterate through it, or use > an index > to extract each string. According to "DIP," "Byte of Python," and > other > books I should be able to get each string as a separate item. Since what you have is a list containing a tuple containing 7 strings, you need to first select which entry in the list you want, then which entries in the tuple you want: >>> l = [(u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', u'string6', u'string 7')] >>> l[0] (u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', u'string6', u'string 7') >>> l[0][1:3] (u'string 2', u'string 3') When dealing with databases you end up with this idiom a lot: search_results = getStuffFromDB() for row in search_results: print "String 1:", row[0], "String 2:", row[1] Does that answer your question? Adam From freyley at gmail.com Sat Nov 3 00:03:11 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Fri, 2 Nov 2007 16:03:11 -0700 Subject: [portland] Extracting strings from a tuple In-Reply-To: References: Message-ID: <8db4a1910711021603s2140a007vab06defb4fbcefaa@mail.gmail.com> [a[0][i] for i in range(len(a[0]))] To unpack that, it's a list comprehension which look like this: [a for a in listofthings ] or equivalent to newlist=[] for a in listofthings: newlist += a but this one is a[0][i] which gets into the list and then into the tuple. Jeff On 11/2/07, Rich Shepard wrote: > While this should be simple, I cannot get it working and would appreciate > guidance on solving my problem. > > There is a database table with a single record. When I retrieve that > record I have a list consisting of a single tuple. However, that tuple has 7 > strings; when printed it looks like this: > > [(u'string 1', u'string 2', u'string 3', u'string 4', u'string 5', u'string > 6', u'string 7')] > > What I want to do is walk through that tuple and extract each string. > However, I cannot successfully slice it, iterate through it, or use an index > to extract each string. According to "DIP," "Byte of Python," and other > books I should be able to get each string as a separate item. > > What have I missed? > > Rich > > -- > Richard B. Shepard, Ph.D. | The Environmental Permitting > Applied Ecosystem Services, Inc. | Accelerators(TM) > Voice: 503-667-4517 Fax: 503-667-8863 > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > From mccredie at gmail.com Sat Nov 3 00:18:16 2007 From: mccredie at gmail.com (Matt McCredie) Date: Fri, 2 Nov 2007 16:18:16 -0700 Subject: [portland] Extracting strings from a tuple In-Reply-To: <8db4a1910711021603s2140a007vab06defb4fbcefaa@mail.gmail.com> References: <8db4a1910711021603s2140a007vab06defb4fbcefaa@mail.gmail.com> Message-ID: <9e95df10711021618k60f77478na93eed609888d389@mail.gmail.com> > [a[0][i] for i in range(len(a[0]))] > wouldn't that be better written: list(a[0]) In python if you find yourself doing 'range(len(something))' it is time to backup and re-evaluate. Heck, you can even use list comprehension without the range(len(a[0])): [val for val in a[0]] > To unpack that, it's a list comprehension which look like this: > > [a for a in listofthings ] What are you doing here? Just making a copy? That is better written: x = listofthings[:] I'm not trying to be a pain, just trying to encourage more pythonic habits. Matt From rshepard at appl-ecosys.com Sat Nov 3 00:33:19 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Fri, 2 Nov 2007 16:33:19 -0700 (PDT) Subject: [portland] Extracting strings from a tuple In-Reply-To: <9e95df10711021601h5e19fccard2da7c9387f62fb6@mail.gmail.com> References: <9e95df10711021601h5e19fccard2da7c9387f62fb6@mail.gmail.com> Message-ID: On Fri, 2 Nov 2007, Matt McCredie wrote: > My guess is that you are dereferencing from the list incorrectly. If you > don't want to use intermediate variables this should work: Matt, Yes, that was my problem: not seeing how to properly dereference the list. > [code] > returned_data = [(u'string 1', u'string 2', u'string 3', u'string 4', > u'string 5', u'string6', u'string 7')] > > for txt in returned_data[0]: > print txt > [/code] Thank you. Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc. | Accelerators(TM) Voice: 503-667-4517 Fax: 503-667-8863 From rshepard at appl-ecosys.com Sat Nov 3 00:40:11 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Fri, 2 Nov 2007 16:40:11 -0700 (PDT) Subject: [portland] Extracting strings from a tuple In-Reply-To: <9e95df10711021618k60f77478na93eed609888d389@mail.gmail.com> References: <8db4a1910711021603s2140a007vab06defb4fbcefaa@mail.gmail.com> <9e95df10711021618k60f77478na93eed609888d389@mail.gmail.com> Message-ID: On Fri, 2 Nov 2007, Matt McCredie wrote: > I'm not trying to be a pain, just trying to encourage more pythonic habits. Thank you all. I was trying list comprehensions, various transformations, and totally spaced on using a double index. I greatly appreciate the replies from all of you. Carpe weekend, Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc. | Accelerators(TM) Voice: 503-667-4517 Fax: 503-667-8863 From freyley at gmail.com Sat Nov 3 01:11:35 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Fri, 2 Nov 2007 17:11:35 -0700 Subject: [portland] Extracting strings from a tuple In-Reply-To: <8db4a1910711021711n585bc9dem5c5ed71554efdcb9@mail.gmail.com> References: <8db4a1910711021603s2140a007vab06defb4fbcefaa@mail.gmail.com> <9e95df10711021618k60f77478na93eed609888d389@mail.gmail.com> <8db4a1910711021711n585bc9dem5c5ed71554efdcb9@mail.gmail.com> Message-ID: <8db4a1910711021711m7c4b06edh62a358f19dc63259@mail.gmail.com> On 11/2/07, Matt McCredie wrote: > In python if you find yourself doing 'range(len(something))' it is > time to backup and re-evaluate. Heck, you can even use list > comprehension without the range(len(a[0])): > > [val for val in a[0]] This is really the best form for this particular discussion because we don't know quite what Rich is doing. > > To unpack that, it's a list comprehension which look like this: > > > > [a for a in listofthings ] > > What are you doing here? Just making a copy? That is better written: I'm not assuming Rich is familiar with list comprehensions and so was attempting to describe their general form. Your use is cleaner, though. Thanks, Jeff From bradallen at mac.com Tue Nov 6 00:28:58 2007 From: bradallen at mac.com (Brad Allen) Date: Mon, 5 Nov 2007 18:28:58 -0500 Subject: [portland] Fwd: [plone_portland] November Meeting Message-ID: In case anyone on the Portland Python list doesn't know about the Portland Plone user group, see announced meeting below. >Date: Mon, 05 Nov 2007 08:11:07 -0800 >From: Darci Hanning >Subject: [plone_portland] November Meeting >Sender: Darci Hanning >To: "plone_portland at lists.onenw.org" >List-Owner: >List-Post: >List-Subscribe: > >List-Unsubscribe: > >List-Archive: >List-Help: > > >Greetings Portland Plonistas! > >Join us for our last meeting in 2007! The Plone Users Group will be >meeting on November 13th at 5:30pm at the Portland offices of >One/NW: 1306 NW Hoyt, Suite 406, Portland, OR 97209 (Map: >http://tinyurl.com/yu2sft). There will >also be treats (but not tricks, sorry! ;-) > >Darci Hanning will be giving the presentation she gave at >this year's Plone Conference ("Top 10 Ways to Get Involved in the >Plone Community") and will be sharing highlights of the conference >and fielding any questions you might have about the conference. > >(She has also been elected to the Plone Foundation Board so if you >have any questions about Foundation membership or the board, she >would be happy to address those as well.) > >Please note that we won't be meeting again until January 8, 2008 due >to the upcoming holiday season :-) > >Cheers! >Darci > >------------------------------------------------------------------------------------------ >Darci Hanning * Technology Development Consultant * Library >Development Services >Oregon State Library, 250 Winter St. NE, Salem, OR 97301 >503-378-2527 darci.hanning at state.or.us > > Ask me about Plinkit! >http://www.plinkit.org/ >http://oregon.plinkit.org From freyley at gmail.com Wed Nov 7 22:42:32 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Wed, 7 Nov 2007 13:42:32 -0800 Subject: [portland] Reminder: Code Sprint tonight! Message-ID: <8db4a1910711071342n31051de0vb7c87647107555a@mail.gmail.com> Last minute reminder: Tonight (Wednesday), we're having another code sprint. Come join us at 7pm at CubeSpace. Jeff From freyley at gmail.com Wed Nov 7 22:51:37 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Wed, 7 Nov 2007 13:51:37 -0800 Subject: [portland] Meeting next week Message-ID: <8db4a1910711071351k52fc0dd2m67df9d0fa16107f7@mail.gmail.com> Pythonists, Next Tuesday, the 13th, we're getting back together. The good news: We've got pizza (thank you Kavi and Adam!) The other news: We're going to be in a bit of a weird space. I think we're going to take over a row of cubicles and a couple of small conference rooms in the space known as the Cave of CubeSpace. Our plan at this point is to have a couple of lightning talks and then break off into groups talking about the topics that were brought up, so this should work fine. It's an adventure! So, who's talking? This is your chance to tell us about this thing you've wanted to do in Python. You don't need to be an expert. Find a module or a piece of your code that does something interesting, show us it and tell us why you find it fascinating. See you all soon. Jeff From freyley at gmail.com Wed Nov 7 23:04:00 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Wed, 7 Nov 2007 14:04:00 -0800 Subject: [portland] December Social Message-ID: <8db4a1910711071404w49caf6c4ld15bf90a50fb173b@mail.gmail.com> Hey folks, Sam Keen, who runs PHP, approached me about joining forces for December. December's not generally a time of lots of stress, so instead of having many usergroups, he proposes to have a holiday social for coders. Specifically we're inviting RP4 (Ruby, Python, PHP, Perl, Postgresql) to get together and talk and hang out. This would replace our December meeting but happen at the meeting time we normally meet. So, I'm asking for some specific things from you all. They are: * tell me what we can do to make the December meeting a good one for you * if you know anybody who can be cajoled into sponsoring either the Python group or a holiday social for programmers, tell me how I can help you cajole them. lastly, I'm thinking about some games we could play to make this party ridiculous and fun. I'd really appreciate some help with specific tasks. I'll talk more about this at the meeting, but, lastly: * tell me if you'd be willing to help out with some setup for the december party. Many thanks to you all for all your awesomeness. =) Jeff From rshepard at appl-ecosys.com Thu Nov 8 18:25:55 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 8 Nov 2007 09:25:55 -0800 (PST) Subject: [portland] Sorting A List of Tuples Message-ID: All the information I find on sorting lists assumes the list has only a single value to be sorted. What to do with multiple values when the sort is on the second or third item and all must be kept together? I have lists of tuples which I'd like to sort on the second item while retaining the relationships among the item pairs. Could I do terms.sort([][1]) ? A pointer to a reference would be fine. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From jek at discorporate.us Thu Nov 8 18:48:09 2007 From: jek at discorporate.us (jason kirtland) Date: Thu, 08 Nov 2007 09:48:09 -0800 Subject: [portland] Sorting A List of Tuples In-Reply-To: References: Message-ID: <47334BD9.5010007@discorporate.us> Rich Shepard wrote: > All the information I find on sorting lists assumes the list has only a > single value to be sorted. What to do with multiple values when the sort is > on the second or third item and all must be kept together? > > I have lists of tuples which I'd like to sort on the second item while > retaining the relationships among the item pairs. > > Could I do > terms.sort([][1]) > ? The array 'sort' method and the 'sorted' function both take an optional 'key' function. The function is applied to each item in the list and the result is used for comparison instead of the list value itself. If you only want to consider the second item in the tuple, the operator module's 'itemgetter' is perfect: >>> stuff = [(1,2),(3,3),(2,1),(1,3)] >>> from operator import itemgetter >>> sorted(stuff, key=itemgetter(1)) [(2, 1), (1, 2), (3, 3), (1, 3)] You can also get fancy and do some tuple-reordering for a stable sort: >>> last_then_first = lambda t: (t[1], t[0]) >>> last_then_first( (1, 0) ) (0, 1) >>> sorted(stuff, key=last_then_first) [(2, 1), (1, 2), (1, 3), (3, 3)] -j From rshepard at appl-ecosys.com Thu Nov 8 18:51:49 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 8 Nov 2007 09:51:49 -0800 (PST) Subject: [portland] Sorting A List of Tuples In-Reply-To: <4c645a720711080940u647344ch393e6e2d382ab180@mail.gmail.com> References: <4c645a720711080940u647344ch393e6e2d382ab180@mail.gmail.com> Message-ID: On Thu, 8 Nov 2007, Dylan Reinhardt wrote: > Try DSU: > > http://www.goldb.org/goldblog/CommentView,guid,6969f8b8-5710-4b4c-ad7a-0f545da805da.aspx How cool! > HTH Yes, it does, Dylan. Thanks very much, Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From kirby.urner at gmail.com Thu Nov 8 18:52:59 2007 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 8 Nov 2007 09:52:59 -0800 Subject: [portland] Sorting A List of Tuples In-Reply-To: References: Message-ID: Hi Rich -- The list.sort() method takes an optional 'key' argument that'd be a function, which you might use to pick out the value you want to compare, as follows: IDLE 1.2.1 >>> mylist = [(1,2,3), (8,1,7), (8,5,2)] >>> def f(x): return x[1] >>> mylist.sort(key=f) >>> mylist [(8, 1, 7), (1, 2, 3), (8, 5, 2)] Or just use lambda in this case: >>> mylist = [(1,2,3), (8,1,7), (8,5,2)] >>> mylist.sort(key=lambda x: x[1]) >>> mylist [(8, 1, 7), (1, 2, 3), (8, 5, 2)] Kirby On Nov 8, 2007 9:25 AM, Rich Shepard wrote: > All the information I find on sorting lists assumes the list has only a > single value to be sorted. What to do with multiple values when the sort is > on the second or third item and all must be kept together? > > I have lists of tuples which I'd like to sort on the second item while > retaining the relationships among the item pairs. > > Could I do > terms.sort([][1]) > ? > > A pointer to a reference would be fine. > > Rich > > -- > Richard B. Shepard, Ph.D. | Integrity Credibility > Applied Ecosystem Services, Inc. | Innovation > Voice: 503-667-4517 Fax: 503-667-8863 > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > From rshepard at appl-ecosys.com Thu Nov 8 18:53:02 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 8 Nov 2007 09:53:02 -0800 (PST) Subject: [portland] Sorting A List of Tuples In-Reply-To: <47334BD9.5010007@discorporate.us> References: <47334BD9.5010007@discorporate.us> Message-ID: On Thu, 8 Nov 2007, jason kirtland wrote: > The array 'sort' method and the 'sorted' function both take an optional > 'key' function. The function is applied to each item in the list and the > result is used for comparison instead of the list value itself. > > If you only want to consider the second item in the tuple, the operator > module's 'itemgetter' is perfect: Thanks very much, Jason. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From kirby.urner at gmail.com Thu Nov 8 18:55:14 2007 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 8 Nov 2007 09:55:14 -0800 Subject: [portland] Sorting A List of Tuples In-Reply-To: References: <4c645a720711080940u647344ch393e6e2d382ab180@mail.gmail.com> Message-ID: Again, the 'key' argument helps get around the need for DSU in many cases: >>> seq = [ ['a', 1, 5], ['b', 3, 4], ['c', 2, 2], ['d', 4, 3], ['e', 5, 1], ] >>> seq.sort(key=lambda x: x[2]) >>> seq [['e', 5, 1], ['c', 2, 2], ['d', 4, 3], ['b', 3, 4], ['a', 1, 5]] Kirby On Nov 8, 2007 9:51 AM, Rich Shepard wrote: > On Thu, 8 Nov 2007, Dylan Reinhardt wrote: > > > Try DSU: > > > > http://www.goldb.org/goldblog/CommentView,guid,6969f8b8-5710-4b4c-ad7a-0f545da805da.aspx > > How cool! > > > HTH > > Yes, it does, Dylan. > > Thanks very much, > > > Rich > > -- > Richard B. Shepard, Ph.D. | Integrity Credibility > Applied Ecosystem Services, Inc. | Innovation > Voice: 503-667-4517 Fax: 503-667-8863 > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > From mccredie at gmail.com Thu Nov 8 18:56:16 2007 From: mccredie at gmail.com (Matt McCredie) Date: Thu, 8 Nov 2007 09:56:16 -0800 Subject: [portland] Sorting A List of Tuples In-Reply-To: References: Message-ID: <9e95df10711080956w46481ffy9d25ef691c24fdaf@mail.gmail.com> On Nov 8, 2007 9:25 AM, Rich Shepard wrote: > All the information I find on sorting lists assumes the list has only a > single value to be sorted. What to do with multiple values when the sort is > on the second or third item and all must be kept together? > > I have lists of tuples which I'd like to sort on the second item while > retaining the relationships among the item pairs. > > Could I do > terms.sort([][1]) > ? > > A pointer to a reference would be fine. > > Rich First the example: >>> import operator >>> terms [(0, 9), (1, 8), (2, 7), (3, 6), (4, 5), (5, 4), (6, 3), (7, 2), (8, 1), (9, 0)] >>> terms.sort(key=operator.itemgetter(1)) >>> terms [(9, 0), (8, 1), (7, 2), (6, 3), (5, 4), (4, 5), (3, 6), (2, 7), (1, 8), (0, 9)] Then the explanation: operator.itemgetter(n) returns a callable object (function) that when passed a sequence will always return the nth item of the sequence. so... >>> foo = operator.itemgetter(3) >>> foo([0,1,2,3]) 3 >>> foo('abcd') 'd' The key parameter to sort accepts a callable object (function) that will be called on each item in the list to determine the actual value to sort by. So, the example I gave you is essentially just saying, sort by the item at index 1 of each tuple in the list terms. Hope this helps, Matt From jek at discorporate.us Thu Nov 8 19:14:56 2007 From: jek at discorporate.us (jason kirtland) Date: Thu, 08 Nov 2007 10:14:56 -0800 Subject: [portland] Sorting A List of Tuples In-Reply-To: References: <47334BD9.5010007@discorporate.us> Message-ID: <47335220.7050706@discorporate.us> Rich Shepard wrote: > On Thu, 8 Nov 2007, jason kirtland wrote: > >> The array 'sort' method and the 'sorted' function both take an optional >> 'key' function. The function is applied to each item in the list and the >> result is used for comparison instead of the list value itself. >> >> If you only want to consider the second item in the tuple, the operator >> module's 'itemgetter' is perfect: > > Thanks very much, Jason. Also, there's a good sorting discussion at python.org: http://wiki.python.org/moin/HowTo/Sorting It has some gems, for example: >>> l = ['A', 'b', 'C', 'd'] >>> sorted(l) ['A', 'C', 'b', 'd'] >>> sorted(l, key=str.lower) ['A', 'b', 'C', 'd'] -j From rshepard at appl-ecosys.com Thu Nov 8 19:24:03 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 8 Nov 2007 10:24:03 -0800 (PST) Subject: [portland] Sorting A List of Tuples In-Reply-To: <9e95df10711080956w46481ffy9d25ef691c24fdaf@mail.gmail.com> References: <9e95df10711080956w46481ffy9d25ef691c24fdaf@mail.gmail.com> Message-ID: On Thu, 8 Nov 2007, Matt McCredie wrote: > Then the explanation: > > operator.itemgetter(n) returns a callable object (function) that when > passed a sequence will always return the nth item of the sequence. ... > Hope this helps, Very much, Matt. Thank you. RIch -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From kirby.urner at gmail.com Thu Nov 8 19:18:34 2007 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 8 Nov 2007 10:18:34 -0800 Subject: [portland] Meeting next week In-Reply-To: <8db4a1910711071351k52fc0dd2m67df9d0fa16107f7@mail.gmail.com> References: <8db4a1910711071351k52fc0dd2m67df9d0fa16107f7@mail.gmail.com> Message-ID: Hey Jeff -- I thought I wasn't able to come, because Suz, my biz partner, was scheduled to speak in another venue on my invitation and I wanted to be there in support. However, that's not happening on the 13th, so I'm back on tap for attending this meetup. Professionally, I'm in the thick of battle re open source in the health care sector and would be happy to discuss that if it's an interest, including flipping through my slides on that topic if there's going to be a working projector. Just put me down as a willing subject. Could be a lightning talk, could be a longer conversation. I think you're doing a good job managing agendas, so hey, whatever works. I'm too busy to mess with the Wiki or anything like that. I'll go to meetup.com and change my RSVP to 'Yes' now... (at least I have time to do that). Kirby On Nov 7, 2007 1:51 PM, Jeff Schwaber wrote: > Pythonists, > > Next Tuesday, the 13th, we're getting back together. > > The good news: We've got pizza (thank you Kavi and Adam!) > > The other news: We're going to be in a bit of a weird space. I think > we're going to take over a row of cubicles and a couple of small > conference rooms in the space known as the Cave of CubeSpace. Our plan > at this point is to have a couple of lightning talks and then break > off into groups talking about the topics that were brought up, so this > should work fine. It's an adventure! > > So, who's talking? > > This is your chance to tell us about this thing you've wanted to do in > Python. You don't need to be an expert. Find a module or a piece of > your code that does something interesting, show us it and tell us why > you find it fascinating. > > See you all soon. > > Jeff > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > From rshepard at appl-ecosys.com Thu Nov 8 19:30:35 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 8 Nov 2007 10:30:35 -0800 (PST) Subject: [portland] Meeting next week In-Reply-To: References: <8db4a1910711071351k52fc0dd2m67df9d0fa16107f7@mail.gmail.com> Message-ID: On Thu, 8 Nov 2007, kirby urner wrote: > Professionally, I'm in the thick of battle re open source in the health > care sector and would be happy to discuss that if it's an interest, This seems to be a rather nasty battle. I know of someone who's been forced to use Microsoft stuff rather than the linux and OSS tools/applications he'd prefer. Little doubt who's behind all this, eh? Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From kirby.urner at gmail.com Thu Nov 8 19:39:35 2007 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 8 Nov 2007 10:39:35 -0800 Subject: [portland] Meeting next week In-Reply-To: References: <8db4a1910711071351k52fc0dd2m67df9d0fa16107f7@mail.gmail.com> Message-ID: Actually Microsoft is embracing open source at some levels, IronPython on Codeplex for example, though true to form, MSFT uses its own inhouse nomenclature and rules, as befitting an empire. :-D The deeper issues revolve around the "scruffy hacker" image (per the hilarious opening of 'Revolution OS' -- Eric Raymond telling the story), and this whole "hacker = cracker = pirate" spin. It's a cultural confusion, not specific to health care per se. Hospitals are more buttoned down than the CIA when it comes to medical records, thanks to HIPAA, and there's confusion about how "open source" is consistent with "ultra secret". My role has been to reassure, e.g. you can swap database *schemas* (called "registries" in our business) without sharing any clinical data whatsoever. That's a place to start. Jeff S. and I were involved in this whole set of issues back in the days of Collab at Free Geek (SQL Clinic etc.). I've continued on that trajectory ever since (was on it before I got there), even though Collab is long gone by this time (I sure learned a lot from that experience though). Kirby On Nov 8, 2007 10:30 AM, Rich Shepard wrote: > On Thu, 8 Nov 2007, kirby urner wrote: > > > Professionally, I'm in the thick of battle re open source in the health > > care sector and would be happy to discuss that if it's an interest, > > This seems to be a rather nasty battle. I know of someone who's been > forced to use Microsoft stuff rather than the linux and OSS > tools/applications he'd prefer. Little doubt who's behind all this, eh? > > Rich > > -- > Richard B. Shepard, Ph.D. | Integrity Credibility > Applied Ecosystem Services, Inc. | Innovation > Voice: 503-667-4517 Fax: 503-667-8863 > > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > From rshepard at appl-ecosys.com Thu Nov 8 20:44:48 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 8 Nov 2007 11:44:48 -0800 (PST) Subject: [portland] Sorting A List of Tuples In-Reply-To: References: <4c645a720711080940u647344ch393e6e2d382ab180@mail.gmail.com> Message-ID: On Thu, 8 Nov 2007, kirby urner wrote: > Again, the 'key' argument helps get around the need for DSU in many cases: Yes. Importing itemgetter from operator, and using sorted() followed by .reverse() the results are what are needed in the report. Thanks, Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From adam at therobots.org Thu Nov 8 20:51:28 2007 From: adam at therobots.org (Adam Lowry) Date: Thu, 8 Nov 2007 11:51:28 -0800 Subject: [portland] Sorting A List of Tuples In-Reply-To: References: <4c645a720711080940u647344ch393e6e2d382ab180@mail.gmail.com> Message-ID: On Nov 8, 2007, at 11:44 AM, Rich Shepard wrote: > Yes. Importing itemgetter from operator, and using sorted() > followed by > .reverse() the results are what are needed in the report. You can do the reverse at the same time, if you'd like: sorted(key=blahblahblah, reverse=True) The reverse flag is also available on [].sort(). Adam From rshepard at appl-ecosys.com Thu Nov 8 21:35:38 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 8 Nov 2007 12:35:38 -0800 (PST) Subject: [portland] Sorting A List of Tuples In-Reply-To: References: <4c645a720711080940u647344ch393e6e2d382ab180@mail.gmail.com> Message-ID: On Thu, 8 Nov 2007, Adam Lowry wrote: > You can do the reverse at the same time, if you'd like: > sorted(key=blahblahblah, reverse=True) > > The reverse flag is also available on [].sort(). Adam, Thank you. I looked to see if there was a way to do this in one step, but I didn't see it. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From rshepard at appl-ecosys.com Mon Nov 12 18:48:45 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Mon, 12 Nov 2007 09:48:45 -0800 (PST) Subject: [portland] Python-2.5.1 and SQLite3 Message-ID: I'm stymied. Pysqlite support for SQLite3 is supposed to be built in to Python-2.5, and this does seem to be the case. But, when I try to run my application Python complains that it cannot find _sqlite3.so so the import (from sqlite3 import *) in the hierarchy fails. This library is supposed to be in /usr/lib/python2.5/lib-dynload/, but it's not. I see nothing on the Python web site about SQLite support, I've upgraded to pysqlite-2.3.5 (python2.5 apparently comes with -2.1.3), there are no specific option switches in the python2.5 ./configure file, and I have no responses to my request for help in the Slackware-12 forum. What's a person to do? I cannot find the source for this library so I can build and install it. Help greatly appreciated, Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From jek at discorporate.us Mon Nov 12 19:26:02 2007 From: jek at discorporate.us (jason kirtland) Date: Mon, 12 Nov 2007 10:26:02 -0800 Subject: [portland] Python-2.5.1 and SQLite3 In-Reply-To: References: Message-ID: <47389ABA.9080400@discorporate.us> Rich Shepard wrote: > I'm stymied. Pysqlite support for SQLite3 is supposed to be built in to > Python-2.5, and this does seem to be the case. But, when I try to run my > application Python complains that it cannot find _sqlite3.so so the import > (from sqlite3 import *) in the hierarchy fails. > > This library is supposed to be in /usr/lib/python2.5/lib-dynload/, but > it's not. I see nothing on the Python web site about SQLite support, I've > upgraded to pysqlite-2.3.5 (python2.5 apparently comes with -2.1.3), there > are no specific option switches in the python2.5 ./configure file, and I > have no responses to my request for help in the Slackware-12 forum. > > What's a person to do? I cannot find the source for this library so I can > build and install it. > > Help greatly appreciated, It looks like the slackware package is broken. You could try rebuilding Python from source and cherry-picking _sqlite3.so out of the built files. It's built automatically as part of the extension module build process, although it will be quietly omitted if you don't have the sqlite headers installed or the compilation otherwise fails. Using the newer pysqlite you've built instead of the distribution's broken sqlite3 is also an option. -j From rshepard at appl-ecosys.com Mon Nov 12 20:28:25 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Mon, 12 Nov 2007 11:28:25 -0800 (PST) Subject: [portland] Python-2.5.1 and SQLite3 In-Reply-To: <47389ABA.9080400@discorporate.us> References: <47389ABA.9080400@discorporate.us> Message-ID: On Mon, 12 Nov 2007, jason kirtland wrote: > It looks like the slackware package is broken. Uh-oh. That's not good. > You could try rebuilding Python from source and cherry-picking _sqlite3.so > out of the built files. It's built automatically as part of the extension > module build process, although it will be quietly omitted if you don't > have the sqlite headers installed or the compilation otherwise fails. I'll try this. > Using the newer pysqlite you've built instead of the distribution's broken > sqlite3 is also an option. Would I then use the older syntax of 'from pysqlite2 import dbapi2 as sqlite3' rather than the newer 'import sqlite3?' Thanks very much, Jason, Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From jek at discorporate.us Mon Nov 12 20:43:10 2007 From: jek at discorporate.us (jason kirtland) Date: Mon, 12 Nov 2007 11:43:10 -0800 Subject: [portland] Python-2.5.1 and SQLite3 In-Reply-To: References: <47389ABA.9080400@discorporate.us> Message-ID: <4738ACCE.9040301@discorporate.us> Rich Shepard wrote: > On Mon, 12 Nov 2007, jason kirtland wrote: > >> Using the newer pysqlite you've built instead of the distribution's broken >> sqlite3 is also an option. > > Would I then use the older syntax of 'from pysqlite2 import dbapi2 as > sqlite3' rather than the newer 'import sqlite3?' Yep. You could also try both modules and pick the best one available at runtime. Like this, yanked from SQLAlchemy's sqlite support: try: from pysqlite2 import dbapi2 as sqlite except ImportError, e: try: # try the 2.5+ stdlib name. from sqlite3 import dbapi2 as sqlite except ImportError: raise e # connection = sqlite.connect(...) # ... From rshepard at appl-ecosys.com Mon Nov 12 20:44:08 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Mon, 12 Nov 2007 11:44:08 -0800 (PST) Subject: [portland] Python-2.5.1 and SQLite3 In-Reply-To: <47389ABA.9080400@discorporate.us> References: <47389ABA.9080400@discorporate.us> Message-ID: On Mon, 12 Nov 2007, jason kirtland wrote: > You could try rebuilding Python from source and cherry-picking _sqlite3.so > out of the built files. This worked, Jason. Thank you. Now I have a wxPython error related to wxGTK and the grid widget. Sigh. Off to that mail list. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From freyley at gmail.com Tue Nov 13 02:13:46 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Mon, 12 Nov 2007 17:13:46 -0800 Subject: [portland] Reminder: Meeting tomorrow (Tuesday) at 7pm Message-ID: <8db4a1910711121713s7e5c0fbav531f4671411ab9c8@mail.gmail.com> Hey folks, Remember, we're meeting tomorrow, that's Tuesday, at 7pm. We've had some discussion on IRC about possible talks, a few of our star presenters return from cancelling, But nothing's final. If you'd like to talk tomorrow, you're on. Either way, I'll see y'all for beer and discussing the December social. Jeff From freyley at gmail.com Tue Nov 13 02:20:03 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Mon, 12 Nov 2007 17:20:03 -0800 Subject: [portland] Reminder: Meeting tomorrow (Tuesday) at 7pm + Pizza Message-ID: <8db4a1910711121720h4ff735bbn69de3d14130d10cb@mail.gmail.com> On 11/12/07, Jeff Schwaber wrote: > Hey folks, > > Remember, we're meeting tomorrow, that's Tuesday, at 7pm. > > We've had some discussion on IRC about possible talks, a few of our > star presenters return from cancelling, But nothing's final. If you'd > like to talk tomorrow, you're on. Either way, I'll see y'all for beer > and discussing the December social. The other half of this email: Remember, there'll be pizza, provided by Kavi (who are, incidentally, looking to hire a programmer). Adam deserves many props for finding us a willing sponsor. Thank you Adam! Jeff PS: Your company could be the next one being plugged... From dylanr at dylanreinhardt.com Thu Nov 8 18:40:54 2007 From: dylanr at dylanreinhardt.com (Dylan Reinhardt) Date: Thu, 8 Nov 2007 09:40:54 -0800 Subject: [portland] Sorting A List of Tuples In-Reply-To: References: Message-ID: <4c645a720711080940u647344ch393e6e2d382ab180@mail.gmail.com> Try DSU: http://www.goldb.org/goldblog/CommentView,guid,6969f8b8-5710-4b4c-ad7a-0f545da805da.aspx HTH On 11/8/07, Rich Shepard wrote: > > All the information I find on sorting lists assumes the list has only a > single value to be sorted. What to do with multiple values when the sort > is > on the second or third item and all must be kept together? > > I have lists of tuples which I'd like to sort on the second item while > retaining the relationships among the item pairs. > > Could I do > terms.sort([][1]) > ? > > A pointer to a reference would be fine. > > Rich > > -- > Richard B. Shepard, Ph.D. > | Integrity Credibility > Applied Ecosystem Services, Inc. | Innovation > Voice: 503-667-4517 Fax: > 503-667-8863 > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/portland/attachments/20071108/d294271d/attachment.htm From freyley at gmail.com Fri Nov 16 19:42:30 2007 From: freyley at gmail.com (Jeff Schwaber) Date: Fri, 16 Nov 2007 10:42:30 -0800 Subject: [portland] Last Code Sprint of 2007, Tomorrow + Holiday Social Message-ID: <8db4a1910711161042h2b920aa0scd9e47142b3749f6@mail.gmail.com> Hey folks, With the holidays coming up we're going to take a break on the sprints. After tomorrow, that is. Tomorrow, all day, 10am-6pm, delicious code. http://code.arlim.org/wiki for those seeking to follow along at home. (Pizza funding jar at the door, will order pizza...) Then it's into the dark winter of the end of the year for us, and we'll return in early January. But! The 2nd Tuesday of December we'll be gathering around a large beverage container and being friendly. Just cause. http://pdxgroups.pbwiki.com/2007-December-Coders-Social Jeff From rshepard at appl-ecosys.com Wed Nov 21 00:36:36 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 20 Nov 2007 15:36:36 -0800 (PST) Subject: [portland] Python 2.5 Warnings Message-ID: Please point me toward a source that will help me to resolve this issue. When I upgraded my notebook to Slackware-12.0 it upgraded Python from 2.4.3 to 2.5. When I run my application I see this: (python:2862): Gtk-CRITICAL **: gtk_file_system_unix_get_info: assertion `g_path_is_absolute (filename)' failed (python:2862): Gtk-WARNING **: file_system_unix=0x8b89540 still has handle=0x8de2ac8 at finalization which is NOT CANCELLED! I learned from you folks that the provided Python2.5 package did not include support for SQLite3 and pysqlite2, and I added that library myself. Is the above also part of an incomplete Python? It's brand new to me. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From rshepard at appl-ecosys.com Wed Nov 21 00:52:02 2007 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 20 Nov 2007 15:52:02 -0800 (PST) Subject: [portland] Python 2.5 Warnings In-Reply-To: References: Message-ID: On Tue, 20 Nov 2007, Rich Shepard wrote: > (python:2862): Gtk-CRITICAL **: gtk_file_system_unix_get_info: assertion > `g_path_is_absolute (filename)' failed > > (python:2862): Gtk-WARNING **: file_system_unix=0x8b89540 still has > handle=0x8de2ac8 at finalization which is NOT CANCELLED! I suppose that I should mention that I'm using wxPython-2.8.6.1, also built as a Slackware package with wxGTK. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation Voice: 503-667-4517 Fax: 503-667-8863 From tseaver at agendaless.com Wed Nov 21 16:22:42 2007 From: tseaver at agendaless.com (Tres Seaver) Date: Wed, 21 Nov 2007 10:22:42 -0500 Subject: [portland] Repoze presentation at Portland Plone Users' Group / Portland Pythoneers? Message-ID: <47444D42.7020902@agendaless.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 (Sorry for the resend, Darci, I mistyped Jon's email on the first pass). Howdy, It looks as though one or more of the Agendaless principals (Chris McDonough, Paul Everitt, myself) will be on the West Coast in February for the Plone Summit at the Googleplex, 8 - 10 February 2007. We thought it would be a good use of plane fare, etc. to ask if the various Zope / Plone / Python user groups might be interested in a presentation about Repoze: http://repoze.org/ I see from your site that both groups meet on second Tuesdays, which would put the February meeting falling on the twelfth. Would either group be interested in such a talk, if we could work our way up to Portland following the summit? If so, could your group help with travel costs? We would like to speak before as many groups as feasible, but we won't be able to cover all costs for the full set of groups; the more that the groups can help pay costs, the more we can do. Best, Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver at agendaless.com Agendaless Consulting http://agendaless.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHRE1CFXKVXuSL+CMRAoRsAJ9kY3CXyfIgTd6y6XYZk2roL86EwACfR1rM +QjrzY0LPFaVC79PH5WvSmw= =vq8M -----END PGP SIGNATURE----- From tseaver at agendaless.com Wed Nov 21 16:14:12 2007 From: tseaver at agendaless.com (Tres Seaver) Date: Wed, 21 Nov 2007 10:14:12 -0500 Subject: [portland] Repoze presentation at Portland Plone Users' Group / Portland Pythoneers? Message-ID: <47444B44.6020406@agendaless.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Howdy, It looks as though one or more of the Agendaless principals (Chris McDonough, Paul Everitt, myself) will be on the West Coast in February for the Plone Summit at the Googleplex, 8 - 10 February 2007. We thought it would be a good use of plane fare, etc. to ask if the various Zope / Plone / Python user groups might be interested in a presentation about Repoze: http://repoze.org/ I see from your site that both groups meet on second Tuesdays, which would put the February meeting falling on the twelfth. Would either group be interested in such a talk, if we could work our way up to Portland following the summit? If so, could your group help with travel costs? We would like to speak before as many groups as feasible, but we won't be able to cover all costs for the full set of groups; the more that the groups can help pay costs, the more we can do. Best, Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver at agendaless.com Agendaless Consulting http://agendaless.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHREtDFXKVXuSL+CMRAnziAJ9QW71ndo/RzRrIRT0cjTe3L1TlNgCeOYoM hsv7phonPTC15fwQFd/ySyI= =Euew -----END PGP SIGNATURE----- From darci.hanning at gmail.com Wed Nov 21 17:43:31 2007 From: darci.hanning at gmail.com (Darci Hanning) Date: Wed, 21 Nov 2007 08:43:31 -0800 Subject: [portland] Repoze presentation at Portland Plone Users' Group / Portland Pythoneers? In-Reply-To: <47444D42.7020902@agendaless.com> References: <47444D42.7020902@agendaless.com> Message-ID: <7b0067070711210843h2357730bqc04d6b02f3b720ee@mail.gmail.com> Hi Tres, I think it's fair to say that the Portland Plone User's group could be very interested in having this talk in Portland and we would love to co-meet with the local Python group as well :) I'm going to query Plone group to confirm. Do you have an idea of a minimum amount you're thinking of to help defer your total costs? We have a small budget at the moment and no real income. We might be able to do a bit of fundraising if your needs are above our current budget but I'd like to have some idea of what you would need minimally for this to work for you all :) Also, are you planning on going up to Seattle to do the same? I'm asking because to be honest our turnout to regular meetings has been rather low; we hope having you folks give this great talk would boost our attendance (at least for that night ;-) So along those lines, another approach would be to encourage Seattle Plonistas to come your talk in Portland -- but if you're planning to be there as well, that's fine too :) Either way, it will just help us with out planning, etc. Let me know and I'll follow-up as soon as I hear back from local users :-) Cheers! Darci On Nov 21, 2007 7:22 AM, Tres Seaver wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > (Sorry for the resend, Darci, I mistyped Jon's email on the first pass). > > Howdy, > > It looks as though one or more of the Agendaless principals (Chris > McDonough, Paul Everitt, myself) will be on the West Coast in February > for the Plone Summit at the Googleplex, 8 - 10 February 2007. We > thought it would be a good use of plane fare, etc. to ask if the various > Zope / Plone / Python user groups might be interested in a presentation > about Repoze: > > http://repoze.org/ > > I see from your site that both groups meet on second Tuesdays, which > would put the February meeting falling on the twelfth. Would either > group be interested in such a talk, if we could work our way up to > Portland following the summit? > > If so, could your group help with travel costs? We would like to speak > before as many groups as feasible, but we won't be able to cover all > costs for the full set of groups; the more that the groups can help pay > costs, the more we can do. > > > Best, > > > Tres. > - -- > =================================================================== > Tres Seaver +1 540-429-0999 tseaver at agendaless.com > Agendaless Consulting http://agendaless.com > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFHRE1CFXKVXuSL+CMRAoRsAJ9kY3CXyfIgTd6y6XYZk2roL86EwACfR1rM > +QjrzY0LPFaVC79PH5WvSmw= > =vq8M > -----END PGP SIGNATURE----- > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/portland/attachments/20071121/4052b96f/attachment.htm From tseaver at agendaless.com Wed Nov 21 20:06:53 2007 From: tseaver at agendaless.com (Tres Seaver) Date: Wed, 21 Nov 2007 14:06:53 -0500 Subject: [portland] Repoze presentation at Portland Plone Users' Group / Portland Pythoneers? In-Reply-To: <7b0067070711210843h2357730bqc04d6b02f3b720ee@mail.gmail.com> References: <47444D42.7020902@agendaless.com> <7b0067070711210843h2357730bqc04d6b02f3b720ee@mail.gmail.com> Message-ID: <474481CD.1050501@agendaless.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Darci Hanning wrote: > I think it's fair to say that the Portland Plone User's group could be very > interested in having this talk in Portland and we would love to co-meet with > the local Python group as well :) I'm going to query Plone group to confirm. Great! > Do you have an idea of a minimum amount you're thinking of to help defer > your total costs? We have a small budget at the moment and no real income. > We might be able to do a bit of fundraising if your needs are above our > current budget but I'd like to have some idea of what you would need > minimally for this to work for you all :) We will definitely be covering airfare to San Francisco and such; we would likely want help at least for lodging in the location where we do a presentation. Depending on how the set of groups shake out, we might be either renting a car to drive up (e.g., to Portland and Seattle) or flying. Hmmm, actually looking at a map, that drive is a little farther than my fifteen-year-old memory. ~450 miles from San Francisco to Portland, but only about 100 from Portland to Seattle? That makes flying a lot more attractive: airfare from SFO to PDX looks to be ~$230 per person. > Also, are you planning on going up to Seattle to do the same? I'm asking > because to be honest our turnout to regular meetings has been rather low; we > hope having you folks give this great talk would boost our attendance (at > least for that night ;-) So along those lines, another approach would be to > encourage Seattle Plonistas to come your talk in Portland -- but if you're > planning to be there as well, that's fine too :) Either way, it will just > help us with out planning, etc. I wrote the Seattle group as well: doing a joint meeting would obviously be less expensive / stressful, so if that idea appeals to both groups, we'd be glad to take that route. > Let me know and I'll follow-up as soon as I hear back from local users :-) Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver at agendaless.com Agendaless Consulting http://agendaless.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHRIHNFXKVXuSL+CMRAqH5AJ94YHMOT+1ZyrdpeeZ0qpWi4z7TygCgjEfn io9KOfmDlooYZlJjQ05CsBc= =p6vh -----END PGP SIGNATURE----- From darci.hanning at gmail.com Wed Nov 21 20:44:08 2007 From: darci.hanning at gmail.com (Darci Hanning) Date: Wed, 21 Nov 2007 11:44:08 -0800 Subject: [portland] Repoze presentation at Portland Plone Users' Group / Portland Pythoneers? In-Reply-To: <474481CD.1050501@agendaless.com> References: <47444D42.7020902@agendaless.com> <7b0067070711210843h2357730bqc04d6b02f3b720ee@mail.gmail.com> <474481CD.1050501@agendaless.com> Message-ID: <7b0067070711211144l2a0e7ff5q34b9153be8cd44e9@mail.gmail.com> Thanks for the info Tres -- Andrew Burkhalter (from the Seattle User's group) and I have been talking about a joint meeting in Portland and we agree that's the best first option. We're going to gather info from our users to gauge interest, etc. Expect to hear back from us later next week -- if you need to know something sooner, please let us know :) Cheers, Darci On Nov 21, 2007 11:06 AM, Tres Seaver wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Darci Hanning wrote: > > > I think it's fair to say that the Portland Plone User's group could be > very > > interested in having this talk in Portland and we would love to co-meet > with > > the local Python group as well :) I'm going to query Plone group to > confirm. > > Great! > > > Do you have an idea of a minimum amount you're thinking of to help defer > > your total costs? We have a small budget at the moment and no real > income. > > We might be able to do a bit of fundraising if your needs are above our > > current budget but I'd like to have some idea of what you would need > > minimally for this to work for you all :) > > We will definitely be covering airfare to San Francisco and such; we > would likely want help at least for lodging in the location where we do > a presentation. Depending on how the set of groups shake out, we might > be either renting a car to drive up (e.g., to Portland and Seattle) or > flying. > > Hmmm, actually looking at a map, that drive is a little farther than my > fifteen-year-old memory. ~450 miles from San Francisco to Portland, but > only about 100 from Portland to Seattle? That makes flying a lot more > attractive: airfare from SFO to PDX looks to be ~$230 per person. > > > Also, are you planning on going up to Seattle to do the same? I'm asking > > because to be honest our turnout to regular meetings has been rather > low; we > > hope having you folks give this great talk would boost our attendance > (at > > least for that night ;-) So along those lines, another approach would be > to > > encourage Seattle Plonistas to come your talk in Portland -- but if > you're > > planning to be there as well, that's fine too :) Either way, it will > just > > help us with out planning, etc. > > I wrote the Seattle group as well: doing a joint meeting would > obviously be less expensive / stressful, so if that idea appeals to both > groups, we'd be glad to take that route. > > > Let me know and I'll follow-up as soon as I hear back from local users > :-) > > > Tres. > - -- > =================================================================== > Tres Seaver +1 540-429-0999 tseaver at agendaless.com > Agendaless Consulting http://agendaless.com > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFHRIHNFXKVXuSL+CMRAqH5AJ94YHMOT+1ZyrdpeeZ0qpWi4z7TygCgjEfn > io9KOfmDlooYZlJjQ05CsBc= > =p6vh > -----END PGP SIGNATURE----- > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/portland/attachments/20071121/7c685bd0/attachment.htm From kirby.urner at gmail.com Tue Nov 27 05:33:26 2007 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 26 Nov 2007 20:33:26 -0800 Subject: [portland] seeking Unicode case studies Message-ID: As a function of my hospital work, the focus of my presentation last meetup, I'm looking for good examples of web frameworks using Python 3.x's new Unicode capabilities, in combination with a well-endowed browser. Of course a browser needn't look like a browser, per the XUL model and others -- so picture some medical device front end with your name spelled correctly, in its native Cyrillic alphabet. Maybe it's Gecko under the hood, we don't need to know. A prime examples of what I'm looking for would be: geographic equivalents of my all Latin-1 USA quiz, a simple demo of LAMP using Python 2.x for CGI and a MySQL back end. http://www.4dsolutions.net/ocn/geoquiz.html Imagine something similar all in Chinese, Japanese, Thai or Urdu (or...), with everything "how to" well explained. I realize what I'm looking for is still very not prevalent, because Python 3.0 is still in alpha. Plus I realize it's not strictly necessary to be using Python 3.x to be working in Unicode (wxPython has supported it for years). So yeah, somewhat pie in the sky at this point. Anyway, please keep me in mind, throw me a Unicode bone or two if you find one. Related blog post (just recently filed): http://controlroom.blogspot.com/2007/11/unicode.html Kirby 4Dsolutions.net From ray at bme.ogi.edu Tue Nov 27 21:23:05 2007 From: ray at bme.ogi.edu (ray at bme.ogi.edu) Date: Tue, 27 Nov 2007 12:23:05 -0800 Subject: [portland] Seeking opinions on choosing data types: dictionary or instance attributes? Message-ID: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> I'm new to python and the Portland users group and all. Correct me if I'm offtopic or out of line or anything... I'm wondering if you experienced coders have any advice on choosing data types in Python. We're writing a program with a large data structure and I'm wondering when we should use instance attributes vs. when we should use dictionaries. (We'll have some lists when sequence matters) My friend loves dictionaries and says to make every class a dictionary; then instead of any instance attributes, have key value pairs. To me, struct['substruct']['mywidget']['color'] seems more awkward than struct.substruct.mywidget.color but he points out that with dictionaries it's easier to implement code where you ask the user, "What do you want to know about your widget?" and then return struct[2]['substruct']['mywidget']['userRequest']. I don't know yet if we'll ask any such questions. If the class "Widget" only has two attributes, 'color' and 'make' I'm inclined to make them instance attributes. But I really don't know... Any advice or guidelines? Are there any disadvantages to using all these dictionaries? Thank you, Raychel From kirby.urner at gmail.com Tue Nov 27 22:30:44 2007 From: kirby.urner at gmail.com (kirby urner) Date: Tue, 27 Nov 2007 13:30:44 -0800 Subject: [portland] Seeking opinions on choosing data types: dictionary or instance attributes? In-Reply-To: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> References: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> Message-ID: On Nov 27, 2007 12:23 PM, wrote: << SNIP >> > Any advice or guidelines? Are there any disadvantages to using all > these dictionaries? > > Thank you, > Raychel Just off the top, having trouble seeing how multiple instances gets you off the hook from still needing top level collection types, i.e. lists and/or dicts. Another way of looking at the problem is what kind of bulk updates will you be doing. I sure like list comprehensions for readability. It's very possible to have ungainly classes *and* dictionaries i.e. neither design need be any good if there's not enough overall flatness. Remember from 'import this': Flat is better than nested. Kirby From mccredie at gmail.com Tue Nov 27 22:39:09 2007 From: mccredie at gmail.com (Matt McCredie) Date: Tue, 27 Nov 2007 13:39:09 -0800 Subject: [portland] Seeking opinions on choosing data types: dictionary or instance attributes? In-Reply-To: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> References: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> Message-ID: <9e95df10711271339hd9407a6x9db195c057527043@mail.gmail.com> On Nov 27, 2007 12:23 PM, wrote: > I'm new to python and the Portland users group and all. Correct me if > I'm offtopic or out of line or anything... > > I'm wondering if you experienced coders have any advice on choosing > data types in Python. We're writing a program with a large data > structure and I'm wondering when we should use instance attributes vs. > when we should use dictionaries. (We'll have some lists when sequence > matters) My friend loves dictionaries and says to make every class > a dictionary; then instead of any instance attributes, have key value pairs. > > To me, struct['substruct']['mywidget']['color'] seems more awkward than > struct.substruct.mywidget.color but he points out that with > dictionaries it's easier to implement code where you ask the user, > "What do you want to know about your widget?" and then return > struct[2]['substruct']['mywidget']['userRequest']. I don't know yet > if we'll ask any such questions. If the class "Widget" only has two > attributes, 'color' and 'make' I'm inclined to make them instance > attributes. But I really don't know... > > Any advice or guidelines? Are there any disadvantages to using all > these dictionaries? > > Thank you, > Raychel Use classes, that is what they are for. It should be mentioned that dicts are cool, which is why all namespaces in Python are implemented as dicts. That includes class attributes. >>> class C(object): ... def __init__(self, a, b, c): ... self.a = a ... self.b = b ... self.c = c ... >>> c = C(1,2,3) >>> d = C('a','b','c') >>> e = C(0.1, 0.2, 0.3) >>> f = C(c,d,e) >>> f.a.a 1 >>> f.__dict__['a'].__dict__['a'] 1 >>> getattr(getattr(f,'a'),'a') 1 Hopefully the above demonstrates how trivial it is to get an attribute when given the name of the attribute as a string. Matt From adam at therobots.org Tue Nov 27 22:44:53 2007 From: adam at therobots.org (Adam Lowry) Date: Tue, 27 Nov 2007 13:44:53 -0800 Subject: [portland] Seeking opinions on choosing data types: dictionary or instance attributes? In-Reply-To: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> References: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> Message-ID: <00081003-6498-4085-8465-6FD52A8221C1@therobots.org> On Nov 27, 2007, at 12:23 PM, ray at bme.ogi.edu wrote: > and I'm wondering when we should use instance attributes vs. > when we should use dictionaries. (We'll have some lists when sequence > matters) My friend loves dictionaries and says to make every class > a dictionary; then instead of any instance attributes, have key > value pairs. First off, I'd suggest not making the class itself a dict (that is, inheriting from UserDict). In my experience, unless you're really just making a dictionary variant, not a class that uses a dictionary, it'll end being more complicated. Others might disagree, though. One common way is to have classes that contain a dictionary with the values: class MyThingie(object): def __init__(): self.values = then internally you can use the values dict, but you won't have to worry about accidentally changing the behavior of the dict or if another non-dictionary storage starts to look better. But to the original question; I would suggest writing a bit of experimental code using the classes you're working on; that way you can see which code is more readable. Adam From ray at bme.ogi.edu Tue Nov 27 23:43:41 2007 From: ray at bme.ogi.edu (ray at bme.ogi.edu) Date: Tue, 27 Nov 2007 14:43:41 -0800 Subject: [portland] Seeking opinions on choosing data types: dictionary or instance attributes? In-Reply-To: <9e95df10711271339hd9407a6x9db195c057527043@mail.gmail.com> References: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> <9e95df10711271339hd9407a6x9db195c057527043@mail.gmail.com> Message-ID: <20071127144341.rnqbxsi2gwc8ko4g@mail.bme.ogi.edu> > Use classes, that is what they are for. It should be mentioned that > dicts are cool, which is why all namespaces in Python are implemented > as dicts. That includes class attributes. Sorry, I wasn't clear on that. He wants classes, but he wants all the classes to inherit from dictionary. This example is very helpful. Thanks, Matt! >>>> class C(object): > ... def __init__(self, a, b, c): > ... self.a = a > ... self.b = b > ... self.c = c > ... >>>> c = C(1,2,3) >>>> d = C('a','b','c') >>>> e = C(0.1, 0.2, 0.3) >>>> f = C(c,d,e) >>>> f.a.a > 1 >>>> f.__dict__['a'].__dict__['a'] > 1 >>>> getattr(getattr(f,'a'),'a') > 1 > > Hopefully the above demonstrates how trivial it is to get an attribute > when given the name of the attribute as a string. > > Matt > From mack at incise.org Wed Nov 28 06:19:20 2007 From: mack at incise.org (Nick Welch) Date: Tue, 27 Nov 2007 21:19:20 -0800 Subject: [portland] Seeking opinions on choosing data types: dictionary or instance attributes? In-Reply-To: <00081003-6498-4085-8465-6FD52A8221C1@therobots.org> References: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> <00081003-6498-4085-8465-6FD52A8221C1@therobots.org> Message-ID: <20071128051920.GA14971@incise.org> On Tue, Nov 27, 2007 at 01:44:53PM -0800, Adam Lowry wrote: > First off, I'd suggest not making the class itself a dict (that is, > inheriting from UserDict). Isn't UserDict pretty much a relic now, since new-style classes came around and let us inherit directly from dict? On the original topic -- I've personally turned against abusing classes (or __getattr__) simply for the .foo.bar syntax. Dict key access may be a little more punctuationey, but it reminds you that you're dealing with just a plain ol' dictionary, and that always feels nice to me. If your classes are only there to contain some keys and values (and don't have any methods), then I feel that they fall into the category of needless syntactic sugar. If you just need a dict, then.. just use a dict! -- Nick Welch | mack @ incise.org | http://incise.org From jeff at taupro.com Wed Nov 28 13:00:09 2007 From: jeff at taupro.com (Jeff Rush) Date: Wed, 28 Nov 2007 06:00:09 -0600 Subject: [portland] Seeking opinions on choosing data types: dictionary or instance attributes? In-Reply-To: <20071128051920.GA14971@incise.org> References: <20071127122305.2kmph3cbcw884w08@mail.bme.ogi.edu> <00081003-6498-4085-8465-6FD52A8221C1@therobots.org> <20071128051920.GA14971@incise.org> Message-ID: <474D5849.60503@taupro.com> Nick Welch wrote: > > Isn't UserDict pretty much a relic now, since new-style classes came > around and let us inherit directly from dict? Yes, UserDict is obsolete - subclassing from dict gives you more functionality and better performance. > On the original topic -- I've personally turned against abusing classes > (or __getattr__) simply for the .foo.bar syntax. Dict key access may be > a little more punctuationey, but it reminds you that you're dealing with > just a plain ol' dictionary, and that always feels nice to me. If your > classes are only there to contain some keys and values (and don't have > any methods), then I feel that they fall into the category of needless > syntactic sugar. If you just need a dict, then.. just use a dict! One objective factor for choosing between attribute and dictionary access is whether the key names are legal Python identifiers. If they are not, you really want to use a dictionary rather than getattr(), in my opinion. Using attribute access also gives you the option later of refactoring and inserting special handling code. Suppose you have: x.firstname -> "Jeff" x.lastname -> "Rush" and one day you need the fullname. Just add to your container class: @property def fullname(self): return "%s, %s" % (self.lastname, self.firstname) and you have: x.fullname -> "Rush, Jeff" Using a plain dictionary limits your flexibility in the future. -Jeff From kirby.urner at gmail.com Wed Nov 28 17:21:11 2007 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 28 Nov 2007 08:21:11 -0800 Subject: [portland] PPUG speaker proposal Message-ID: Yo Jeff! Could be a code sprint topic, could be a speaker proposal... I've met with the head honcho behind democracylab.org (plus Mark Frischmuth gave us a presentation at Wanderers **). There's lots of MVC stuff going, with no Controller truly seized upon yet (gotta finish sketching the M & V stuff first -- pretty far along, the Vs especially). The end result will be a lot of control panels, like the inside of a cockpit, looking out over some democratic vista of other voters / politicos likewise so equipped. Like this: http://democracylab.org/demo/post1_opinion/evaluation.html There's a dev-list and I've already name dropped SQL Alchemy, but he may not know that's a brand (I forgot to put a [tm] or anything). Kirby ** http://mybizmo.blogspot.com/2007/10/wanderers-20071024.html