Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-07 Thread Chris Rebert (cybercobra)
Agreed, I dislike map and its ilk as well. However, they are handy in some cases. I particularly like the way Ruby deals with this problem. Instead of all these functions, internal iterators and true anonymous blocks are used. Case in point: def gt_than_5(obj): return obj > 5 results = filter(

Re: Favorite non-python language trick?

2005-07-01 Thread Chris Rebert (cybercobra)
My personal favorite would be ruby's iterators and blocks. Instead of writing a bunch of repetitive list comprehensions or defining a bunch of utility functions, you just use the iterators supported by container objects. For instance, [f(x) for x in y] could be written in Ruby as y.collect |x| d

Re: Archives and magic bytes

2005-03-23 Thread Chris Rebert (cybercobra)
Have you tried the tarfile or zipfile modules? You might need to ugrade your python if you don't have them. They look pretty easy and should make this a snap. You can grab the output from the *nix "file" command using the new subprocess module. Good Luck - Chris === PYTHON POWERs all! All your

Re: Simple account program

2005-03-21 Thread Chris Rebert (cybercobra)
You probably want: import pickle pickle.dump(myAccount, file("account.pickle", "w")) To reload your account: import pickle myAccount = pickle.load(file("account.pickle")) -- http://mail.python.org/mailman/listinfo/python-list

Re: missing? dictionary methods

2005-03-21 Thread Chris Rebert (cybercobra)
Antoon Pardon wrote: > Well at least I find them missing. > > For the moment I frequently come across the following cases. > > 1) Two files, each with key-value pairs for the same dictionary. > However it is an error if the second file contains a key that > was not in the first file. > > In treati

Re: (",) Do You Want To Know For Sure You Are Going To Heaven?

2005-03-20 Thread Chris Rebert (cybercobra)
Please do STFU! You are most annoying and this is the wrong place to post this. If anyone else if reading this, yes, I do realize it's probably a bot. But I need to vent some rage. Now if only his nick didn't have a "..." in it... I would so report it to yahoo and/or counterspam it. -- http://mai

Re: getting text from WinXP console

2005-03-20 Thread Chris Rebert (cybercobra)
You want the function raw_input(). Have you read the tutorial? I should have been covered there. -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple account program

2005-03-18 Thread Chris Rebert (cybercobra)
Since everyone's improving the program, I thought I'd just tweak Dennis Lee Bieber's code a little. Here's the result. Good luck Ignorati! import time class Transaction(object): def __init__(self, payee, amount, date=None): # amount is the amt withdrawn/deposited self.payee =