We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When accessing an attribute on a node, RedBaron searches recursively for a matching node.
This is infuriating to program against because it finds matches that I don't expect, at any depth in the AST.
This makes working with blocks harder - if/elif/else, try/except/else/finally and so on.
>>> cond = RedBaron(""" ... if foo: ... if bar: ... x ... else: ... y ... """)[0] >>> cond.else_ else: y
Here the answer I'm looking for is None.
None
It is very odd that searching recursively is a convenient node.foo.bar while to avoid searching recursively is a laborious
node.foo.bar
node.find('foo', recursive=False).find('bar', recursive=False)
The text was updated successfully, but these errors were encountered:
In case anyone wants a quick workaround for this, I wrote some monkey-patches using patchy:
import patchy patchy.mc_patchface(Node.__getattr__, """ @@ -12,1 +12,1 @@ - return self.find(key) + return self.find(key, recursive=False) """) patchy.mc_patchface(NodeList.__getattr__, """ @@ -7,1 +7,1 @@ - return self.find(key) + return self.find(key, recursive=False) """)
Sorry, something went wrong.
No branches or pull requests
When accessing an attribute on a node, RedBaron searches recursively for a matching node.
This is infuriating to program against because it finds matches that I don't expect, at any depth in the AST.
This makes working with blocks harder - if/elif/else, try/except/else/finally and so on.
Here the answer I'm looking for is
None
.It is very odd that searching recursively is a convenient
node.foo.bar
while to avoid searching recursively is a laboriousThe text was updated successfully, but these errors were encountered: