From mike at hostetlerhome.com Tue Jan 1 19:28:50 2008 From: mike at hostetlerhome.com (Mike Hostetler) Date: Tue, 01 Jan 2008 12:28:50 -0600 Subject: [omaha] Can't make Jan 9 Message-ID: <20080101122850.teca7pyc6yckcgks@email.powweb.com> Something has just come up for Jan. 9 that I can't reschedule. I know I was scheduled for a Beautiful Soup talk -- can that be moved to Feb? Sorry about the late notice. Hopefully someone can come up with something over in a week . . . -- Mike Hostetler mike at hostetlerhome.com http://mike.hostetlerhome.com From jeffh at dundeemt.com Thu Jan 3 05:11:02 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 2 Jan 2008 22:11:02 -0600 Subject: [omaha] Can't make Jan 9 In-Reply-To: <20080101122850.teca7pyc6yckcgks@email.powweb.com> References: <20080101122850.teca7pyc6yckcgks@email.powweb.com> Message-ID: <5aaed53f0801022011m424749aekb1aacd1dc69736a2@mail.gmail.com> Mike, No problem rescheduling you for February. Hope that the unexpected event isn't bad news. Anyone else want to jump in and offer up a presentation for the spot that just opened up? -Jeff On Jan 1, 2008 12:28 PM, Mike Hostetler wrote: > > Something has just come up for Jan. 9 that I can't reschedule. I know > I was scheduled for a Beautiful Soup talk -- can that be moved to Feb? > > Sorry about the late notice. Hopefully someone can come up with > something over in a week . . . > > -- > > Mike Hostetler > mike at hostetlerhome.com > http://mike.hostetlerhome.com > > _______________________________________________ > 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 choman at gmail.com Fri Jan 4 17:23:25 2008 From: choman at gmail.com (Chad Homan) Date: Fri, 4 Jan 2008 10:23:25 -0600 Subject: [omaha] utility mill Message-ID: Happy New year New year, new python things http://utilitymill.com/ -- Chad From jeffh at dundeemt.com Tue Jan 8 04:53:01 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Mon, 7 Jan 2008 21:53:01 -0600 Subject: [omaha] ANN: Omaha Python Users Group Meeting -- Wed, Jan 9 @ 7pm Message-ID: <5aaed53f0801071953i24a4ef02n4f5e0b6a85b2f3fa@mail.gmail.com> Hope that everyone had an enjoyable holiday season. The first meeting of the new year is just 2 days from tonight.. This is our first meeting on campus at UNO. For additional details, maps and parking info see the website: http://www.omahapython.org January 9, 2008 - 7pm Topics: + Crunchy and/or Idiomatic Python + Lightning Talks + Group Q and A session Location: Roskens Hall (College of Business Administration), Room 402 University of Nebraska at Omaha 6000 Dodge Street Omaha Nebraska 68104 Refreshments: The venue does not allow food/drink so we'll meet socially afterwards Door Prize(s)?: Rapid Web Applications with TurboGears, Mark Ramm I look forward to seeing all of you there. -- Jeff Hinrichs From elicriffield at gmail.com Wed Jan 9 20:27:38 2008 From: elicriffield at gmail.com (Eli Criffield) Date: Wed, 9 Jan 2008 13:27:38 -0600 Subject: [omaha] Tonights Meeting Message-ID: <18e3f33d0801091127r26eb7967od19ab3eb1b343aa3@mail.gmail.com> Looks like i mite be able to make tonights meeting. Whats the room number again? Hope to see all of you there. Eli From JeffH at delasco.com Wed Jan 9 20:29:30 2008 From: JeffH at delasco.com (Jeff Hinrichs) Date: Wed, 9 Jan 2008 13:29:30 -0600 Subject: [omaha] Tonights Meeting In-Reply-To: <18e3f33d0801091127r26eb7967od19ab3eb1b343aa3@mail.gmail.com> Message-ID: <94BC3D204A17734681830A69CBF99993DF7E7C@lilo.delasco.pri> Roskens Hall (College of Business Administration), Room 402 Maps and parking info is on the web http://www.omahapython.org/ -jeff -----Original Message----- From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On Behalf Of Eli Criffield Sent: Wednesday, January 09, 2008 1:28 PM To: Omaha Python Users Group Subject: [omaha] Tonights Meeting Looks like i mite be able to make tonights meeting. Whats the room number again? Hope to see all of you there. Eli _______________________________________________ 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 Thu Jan 10 05:52:03 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 9 Jan 2008 22:52:03 -0600 Subject: [omaha] Meeting notes are on the web Message-ID: <5aaed53f0801092052q291e5cddt56f9d4c9f26f30ab@mail.gmail.com> http://www.omahapython.org/ If you see anything that I left out just send me a note. Thanks, -j -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Mon Jan 14 04:43:19 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sun, 13 Jan 2008 21:43:19 -0600 Subject: [omaha] Video from the ChiPy meeting Message-ID: <5aaed53f0801131943t1c640800oe20324f64c445902@mail.gmail.com> This is cool. One of the members of the ChiPy group has started video taping the meetings and putting them up on Google video. See the original email here: http://mail.python.org/pipermail/chicago/2008-January/003272.html the google video is here: http://video.google.com/videoplay?docid=-906354546937878632 -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From elicriffield at gmail.com Mon Jan 14 23:05:34 2008 From: elicriffield at gmail.com (Eli Criffield) Date: Mon, 14 Jan 2008 16:05:34 -0600 Subject: [omaha] Decorators Message-ID: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> I was looking around the web for examples of decorators and i saw the baypiggies meeting video that goes over decorators for about 30 seconds. They use the "decorator" module. Turns out its in the ubuntu packages so a simple apt-get install python-decorator installs it. Using this module now i get what decorators are for! You can add functionality to any or every method you define without having to change that method, just add the decorator. Here's my simple example. --snip-- from decorator import decorator @decorator def trace(f, *args, **kw): print "call %s with args, %s, %s"%(f.func_name,args,kw) return f(*args, **kw) @trace def sum_three(a, b, c): return a + b + c print sum_three(1,2,3) --snip-- You could just as easy make a logging decorator, or a profiler decorator to find out where the slowdown is, all kinds of useful examples pop into my head. My question is how do you do this without using the decorator module? What am i missing about decorators, they don't seem that useful without the decorator module, witch isn't part of core python. Eli Criffield From newz at bearfruit.org Mon Jan 14 23:40:44 2008 From: newz at bearfruit.org (Matthew Nuzum) Date: Mon, 14 Jan 2008 16:40:44 -0600 Subject: [omaha] Decorators In-Reply-To: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> References: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> Message-ID: On 1/14/08, Eli Criffield wrote: > > You can add functionality to any or every method you define without > having to change that method, just add the decorator. > > Here's my simple example. > > --snip-- > > from decorator import decorator > > @decorator > def trace(f, *args, **kw): > print "call %s with args, %s, %s"%(f.func_name,args,kw) > return f(*args, **kw) > > @trace > def sum_three(a, b, c): > return a + b + c > > print sum_three(1,2,3) > Would you mind explaining what's going on here? I'm not sure what you're doing. I've heard of decorators but never tried using them. -- Matthew Nuzum newz2000 on freenode From elicriffield at gmail.com Mon Jan 14 23:58:28 2008 From: elicriffield at gmail.com (Eli Criffield) Date: Mon, 14 Jan 2008 16:58:28 -0600 Subject: [omaha] Decorators In-Reply-To: References: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> Message-ID: <18e3f33d0801141458k4fdf648au277349d9f7688ba4@mail.gmail.com> > Would you mind explaining what's going on here? I'm not sure what you're > doing. I've heard of decorators but never tried using them. Sure. from decorator import decorator #simple import of the 3rd party decorator module @decorator #you decorate your new decorator, what this does i don't really know.... # the function you define here will kind of run instead of the funtion you decorate it with, but you can call the real function in this function, and thats what this does at the end. def trace(f, *args, **kw): print "call %s with args, %s, %s"%(f.func_name,args,kw) return f(*args, **kw) # you decorate your function with the trace decorator you made @trace def sum_three(a, b, c): return a + b + c print sum_three(1,2,3) The output is like this: call sum_three with args, (1, 2, 3), {} 6 Eli Criffield From JeffH at delasco.com Tue Jan 15 00:04:30 2008 From: JeffH at delasco.com (Jeff Hinrichs) Date: Mon, 14 Jan 2008 17:04:30 -0600 Subject: [omaha] Decorators In-Reply-To: <18e3f33d0801141458k4fdf648au277349d9f7688ba4@mail.gmail.com> Message-ID: <94BC3D204A17734681830A69CBF99993DF7E98@lilo.delasco.pri> Not quite sure about the 3rd party decorator module, but with stock 2.4 -----Original Message----- From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On Behalf Of Eli Criffield Sent: Monday, January 14, 2008 4:58 PM To: Omaha Python Users Group Subject: Re: [omaha] Decorators > Would you mind explaining what's going on here? I'm not sure what you're > doing. I've heard of decorators but never tried using them. Sure. from decorator import decorator #simple import of the 3rd party decorator module @decorator #you decorate your new decorator, what this does i don't really know.... # the function you define here will kind of run instead of the funtion you decorate it with, but you can call the real function in this function, and thats what this does at the end. def trace(f, *args, **kw): print "call %s with args, %s, %s"%(f.func_name,args,kw) return f(*args, **kw) # you decorate your function with the trace decorator you made @trace def sum_three(a, b, c): return a + b + c print sum_three(1,2,3) The output is like this: call sum_three with args, (1, 2, 3), {} 6 Eli Criffield _______________________________________________ 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 Tue Jan 15 03:40:02 2008 From: jay at jays.net (Jay Hannah) Date: Mon, 14 Jan 2008 20:40:02 -0600 Subject: [omaha] Decorators In-Reply-To: References: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> Message-ID: <8EC5B459-7ECB-49CC-80E1-32E4D358C4F0@jays.net> On Jan 14, 2008, at 4:40 PM, Matthew Nuzum wrote: > Would you mind explaining what's going on here? I'm not sure what > you're > doing. I've heard of decorators but never tried using them. http://en.wikipedia.org/wiki/Decorator_pattern http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Decorators My favorite design patterns book: http://www.oreilly.com/catalog/hfdesignpat/ As luck would have it, the free sample chapter just happens to be on the Decorator Pattern: http://www.oreilly.com/catalog/hfdesignpat/chapter/ch03.pdf (I never felt good about any Decorator Pattern I tried in Perl (years ago). -grin-) j From jeffh at dundeemt.com Tue Jan 15 04:11:00 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Mon, 14 Jan 2008 21:11:00 -0600 Subject: [omaha] Decorators In-Reply-To: <8EC5B459-7ECB-49CC-80E1-32E4D358C4F0@jays.net> References: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> <8EC5B459-7ECB-49CC-80E1-32E4D358C4F0@jays.net> Message-ID: <5aaed53f0801141911q471554a6y4e827546ff1f4dc9@mail.gmail.com> To add to my prematurely sent email from above: Decorators in python are syntactic sugar to let you wrap a function/method with another function. While possible, to a degree(ease), before the implementation of pep 318 http://www.python.org/dev/peps/pep-0318/ the pep standardizes the idiom and created a new syntactic element, '@'. The decorator module that Eli has been experimenting with is itself a decorator. Its purpose is to preserve the function signature of a function that has been decorated. If you check out the docs for the module by Michelle Simionato, http://www.phyast.pitt.edu/~micheles/python/documentation.html you'll get a feel for why the function signature might be meaningful to you or tools that you use. I would strongly recommend taking a read as the decorator module has some nice side effects. Read it through to the end as this document talks about the downside of decorators too. -j On 1/14/08, Jay Hannah wrote: > On Jan 14, 2008, at 4:40 PM, Matthew Nuzum wrote: > > Would you mind explaining what's going on here? I'm not sure what > > you're > > doing. I've heard of decorators but never tried using them. > > http://en.wikipedia.org/wiki/Decorator_pattern > > http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Decorators > > My favorite design patterns book: > > http://www.oreilly.com/catalog/hfdesignpat/ > > As luck would have it, the free sample chapter just happens to be on > the Decorator Pattern: > > http://www.oreilly.com/catalog/hfdesignpat/chapter/ch03.pdf > > (I never felt good about any Decorator Pattern I tried in Perl (years > ago). -grin-) > > 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 elicriffield at gmail.com Tue Jan 15 05:50:23 2008 From: elicriffield at gmail.com (Eli Criffield) Date: Mon, 14 Jan 2008 22:50:23 -0600 Subject: [omaha] Decorators In-Reply-To: <5aaed53f0801141911q471554a6y4e827546ff1f4dc9@mail.gmail.com> References: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> <8EC5B459-7ECB-49CC-80E1-32E4D358C4F0@jays.net> <5aaed53f0801141911q471554a6y4e827546ff1f4dc9@mail.gmail.com> Message-ID: <18e3f33d0801142050r32b75cd2pdad41f13dbf255b8@mail.gmail.com> > Decorators in python are syntactic sugar to let you wrap a > function/method with another function. How would you do the same thing a decorator does without using a decorators. > http://www.phyast.pitt.edu/~micheles/python/documentation.html you'll > get a feel for why the function signature might be meaningful to you Ok whats a function signature, and why would it change, or even stay the same? Eli From jeffh at dundeemt.com Tue Jan 15 15:27:57 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Tue, 15 Jan 2008 08:27:57 -0600 Subject: [omaha] Decorators In-Reply-To: <18e3f33d0801142050r32b75cd2pdad41f13dbf255b8@mail.gmail.com> References: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> <8EC5B459-7ECB-49CC-80E1-32E4D358C4F0@jays.net> <5aaed53f0801141911q471554a6y4e827546ff1f4dc9@mail.gmail.com> <18e3f33d0801142050r32b75cd2pdad41f13dbf255b8@mail.gmail.com> Message-ID: <5aaed53f0801150627r1b443121j72a83ab127839994@mail.gmail.com> On 1/14/08, Eli Criffield wrote: > > Decorators in python are syntactic sugar to let you wrap a > > function/method with another function. > > How would you do the same thing a decorator does without using a decorators. "Function Decorators by Hacking Bytecodes" http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286147 DecoratorTools http://pypi.python.org/pypi/DecoratorTools/1.7 > > http://www.phyast.pitt.edu/~micheles/python/documentation.html you'll > > get a feel for why the function signature might be meaningful to you > > Ok whats a function signature, and why would it change, or even stay the same? > > Eli so here is an example of a decorator that I grabbed from http://wiki.python.org/moin/PythonDecoratorLibrary #!/usr/bin/env python from inspect import getargspec def dumpArgs(func): "This decorator dumps out the arguments passed to a function before calling it" argnames = func.func_code.co_varnames[:func.func_code.co_argcount] fname = func.func_name def echoFunc(*args,**kwargs): print fname, ":", ', '.join('%s=%r' % entry for entry in zip(argnames,args) + kwargs.items()) return func(*args, **kwargs) return echoFunc @dumpArgs def f1(a,b,c): print a + b + c def f2(a,b,c): print a + b + c f1(1, 2, 3) f2(1, 2, 3) print getargspec(f1) print getargspec(f2) The output generated looks like: f1 : a=1, b=2, c=3 6 6 ([], 'args', 'kwargs', None) (['a', 'b', 'c'], None, None, None) Both functions f1 and f2 take and compute the same thing. They should have the same function signature. But looking at the output of getargspec for the two functions show two different things. the decorated function, f1, appears to take an unlimited number of args/keywordargs where as the undecorated function, f2 shows that it takes 3 values, named a,b and c. If you use an editor that supports (i forget the exact name) parameter help pop-ups, it's using the function signature to help you out by telling you what input parameters are being expected. Other code inspection tools and pydoc will give you incorrect information too. using the decorator module (easy_install decorator) that Eli was talking about, you get: #assumes you have easy_installed the 3rd party decorator module from decorator import decorator @decorator def dumpArgs2(f, *args, **kw): argnames = f.func_code.co_varnames[:f.func_code.co_argcount] fname = f.func_name print fname, ":", ', '.join('%s=%r' % entry for entry in zip(argnames,args) + kw.items()) return f(*args, **kw) @dumpArgs2 def f3(a,b,c): print a+b+c f3(1,2,3) print getargspec(f3) Which results in: f3 : a=1, b=2, c=3 6 (['a', 'b', 'c'], None, None, None) You'll notice that the function signature now matches the undecorated function. This means pydoc and other code inspection tools are now able to return useful information. -jeff From cbc at unc.edu Tue Jan 15 16:41:58 2008 From: cbc at unc.edu (Chris Calloway) Date: Tue, 15 Jan 2008 10:41:58 -0500 Subject: [omaha] Decorators In-Reply-To: <18e3f33d0801142050r32b75cd2pdad41f13dbf255b8@mail.gmail.com> References: <18e3f33d0801141405l64923c74uf63f1b70c8a70a8e@mail.gmail.com> <8EC5B459-7ECB-49CC-80E1-32E4D358C4F0@jays.net> <5aaed53f0801141911q471554a6y4e827546ff1f4dc9@mail.gmail.com> <18e3f33d0801142050r32b75cd2pdad41f13dbf255b8@mail.gmail.com> Message-ID: <478CD446.9020407@unc.edu> Eli Criffield wrote: >> Decorators in python are syntactic sugar to let you wrap a >> function/method with another function. Hey guys, two things. 1) This article about decorators is what you need to know, is comprehensive, and is the most digestible thing about decorators out there: http://www.ddj.com/184406073 The Python documentation about decorators should be as good as that article. And the fact that it's not says, um, several things I don't want to go into. Also, here's another very respectable article, if you already understand the previous one (and a good bit about metaclasses): http://www.ibm.com/developerworks/linux/library/l-cpdecor.html (The good Dr. Mertz might be the best writer about Python out there.) 2) You don't need the third party decorator module. It just pulls in some predefined decorators that some people have found useful like memoize, locked, delayed, threaded, and blocking. Plus it adds a decorator which is confusingly called "decorator," and which you *can* use to create decorators of a particular convention that *may* occasionally be useful (if using a factory-factory could ever be useful). Most people who use decorators already have their own utility module of useful decorators. The thing about decorators is they get used a lot by decorator-happy people who just learned about them or are trying to be overly clever. They are seldom all that useful. They have their place. There are some pretty standard decorators like memoize that many people understand already without having to look at what they do or how they do it. But often decorator usage is a bit overblown. Anything more than the simplest decorators add unnecessary and unreadable complexity to you code. And you don't want that. It isn't pythonic to add unnecessary and unreadable complexity to you code. The idea is to quickly write useful, testable, tested, sharable, and maintainable code; not to prove what an awesome computer scientist you are. :) You have to invest a lot to properly understand and use decorators. And then they get only a little and often trivial usage (do we really need an "author" attribute added to all of our functions; and if so, do we really need a decorator to do that?). Most of the time, decorators aren't worth it. Decorators are most useful for dorking around with metaclasses, which is another high investment/low return pattern. They're something you need to know to understand other people's code sometimes. If you find yourself using them a lot, you need to look in the mirror and ask yourself if you've really got a good overriding reason. Decorators tend to add "magic" at the cost of readability. They can also be seriously misused because using them requires remembering and following some recommendations that are not enforced by Python. The third party decorator module's "decorator" decorator is supposed to help with that somewhat. But then, if you need help with that, you probably shouldn't be using them. Certain levels of abstraction come at a steep cost. If understanding the abstraction is more difficult than understanding what is being abstracted, some soul searching is in order. Apparently, decorators had to be added to Python because Java had them. Oof. Notice that even though decorators are officially part of Python syntax, the official Python tutorial doesn't mention them. Anywhere. The fact is, if you know and need the decorator *programming pattern* (and the need and the knowledge should come before throwing around the syntax), then you don't even need the syntatic sugar that Python provides to use them. There were two built-in decorators (classmethod and staticmethod) already available in Python 2.2 before the decorator syntax was even added in Python 2.4. It's just passing a callable to a callable which returns a callable which is then assigned to the original callable's identifier. Like this: a = b(a) where "a" is callable as well as b. The callable "b" just "decorates" the callable "a" with, um, something. Like maybe a new attribute. The decorator syntax just moves the order of reading the code around by showing "b" will decorate "a" after "a" is defined: @b def a(some, arguments, maybe): # a's body goes here It'd kind of like saying, "Here's an ornament which will go on the tree I'm about to put up," and then saying, "Here's the tree!," instead of saying, "Here's the tree, now let's decorate it with these ornaments." Six of one... -- Sincerely, Chris Calloway http://www.seacoos.org office: 332 Chapman Hall phone: (919) 962-4323 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From JeffH at delasco.com Tue Jan 15 20:29:11 2008 From: JeffH at delasco.com (Jeff Hinrichs) Date: Tue, 15 Jan 2008 13:29:11 -0600 Subject: [omaha] Decorators In-Reply-To: <478CD446.9020407@unc.edu> Message-ID: <94BC3D204A17734681830A69CBF99993DF7E9B@lilo.delasco.pri> Chris, The ddj article was excellent. I had not read it before. Thanks! I agree in principle with your sentiments about decorators. However, from time to time they do come in handy and if used/implemented properly/wisely, increase readability. Personally, I think that anything that reduces readability is a bug. (e.g. I'm torn in the debate over map v. list comprehensions. I feel that map is more readable than the equivalent list comprehension. But that might be due to familiarity so I've been forcing myself to use comprehensions to see if I change my mind.) http://wiki.python.org/moin/PythonDecoratorLibrary is a decent resource for some decorator use cases. Ones I have used are Memoizing, dumpArgs and Deprecation warnings. -j -----Original Message----- From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On Behalf Of Chris Calloway Sent: Tuesday, January 15, 2008 9:42 AM To: Omaha Python Users Group Subject: Re: [omaha] Decorators Eli Criffield wrote: >> Decorators in python are syntactic sugar to let you wrap a >> function/method with another function. Hey guys, two things. 1) This article about decorators is what you need to know, is comprehensive, and is the most digestible thing about decorators out there: http://www.ddj.com/184406073 The Python documentation about decorators should be as good as that article. And the fact that it's not says, um, several things I don't want to go into. Also, here's another very respectable article, if you already understand the previous one (and a good bit about metaclasses): http://www.ibm.com/developerworks/linux/library/l-cpdecor.html (The good Dr. Mertz might be the best writer about Python out there.) 2) You don't need the third party decorator module. It just pulls in some predefined decorators that some people have found useful like memoize, locked, delayed, threaded, and blocking. Plus it adds a decorator which is confusingly called "decorator," and which you *can* use to create decorators of a particular convention that *may* occasionally be useful (if using a factory-factory could ever be useful). Most people who use decorators already have their own utility module of useful decorators. The thing about decorators is they get used a lot by decorator-happy people who just learned about them or are trying to be overly clever. They are seldom all that useful. They have their place. There are some pretty standard decorators like memoize that many people understand already without having to look at what they do or how they do it. But often decorator usage is a bit overblown. Anything more than the simplest decorators add unnecessary and unreadable complexity to you code. And you don't want that. It isn't pythonic to add unnecessary and unreadable complexity to you code. The idea is to quickly write useful, testable, tested, sharable, and maintainable code; not to prove what an awesome computer scientist you are. :) You have to invest a lot to properly understand and use decorators. And then they get only a little and often trivial usage (do we really need an "author" attribute added to all of our functions; and if so, do we really need a decorator to do that?). Most of the time, decorators aren't worth it. Decorators are most useful for dorking around with metaclasses, which is another high investment/low return pattern. They're something you need to know to understand other people's code sometimes. If you find yourself using them a lot, you need to look in the mirror and ask yourself if you've really got a good overriding reason. Decorators tend to add "magic" at the cost of readability. They can also be seriously misused because using them requires remembering and following some recommendations that are not enforced by Python. The third party decorator module's "decorator" decorator is supposed to help with that somewhat. But then, if you need help with that, you probably shouldn't be using them. Certain levels of abstraction come at a steep cost. If understanding the abstraction is more difficult than understanding what is being abstracted, some soul searching is in order. Apparently, decorators had to be added to Python because Java had them. Oof. Notice that even though decorators are officially part of Python syntax, the official Python tutorial doesn't mention them. Anywhere. The fact is, if you know and need the decorator *programming pattern* (and the need and the knowledge should come before throwing around the syntax), then you don't even need the syntatic sugar that Python provides to use them. There were two built-in decorators (classmethod and staticmethod) already available in Python 2.2 before the decorator syntax was even added in Python 2.4. It's just passing a callable to a callable which returns a callable which is then assigned to the original callable's identifier. Like this: a = b(a) where "a" is callable as well as b. The callable "b" just "decorates" the callable "a" with, um, something. Like maybe a new attribute. The decorator syntax just moves the order of reading the code around by showing "b" will decorate "a" after "a" is defined: @b def a(some, arguments, maybe): # a's body goes here It'd kind of like saying, "Here's an ornament which will go on the tree I'm about to put up," and then saying, "Here's the tree!," instead of saying, "Here's the tree, now let's decorate it with these ornaments." Six of one... -- Sincerely, Chris Calloway http://www.seacoos.org office: 332 Chapman Hall phone: (919) 962-4323 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 _______________________________________________ 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 Mon Jan 21 04:58:40 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Sun, 20 Jan 2008 21:58:40 -0600 Subject: [omaha] PyCon 2008 Registration is now open Message-ID: <5aaed53f0801201958j5b3c602ax6cfa4eb93e3832e6@mail.gmail.com> Here is a link to the blog post announcing it. http://pycon.blogspot.com/2008/01/pycon-2008-registration-open.html I jumped over and found a couple glitches already with the system -- it's only been live minutes so there are bound to be a few. If you are going or thinking about going post a comment. -jeff -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Tue Jan 22 06:09:59 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Mon, 21 Jan 2008 23:09:59 -0600 Subject: [omaha] Plugin Framework/Architecture Message-ID: <5aaed53f0801212109v1d1ae4a6md2003873dde742a5@mail.gmail.com> There is an interesting write up on plugin architecture -- "g :: A Simple Plugin Framework", http://gulopine.gamemusic.org/2008/jan/10/simple-plugin-framework/ A project that I'm working on is going to require a plugin framework for a number of things: Logic, Data Storage, Reporting and I've been keeping my eyes open for papers/articles on plugin frameworks. Do you know of any resources/articles? -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From elicriffield at gmail.com Tue Jan 22 17:01:55 2008 From: elicriffield at gmail.com (Eli Criffield) Date: Tue, 22 Jan 2008 10:01:55 -0600 Subject: [omaha] off topic, windows updates? Message-ID: <18e3f33d0801220801n3b94089dv6fe7c61d7e8aaf17@mail.gmail.com> I remember in a meeting once someone talking about a website where you could get one program that will update a new windows install to current all in one swoop instead of the get 10 updates, reboot, get 10 updates reboot, ect... nightmare of windowsupdate.microsoft.com. Anyone remember what that was? Eli From JeffH at delasco.com Tue Jan 22 18:45:48 2008 From: JeffH at delasco.com (Jeff Hinrichs) Date: Tue, 22 Jan 2008 11:45:48 -0600 Subject: [omaha] off topic, windows updates? In-Reply-To: <18e3f33d0801220801n3b94089dv6fe7c61d7e8aaf17@mail.gmail.com> Message-ID: <94BC3D204A17734681830A69CBF99993DF7EC2@lilo.delasco.pri> Sorry, nope. We use shavlik for the day job and I stay away from w32 otherwise ;) -----Original Message----- From: omaha-bounces at python.org [mailto:omaha-bounces at python.org] On Behalf Of Eli Criffield Sent: Tuesday, January 22, 2008 10:02 AM To: Omaha Python Users Group Subject: [omaha] off topic, windows updates? I remember in a meeting once someone talking about a website where you could get one program that will update a new windows install to current all in one swoop instead of the get 10 updates, reboot, get 10 updates reboot, ect... nightmare of windowsupdate.microsoft.com. Anyone remember what that was? Eli _______________________________________________ Omaha Python Users Group mailing list Omaha at python.org http://mail.python.org/mailman/listinfo/omaha http://www.OmahaPython.org From choman at gmail.com Tue Jan 22 22:27:55 2008 From: choman at gmail.com (Chad Homan) Date: Tue, 22 Jan 2008 15:27:55 -0600 Subject: [omaha] GnuCash and others Message-ID: Hey all, last python meeting (or two ago) there was a tangent discussion on gnuCash. Here is an article form CPU Mag on that same topic. http://www.computerpoweruser.com/editorial/article.asp?article=articles%2farchive%2fc0803%2f40c03%2f40c03.asp&guid=3084CA441C0F44939952641F05F35ABA TinyUrl: *http://tinyurl.com/2eujpp *I am a bigger fan of url(x) but it seems shutdown at the moment. Jeff I definitely would like to hear you two cents on these projects from the article -- Chad From jeff at taupro.com Wed Jan 23 04:25:34 2008 From: jeff at taupro.com (Jeff Rush) Date: Tue, 22 Jan 2008 21:25:34 -0600 Subject: [omaha] Plugin Framework/Architecture In-Reply-To: <5aaed53f0801212109v1d1ae4a6md2003873dde742a5@mail.gmail.com> References: <5aaed53f0801212109v1d1ae4a6md2003873dde742a5@mail.gmail.com> Message-ID: <4796B3AE.1040707@taupro.com> Jeff Hinrichs - DM&T wrote: > There is an interesting write up on plugin architecture -- "g :: A > Simple Plugin Framework", > http://gulopine.gamemusic.org/2008/jan/10/simple-plugin-framework/ Thanks for the reading material! > A project that I'm working on is going to require a plugin framework > for a number of things: Logic, Data Storage, Reporting and I've been > keeping my eyes open for papers/articles on plugin frameworks. Do you > know of any resources/articles? Two options you should consider: 1) The Twisted framework has a very nice plugin-architecture you can use, whether you use the rest of Twisted or not. Google for "twisted IPlugin". For an example, you can take a peek at the Dallas-Ft. Worth Pythoneers' subversion repository - we played with it a bit, in relation to providing plugins to the D-BUS architecture. https://www.dfwpython.org/repo/Projects/DBUS/ 2) Python eggs, using the Setuptools software, have a concept of entrypoints, which are named and categorized. They are an upcoming standard way of doing plugins for Python. There is a standard API for querying for entrypoints. You can read all about it at: http://peak.telecommunity.com/DevCenter/setuptools#extensible-applications-and-frameworks It is also the method used by zc.buildout, a great tool for managing development/deployment for repeatability. And then the third way, of leveraging the interfaces database of the Zope component system, as described in the article you provided. -Jeff From jeffh at dundeemt.com Wed Jan 23 05:49:59 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Tue, 22 Jan 2008 22:49:59 -0600 Subject: [omaha] GnuCash and others In-Reply-To: References: Message-ID: <5aaed53f0801222049u6dcfad5ax367394d7b4c4f8e8@mail.gmail.com> Of the main 3, gnuCash, KMyMoney2 and MoneyDance only MoneyDance has real python support. However it is not scriptable, reportable from outside of MoneyDance. Your scripts run under the auspices of MoneyDance - fire up MD and run your python macro. MD also costs $,not much but still. KMyMoney2 is a decent, "where's my money" app -- every bit as good as MSMoney or Quicken in terms of data entry. However, gnuCash is more established and is a solid double entry accounting system. After trying out all 3 I decided to go with gnuCash and it has been acceptable to a point. To clarify, gnuCash is solid and a decent replacement for quick or money but it has a few blemishes in my estimation. 1) It is written in C++/Guile/Scheme - fine, great whatever works for you. but it makes it decidedly slow in getting additional contributors. Take the number of people who know guile or want to learn it for this one reason and then subtract those not interested in contributing to an accounting program and you are left with a very small number. Very bright, very intelligent but a very small number of developers. 2) They fix bugs as they are encounted -- but unless you are up to recompiling the whole shebang you are stuck with the packages your dist is supplying. 3) Documentation for extending or adding reports is non-existent -- they point you to a couple of example reports but that is not much help. Even if you were a Guile pro it wouldn't help because there isn't any docs on what is available to the reporting engine. Now it sounds like I'm really down on gnuCash -- and I'll admit I've just slapped it around quite a bit but compared to the other apps available, both closed and open -- gnuCash is the reigning champion. They do lots of things right -- there is a lot of experience with it and a pretty active user mail list. I use gnuCash for my personal accounting. On 1/22/08, Chad Homan wrote: > Hey all, last python meeting (or two ago) there was a tangent discussion on > gnuCash. Here is > an article form CPU Mag on that same topic. > > http://www.computerpoweruser.com/editorial/article.asp?article=articles%2farchive%2fc0803%2f40c03%2f40c03.asp&guid=3084CA441C0F44939952641F05F35ABA > > TinyUrl: *http://tinyurl.com/2eujpp > > *I am a bigger fan of url(x) but it seems shutdown at the moment. > > Jeff I definitely would like to hear you two cents on these projects from > the article > > -- > Chad > _______________________________________________ > 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 Wed Jan 23 06:00:51 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Tue, 22 Jan 2008 23:00:51 -0600 Subject: [omaha] Plugin Framework/Architecture In-Reply-To: <4796B3AE.1040707@taupro.com> References: <5aaed53f0801212109v1d1ae4a6md2003873dde742a5@mail.gmail.com> <4796B3AE.1040707@taupro.com> Message-ID: <5aaed53f0801222100k5afcaebcgefeee562f38f6c2@mail.gmail.com> On 1/22/08, Jeff Rush wrote: > Jeff Hinrichs - DM&T wrote: > > There is an interesting write up on plugin architecture -- "g :: A > > Simple Plugin Framework", > > http://gulopine.gamemusic.org/2008/jan/10/simple-plugin-framework/ > > Thanks for the reading material! > > > > A project that I'm working on is going to require a plugin framework > > for a number of things: Logic, Data Storage, Reporting and I've been > > keeping my eyes open for papers/articles on plugin frameworks. Do you > > know of any resources/articles? > > Two options you should consider: > > 1) The Twisted framework has a very nice plugin-architecture you > can use, whether you use the rest of Twisted or not. Google > for "twisted IPlugin". > > For an example, you can take a peek at the Dallas-Ft. Worth > Pythoneers' subversion repository - we played with it a bit, > in relation to providing plugins to the D-BUS architecture. > > https://www.dfwpython.org/repo/Projects/DBUS/ > > 2) Python eggs, using the Setuptools software, have a concept of > entrypoints, which are named and categorized. They are an > upcoming standard way of doing plugins for Python. There is > a standard API for querying for entrypoints. > > You can read all about it at: > > http://peak.telecommunity.com/DevCenter/setuptools#extensible-applications-and-frameworks > > It is also the method used by zc.buildout, a great > tool for managing development/deployment for repeatability. Hmmm.. now I've got some reading to do. Thanks! > And then the third way, of leveraging the interfaces database of the Zope > component system, as described in the article you provided. Are you going to be speaking about zc.buildout quite a bit at the Tutorial? If so, I might need to update my registration Look forward to seeing you @ PyCon. -jeff From jeff at taupro.com Wed Jan 23 06:58:10 2008 From: jeff at taupro.com (Jeff Rush) Date: Tue, 22 Jan 2008 23:58:10 -0600 Subject: [omaha] Plugin Framework/Architecture In-Reply-To: <5aaed53f0801222100k5afcaebcgefeee562f38f6c2@mail.gmail.com> References: <5aaed53f0801212109v1d1ae4a6md2003873dde742a5@mail.gmail.com> <4796B3AE.1040707@taupro.com> <5aaed53f0801222100k5afcaebcgefeee562f38f6c2@mail.gmail.com> Message-ID: <4796D772.4040708@taupro.com> Jeff Hinrichs - DM&T wrote: > On 1/22/08, Jeff Rush wrote: >> >> It is also the method used by zc.buildout, a great >> tool for managing development/deployment for repeatability. > > Are you going to be speaking about zc.buildout quite a bit at the > Tutorial? If so, I might need to update my registration I'm planning on doing 1/3 on distutils, 1/3 on setuptools/eggs, and 1/3 on zc.buildout, leveraging each section from the previous and showing how they relate. 40 minutes of talk plus 20 minutes of hands-on exercises for each phase. That's the allotment plan anyway - we'll see once I begin timing it. In that time we're not going to get into the more obscure options or very advanced usage. -Jeff From jeff at taupro.com Wed Jan 23 07:11:36 2008 From: jeff at taupro.com (Jeff Rush) Date: Wed, 23 Jan 2008 00:11:36 -0600 Subject: [omaha] GnuCash and others In-Reply-To: <5aaed53f0801222049u6dcfad5ax367394d7b4c4f8e8@mail.gmail.com> References: <5aaed53f0801222049u6dcfad5ax367394d7b4c4f8e8@mail.gmail.com> Message-ID: <4796DA98.9010207@taupro.com> By coincidence I've just started evaluating GnuCash this week, to replace a homegrown system I wrote in Zope years ago and no longer have time to maintain. Jeff Hinrichs - DM&T wrote: > > After trying out all 3 I decided to go with gnuCash and it has been > acceptable to a point. To clarify, gnuCash is solid and a decent > replacement for quick or money but it has a few blemishes in my > estimation. 1) It is written in C++/Guile/Scheme - fine, great > whatever works for you. but it makes it decidedly slow in getting > additional contributors. Yeah, I wish it was more accessible to Python as well. Although reading the site, the interface to Scheme is via SWIG, so it wouldn't be too hard to re-run SWIG on the definition files and get a Python interface. And then you'd have to document it for Python folks. > 3) Documentation for extending or adding reports is non-existent -- > they point you to a couple of example reports but that is not much > help. Even if you were a Guile pro it wouldn't help because there > isn't any docs on what is available to the reporting engine. And we need API docs to the GnuCash internals, even if we got Python hooked in. > Now it sounds like I'm really down on gnuCash -- and I'll admit I've > just slapped it around quite a bit but compared to the other apps > available, both closed and open -- gnuCash is the reigning champion. > They do lots of things right -- there is a lot of experience with it > and a pretty active user mail list. One other attribute - GnuCash doesn't use a mainstream relational database but their own b-tree format that isn't really multi-user and hence not potentially web accessible either. Doesn't matter for some folks. -Jeff From jeffh at dundeemt.com Wed Jan 23 13:44:10 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 23 Jan 2008 06:44:10 -0600 Subject: [omaha] GnuCash and others In-Reply-To: <4796DA98.9010207@taupro.com> References: <5aaed53f0801222049u6dcfad5ax367394d7b4c4f8e8@mail.gmail.com> <4796DA98.9010207@taupro.com> Message-ID: <5aaed53f0801230444m33005c7fydb9b9c7d722c08e0@mail.gmail.com> On 1/23/08, Jeff Rush wrote: > By coincidence I've just started evaluating GnuCash this week, to replace a > homegrown system I wrote in Zope years ago and no longer have time to maintain. > > Jeff Hinrichs - DM&T wrote: > > > > After trying out all 3 I decided to go with gnuCash and it has been > > acceptable to a point. To clarify, gnuCash is solid and a decent > > replacement for quick or money but it has a few blemishes in my > > estimation. 1) It is written in C++/Guile/Scheme - fine, great > > whatever works for you. but it makes it decidedly slow in getting > > additional contributors. > > Yeah, I wish it was more accessible to Python as well. Although reading the > site, the interface to Scheme is via SWIG, so it wouldn't be too hard to > re-run SWIG on the definition files and get a Python interface. And then > you'd have to document it for Python folks. There is a project http://www.parit.ca/projects/pythongnucash that has SWIG bindings and additional python code. I've not had a chance to play with it. > > > 3) Documentation for extending or adding reports is non-existent -- > > they point you to a couple of example reports but that is not much > > help. Even if you were a Guile pro it wouldn't help because there > > isn't any docs on what is available to the reporting engine. > > And we need API docs to the GnuCash internals, even if we got Python hooked in. > > > > Now it sounds like I'm really down on gnuCash -- and I'll admit I've > > just slapped it around quite a bit but compared to the other apps > > available, both closed and open -- gnuCash is the reigning champion. > > They do lots of things right -- there is a lot of experience with it > > and a pretty active user mail list. > > One other attribute - GnuCash doesn't use a mainstream relational database but > their own b-tree format that isn't really multi-user and hence not potentially > web accessible either. Doesn't matter for some folks. > Actually, gnucash 2.x uses an XML format and there is a project http://www.nabble.com/python-parser-of-gnucash-file-td14736483.html that use ElementTree to read the db. The Multi-user dilemma is still a problem and will most likely remain from what I've read in the lists. -jeff From mike at hostetlerhome.com Wed Jan 23 14:36:47 2008 From: mike at hostetlerhome.com (Mike Hostetler) Date: Wed, 23 Jan 2008 07:36:47 -0600 (CST) Subject: [omaha] DjangoPeople Message-ID: <54065.69.58.248.102.1201095407.squirrel@email.powweb.com> Facebook for Django users -- written in Django (I assume) http://djangopeople.net/ Mike From jeffh at dundeemt.com Wed Jan 23 15:46:34 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 23 Jan 2008 08:46:34 -0600 Subject: [omaha] DjangoPeople In-Reply-To: <54065.69.58.248.102.1201095407.squirrel@email.powweb.com> References: <54065.69.58.248.102.1201095407.squirrel@email.powweb.com> Message-ID: <5aaed53f0801230646y79460d24ld389f8359959fce0@mail.gmail.com> On 1/23/08, Mike Hostetler wrote: > > > Facebook for Django users -- written in Django (I assume) > > http://djangopeople.net/ > I saw that this morning but I didn't see you listed. Must have been looking right before you submitted. ;) Mike are you going to speak at the next meeting? (Feb 6) -jeff From mike at hostetlerhome.com Wed Jan 23 16:06:34 2008 From: mike at hostetlerhome.com (Mike Hostetler) Date: Wed, 23 Jan 2008 09:06:34 -0600 (CST) Subject: [omaha] DjangoPeople In-Reply-To: <5aaed53f0801230646y79460d24ld389f8359959fce0@mail.gmail.com> References: <54065.69.58.248.102.1201095407.squirrel@email.powweb.com> <5aaed53f0801230646y79460d24ld389f8359959fce0@mail.gmail.com> Message-ID: <50872.69.58.248.102.1201100794.squirrel@email.powweb.com> Jeff Hinrichs - DM&T wrote: > On 1/23/08, Mike Hostetler wrote: >> >> >> Facebook for Django users -- written in Django (I assume) >> >> http://djangopeople.net/ >> > I saw that this morning but I didn't see you listed. Must have been > looking right before you submitted. ;) > > Mike are you going to speak at the next meeting? (Feb 6) > I listed myself before sending it to you guys. :) I am planning on Feb 6.? Man, that is just around the corner. Expect a talk on BeautifulSoup! I will have my daughter in tow. Mike Hostetler http://mike.hostetlerhome.com From jeffh at dundeemt.com Wed Jan 30 04:30:43 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Tue, 29 Jan 2008 21:30:43 -0600 Subject: [omaha] ANN: Omaha Python Users Group Meeting -- Wed, Feb 6th @ 7pm Message-ID: <5aaed53f0801291930s489bb570s13a0b24818580e1f@mail.gmail.com> Where: Roskens Hall (College of Business Administration), Room 310 University of Nebraska at Omaha 6000 Dodge Street Omaha Nebraska 68104 When: February 6, 2008 @ 7pm Topics: * django - Mike Hostetler * Lightning Talks * Group Q and A session Refreshments: The venue does not allow food/drink so we'll meet socially afterwards Contact Information * Mail list: http://mail.python.org/mailman/listinfo/omaha * Web Site: http://www.omahapython.org/ For more information and maps please see the website http://www.omahapython.org -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473 From jeffh at dundeemt.com Wed Jan 30 14:41:06 2008 From: jeffh at dundeemt.com (Jeff Hinrichs - DM&T) Date: Wed, 30 Jan 2008 07:41:06 -0600 Subject: [omaha] ANN: PyCon 2008 Message-ID: <5aaed53f0801300541i782b54fdw44c9bec0c296e47e@mail.gmail.com> PyCon 2008 is coming up fast. Here is some information on the conference and links for more information: Chicago, IL March 14-16, 2008 http://us.pycon.org PyCon 2008, the sixth annual community conference for the Python programming language, will take place March 14-16 at the Crowne Plaza Chicago O'Hare Hotel. A rich schedule is being planned, including presentations, keynotes, Lightning Talks, an exhibition hall, and the hands-on Python Lab. Plentiful Open Space has been set aside for Birds-of-a-Feather sessions and other unscheduled "unconference"-style activity. Topics span the range of Python programming activity from introductory to advanced. Some topics are perennial; others focus on recent news, like Python 3000 and new developments in Python for the .NET and Java environments. The conference will be preceded by a day of intensive tutorials (March 13). Afterward, four days of development sprints (March 17-20) will bring participants together for face-to-face cooperation to advance several Python open-source projects. PyCon attendance grew 44% from 2006 to 2007, reflecting the rapidly growing popularity of the language. PyCon 2008 has already set records for number of talks, tutorials, and sprints planned. Registration is open now. Early-bird registration rates ($400 corporate, $220 hobbyist, $125 student) are available through February 20. PyCon: http://us.pycon.org PyCon blog: http://pycon.blogspot.com/ Python language: http://python.org -- Jeff Hinrichs Dundee Media & Technology, Inc jeffh at dundeemt.com 402.218.1473