From jeffh at dundeemt.com Sat Dec 1 05:50:12 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Fri, 30 Nov 2007 22:50:12 -0600 Subject: [omaha] Fwd: Omaha post from academicedgar@gmail.com requires approval In-Reply-To: References: Message-ID: <5aaed53f0711302050r6f743dq6672829ca53e0448@mail.gmail.com> Burch, seems that you discarded your message as I went to approve it but it wasn't there anymore. Say that your data is in a file 'data.txt' , then to process that file in to memory you could do something like: thedata = [] # a list to hold the records for line in file('data.txt'): line = line.strip() #remove the newline char rec = line.split('|') #split at '|' chars, returning a #list ['1000045','NICHOLAS FINANCIAL INC','10-Q','2007-02-14','edgar...'] as a record thedata.append(rec) # at this point thedata is a list of records(lists), let's iterate through it for rec in thedata: print rec If you have a giant file to process you don't have to read it all into memory to begin with, you could just process a record at a time. The snippet you have does the same, but doesn't exploit python's strengths. The 'for line in file():' idiom is very pythonic. As it is very readable. I could combine some things to make it smaller, but it would make it less readable. I hope this answers your question and please feel free to join the email list. -Jeff ---------- Forwarded message ---------- From: "Burch Kealey" To: omaha at python.org Date: Fri, 30 Nov 2007 16:41:42 -0600 Subject: Help I am a long-time SAS programmer. One of the reasons I have joined this group is a desire to branch out to a new, hopefully more versatile language. I am struggling to get my head around how the language is structured. After trying to plow through a number of books I have finally taken the plunge and am starting to try to find ways to do things in PYTHON that I have been doing in SAS. I am still trying to get over the basics and need some help. However, if you read this question and think that this is not the forum for these types of questions then I would appreciate any indication of the appropriate forum. Thanks Burch Here is an example of some raw data I am trying to input 1000045|NICHOLAS FINANCIAL INC|10-Q|2007-02-14|edgar/data/1000045/0001193125-07-031642.txt 1000045|NICHOLAS FINANCIAL INC|4|2007-01-18|edgar/data/1000045/0001144204- 07-002274.txt 1000045|NICHOLAS FINANCIAL INC|8-K|2007-01-29|edgar/data/1000045/0001193125-07-015318.txt 1000045|NICHOLAS FINANCIAL INC|SC 13G/A|2007-02-14|edgar/data/1000045/0000950134-07-003261.txt 1000045|NICHOLAS FINANCIAL INC|SC 13G|2007-02-14|edgar/data/1000045/0000315066- 07-002043.txt 1000045|NICHOLAS FINANCIAL INC|SC 13G|2007-02-21|edgar/data/1000045/0000950135-07-000971.txt 1000069|EMPIRIC FUNDS, INC|497|2007-01-31|edgar/data/1000069/0000894189-07-000334.txt 1000069|EMPIRIC FUNDS, INC|N-Q|2007-02-22|edgar/data/1000069/0000894189- 07-000461.txt 1000069|TEXAS CAPITAL VALUE FUNDS INC|485BPOS|2007-01-26|edgar/data/1000069/0000894189-07-000234.txt I need to read the file and use the values as inputs to some later tasks. The | is a delimitter. One of the things I think I want to do is specific items from the list. I can make it happen to an output file but after two days of trying (say ten hours total) I can't create a list in memory of just one of the items. Here is the code that will create what I need in a flat file: import os y=file('c:/newout4.txt','w') x=file('C:/2007/QTR1/master.idx',"r") obsname=[line.strip() for line in x.readlines()] x3=[i.split('|',5) for i in obsname] for thing in x3: y.write('%s%s' % (thing[0],os.linesep)) y.close() Here is one of my many attempts to create a list in memory import os x=file('C:/2007/QTR1/master.idx',"r") obsname=[line.strip() for line in x.readlines()] x3=[i.split('|',5) for i in obsname] for thing in x3: cik=[thing[0]] Any suggestions? Cheers Burch ---------- Forwarded message ---------- From: omaha-request at python.org To: Date: Subject: confirm 6f1d1eccfaea12b908759381f0510a7e2756cc45 If you reply to this message, keeping the Subject: header intact, Mailman will discard the held message. Do this if the message is spam. If you reply to this message and include an Approved: header with the list password in it, the message will be approved for posting to the list. The Approved: header can also appear in the first line of the body of the reply. -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Sat Dec 1 05:56:50 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Fri, 30 Nov 2007 22:56:50 -0600 Subject: [omaha] Fwd: [Chicago] constant length string manipulation In-Reply-To: <3096c19d0711300752i6a2b7bb6o68925dae2a3d191a@mail.gmail.com> References: <804e5c70711291306rb3faf64wdb6a6ae521abf133@mail.gmail.com> <804e5c70711291321s489888dbj9415b4411300643d@mail.gmail.com> <3096c19d0711300752i6a2b7bb6o68925dae2a3d191a@mail.gmail.com> Message-ID: <5aaed53f0711302056w471ee58bx3b3f9d719efab333@mail.gmail.com> Ok, now this is funny. For the past two days this thread about returning a len 5 string has been going on the Chicago user group list. Everyone creating a more boneheaded obfuscated method to do it, even Ian Bicking wrote some off the cuff C extension for python to do it at blazing fast speeds. (The original posters question had been answered in the first response, but the conversation since then this thread is the closest thing to a monty python skit I've read in a while) ---------- Forwarded message ---------- From: Chris McAvoy Date: Nov 30, 2007 9:52 AM Subject: Re: [Chicago] constant length string manipulation To: The Chicago Python Users Group On Nov 29, 2007 3:21 PM, Lukasz Szybalski wrote: > On Nov 29, 2007 3:06 PM, Lukasz Szybalski wrote: > > Hello, > > Is there a string function in python that does the following: > > I need a string of length 5 char, and I will pass a longer and shorter > > string but I always need to get string of length 5. > > If my string is longer its easy: This task is stupid. You should only address the "string is longer" issue, use cut (see 'man cut' if you need help), and then tell whomever is asking you to do this that it can't be done. (wipes hands, beams triumphantly) I win. Otherwise, if they insist that the "edge case" of a string shorter than five characters needs to be lengthened (do those even exist???) insist that their inflexibility is hurting the agility of your team, and demand that they find budget to hire an intern. Also, pad your estimate with acronyms, like TDD and BUTT. If they continue to give you flak, cough and say "anassholesayswhat." When they say, "what?" Laugh. Maybe try writing this in Rails. I'm pretty sure they have a template tag that says ""some string of unfathomable length".shorten_this_if_its_greater_than_five_characters_but_if_its_less_make_it_longer Notice that you don't have to import that (agile!) and you don't have to use parens (agile!). If they won't let you write it in Rails, quit. Maybe Erlang can handle this? I'm pretty sure conditional lengthening / shortening of strings is something that Functional languages do better than procedural languages. Paul Graham wrote an article about it in 1992, right before he created Ebay in Lisp. Do you use a Mac? You should. Because the Mac takes care of Strings. Automagically. Chris _______________________________________________ Chicago mailing list Chicago at python.org http://mail.python.org/mailman/listinfo/chicago -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jay at jays.net Sat Dec 1 15:26:36 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 1 Dec 2007 08:26:36 -0600 Subject: [omaha] Tutorial: integer division Message-ID: <678BEDC5-A476-4BF6-B926-CBC37AF916E4@jays.net> This surprised me: http://docs.python.org/tut/node5.html >>> # Integer division returns the floor: ... 7/3 2 So I tried my own: >>> x = 7 >>> y = 3 >>> x / y 2 This strikes me as very counter-intuitive... How do you avoid getting burned by this? Forcing a decimal point into the mix does what I expect: >>> x = 7.0 >>> y = 3 >>> x / y 2.3333333333333335 But how do I systematically enforce floating point division into my applications? Thanks, j didn't even mention Perl. Aren't you proud of me? -grin- From jeffh at dundeemt.com Sat Dec 1 16:52:11 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sat, 1 Dec 2007 09:52:11 -0600 Subject: [omaha] This is the message I tried to send/post this morning In-Reply-To: References: Message-ID: <5aaed53f0712010752l1fcde5c9qceca253dc01da332@mail.gmail.com> Burch, First off, I'm not sure what is happening to your messages. I've told mailman to forward me any email that it would have discarded so I can figure out what is going on. I'll get this resolved as quickly as possible. Now back to your original question, so if I'm understanding you want to create a list of fld2 entries. The first thing to clarify is that lists are 0 based. so if you want (referring to the first rec in your example) the "NICHOLAS FINANCIAL INC" that would be rec[1], if you wanted the "10-Q" it would be rec[2] so continuing on with my example code, sublist = [] for rec in thedata: sublist.append(rec[1]) #now sublist is a list of values and thedata is still the original list of lists #['"NICHOLAS FINANCIAL INC','NICHOLAS FINANCIAL INC',...] A list comprehension could be used as well, it would look like: sublist = [rec[1] for rec in thedata] I think the first example is more clear when you are new to python. Both return the same sublist. For more on lists and list comprehensions see http://docs.python.org/tut/node7.html 5.1.4 List Comprehensions. The python tutorial section is pretty good but I normally recommend Dive in to Python http://www.diveintopython.org/toc/index.html as one of the best on-line resources for python. Now if you want a sublist of complete records when it is a '10-Q' record you would use filtering sublist = [rec for rec in thedata if rec[2] == '10-Q'] Now sublist is a list of 10-Q records, which from your example data would have 1 element. You can replace the rec[2] == '10-Q' test with any test or user defined function that returns a True/False value. sublist = [rec for rec in thedata if rec[2] == '10-Q'] is equivalent to sublist = [] for rec in thedata: if rec[2] == '10-Q': sublist.append(rec[1]) Because I'm simple minded I would initially write my code in the looping structure I just showed and then re-factor using the list comprehension later. I consider it a speed optimization. Not to go into detail but the comprehension is more efficient internally something I don't worry about except in extreme cases. (I believe you should always optimize for readability first.) On Dec 1, 2007 8:45 AM, Burch Kealey wrote: > > Burch T. Kealey, PhD. > RH-CBA 408-N > University of Nebraska at Omaha > 6000 Dodge Street > Omaha Nebraska 68104 > > 402-554-3571 > > This message (including any attachments) contains confidential information > intended for a specific individual and purpose, and is protected by law. If > you are not the intended recipient, you should delete this message. Any > disclosure, copying, or distribution of this message, or the taking of any > action based on it, is strictly prohibited. > > -----Forwarded by Burch Kealey/FACSTAFF/UNO/UNEBR on 12/01/2007 08:45AM > ----- > > To: Omaha Python Users Group > From: Burch Kealey/FACSTAFF/UNO/UNEBR > Date: 12/01/2007 07:57AM > Subject: Re: [omaha] Fwd: Omaha post from academicedgar at gmail.com requires > approval > > > Hi Jeff > > Thanks for your reply. After I saw the bounce message I realized I had sent > it from the wrong account but for some reason-I am not sure messages from > this account are getting through as I sent it again but it has never shown > back up in my in box. > > I think from reading your code I am just getting back my original input file > as a list of lists-the input file is now a list and each line has been > transformed into a list. My inelegant solution gets me there (x3 is a list > of lists] My ultimate goal though is to pull fields from the records. One > of the things I see myself doing is creating logic based on values of > particular fields in each record. In the simple case I would want to create > a new list with just say the first (or second . . .) field from each record. > So how do I selectively subset items in the x3 list say I want all i in > x3[i][2]-I think that is all rows in x3, field 2? > > Cheers > > Burch > > > > -----omaha-bounces at python.org wrote: ----- > > To: "Omaha Python Users Group" > From: "Jeff Hinrichs - DM&T" > Sent by: omaha-bounces at python.org > Date: 11/30/2007 10:50PM > cc: academicedgar at gmail.com > Subject: [omaha] Fwd: Omaha post from academicedgar at gmail.com requires > approval > > Burch, > seems that you discarded your message as I went to approve it but it > wasn't there anymore. > > Say that your data is in a file 'data.txt' , then to process that file > in to memory you could do something like: > > thedata = [] # a list to hold the records > for line in file('data.txt'): > line = line.strip() #remove the newline char > rec = line.split('|') #split at '|' chars, returning a > #list ['1000045','NICHOLAS > FINANCIAL INC','10-Q','2007-02-14','edgar...'] as a record > thedata.append(rec) > > # at this point thedata is a list of records(lists), let's iterate through > it > > for rec in thedata: > print rec > > > If you have a giant file to process you don't have to read it all into > memory to begin with, you could just process a record at a time. The > snippet you have does the same, but doesn't exploit python's > strengths. The 'for line in file():' idiom is very pythonic. As it > is very readable. I could combine some things to make it smaller, but > it would make it less readable. > > > I hope this answers your question and please feel free to join the email > list. > > -Jeff > > > ---------- Forwarded message ---------- > From: "Burch Kealey" > To: omaha at python.org > Date: Fri, 30 Nov 2007 16:41:42 -0600 > Subject: Help > I am a long-time SAS programmer. One of the reasons I have joined > this group is a desire to branch out to a new, hopefully more > versatile language. I am struggling to get my head around how the > language is structured. After trying to plow through a number of > books I have finally taken the plunge and am starting to try to find > ways to do things in PYTHON that I have been doing in SAS. I am still > trying to get over the basics and need some help. However, if you > read this question and think that this is not the forum for these > types of questions then I would appreciate any indication of the > appropriate forum. > > Thanks > > Burch > > Here is an example of some raw data I am trying to input > 1000045|NICHOLAS FINANCIAL > INC|10-Q|2007-02-14|edgar/data/1000045/0001193125-07-031642.txt > 1000045|NICHOLAS FINANCIAL > INC|4|2007-01-18|edgar/data/1000045/0001144204- 07-002274.txt > 1000045|NICHOLAS FINANCIAL > INC|8-K|2007-01-29|edgar/data/1000045/0001193125-07-015318.txt > 1000045|NICHOLAS FINANCIAL INC|SC > 13G/A|2007-02-14|edgar/data/1000045/0000950134-07-003261.txt > 1000045|NICHOLAS FINANCIAL INC|SC > 13G|2007-02-14|edgar/data/1000045/0000315066- 07-002043.txt > 1000045|NICHOLAS FINANCIAL INC|SC > 13G|2007-02-21|edgar/data/1000045/0000950135-07-000971.txt > 1000069|EMPIRIC FUNDS, > INC|497|2007-01-31|edgar/data/1000069/0000894189-07-000334.txt > 1000069|EMPIRIC FUNDS, > INC|N-Q|2007-02-22|edgar/data/1000069/0000894189- 07-000461.txt > 1000069|TEXAS CAPITAL VALUE FUNDS > INC|485BPOS|2007-01-26|edgar/data/1000069/0000894189-07-000234.txt > > > I need to read the file and use the values as inputs to some later > tasks. The | is a delimitter. One of the things I think I want to do > is specific items from the list. I can make it happen to an output > file but after two days of trying (say ten hours total) I can't create > a list in memory of just one of the items. > > Here is the code that will create what I need in a flat file: > import os > y=file('c:/newout4.txt','w') > x=file('C:/2007/QTR1/master.idx',"r") > obsname=[line.strip() for line in x.readlines()] > x3=[i.split('|',5) for i in obsname] > for thing in x3: > y.write('%s%s' % (thing[0],os.linesep)) > y.close() > > Here is one of my many attempts to create a list in memory > import os > x=file('C:/2007/QTR1/master.idx',"r") > obsname=[line.strip() for line in x.readlines()] > x3=[i.split('|',5) for i in obsname] > for thing in x3: > cik=[thing[0]] > > Any suggestions? > > Cheers > > Burch > > > > ---------- Forwarded message ---------- > From: omaha-request at python.org > To: > Date: > Subject: confirm 6f1d1eccfaea12b908759381f0510a7e2756cc45 > If you reply to this message, keeping the Subject: header intact, > Mailman will discard the held message. Do this if the message is > spam. If you reply to this message and include an Approved: header > with the list password in it, the message will be approved for posting > to the list. The Approved: header can also appear in the first line > of the body of the reply. > > > > -- > Jeff Hinrichs > Dundee Media & Technology, Inc > jeffh at dundeemt.com > 402.218.1473 > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > > > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jay at jays.net Sat Dec 1 17:01:24 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 1 Dec 2007 10:01:24 -0600 Subject: [omaha] Tutorial: Keyword Arguments Message-ID: <68C7282E-8299-46E8-9FCA-2D82E5698983@jays.net> I like Python's keyword argument system... :) http://docs.python.org/tut/node6.html#SECTION006720000000000000000 Clean and powerful. Does the colon that starts every simple block have a purpose? (Isn't the mandatory indenting sufficient to tell the interpreter what it needs to know?) j $ cat j.py def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'): print "-- This parrot wouldn't", action, print "if you put", voltage, "volts through it." print "-- Lovely plumage, the", type print "-- It's", state, "!" parrot(1000) print parrot(action = 'VOOOOOM', voltage = 1000000) print parrot('a thousand', state = 'pushing up the daisies') print parrot('a million', 'bereft of life', 'jump') From luke at dashjr.org Sat Dec 1 17:06:58 2007 From: luke at dashjr.org (Luke -Jr) Date: Sat, 1 Dec 2007 10:06:58 -0600 Subject: [omaha] Tutorial: Keyword Arguments In-Reply-To: <68C7282E-8299-46E8-9FCA-2D82E5698983@jays.net> References: <68C7282E-8299-46E8-9FCA-2D82E5698983@jays.net> Message-ID: <200712011006.58843.luke@dashjr.org> On Saturday 01 December 2007, Jay Hannah wrote: > Does the colon that starts every simple block have a purpose? (Isn't > the mandatory indenting sufficient to tell the interpreter what it > needs to know?) It's not mandatory if you do if a: b() From jeffh at dundeemt.com Sat Dec 1 17:27:20 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sat, 1 Dec 2007 10:27:20 -0600 Subject: [omaha] Tutorial: integer division In-Reply-To: <678BEDC5-A476-4BF6-B926-CBC37AF916E4@jays.net> References: <678BEDC5-A476-4BF6-B926-CBC37AF916E4@jays.net> Message-ID: <5aaed53f0712010827ne78be0cma8d9c4f1225b13d6@mail.gmail.com> You are correct that it is a problem and one that is going to be changed in the future. Currently 2.5.x and previous all division defaulted to integer division, you had to make at least one number a floating point. You can change the current behavior and jump in to the future by using the __future__ module (not kidding) . Here is an example: jlh at jlh-d520:~$ python Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 2/3 0 >>> 2/3.0 0.66666666666666663 >>> from __future__ import division >>> 2/3 0.66666666666666663 >>> 2//3 0 >>> You will notice that the division from __future__ defaults to the more commonly used definition of '/' and if you want the old style integer division you would use // The __future__ module (note the double underscores on both sides) contains those approved and upcoming changes. It provides a way to test current code against upcoming changes and take advantage of new features before they are made part of the core. see >>> import __future__ >>> help(__future__) for more details -jeff On Dec 1, 2007 8:26 AM, Jay Hannah wrote: > This surprised me: > > http://docs.python.org/tut/node5.html > > >>> # Integer division returns the floor: > ... 7/3 > 2 > > So I tried my own: > > >>> x = 7 > >>> y = 3 > >>> x / y > 2 > > This strikes me as very counter-intuitive... How do you avoid getting > burned by this? > > Forcing a decimal point into the mix does what I expect: > > >>> x = 7.0 > >>> y = 3 > >>> x / y > 2.3333333333333335 > > But how do I systematically enforce floating point division into my > applications? > > Thanks, > > j > didn't even mention Perl. Aren't you proud of me? -grin- > > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jay at jays.net Sat Dec 1 17:32:33 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 1 Dec 2007 10:32:33 -0600 Subject: [omaha] Tutorial: Keyword Arguments In-Reply-To: <200712011006.58843.luke@dashjr.org> References: <68C7282E-8299-46E8-9FCA-2D82E5698983@jays.net> <200712011006.58843.luke@dashjr.org> Message-ID: <44C15697-4478-40C4-BA30-4117CC64423F@jays.net> On Dec 1, 2007, at 10:06 AM, Luke -Jr wrote: > On Saturday 01 December 2007, Jay Hannah wrote: >> Does the colon that starts every simple block have a purpose? (Isn't >> the mandatory indenting sufficient to tell the interpreter what it >> needs to know?) > > It's not mandatory if you do > if a: b() Can you do additional steps beyond b() somehow? Thanks, j From bkealey at mail.unomaha.edu Sat Dec 1 17:34:46 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Sat, 1 Dec 2007 10:34:46 -0600 Subject: [omaha] Response In-Reply-To: References: <5aaed53f0712010816u679ae1a8nee9ca32851585345@mail.gmail.com>, Message-ID: Okay-another message-notice that the default signature is back in. Burch T. Kealey, PhD. RH-CBA 408-N University of Nebraska at Omaha 6000 Dodge Street Omaha Nebraska 68104 402-554-3571 This message (including any attachments) contains confidential informa tion intended for a specific individual and purpose, and is protected by la w. If you are not the intended recipient, you should delete this message. A ny disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. From jeffh at dundeemt.com Sat Dec 1 17:38:45 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sat, 1 Dec 2007 10:38:45 -0600 Subject: [omaha] Tutorial: Keyword Arguments In-Reply-To: <44C15697-4478-40C4-BA30-4117CC64423F@jays.net> References: <68C7282E-8299-46E8-9FCA-2D82E5698983@jays.net> <200712011006.58843.luke@dashjr.org> <44C15697-4478-40C4-BA30-4117CC64423F@jays.net> Message-ID: <5aaed53f0712010838r19ecc6c3v6ac7f89988391454@mail.gmail.com> because the language rules allow things like this: def parrot( voltage, state='a stiff', action='voom', type='NorwegianBlue'): print "-- This parrot wouldn't", action, print "if you put", voltage, "volts through it." print "-- Lovely plumage, the", type print "-- It's", state, "!" Now you may be correct that you could infer without it, I've never seen a discussion that talks about dropping the colon. However, I would bet that GvR has considered it and decided that it is problematic without it. However, the colon is a part of the language definition. On Dec 1, 2007 10:32 AM, Jay Hannah wrote: > On Dec 1, 2007, at 10:06 AM, Luke -Jr wrote: > > On Saturday 01 December 2007, Jay Hannah wrote: > >> Does the colon that starts every simple block have a purpose? (Isn't > >> the mandatory indenting sufficient to tell the interpreter what it > >> needs to know?) > > > > It's not mandatory if you do > > if a: b() > > Can you do additional steps beyond b() somehow? > > Thanks, > > > j > > > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Sat Dec 1 17:43:12 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sat, 1 Dec 2007 10:43:12 -0600 Subject: [omaha] Response In-Reply-To: References: <5aaed53f0712010816u679ae1a8nee9ca32851585345@mail.gmail.com> Message-ID: <5aaed53f0712010843n101faa75nf74eee564f045050@mail.gmail.com> Ok, that made it. I see it in the archives. I disabled the mime/type filter. -jeff On Dec 1, 2007 10:21 AM, Burch Kealey wrote: > This is a message w/o the confidentiality clause > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From bkealey at mail.unomaha.edu Sat Dec 1 18:27:18 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Sat, 1 Dec 2007 11:27:18 -0600 Subject: [omaha] This is the message I tried to send/post this morning Message-ID: sublist = [] for rec in thedata: sublist.append(rec[1]) Actually-this does not work-I am getting an index out of range error. When I change the subscript to 0 as in sublist.append(rec[0]) it works, I get the first item from each item in the list. when the subscript is anything but 0 I get an error message. Burch T. Kealey, PhD. RH-CBA 408-N University of Nebraska at Omaha 6000 Dodge Street Omaha Nebraska 68104 402-554-3571 This message (including any attachments) contains confidential informa tion intended for a specific individual and purpose, and is protected by la w. If you are not the intended recipient, you should delete this message. A ny disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. From bkealey at mail.unomaha.edu Sat Dec 1 18:50:07 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Sat, 1 Dec 2007 11:50:07 -0600 Subject: [omaha] This is the message I tried to send/post this morning In-Reply-To: References: Message-ID: I am thinking I have to create some sort of iterator to move through the first subscript I had tried various forms of list comprehension and things like append in my many failed attempts. I was sure that I could just say something like for each in data: field1=[data[1]] I assumed that by referencing each I was handling the record number (equivalent) and field1 is created as a list of single item lists The solution that you proposed is similar-it presumes the record number is handled by iterating through rec. Why this works for [0] and not any other value?? -----omaha-bounces at python.org wrote: ----- To: [1]omaha at python.org From: Burch Kealey [2] Sent by: [3]omaha-bounces at python.org Date: 12/01/2007 11:27AM Subject: Re: [omaha] This is the message I tried to send/post this morning sublist = [] for rec in thedata: sublist.append(rec[1]) Actually-this does not work-I am getting an index out of range error. When I change the subscript to 0 as in sublist.append(rec[0]) it works, I get the first item from each item in the list. when the subscript is anything but 0 I get an error message. References 1. mailto:omaha at python.org 2. mailto:bkealey at mail.unomaha.edu 3. mailto:omaha-bounces at python.org From jeffh at dundeemt.com Sat Dec 1 19:16:26 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sat, 1 Dec 2007 12:16:26 -0600 Subject: [omaha] This is the message I tried to send/post this morning In-Reply-To: References: Message-ID: <5aaed53f0712011016j88e7433h8c3d4e009fbb6870@mail.gmail.com> On Dec 1, 2007 11:50 AM, Burch Kealey wrote: > > I am thinking I have to create some sort of iterator to move through > the first subscript I had tried various forms of list comprehension > and things like append in my many failed attempts. I was sure that I > could just say something like > for each in data: > field1=[data[1]] field1 will always return a list containing a single item, you keep rewriting it with the last value. Here is what is happening >>> f=['a'] >>> f=['b'] >>> f ['b'] I'm attaching demo script and a mock data file to illustrate what I was writing about. Note that my demo script uses the pretty print module to make looking at the structures more palatable than plain print statements. -jeff > I assumed that by referencing each I was handling the record number > (equivalent) and field1 is created as a list of single item lists > The solution that you proposed is similar-it presumes the record > number is handled by iterating through rec. Why this works for [0] > and not any other value?? > -----omaha-bounces at python.org wrote: ----- > > To: [1]omaha at python.org > From: Burch Kealey [2] > Sent by: [3]omaha-bounces at python.org > Date: 12/01/2007 11:27AM > Subject: Re: [omaha] This is the message I tried to send/post this > morning > sublist = [] > for rec in thedata: > sublist.append(rec[1]) > Actually-this does not work-I am getting an index out of range > error. > When I change the subscript to 0 as in sublist.append(rec[0]) it > works, I get the first item from each item in the list. when > the > subscript is anything but 0 I get an error message. > > References > > 1. mailto:omaha at python.org > 2. mailto:bkealey at mail.unomaha.edu > 3. mailto:omaha-bounces at python.org > > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: data.txt Url: http://mail.python.org/pipermail/omaha/attachments/20071201/5023e7a4/attachment.txt -------------- next part -------------- A non-text attachment was scrubbed... Name: junk.py Type: text/x-python Size: 596 bytes Desc: not available Url : http://mail.python.org/pipermail/omaha/attachments/20071201/5023e7a4/attachment.py From luke at dashjr.org Sat Dec 1 18:34:30 2007 From: luke at dashjr.org (Luke -Jr) Date: Sat, 1 Dec 2007 11:34:30 -0600 Subject: [omaha] Response In-Reply-To: References: Message-ID: <200712011134.31539.luke@dashjr.org> That signature prohibits the ML from distributing it to the list members. On Saturday 01 December 2007, Burch Kealey wrote: > Okay-another message-notice that the default signature is back in. > Burch T. Kealey, PhD. > RH-CBA 408-N > University of Nebraska at Omaha > 6000 Dodge Street > Omaha Nebraska 68104 > 402-554-3571 > This message (including any attachments) contains confidential informa > tion > intended for a specific individual and purpose, and is protected by la > w. If > you are not the intended recipient, you should delete this message. A > ny > disclosure, copying, or distribution of this message, or the taking of > any > action based on it, is strictly prohibited. > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org From jay at jays.net Sat Dec 1 20:55:47 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 1 Dec 2007 13:55:47 -0600 Subject: [omaha] Tutorial: integer division In-Reply-To: <5aaed53f0712010827ne78be0cma8d9c4f1225b13d6@mail.gmail.com> References: <678BEDC5-A476-4BF6-B926-CBC37AF916E4@jays.net> <5aaed53f0712010827ne78be0cma8d9c4f1225b13d6@mail.gmail.com> Message-ID: <8B772C65-7D2B-4CAE-8BD3-FABE674CAB5A@jays.net> On Dec 1, 2007, at 10:27 AM, Jeff Hinrichs - DM&T wrote: > You can change the current behavior and jump in to > the future by using the __future__ module (not kidding) . Wow... Thanks! More than anyone ever wanted to know: http://www.python.org/dev/peps/pep-0238/ So I guess this change has been flagged for future release since 2001... For release in Python 3, which is not scheduled. j Many good ideas from Perl 6 (whose release is not scheduled) are being stolen and incorporated into Perl 5, changing the language definition... :) Python There should be one -- and preferably only one -- obvious way to do it. http://www.python.org/dev/culture.html Perl There is more than one way to do it. http://c2.com/cgi/wiki?ThereIsMoreThanOneWayToDoIt (There are way too many ways to do it?) Others http://www.shlomifish.org/humour/ways_to_do_it.html From jay at jays.net Sat Dec 1 20:56:11 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 1 Dec 2007 13:56:11 -0600 Subject: [omaha] Tutorial: Keyword Arguments In-Reply-To: <5aaed53f0712010838r19ecc6c3v6ac7f89988391454@mail.gmail.com> References: <68C7282E-8299-46E8-9FCA-2D82E5698983@jays.net> <200712011006.58843.luke@dashjr.org> <44C15697-4478-40C4-BA30-4117CC64423F@jays.net> <5aaed53f0712010838r19ecc6c3v6ac7f89988391454@mail.gmail.com> Message-ID: <9A1F1F54-3255-48B8-AA82-B533CBA28EA5@jays.net> On Dec 1, 2007, at 10:38 AM, Jeff Hinrichs - DM&T wrote: > because the language rules allow things like this: > > def parrot( voltage, > state='a stiff', > action='voom', > type='NorwegianBlue'): Ahh... parameter indention. Gotcha. Ya, that colon might be important then. I'm not used to any mandatory rules regarding indention. :) Thanks, j From jeffh at dundeemt.com Sat Dec 1 22:04:41 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sat, 1 Dec 2007 15:04:41 -0600 Subject: [omaha] Response In-Reply-To: <200712011134.31539.luke@dashjr.org> References: <200712011134.31539.luke@dashjr.org> Message-ID: <5aaed53f0712011304k1a700ff2o1296f037a51d3533@mail.gmail.com> On Dec 1, 2007 11:34 AM, Luke -Jr wrote: > That signature prohibits the ML from distributing it to the list members. > That's what I thought at first, so he sent an email that didn't have it and mailman still filtered it. I had to stop it from filtering email mime/types -- if that proves problematic, I'll turn it back on. But that appears to have fixed the situation. But then again, my expertise with mailman could be measured with a thimble. ;) -j From bkealey at mail.unomaha.edu Sat Dec 1 22:32:48 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Sat, 1 Dec 2007 15:32:48 -0600 Subject: [omaha] This is the message I tried to send/post this morning In-Reply-To: <5aaed53f0712011016j88e7433h8c3d4e009fbb6870@mail.gmail.com> References: , <5aaed53f0712011016j88e7433h8c3d4e009fbb6870@mail.gmail.com> Message-ID: Thanks-It was a silly and obvious mistake. When you sent the same code back a second time I decided to think about my data file versus the extract I sent you. The first 11 obs in my data file are a single 'item' (basically header information). Once I dumped them your code worked like a charm. A few of my less elegant solutions worked also. Thanks for your patience and interest. Burch From jeffh at dundeemt.com Sun Dec 2 01:30:49 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sat, 1 Dec 2007 18:30:49 -0600 Subject: [omaha] This is the message I tried to send/post this morning In-Reply-To: References: <5aaed53f0712011016j88e7433h8c3d4e009fbb6870@mail.gmail.com> Message-ID: <5aaed53f0712011630y152a8b7fq544bb7c7a690b347@mail.gmail.com> Glad to hear things worked out, I had faith that they would. Depending on your needs, sqlite comes standard with python 2.4+. Depending on your data set size and needs it might be helpful. I've been playing around with the netflix prize data set and I've learned quite a bit from it. I do lots of processing on files with 10's and 100's of thousands of records, but the netflix set comes in at just over 100M records. lot's of the normal idioms just don't scale at that size. Let's just say that 100M recs in a sqlite file is not an optimal usage scenario ;) -j On Dec 1, 2007 3:32 PM, Burch Kealey wrote: > > Thanks-It was a silly and obvious mistake. When you sent the same > code back a second time I decided to think about my data file > versus the extract I sent you. The first 11 obs in my data file are a > single 'item' (basically header information). Once I dumped them your > code worked like a charm. A few of my less elegant solutions worked > also. Thanks for your patience and interest. > Burch > > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From elicriffield at gmail.com Mon Dec 3 04:32:04 2007 From: elicriffield at gmail.com (Eli Criffield) Date: Sun, 2 Dec 2007 21:32:04 -0600 Subject: [omaha] Tutorial: integer division In-Reply-To: <678BEDC5-A476-4BF6-B926-CBC37AF916E4@jays.net> References: <678BEDC5-A476-4BF6-B926-CBC37AF916E4@jays.net> Message-ID: <18e3f33d0712021932s73c81883w986f0f866721e8f5@mail.gmail.com> you can also typecast any of the values to a float. >> x = 7 >> y = 3 >> x / float(y) > 2.3333333333333335 From jeffh at dundeemt.com Tue Dec 4 04:56:48 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Mon, 3 Dec 2007 21:56:48 -0600 Subject: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting Message-ID: <5aaed53f0712031956l3ce3c545t8968eac89101216d@mail.gmail.com> Well the first Wednesday of the month is fast approaching. Currently I don't have a commitment for a room at PKI. I'm not quite sure what happened or hasn't. I am hoping to hear something from our faculty sponsor but we might not in time for the meeting this month. Along those lines, We have been meeting at Clancy's on 72nd and Pacific. The food is good, but the noise levels have been high and I've got word that an X-mas party will be in swing Wednesday night. So I am changing the meeting location to Godfather's on 75th and Pacific (7515 Pacific to be exact -- right next to Spirit World) I'm expecting that the noise levels will be dramatically lower and it will be easier to hear one another. I look forward to seeing all of you there @ 7pm. -Jeff -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Wed Dec 5 07:24:34 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 5 Dec 2007 00:24:34 -0600 Subject: [omaha] xkcd on Python Message-ID: <5aaed53f0712042224w5b7b0d95u3d8ca6a5f571f125@mail.gmail.com> http://imgs.xkcd.com/comics/python.png "Better than everything in the medicine cabinet" --jeff From bkealey at mail.unomaha.edu Wed Dec 5 16:20:18 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Wed, 5 Dec 2007 09:20:18 -0600 Subject: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting In-Reply-To: <5aaed53f0712031956l3ce3c545t8968eac89101216d@mail.gmail.com> Message-ID: I took it upon myself to investigate the options for having meetings here on campus. We can have meetings iin the College of Business and I have made arrangements for us to use the Innovation Lab first, but if there is a class need for the room on one of our meeting dates I have a back-up conference room we can use. I still need to research parking and will have an answer tonight. If you prefer to meet at PKI that is fine, but this will be an option. Cheers Burch From JeffH at delasco.com Wed Dec 5 18:09:19 2007 From: JeffH at delasco.com (Jeff Hinrichs) Date: Wed, 5 Dec 2007 11:09:19 -0600 Subject: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting In-Reply-To: Message-ID: <94BC3D204A17734681830A69CBF99993DF7DE3@lilo.delasco.pri> Burch, I would think that would be a great thing. -Jeff -----Original Message----- From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On Behalf Of Burch Kealey Sent: Wednesday, December 05, 2007 9:20 AM To: Omaha Python Users Group Subject: Re: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting I took it upon myself to investigate the options for having meetings here on campus. We can have meetings iin the College of Business and I have made arrangements for us to use the Innovation Lab first, but if there is a class need for the room on one of our meeting dates I have a back-up conference room we can use. I still need to research parking and will have an answer tonight. If you prefer to meet at PKI that is fine, but this will be an option. Cheers Burch _______________________________________________ Omaha Python Users Group mailing list Omaha at python.org http://mail.python.org/mailman/listinfo/omaha http://www.OmahaPython.org From jay at jays.net Wed Dec 5 20:52:41 2007 From: jay at jays.net (Jay Hannah) Date: Wed, 05 Dec 2007 13:52:41 -0600 Subject: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting In-Reply-To: References: Message-ID: <47570189.1080300@jays.net> Burch Kealey wrote: > I took it upon myself to investigate the options for having meetings here > on campus. Yay! Whatever works. :) Incidentally: Last night at the Dynamic Language Users Group the leader (Blaine Buxton) said that their PKI faculty sponsor is Matt Payne. http://www.ist.unomaha.edu/index.php?p=directory&category=Faculty Matt hasn't attended any of the meetings as far as I know. If all else fails and you don't want me to strong arm John (or 3 other faculty I could pounce on, or try to sponsor myself (I'm on staff)) you could drop Matt a line. Cheers, j http://clab.ist.unomaha.edu/CLAB/index.php/User:Jhannah From JeffH at delasco.com Wed Dec 5 21:16:22 2007 From: JeffH at delasco.com (Jeff Hinrichs) Date: Wed, 5 Dec 2007 14:16:22 -0600 Subject: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting In-Reply-To: <47570189.1080300@jays.net> Message-ID: <94BC3D204A17734681830A69CBF99993DF7DE4@lilo.delasco.pri> John seems like a nice guy, but I am starting to feel like I'm harassing him ;( about the room. If Burch can get us a room with a projector and some Internet access that would work for me. It would be nice to have a faculty sponsor who is actively using Python too! (Not that you aren't Jay, just that Burch offered first.) But if it doesn't work for him, I will definitely take you up on your offer. -j -----Original Message----- From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On Behalf Of Jay Hannah Sent: Wednesday, December 05, 2007 1:53 PM To: Omaha Python Users Group Subject: Re: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting Burch Kealey wrote: > I took it upon myself to investigate the options for having meetings > here on campus. Yay! Whatever works. :) Incidentally: Last night at the Dynamic Language Users Group the leader (Blaine Buxton) said that their PKI faculty sponsor is Matt Payne. http://www.ist.unomaha.edu/index.php?p=directory&category=Faculty Matt hasn't attended any of the meetings as far as I know. If all else fails and you don't want me to strong arm John (or 3 other faculty I could pounce on, or try to sponsor myself (I'm on staff)) you could drop Matt a line. Cheers, j http://clab.ist.unomaha.edu/CLAB/index.php/User:Jhannah _______________________________________________ Omaha Python Users Group mailing list Omaha at python.org http://mail.python.org/mailman/listinfo/omaha http://www.OmahaPython.org From elicriffield at gmail.com Wed Dec 5 23:33:10 2007 From: elicriffield at gmail.com (Eli Criffield) Date: Wed, 5 Dec 2007 16:33:10 -0600 Subject: [omaha] Where is tonights meeting? Message-ID: <18e3f33d0712051433q29a5a5b0g60bacae0a6449f4f@mail.gmail.com> I know there was a lot of talk about location, but was that for next month or this month? Where do i need to go tonight? Eli From jeffh at dundeemt.com Thu Dec 6 00:51:36 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 5 Dec 2007 17:51:36 -0600 Subject: [omaha] Where is tonights meeting? In-Reply-To: <18e3f33d0712051433q29a5a5b0g60bacae0a6449f4f@mail.gmail.com> References: <18e3f33d0712051433q29a5a5b0g60bacae0a6449f4f@mail.gmail.com> Message-ID: <5aaed53f0712051551m1ce08es42e300a163b723d5@mail.gmail.com> Godfather's 75th and Pacific On Dec 5, 2007 4:33 PM, Eli Criffield wrote: > I know there was a lot of talk about location, but was that for next > month or this month? > > Where do i need to go tonight? > > Eli > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Thu Dec 6 00:52:40 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 5 Dec 2007 17:52:40 -0600 Subject: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting In-Reply-To: <94BC3D204A17734681830A69CBF99993DF7DE4@lilo.delasco.pri> References: <47570189.1080300@jays.net> <94BC3D204A17734681830A69CBF99993DF7DE4@lilo.delasco.pri> Message-ID: <5aaed53f0712051552jd9b3f4bxc8103a54e1b3e5ba@mail.gmail.com> Just a quick note, since I received a couple emails. tonight's meeting will be at Godfather's on 75th and Pacific. See the website http://www.omahapython.org/ for a map -j On Dec 5, 2007 2:16 PM, Jeff Hinrichs wrote: > John seems like a nice guy, but I am starting to feel like I'm harassing > him ;( about the room. > > If Burch can get us a room with a projector and some Internet access > that would work for me. It would be nice to have a faculty sponsor who > is actively using Python too! (Not that you aren't Jay, just that Burch > offered first.) But if it doesn't work for him, I will definitely take > you up on your offer. > > -j > > -----Original Message----- > From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On > Behalf Of Jay Hannah > Sent: Wednesday, December 05, 2007 1:53 PM > To: Omaha Python Users Group > Subject: Re: [omaha] ANN: Omaha Python Users Group - Upcoming Meeting > > > Burch Kealey wrote: > > I took it upon myself to investigate the options for having meetings > > here on campus. > > Yay! Whatever works. :) > > Incidentally: Last night at the Dynamic Language Users Group the leader > (Blaine Buxton) said that their PKI faculty sponsor is Matt Payne. > > http://www.ist.unomaha.edu/index.php?p=directory&category=Faculty > > Matt hasn't attended any of the meetings as far as I know. If all else > fails and you don't want me to strong arm John (or 3 other faculty I > could pounce on, or try to sponsor myself (I'm on staff)) you could drop > Matt a line. > > Cheers, > > j > http://clab.ist.unomaha.edu/CLAB/index.php/User:Jhannah > > > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From cwebber at imagescape.com Wed Dec 5 16:49:15 2007 From: cwebber at imagescape.com (Christopher Allan Webber) Date: Wed, 05 Dec 2007 09:49:15 -0600 Subject: [omaha] [Chicago] xkcd on Python In-Reply-To: <5aaed53f0712042224w5b7b0d95u3d8ca6a5f571f125@mail.gmail.com> (Jeff Hinrichs's message of "Wed, 5 Dec 2007 00:24:34 -0600") References: <5aaed53f0712042224w5b7b0d95u3d8ca6a5f571f125@mail.gmail.com> Message-ID: <6yd4tlrvk4.fsf@imagepc03.rd.imagescape.com> Already printed out, taped to our cabinets. <3 xkcd "Jeff Hinrichs - DM&T" writes: > http://imgs.xkcd.com/comics/python.png > > "Better than everything in the medicine cabinet" > > --jeff > _______________________________________________ > Chicago mailing list > Chicago at python.org > http://mail.python.org/mailman/listinfo/chicago From jeffh at dundeemt.com Thu Dec 6 07:36:24 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Thu, 6 Dec 2007 00:36:24 -0600 Subject: [omaha] Meeting Notes Message-ID: <5aaed53f0712052236w4bcb2164g545eccdd28ca7128@mail.gmail.com> The meeting notes are up on the website, http://www.omahapython.org/ The tiddlywiki I used for the "functional programming" talk is on the web too. See the link in the meeting notes. It was great to see everyone tonight -- for those that couldn't make it, we look forward to seeing you next time. -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From bkealey at mail.unomaha.edu Sat Dec 8 17:35:10 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Sat, 8 Dec 2007 10:35:10 -0600 Subject: [omaha] OOP-Book Selection Message-ID: Hi Everyone; I am looking for a book on OOP. I have decided that I need to step back and get my head around more basic principles while I am trying to learn PYTHON. I feel like I need a more fundamental understanding of what classes, and objects are and all of the other terms that are used to describe the logic/structure of object-oriented programming(inheritance blah-blah-blah). I am believing that one of my problems is that I am bringing over my SAS/FORTRAN thought processes to PYTHON programming and I need to reeducate myself in a fundamental way. Okay-enough said. I have been searching online for the right book. There are a fair number. The one I have finally settled on-I think-is Object-Oriented Software Construction, Edition #2 Book and CD-ROM Bertrand Meyer. The problem is that this book does not seem to be available in town. I am going to have to order it and since it is $100(roughly) I am looking for second opinions. If anyone has used this book or has another book to suggest, I would appreciate your comments/feedback. Don't mug me for this, but I am thinking that the difference between languages like Python-Perl and Java (as well as a host of others) is syntax. They are all predicated on some very fundamental principles. I am trying to get to those fundamental principles. Cheers Burch Burch T. Kealey, PhD. RH-CBA 408-N University of Nebraska at Omaha 6000 Dodge Street Omaha Nebraska 68104 402-554-3571 This message (including any attachments) contains confidential informa tion intended for a specific individual and purpose, and is protected by la w. If you are not the intended recipient, you should delete this message. A ny disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. From fitz at red-bean.com Mon Dec 10 04:43:29 2007 From: fitz at red-bean.com (Brian W. Fitzpatrick) Date: Sun, 9 Dec 2007 21:43:29 -0600 Subject: [omaha] [Chicago] xkcd on Python In-Reply-To: <5aaed53f0712042224w5b7b0d95u3d8ca6a5f571f125@mail.gmail.com> References: <5aaed53f0712042224w5b7b0d95u3d8ca6a5f571f125@mail.gmail.com> Message-ID: On Dec 5, 2007 12:24 AM, Jeff Hinrichs - DM&T wrote: > http://imgs.xkcd.com/comics/python.png > > "Better than everything in the medicine cabinet" Randall Munroe, xkcd's creator, talked at Google on Friday (In Mountain View). Donald Knuth came and asked "What's the name of my O(log log n) search algorithm?" I swear I'm not kidding. Guido van Rossum was also there and he asked "Do you expect me to fly?" See http://xkcd.com/353/ and http://xkcd.com/342/ respectively. -Fitz From jeffh at dundeemt.com Tue Dec 11 02:42:51 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Mon, 10 Dec 2007 19:42:51 -0600 Subject: [omaha] OOP-Book Selection In-Reply-To: References: Message-ID: <5aaed53f0712101742s3dc1681p755d086c33cf18a7@mail.gmail.com> Burch, Sorry for the tardy response, but I've just returned from Chicago. On Dec 8, 2007 10:35 AM, Burch Kealey wrote: > > Hi Everyone; > I am looking for a book on OOP. I have decided that I need to step > back and get my head around more basic principles while I am trying to > learn PYTHON. I feel like I need a more fundamental understanding of > what classes, and objects are and all of the other terms that are used > to describe the logic/structure of object-oriented > programming(inheritance blah-blah-blah). I am believing that one of my > problems is that I am bringing over my SAS/FORTRAN thought processes > to PYTHON programming and I need to reeducate myself in a fundamental > way. Okay-enough said. I have been searching online for the right > book. There are a fair number. The one I have finally settled on-I > think-is Object-Oriented Software Construction, Edition #2 Book and > CD-ROM Bertrand Meyer. The problem is that this book does not seem to > be available in town. I am going to have to order it and since it is > $100(roughly) I am looking for second opinions. If anyone has used > this book or has another book to suggest, I would appreciate your > comments/feedback. Sorry but I don't have any input for you on this. Most of my knowledge of OO was picked up in classes and hacking. The move from stuctured to OO was not that big for me. I found it to be a natural extension, structured+data. I know that my view of OO is skewed, but then I think everyone's view of OO is skewed to some degree Perhaps now that Matt P. has joined the list, he might be able to comment on the titles. > Don't mug me for this, but I am thinking that the > difference between languages like Python-Perl and Java (as well as a > host of others) is syntax. They are all predicated on some very > fundamental principles. I am trying to get to those fundamental > principles. Actually their are some pretty big differences between java and python. A good discussion of these differences can be found here: http://www.ferg.org/projects/python_java_side-by-side.html Since Jay Hannah is on the list, I'll defer to him on differences between Python and Perl. I've not done enough perl hacking to give a good overview of the differences. The Dynamics Languages group had a programming challenge earlier this year. It's not a bad way to see how different languages(erlang, lisp, ruby, perl and of course python) solve the same task. http://vc.jays.net/viewvc.cgi/carwash/?root=dynamic_omaha -Jeff > Cheers > Burch > Burch T. Kealey, PhD. > RH-CBA 408-N > University of Nebraska at Omaha > 6000 Dodge Street > Omaha Nebraska 68104 > 402-554-3571 -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Wed Dec 12 04:05:28 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Tue, 11 Dec 2007 21:05:28 -0600 Subject: [omaha] Cool Python tidbits Message-ID: <5aaed53f0712111905o5a21cfctc7aece9a3967685e@mail.gmail.com> SAGE While Working on the nextflix challenge I came across, SAGE - no note the sysadmin usenix group, not the Firefox rss addon, and not the account package, but the Software for Algebra and Geometry Experimentation, http://www.sagemath.org/ . There have been a couple of recent articles about it on Network World and /. http://science.slashdot.org/article.pl?sid=07/12/08/1350258 Has anyone tried it out yet? It didn't seem to look like what I wanted at the time but I made a bookmark http://del.icio.us/dundeemt/python to get back to it. Human Friendly Sorting The Planet Python feed had an interesting article on "Human Friendly" sorting, http://nedbatchelder.com/blog/200712.html#e20071211T054956 I've done a number of very helpful things with list.sort method by handing it a user defined function so that it could sort an array of objects http://wiki.python.org/moin/HowTo/Sorting#head-e14f7c85c8ba38eb451a659e6f8784eefe2f0b6b the way I wanted but this type of sort is something that I could use for another project I'm working on. PyCon 2008 PyCon is coming up and this year it's being held in Chicago, hosted by the Chicago Users group (http://chipy.org/) http://us.pycon.org/2008/about/ The dates are March 14-16, last years conference reg cost was $195 early, $260 normal. The conference is held from Fri - Sun, with a day of tutorials (extra $) on the 13 and code sprints from 17 - 20. I've always had good experiences at PyCon and have every intention of making this one. Anyone else thinking about going? -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Wed Dec 12 04:36:49 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Tue, 11 Dec 2007 21:36:49 -0600 Subject: [omaha] Parsing bad html Message-ID: <5aaed53f0712111936w6d56b7b6ue2028696cde661ff@mail.gmail.com> One of the reasons I like Python: I had to reformat some html today to take it from a poorly hand coded page and get it in to a wiki. Here is an example nugget of the raw source html ( this isn't the worst - which had mangled mismatched tags) NS+ -- Classified Ads -- Radio -- Book Links -- Obscure -- eBAY -- Online PR -- Catalogs -- FirstChaps -- LOC -- WebRadio I needed to get in into a form like "* [[ TITLE | URL ]]" Well I've used Beautifulsoup (http://www.crummy.com/software/BeautifulSoup/) before but its been a while so the exact way to do it was not in my L1 cache. I knew I didn't have the module on this machine so I had to get it loaded and start from there. I searched the docs for "links" and found http://www.crummy.com/software/BeautifulSoup/documentation.html#Improving%20Performance%20by%20Parsing%20Only%20Part%20of%20the%20Document -- midway of the section is an example that is darn near exactly what I want. What follows is what I did next: jlh at jlh-d520:~$ sudo easy_install beautifulsoup [sudo] password for jlh: Searching for beautifulsoup Reading http://cheeseshop.python.org/pypi/beautifulsoup/ Couldn't find index page for 'beautifulsoup' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading http://cheeseshop.python.org/pypi/ Reading http://cheeseshop.python.org/pypi/BeautifulSoup/3.0.4 Reading http://www.crummy.com/software/BeautifulSoup/ Reading http://www.crummy.com/software/BeautifulSoup/download/ Best match: BeautifulSoup 3.0.4 Downloading http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup-3.0.4.tar.gz Processing BeautifulSoup-3.0.4.tar.gz Running BeautifulSoup-3.0.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Ihuiu5/BeautifulSoup-3.0.4/egg-dist-tmp-gKUTwa zip_safe flag not set; analyzing archive contents... Adding BeautifulSoup 3.0.4 to easy-install.pth file Installed /usr/lib/python2.5/site-packages/BeautifulSoup-3.0.4-py2.5.egg Processing dependencies for beautifulsoup Finished processing dependencies for beautifulsoup jlh at jlh-d520:~$ python Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> s = """ ... Google ... -- FAST -- Prof ... -- FTP -- Dogpile --Beaucoup -- ... Articles -- Archives ... -- Academic -- Kartoo ... -- Clusty -- Teoma ... -- MSN -- Cranky ... -- Discussions -- ... """ >>> from BeautifulSoup import BeautifulSoup, SoupStrainer >>> >>> >>> links = SoupStrainer('a') >>> thelinks = [tag for tag in BeautifulSoup(s, parseOnlyThese=links)] ... for el in thelinks: ... print el ... Google FAST Prof FTP Dogpile Beaucoup Articles Archives Academic Kartoo Clusty Teoma MSN Cranky Discussions >>> dir(thelinks) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] >>> dir(thelinks[0]) ['XML_SPECIAL_CHARS_TO_ENTITIES', '__call__', '__contains__', '__delitem__', '__doc__', '__eq__', '__getattr__', '__getitem__', '__init__', '__iter__', '__len__', '__module__', '__ne__', '__nonzero__', '__repr__', '__setitem__', '__str__', '__unicode__', '_findAll', '_findOne', '_getAttrMap', '_lastRecursiveChild', 'append', 'attrs', 'childGenerator', 'containsSubstitutions', 'contents', 'extract', 'fetch', 'fetchNextSiblings', 'fetchParents', 'fetchPrevious', 'fetchPreviousSiblings', 'fetchText', 'find', 'findAll', 'findAllNext', 'findAllPrevious', 'findChild', 'findChildren', 'findNext', 'findNextSibling', 'findNextSiblings', 'findParent', 'findParents', 'findPrevious', 'findPreviousSibling', 'findPreviousSiblings', 'first', 'firstText', 'get', 'has_key', 'hidden', 'insert', 'isSelfClosing', 'name', 'next', 'nextGenerator', 'nextSibling', 'nextSiblingGenerator', 'parent', 'parentGenerator', 'parserClass', 'prettify', 'previous', 'previousGenerator', 'previousSibling', 'previousSiblingGenerator', 'recursiveChildGenerator', 'renderContents', 'replaceWith', 'setup', 'string', 'substituteEncoding', 'toEncoding'] >>> thelinks[0].attrs [(u'href', u'http://www.google.com/')] >>> thelinks[0].attrs[1] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range >>> thelinks[0].attrs[0][1] u'http://www.google.com/' >>> thelinks[0].fetchText Google> >>> thelinks[0].fetch Google> >>> thelinks[0].name u'a' >>> thelinks[0].setup Google> >>> thelinks[0].extract Google> >>> thelinks[0].extract() >>> thelinks[0].contents [u'Google'] >>> thelinks[0].attrs[0][1] u'http://www.google.com/' >>> dir(something) in the interactive interpreter lists all of the properties and methods available for a given object. By looking at the return of "thelinks" it was obviously a list, or some other object that was implemented as a list. So then I needed to figure out what the list elements were as trying to .strip() them was resulting in a TypeError. a quick dir(thelinks[0]) showed that the elements were not simple strings or lists of strings but a more complicated object. Then I just needed to find what would return the URL and Title. Not caring to read more documentation you'll see my attempts before finding the two necessary properties: .contents and .attrs So I end up with the following script to hammer my way through a few hundred links from BeautifulSoup import BeautifulSoup, SoupStrainer links = SoupStrainer('a') thelinks = [tag for tag in BeautifulSoup(s, parseOnlyThese=links)] for el in thelinks: try: print ' * [[%s|%s]]' % ((el.contents[0]).strip(),el.attrs[0][1]) except TypeError: print ' * [[%s|%s]]' % (el.contents[0],el.attrs[0][1]) You'll notice the try:except block. I needed that when the .contents returned a more complicated element than a string. (i.e. stuff) That is a html element object and it doesn't take kindly when I try to peform a .strip() (string object) method on something that doesn't support it. For those, I just flattened it out and hand edited the output. Total time for researching, experimenting and implementing about 20 minutes. Compared with the time it was taking to edit the source html snippets to wiki links -- that was a huge savings. Not a fancy script by any stretch of the imagination -- but a decent example of using interactive python to your advantage and letting me remain the lazy guy that I am. The other thing to remember, when forced to parse html of questionable quality, BeautifulSoup is your friend. -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From elicriffield at gmail.com Wed Dec 12 06:25:43 2007 From: elicriffield at gmail.com (Eli Criffield) Date: Tue, 11 Dec 2007 23:25:43 -0600 Subject: [omaha] Parsing bad html In-Reply-To: <5aaed53f0712111936w6d56b7b6ue2028696cde661ff@mail.gmail.com> References: <5aaed53f0712111936w6d56b7b6ue2028696cde661ff@mail.gmail.com> Message-ID: <18e3f33d0712112125i45ac55dex941830190a773cbd@mail.gmail.com> I love BeautifulSoup, it takes any random crap html you throw at it and turns in a beautiful pythonic object with methods for everything you would want to be able to do with it. I use it to even "prettify" (yep thats a method for a Soup object too) some of my html before i publish. For example the heart of my Sipie (player for sirius online radio in python) use BeautifulSoup: def getAsxURL(self) ''' Simplified for viewing, for real code see http://sipie.sourceforge.net/ ''' # do i have a valid stream/channel already set in self.__stream? self.validateStream() # self.token is set when you run self.auth(), as are the cookies you need post = {'activity': 'selectStream', 'stream': self.__stream, 'token': self.token} url = 'http://%s/sirius/servlet/MediaPlayer' % self.host data = self.__getURL(url, post).read() soup = BeautifulSoup(data) try: asxURL = soup.find('param', {'name': 'FileName'})['value'] except TypeError: # you get a TypeError if it can't find it # you must not have the right cookies, you probably didn't login yet raise AuthError return asxURL Once you have the url of the it contains a hash key thats good for one connect. you can feed that asxURL to mplayer, totem, VLC or windows media player and it'll play. Its all very simple thinks to python and BeautifulSoup's parsing. Eli Criffield On Dec 11, 2007 9:36 PM, Jeff Hinrichs - DM&T wrote: > One of the reasons I like Python: > > I had to reformat some html today to take it from a poorly hand coded > page and get it in to a wiki. > > Here is an example nugget of the raw source html ( this isn't the > worst - which had mangled mismatched tags) > NS+ > -- Classified Ads -- href="http://www.radio-locator.com/cgi-bin/home">Radio > -- Book > Links face="Arial,Helvetica,Monaco"> href="http://www.ceoexpress.com/"> -- > Obscure -- href="http://www.ebay.com/">eBAY > -- Online PR -- href="http://catalogs.google.com/">Catalogs > -- FirstChaps > -- LOC -- href="http://www.ac6v.com/swl1.htm#WEBRADIO">WebRadio > > I needed to get in into a form like "* [[ TITLE | URL ]]" > > Well I've used Beautifulsoup > (http://www.crummy.com/software/BeautifulSoup/) before but its been a > while so the exact way to do it was not in my L1 cache. I knew I > didn't have the module on this machine so I had to get it loaded and > start from there. I searched the docs for "links" and found > http://www.crummy.com/software/BeautifulSoup/documentation.html#Improving%20Performance%20by%20Parsing%20Only%20Part%20of%20the%20Document > -- midway of the section is an example that is darn near exactly what > I want. > > What follows is what I did next: > > jlh at jlh-d520:~$ sudo easy_install beautifulsoup > [sudo] password for jlh: > Searching for beautifulsoup > Reading http://cheeseshop.python.org/pypi/beautifulsoup/ > Couldn't find index page for 'beautifulsoup' (maybe misspelled?) > Scanning index of all packages (this may take a while) > Reading http://cheeseshop.python.org/pypi/ > Reading http://cheeseshop.python.org/pypi/BeautifulSoup/3.0.4 > Reading http://www.crummy.com/software/BeautifulSoup/ > Reading http://www.crummy.com/software/BeautifulSoup/download/ > Best match: BeautifulSoup 3.0.4 > Downloading http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup-3.0.4.tar.gz > Processing BeautifulSoup-3.0.4.tar.gz > Running BeautifulSoup-3.0.4/setup.py -q bdist_egg --dist-dir > /tmp/easy_install-Ihuiu5/BeautifulSoup-3.0.4/egg-dist-tmp-gKUTwa > zip_safe flag not set; analyzing archive contents... > Adding BeautifulSoup 3.0.4 to easy-install.pth file > > Installed /usr/lib/python2.5/site-packages/BeautifulSoup-3.0.4-py2.5.egg > Processing dependencies for beautifulsoup > Finished processing dependencies for beautifulsoup > jlh at jlh-d520:~$ python > Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> s = """ > ... Google > ... -- FAST -- href="http://www.profusion.com/"> Prof > ... -- FTP -- href="http://dogpile.com/">Dogpile -- href="http://www.beaucoup.com/">Beaucoup > size="1">-- > ... Articles > -- Archives > ... -- Academic -- href="http://www.kartoo.com/">Kartoo > ... -- Clusty -- href="http://www.teoma.com/">Teoma > ... -- MSN -- href="http://www.cranky.com"> Cranky > ... -- Discussions -- > ... """ > >>> from BeautifulSoup import BeautifulSoup, SoupStrainer > >>> > >>> > >>> links = SoupStrainer('a') > >>> thelinks = [tag for tag in BeautifulSoup(s, parseOnlyThese=links)] > ... for el in thelinks: > ... print el > ... > Google > FAST > Prof > FTP > Dogpile > Beaucoup > Articles > Archives > Academic > Kartoo > Clusty > Teoma > > MSN > Cranky > Discussions > >>> dir(thelinks) > ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', > '__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__', > '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', > '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', > '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', > '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', > '__setslice__', '__str__', 'append', 'count', 'extend', 'index', > 'insert', 'pop', 'remove', 'reverse', 'sort'] > >>> dir(thelinks[0]) > ['XML_SPECIAL_CHARS_TO_ENTITIES', '__call__', '__contains__', > '__delitem__', '__doc__', '__eq__', '__getattr__', '__getitem__', > '__init__', '__iter__', '__len__', '__module__', '__ne__', > '__nonzero__', '__repr__', '__setitem__', '__str__', '__unicode__', > '_findAll', '_findOne', '_getAttrMap', '_lastRecursiveChild', > 'append', 'attrs', 'childGenerator', 'containsSubstitutions', > 'contents', 'extract', 'fetch', 'fetchNextSiblings', 'fetchParents', > 'fetchPrevious', 'fetchPreviousSiblings', 'fetchText', 'find', > 'findAll', 'findAllNext', 'findAllPrevious', 'findChild', > 'findChildren', 'findNext', 'findNextSibling', 'findNextSiblings', > 'findParent', 'findParents', 'findPrevious', 'findPreviousSibling', > 'findPreviousSiblings', 'first', 'firstText', 'get', 'has_key', > 'hidden', 'insert', 'isSelfClosing', 'name', 'next', 'nextGenerator', > 'nextSibling', 'nextSiblingGenerator', 'parent', 'parentGenerator', > 'parserClass', 'prettify', 'previous', 'previousGenerator', > 'previousSibling', 'previousSiblingGenerator', > 'recursiveChildGenerator', 'renderContents', 'replaceWith', 'setup', > 'string', 'substituteEncoding', 'toEncoding'] > >>> thelinks[0].attrs > [(u'href', u'http://www.google.com/')] > >>> thelinks[0].attrs[1] > Traceback (most recent call last): > File "", line 1, in > IndexError: list index out of range > >>> thelinks[0].attrs[0][1] > u'http://www.google.com/' > >>> thelinks[0].fetchText > Google> > >>> thelinks[0].fetch > Google> > >>> thelinks[0].name > u'a' > >>> thelinks[0].setup > Google> > >>> thelinks[0].extract > Google> > >>> thelinks[0].extract() > >>> thelinks[0].contents > [u'Google'] > >>> thelinks[0].attrs[0][1] > u'http://www.google.com/' > >>> > > dir(something) in the interactive interpreter lists all of the > properties and methods available for a given object. By looking at > the return of "thelinks" it was obviously a list, or some other > object that was implemented as a list. So then I needed to figure out > what the list elements were as trying to .strip() them was resulting > in a TypeError. a quick dir(thelinks[0]) showed that the elements > were not simple strings or lists of strings but a more complicated > object. Then I just needed to find what would return the URL and > Title. Not caring to read more documentation you'll see my attempts > before finding the two necessary properties: .contents and .attrs > So I end up with the following script to hammer my way through a few > hundred links > > from BeautifulSoup import BeautifulSoup, SoupStrainer > > > links = SoupStrainer('a') > thelinks = [tag for tag in BeautifulSoup(s, parseOnlyThese=links)] > for el in thelinks: > try: > print ' * [[%s|%s]]' % ((el.contents[0]).strip(),el.attrs[0][1]) > except TypeError: > print ' * [[%s|%s]]' % (el.contents[0],el.attrs[0][1]) > > You'll notice the try:except block. I needed that when the .contents > returned a more complicated element than a string. (i.e. color="red">stuff) That is a html element object and it doesn't > take kindly when I try to peform a .strip() (string object) method on > something that doesn't support it. For those, I just flattened it out > and hand edited the output. Total time for researching, experimenting > and implementing about 20 minutes. Compared with the time it was > taking to edit the source html snippets to wiki links -- that was a > huge savings. > > Not a fancy script by any stretch of the imagination -- but a decent > example of using interactive python to your advantage and letting me > remain the lazy guy that I am. The other thing to remember, when > forced to parse html of questionable quality, BeautifulSoup is your > friend. > > > -- > Jeff Hinrichs > Dundee Media & Technology, Inc > jeffh at dundeemt.com > 402.218.1473 > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > From mike at hostetlerhome.com Wed Dec 12 14:57:55 2007 From: mike at hostetlerhome.com (Mike Hostetler) Date: Wed, 12 Dec 2007 07:57:55 -0600 (CST) Subject: [omaha] Parsing bad html In-Reply-To: <18e3f33d0712112125i45ac55dex941830190a773cbd@mail.gmail.com> References: <5aaed53f0712111936w6d56b7b6ue2028696cde661ff@mail.gmail.com> <18e3f33d0712112125i45ac55dex941830190a773cbd@mail.gmail.com> Message-ID: <44891.69.58.248.102.1197467875.squirrel@email.powweb.com> Eli Criffield wrote: > I love BeautifulSoup, it takes any random crap html you throw at it > and turns in a beautiful pythonic object with methods for everything > you would want to be able to do with it. I use it to even "prettify" > (yep thats a method for a Soup object too) some of my html before i > publish. I was going to say the same thing.? If it looks something like HTML, then BeautifulSoup can parse it. It's really a killer library for Python (although now there is a Ruby version of it). BeautifulSoup also has one of my favorite-named classes of all time: ?class UnicodeDammit ???? |? A class for detecting the encoding of a *ML document and ???? |? converting it to a Unicode string. If the source encoding is ???? |? windows-1252, can replace MS smart quotes with their HTML or XML ???? |? equivalents. I have a script that combines BeautifulSoup and ClientCookie to fetch and display application log files, which is much better than my employeers clicky-clicky-clicky web application for it. http://wwwsearch.sourceforge.net/ClientCookie/ (now apparently part of: http://wwwsearch.sourceforge.net/mechanize/ ) Mike Hostetler http://mike.hostetlerhome.com From newz at bearfruit.org Wed Dec 12 16:38:43 2007 From: newz at bearfruit.org (Matthew Nuzum) Date: Wed, 12 Dec 2007 09:38:43 -0600 Subject: [omaha] Parsing bad html In-Reply-To: <44891.69.58.248.102.1197467875.squirrel@email.powweb.com> References: <5aaed53f0712111936w6d56b7b6ue2028696cde661ff@mail.gmail.com> <18e3f33d0712112125i45ac55dex941830190a773cbd@mail.gmail.com> <44891.69.58.248.102.1197467875.squirrel@email.powweb.com> Message-ID: On Dec 12, 2007 7:57 AM, Mike Hostetler wrote: > I was going to say the same thing. If it looks > something like HTML, then BeautifulSoup can parse it. It's really a killer > library for Python (although now there is a Ruby version of it). > > BeautifulSoup also has one of my favorite-named classes of all time: > > class UnicodeDammit > | A > class for detecting the encoding of a *ML document and > | converting it to a Unicode string. If > the source encoding is > | windows-1252, > can replace MS smart quotes with their HTML or XML > | equivalents. > > Oh, that is so beautiful. Nice tip, cp1252 is a curse. -- Matthew Nuzum newz2000 on freenode From jeffh at dundeemt.com Thu Dec 20 06:25:22 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 19 Dec 2007 23:25:22 -0600 Subject: [omaha] New Meeting Location and Call for Talks Message-ID: <5aaed53f0712192125o2b8088c6w42f4f5aae7092227@mail.gmail.com> Just a quick reminder before we enter in to this busy holiday season that the next Python Uses Group meeting will be January 9th. Burch has arranged for us to meet on campus at UNO. Details are on the web site, http://omahapython.org/ . Check it out and let me know if there is anything missing or that needs changing. Also, I'm looking for presenters. Lightning or longer -- we've got what seems to be an excellent facility now would be an excellent time for you to come forward and give a talk about that personal or professional project that you've been working on -- a 3rd party module or library routine that you've just used and made your life easier. The only caveat is that it should be connected to python so no MLM or Timeshare talks please. Maybe we could get Eli to talk on Django or Func. Anyone want to give a talk on using Python on a Mac? We are a new group so really everything is fair game and not a rehash. Maybe we can get MikeH to come in and talk about BeautifulSoup. Since the new location doesn't allow food on premise we'll probably meet somewhere afterwards for a social hour so bring your suggestions to the meeting. -Jeff -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From mike at hostetlerhome.com Thu Dec 20 14:38:03 2007 From: mike at hostetlerhome.com (Mike Hostetler) Date: Thu, 20 Dec 2007 07:38:03 -0600 (CST) Subject: [omaha] New Meeting Location and Call for Talks In-Reply-To: <5aaed53f0712192125o2b8088c6w42f4f5aae7092227@mail.gmail.com> References: <5aaed53f0712192125o2b8088c6w42f4f5aae7092227@mail.gmail.com> Message-ID: <46346.69.58.248.102.1198157883.squirrel@email.powweb.com> Jeff Hinrichs - DM&T wrote: > The only caveat is that it should be connected to python so no MLM or > Timeshare talks please. > How about Amway? ? > Maybe we could get Eli to talk on Django or Func. Anyone want to give > a talk on using Python on a Mac? We are a new group so really > everything is fair game and not a rehash. Maybe we can get MikeH to > come in and talk about BeautifulSoup. My wife works in the evenings, so either I need to bring my daughter or make other arrangements.? Not impossible for me to do but that is an issue for me. Other than that, I'm more than willing to present something. Here are some things I'm comfortable in giving a talk on: Django or Satchmo (ecommerce engine written in Django) XML processing (mostly with ElementTree) BeautifulSoup Jython The Path module (probably a lightening talk) Mike Hostetler From bkealey at mail.unomaha.edu Thu Dec 20 15:16:19 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Thu, 20 Dec 2007 08:16:19 -0600 Subject: [omaha] New Meeting Location and Call for Talks In-Reply-To: <46346.69.58.248.102.1198157883.squirrel@email.powweb.com> References: <5aaed53f0712192125o2b8088c6w42f4f5aae7092227@mail.gmail.com>, <46346.69.58.248.102.1198157883.squirrel@email.powweb.com> Message-ID: How old is your daughter-can we entertain her with a computer and an internet connection? I would really like to learn about BS or XML Processing. From mike at hostetlerhome.com Thu Dec 20 15:43:12 2007 From: mike at hostetlerhome.com (Mike Hostetler) Date: Thu, 20 Dec 2007 08:43:12 -0600 (CST) Subject: [omaha] New Meeting Location and Call for Talks In-Reply-To: References: <5aaed53f0712192125o2b8088c6w42f4f5aae7092227@mail.gmail.com>, <46346.69.58.248.102.1198157883.squirrel@email.powweb.com> Message-ID: <47728.69.58.248.102.1198161792.squirrel@email.powweb.com> Burch Kealey wrote: > > How old is your daughter-can we entertain her with a computer and an > internet connection? I would really like to learn about BS or XML > Processing. She's four and quite computer savvy (chip off the ol' block).? Get her a net connection to NickJr or PBS Kids and she'd probably be alright. That was my Plan A if there were enough PC's available in the room. And I can BS with the best of them. :) Mike From bkealey at mail.unomaha.edu Thu Dec 20 17:04:35 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Thu, 20 Dec 2007 10:04:35 -0600 Subject: [omaha] New Meeting Location and Call for Talks In-Reply-To: <47728.69.58.248.102.1198161792.squirrel@email.powweb.com> References: <5aaed53f0712192125o2b8088c6w42f4f5aae7092227@mail.gmail.com>, <46346.69.58.248.102.1198157883.squirrel@email.powweb.com> , <47728.69.58.248.102.1198161792.squirrel@email.powweb.com> Message-ID: We can handle the connection to PBSKids or NickJr. So I guess I need to let Jeff formalize the invitation. From JeffH at delasco.com Thu Dec 20 17:19:27 2007 From: JeffH at delasco.com (Jeff Hinrichs) Date: Thu, 20 Dec 2007 10:19:27 -0600 Subject: [omaha] New Meeting Location and Call for Talks In-Reply-To: Message-ID: <94BC3D204A17734681830A69CBF99993DF7E19@lilo.delasco.pri> Consider the invitation formalized. We are a "family friendly" organization. Especially considering the new meeting location. I am glad that it might just work out for Mike. We look forward to seeing you and your daughter at the upcoming meetings! As for talks, feel free to pick your favorite to start. Like I said earlier, we are a young group so there isn't much of a worry about over presenting on a given topic. When you decide let me know and I'll make sure to put it in the announcement that goes out a couple days before the meeting. -jeff -----Original Message----- From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On Behalf Of Burch Kealey Sent: Thursday, December 20, 2007 10:05 AM To: Omaha Python Users Group Subject: Re: [omaha] New Meeting Location and Call for Talks We can handle the connection to PBSKids or NickJr. So I guess I need to let Jeff formalize the invitation. _______________________________________________ Omaha Python Users Group mailing list Omaha at python.org http://mail.python.org/mailman/listinfo/omaha http://www.OmahaPython.org From mike at hostetlerhome.com Thu Dec 20 18:06:19 2007 From: mike at hostetlerhome.com (Mike Hostetler) Date: Thu, 20 Dec 2007 11:06:19 -0600 (CST) Subject: [omaha] XML or BeautifulSoup? In-Reply-To: <94BC3D204A17734681830A69CBF99993DF7E19@lilo.delasco.pri> References: <94BC3D204A17734681830A69CBF99993DF7E19@lilo.delasco.pri> Message-ID: <58325.69.58.248.102.1198170379.squirrel@email.powweb.com> Jeff Hinrichs wrote: > Consider the invitation formalized. We are a "family friendly" > organization. > Especially considering the new meeting location. I am glad that it > might just work out for Mike. We look forward to seeing you and your > daughter at the upcoming meetings! I hope I can be regular.? Yeah, UNO is friendlier than Clancy's I gave an XML and Python talk to the Dynamic Users group last? year -- I can redo that or do BeautifulSoup (I think I have a cool script I can resurrect for that.) Let's vote until the New Year on either XML or BeautifulSoup. I'd edit the wiki page for the vote, but it seems I can't. :( Mike From bkealey at mail.unomaha.edu Thu Dec 20 19:12:52 2007 From: bkealey at mail.unomaha.edu (Burch Kealey) Date: Thu, 20 Dec 2007 12:12:52 -0600 Subject: [omaha] BS for me eom In-Reply-To: <58325.69.58.248.102.1198170379.squirrel@email.powweb.com> Message-ID: Burch T. Kealey, PhD. RH-CBA 408-N University of Nebraska at Omaha 6000 Dodge Street Omaha Nebraska 68104 402-554-3571 This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. From elicriffield at gmail.com Thu Dec 20 22:52:08 2007 From: elicriffield at gmail.com (Eli Criffield) Date: Thu, 20 Dec 2007 15:52:08 -0600 Subject: [omaha] XML or BeautifulSoup? In-Reply-To: <58325.69.58.248.102.1198170379.squirrel@email.powweb.com> References: <94BC3D204A17734681830A69CBF99993DF7E19@lilo.delasco.pri> <58325.69.58.248.102.1198170379.squirrel@email.powweb.com> Message-ID: <18e3f33d0712201352p22b555aeh5a25ef35b0cd6cc9@mail.gmail.com> Well I'd vote for XML but i won't be able to make it, We just had a baby here and family will be in from out of town that week. Anyone up for video taping it and posting to youtube or google video? In future meetings i could go over func, (I'm on the author list now), django, or my project Sipie http://en.wikipedia.org/wiki/Sipie . Although I only know func, and django from a 30,000 ft level, but i can show the basics, maybe even do a 20min wiki like demo in django. Eli Criffield On Dec 20, 2007 11:06 AM, Mike Hostetler wrote: > > > Jeff Hinrichs wrote: > > Consider the invitation formalized. We are > a "family friendly" > > organization. > > Especially > considering the new meeting location. I am glad that it > > might > just work out for Mike. We look forward to seeing you and your > > > daughter at the upcoming meetings! > > I hope I can be > regular. Yeah, UNO is friendlier than Clancy's > > I gave an > XML and Python talk to the Dynamic Users group last year -- I can > redo that or do BeautifulSoup (I think I have a cool script I can > resurrect for that.) > > Let's vote until the New Year on either > XML or BeautifulSoup. > > I'd edit the wiki page for the vote, but > it seems I can't. :( > Mike > > _______________________________________________ > Omaha Python Users Group mailing list > Omaha at python.org > http://mail.python.org/mailman/listinfo/omaha > http://www.OmahaPython.org > From jeffh at dundeemt.com Fri Dec 21 01:04:38 2007 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Thu, 20 Dec 2007 18:04:38 -0600 Subject: [omaha] XML or BeautifulSoup? In-Reply-To: <18e3f33d0712201352p22b555aeh5a25ef35b0cd6cc9@mail.gmail.com> References: <94BC3D204A17734681830A69CBF99993DF7E19@lilo.delasco.pri> <58325.69.58.248.102.1198170379.squirrel@email.powweb.com> <18e3f33d0712201352p22b555aeh5a25ef35b0cd6cc9@mail.gmail.com> Message-ID: <5aaed53f0712201604q53f7624arae61c73374a83156@mail.gmail.com> On Dec 20, 2007 3:52 PM, Eli Criffield wrote: > Well I'd vote for XML but i won't be able to make it, We just had a > baby here and family will be in from out of town that week. Congratulations on the +1 to the family. Hope that all are healthy and happy. > Anyone up for video taping it and posting to youtube or google video? No promises but I've got a new toy. > In future meetings i could go over func, (I'm on the author list now), > django, or my project Sipie http://en.wikipedia.org/wiki/Sipie . > Although I only know func, and django from a 30,000 ft level, but i > can show the basics, maybe even do a 20min wiki like demo in django. Any would be cool.