This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def visit(node, parent, field_name, field_index): | |
node_item = handle_item(node, parent, field_name, field_index) | |
if node_item is None: | |
return | |
fields = {} | |
for field_name, field in ast.iter_fields(node): | |
fieldset = fields.setdefault(field_name, []) | |
if isinstance(field, list): | |
for i, item in enumerate(field): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [1,2,3,[4,5,6,[77,88]]] | |
def run_through(data): | |
for x in data: | |
if isinstance(x, list): | |
yield from run_through(x) | |
continue | |
yield x | |
it = run_through(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def towers(num, frompeg, topeg, aux, final): | |
if num > 0: | |
towers(num-1, frompeg, aux, topeg, False) | |
if final: | |
print('final') | |
print("move disk %d from %s to %s" % (num, frompeg, topeg)) | |
towers(num-1, aux, topeg, frompeg, final) | |
towers(5, 'A', 'B', 'C', True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
empty file created by nbx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
empty file created by nbx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
empty file created by nbx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
empty file created by nbx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
empty file created by nbx |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.