[Python-ideas] An easier syntax for writing decorators(&similar things)?
Aaron Brady
castironpi at comcast.net
Fri Jan 25 03:03:38 CET 2008
> [1] I know you didn't copy these from real code anywhere because they
> all have typos -- they're missing urlparse/urlretrieve as the first
> arguments to partial() or prepartial().
Repair treated.
Original function:
1. urlparse( urlstring[, default_scheme[, allow_fragments]])
2. urlretrieve( url[, filename[, reporthook[, data]]])
In action:
1. parseA= prepartial( urlparse, 'ftp', False )
2. retrieveA= prepartial( urlretrieve, 'temp.htm', callbackA )
Equivalent A:
1. parseAB= partial( urlparse,
default_scheme= 'ftp', allow_fragments= False )
2. retrieveAB= partial( urlretrieve,
filename= 'temp.htm', reporthook= callbackA )
Equivalent B:
1. parseAC= lambda url: urlparse( url, 'ftp', False )
2. retrieveAC= lambda url: urlretrieve( url, 'temp.htm', callbackA )
Examples in gestation; check back in several months; a +fraction; you're on
the right track.
More information about the Python-ideas
mailing list