diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-03-04 09:29:46 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-03-04 09:29:46 +0200 |
commit | 230bf69325eef9c58a24db614c2a104638b6fbeb (patch) | |
tree | 5f531c755d247f2c805d1eaca367e679a7fc4f48 /as_string.py | |
parent | 2e0df240db0cf677b0821371af7c2dfc021452ab (diff) | |
download | astroid-git-230bf69325eef9c58a24db614c2a104638b6fbeb.tar.gz |
Drop yield_from API, add a new YieldFrom node instead.
--HG--
branch : yield_from
Diffstat (limited to 'as_string.py')
-rw-r--r-- | as_string.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/as_string.py b/as_string.py index 1863b937..ace1c4e3 100644 --- a/as_string.py +++ b/as_string.py @@ -429,11 +429,7 @@ class AsStringVisitor(object): def visit_yield(self, node): """yield an ast.Yield node as string""" yi_val = node.value and (" " + node.value.accept(self)) or "" - if node.yield_from: - yield_ = 'yield from' - else: - yield_ = 'yield' - expr = yield_ + yi_val + expr = 'yield' + yi_val if node.parent.is_statement: return expr else: @@ -471,6 +467,15 @@ class AsStringVisitor3k(AsStringVisitor): """return Starred node as string""" return "*" + node.value.accept(self) + def visit_yieldfrom(self, node): + """ Return an astroid.YieldFrom node as string. """ + yi_val = node.value and (" " + node.value.accept(self)) or "" + expr = 'yield from' + yi_val + if node.parent.is_statement: + return expr + else: + return "(%s)" % (expr,) + def _import_string(names): """return a list of (name, asname) formatted as a string""" |