DEV Community

loading...

Discussion on: Vim practical example

Collapse
jerpint profile image
jerpint

Why not use a simple python script for this?

Seems like the second someone decides to add/remove a country or number of elements, you have to start all over again. Not saying this isn't cool, but seems overkill.

For example:


langs = ['en','de',...]
elems = [1,2,...]


for elem in elems:
    for lang in langs:
        print(base_url + '/element' + str(elem) + '/' + lang)
    print('')
Collapse
delbetu profile image
M Bellucci Author

The goal is practice new vim commands, the problem is not important in the context of this post.

Collapse
indrora profile image
Morgan Gangwere 🔹

A cleaner way:

import itertools

langs=('en','de','jp','fr')
nums=(1,2,3,4,5,6)

urls = map( lambda k: "http://provider.lol/some-path/{0}#lang/{1}".format(*k),
   itertools.product(nums,langs) )