Skip to content

Iterator / context manager extraction #95

@talwrii

Description

@talwrii

So yeah, I don't seem to be a good beta tester: you might not want to immediately implement this. But this struck me as an interesting idea and this project feels like the correct community for useable python refactoring tools, so I thought I'd throw this idea up here.

Sometimes I don't want to extract a region... so much as everything apart from a region.

An example:

def f():
    for x in blah():
        if filter(x):
           continue
        do_stuff(x)

# should become

def iterate_x():
     for x in blah:
         if filter(x):
             continue
         else:
               yield x

def f():
     for x in iterate_x():
          do_stuff(x)

The same idea applies to context managers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions