Changes between Initial Version and Version 1 of Ticket #28414, comment 48


Ignore:
Timestamp:
09/11/19 11:10:34 (2 years ago)
Author:
SimonKing
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28414, comment 48

    initial v1  
    2222Question: How to test in a py2/py3 invariant way whether a type is a builtin?
    2323
    24 That asked, are there more iterable builtins than list, tuple, str/bytes and dict? I guess it is safer to just explicitly test for list and tuple.
     24That asked, are there more iterable builtins than list, tuple, str/bytes and dict? I guess it is safer to just explicitly test for list and tuple. EDIT Like this:
     25{{{
     26#!python
     27    if isinstance(G, dict):
     28        return dict((pickle_gap_data(k), pickle_gap_data(v)) for k,v in G.items())
     29    if isinstance(G, (list, tuple)]:
     30        return type(G)(pickle_gap_data(X) for X in G)
     31    return G
     32}}}