DEV Community

Discussion on: Automating my Post Starter

Collapse
 
catriel profile image
Catriel Lopez

I generally try to avoid this pattern with something like a list comprehension, but didn't see an obvious solution so I just went with it.

The only way I can think of right now, if you want to declare your tags as a short version of the real ones (py for python, web for webdev) would be to use a dictionary:

reg_tags = {"py":"python", "web":"webdev", "blog":"blog", "data":"data"}
tags = [reg_tags[tag] if tag in reg_tags.keys() else tag for tag in sys.argv[2:] ]
Enter fullscreen mode Exit fullscreen mode

Not pretty, but it allows you to use the short tags and also include new ones for a specific post