D
Drew
All -
I'm currently writing a toy program as I learn python that acts as a
simple address book. I've run across a situation in my search function
where I want to iterate across a filtered list. My code is working
just fine, but I'm wondering if this is the most "elegant" way to do
this. Essentially, I'm searching the dict self.contacts for a key that
matches the pattern entered by the user. If so, I print the value
associated with that key. A pastie to the method is below, any help/
advice is appreciated:
http://pastie.caboo.se/46647
Side note: I'm learning python after ruby experience. In ruby I would
do something like:
contacts.find_all{|name,contact| name =~ /search/}.each{|name,contact|
puts contact}
I'm currently writing a toy program as I learn python that acts as a
simple address book. I've run across a situation in my search function
where I want to iterate across a filtered list. My code is working
just fine, but I'm wondering if this is the most "elegant" way to do
this. Essentially, I'm searching the dict self.contacts for a key that
matches the pattern entered by the user. If so, I print the value
associated with that key. A pastie to the method is below, any help/
advice is appreciated:
http://pastie.caboo.se/46647
Side note: I'm learning python after ruby experience. In ruby I would
do something like:
contacts.find_all{|name,contact| name =~ /search/}.each{|name,contact|
puts contact}