Skip to content

Commit

Permalink
Added itertools to pre-imported modules (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
logworthy authored and FichteFoll committed Dec 15, 2019
1 parent eccf3af commit f21221e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion InsertNums.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Modules for expression evaluation
import math
import random
import itertools

import sublime
import sublime_plugin
Expand Down Expand Up @@ -339,7 +340,7 @@ def run(self, edit, format='', quiet=False):
env = dict(
_=value, i=i, p=eval_value, s=step, n=len(selections),
# Modules
math=math, random=random, re=re
math=math, random=random, re=re, itertools=itertools
)
if EXPRMODE:
del env['s'] # We don't need the step here
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Detailed syntax definition: [format_syntax.txt](format_syntax.txt)
- `i`: Just an integer holding the counter for the iteration; starts at `0` and is increased by `1` in every loop
- `_`: The current value before the expression (`start + i * step`)
- `p`: The result of the previously evaluated value (without formatting); `0` for the first value
- `math`, `random` and `re`: Useful modules that are pre-imported for you
- `math`, `random`, `re` and `itertools`: Useful modules that are pre-imported for you

*Note*: The return value does not have to be a number type, you can also generate strings, tuples or booleans.

Expand Down Expand Up @@ -271,6 +271,20 @@ The `|` pipe is used to show the meaning of piping the current selection to the
25
36
```
- `::list(itertools.product(['a', 'b', 'c'], ['x', 'y', 'z']))[i]`
```
('a', 'x')
('a', 'y')
('a', 'z')
('b', 'x')
('b', 'y')
('b', 'z')
('c', 'x')
('c', 'y')
('c', 'z')
```
### Alpha insert
Expand Down Expand Up @@ -406,6 +420,7 @@ And many more ...
- Marco Novaro, [@MarcoNovaro](https://github.com/MarcoNovaro)
- Oleg Geier, Twitter: [@relikd](https://twitter.com/relikd)
- Arthur Comben, Twitter: [@anthillape](https://twitter.com/anthillape)
- [@logworthy](https://github.com/logworthy)
# License
Expand Down

0 comments on commit f21221e

Please sign in to comment.