Guest User

Untitled

a guest
Oct 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. foo
  2. bar
  3.  
  4. mylist = [
  5. 'hello',
  6. 'world'
  7. ]
  8.  
  9. def _gen():
  10. for x in mylist:
  11. with open('/tmp/list') as fh:
  12. yield('-'.join([x, next(fh)]))
  13.  
  14.  
  15. for i in _gen():
  16. print(i)
  17.  
  18. hello-foo
  19. world-foo
  20.  
  21. hello-foo
  22. hello-bar
  23. world-foo
  24. world-bar
  25.  
  26. for x in mylist:
  27. with open('/tmp/list') as fh:
  28. for line in fh:
  29. yield '-'.join([x, line.strip()])
Add Comment
Please, Sign In to add comment