(May-02-2017, 04:55 AM)Larz60+ Wrote: type(tuple_name).__name__
this just gives me the original name of the object, not the list of keys.
type(sys.version_info).__name__ -> 'version_info' but i am wanting whatever(sys.version_info) -> ('major', 'minor', 'micro', 'releaselevel', 'serial') or something like that (a list, a set, a dict, or whatever). please note that sys.version_info is just one possible example. a different (any) named tuple may be involved, so don't try to focus on that one case.
you know how
d = some dictionary [x for x in d]gives a list of keys in the dictionary. doing that with a named tuple gives a list of the values. there is no .keys() for a named tuple and and dir() of the name tuple includes other attributes. and even if you can remove the other attributes from dir(), the order is sorted, not the original order (tuples have an order).
i just know someone is going to say "dictionaries and tuples are different". i know that. that's why i am asking.
well... much of the real reason i am asking is to figure out how to code for them in a revision of my print_object() function in my printobject module. i want it to produce an expression that can be embedded in python source code.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.