Convert non-Expr objects to Expr objects.
(obj)
| 925 | |
| 926 | |
| 927 | def as_expr(obj): |
| 928 | """Convert non-Expr objects to Expr objects. |
| 929 | """ |
| 930 | if isinstance(obj, complex): |
| 931 | return as_complex(obj.real, obj.imag) |
| 932 | if isinstance(obj, number_types): |
| 933 | return as_number(obj) |
| 934 | if isinstance(obj, str): |
| 935 | # STRING expression holds string with boundary quotes, hence |
| 936 | # applying repr: |
| 937 | return as_string(repr(obj)) |
| 938 | if isinstance(obj, tuple): |
| 939 | return tuple(map(as_expr, obj)) |
| 940 | return obj |
| 941 | |
| 942 | |
| 943 | def as_symbol(obj): |
searching dependent graphs…