Python optional args - great for evolving source code

Submitted by metaperl on Tue, 12/12/2006 - 8:54am.

Optional args are not part of the Haskell Way. I have about 20 calls to this function:

def archive_zip(my):
for f in path('*'):

but then I needed to do the same thing but I needed to prepend the date to the file for one particular invocation of this. So, in Python, I simply tacked on an optional argument and used a default value which led to the behavior that the oroginal 20 calls to this function would expect and then I added some code to handle prepending of date:

def archive_zip(my, prepend_date=False):
for f in path('*'):
if prepend_date:
today =
s = today.strftime("%b-%d-%y")
newfile = "%s-%s" % (s, f)
syscmd = "cd %s; mv %s %s" % (my.archive, f, newfile)
print syscmd

Now, I'm not sure how quickly I could evolve this function in Haskell, but I'm dead curious to know.

Submitted by Bárður Árantsson on Wed, 12/20/2006 - 6:50am.

Oleg (who else?) has Haskell code to do keyword arguments at his site. YMMV, of course.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.