potc.translate.quick¶
transobj¶
-
potc.translate.quick.
transobj
(obj, trans=None) → potc.translate.trans.ObjectTranslation[source]¶ - Overview:
Process-oriented version of
potc.translate.trans.BaseTranslator.transobj()
.- Arguments:
obj: Object to be translated.
trans: Translator to be used, default is
None
which means use an instance of :class:’potc.translate.trans.Translator’.
- Returns:
result (
ObjectTranslation
): Result of object translation.
- Examples::
>>> import math >>> t = transobj([1, '2', 3.4, ..., None, math.e]) >>> t <potc.translate.trans.ObjectTranslation object at 0x7f08a9520f10> >>> t.code "[1, '2', 3.4, ..., None, math.e]" >>> t.imports (<_SelfDirectImport 'import math'>,)
transvars¶
-
potc.translate.quick.
transvars
(vars_, trans=None, reformat=None, isort: bool = True) → potc.translate.trans.VarsTranslation[source]¶ - Overview:
Process-oriented version of
potc.translate.trans.BaseTranslator.transvars()
.- Arguments:
vars_ (
Mapping[str, Any]
): Variables to be translated.trans: Translator to be used, default is
None
which means use an instance of :class:’potc.translate.trans.Translator’.reformat: Reformatter for the final source code, default is
None
which means do not reformat the code.isort (
bool
): Sort the import statements, default isTrue
.
- Returns:
result (
VarsTranslation
): Result of vars translation.
- Examples::
>>> import math >>> t = transvars({ ... 'a': [1, '2', 3.4, ..., None, math.e], ... 'b': dict(a='ds', b=(), c={3, 4, 5}), ... }) >>> t <potc.translate.trans.VarsTranslation object at 0x7f08a95cd5b0> >>> print(t.code) import math __all__ = ['a', 'b'] a = [1, '2', 3.4, ..., None, math.e] b = {'a': 'ds', 'b': (), 'c': {3, 4, 5}}