Re: [Tutor] Pulling items from a dict in a print command

2014-06-18 Thread Danny Yoo
Hi Ben, There's a bit of duplication in the keys being looked up, making it a bit fragile if you need to correct the spelling of a key or need to add additional keys, since there are two places that need to be changed. One way to make this a little cleaner might be to have a helper function that

Re: [Tutor] Pulling items from a dict in a print command

2014-06-18 Thread Peter Otten
Ben Sherman wrote: > Whats a more pythony way to do this? I have a dict with a few dozen > elements, and I want to pull a few out. I've already shortened it with > itemgetter, but it still seems redundant. I feel like I can do something > like I've seen with *kwargs, but I'm not sure. > > I'm

[Tutor] Pulling items from a dict in a print command

2014-06-18 Thread Ben Sherman
Whats a more pythony way to do this? I have a dict with a few dozen elements, and I want to pull a few out. I've already shortened it with itemgetter, but it still seems redundant. I feel like I can do something like I've seen with *kwargs, but I'm not sure. I'm using old style sprintf formatti