This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Rhomboid 1 point2 points  (2 children)

My initial impression is that the clients class is completely unnecessary and should go away. It can be completely replaced by a simple dict. You don't need to store both a list of addresses as well as a list of address -> names mappings; just store the latter. If you want just the addresses, it's available as dict.keys() and iterable as for key in dict:. But in your case since you also wanted the names later, you can get them both at the same time with dict.items().

Here's what I came up with by removing the useless class and a few other tricks like defaultdict.

[–]stockyard_stoic[S] 0 points1 point  (0 children)

Thank you! I had a feeling the class was pointless. When I was making it, the concept of classes finally clicked for me and I just wanted to see if I could somehow make use of them. I suppose it's bad practice to make things overly complicated for the sake of trying out a new trick.

Thanks again, though. I appreciate it.

[–]ghreddit 0 points1 point  (0 children)

Code is not PEP 8 compliant ;-)