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