RepugNaNt [entries|reading|network|archive]
simont

[ userinfo | dreamwidth userinfo ]
[ archive | journal archive ]

Wed 2011-12-07 15:45
RepugNaNt
LinkReply
[personal profile] simontWed 2011-12-07 22:51
Do you think (key, value) in dictionary.viewitems() is horrific? It seems to me that it's pretty close to ideal. The only improvement would be if I'd been able to just write (key, value) in dictionary, on the principle that a dictionary is mathematically speaking a restricted form of relation and a relation is a subset of the set of possible ordered pairs. Sadly, in dictionary was already used for something else.
Link Reply to this | Parent | Thread
[personal profile] andrewduckerWed 2011-12-07 23:21
It doesn't read naturally to me,and tell me what it's doing. I'd rather end up with code like:
if dictionary.itemequals(key,value):
but that may just be my lack of familiary with Python showing. If the former code is idiomatic Python then go for it.
Link Reply to this | Parent | Thread
[personal profile] andrewduckerThu 2011-12-08 08:42
My brain clicked this morning, and suddenly the viewitems seems much more natural. I was clearly too tired to be looking at code when I commented last night.
Link Reply to this | Parent | Thread
[personal profile] simontThu 2011-12-08 09:05
On the other hand, I freely concede the horrificness of the NaN approach! But then, I never intended to put that one in actual code, only to post it on the Internet and marvel at how horrible it was :-)
Link Reply to this | Parent
navigation
[ go | Previous Entry | Next Entry ]
[ add | to Memories ]