Skip to content

kootenpv/python-comprehension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

python-comprehend.el

The goal is to offer a single shortcut to make comprehensions from for loops.

Use the function python-comprehend to search back for a for loop and try to write it as a comprehension:

# if else for dict
options = {}
for i in range(10):
    if i > 5:
        options[i] = i + 1
    else:
        options[i] = None


# becomes
options = {i: i + 1 if i > 5 else None for i in range(10)}

It currently handles:

  • set, list, dict
  • no ifs (a simple for loop), ifs, and if..elses

About

Comprehension and decomprehension refactoring

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published