Iterative printing over two data types in Python

Posted by old Ixfoxleigh on Stack Overflow See other posts from Stack Overflow or by old Ixfoxleigh
Published on 2010-12-29T00:06:40Z Indexed on 2010/12/29 0:54 UTC
Read the original article Hit count: 224

Filed under:

I often browse freely-available art on the web. Actually, I can't think of a better use for the internet than to turn it into a gigantic art gallery. When I encounter a set of pieces I quite like, I download them all to my hard drive. wget makes that easy, especially in combination with Python's print function, and I use this all the time to make a list of URLs that I then wget. Say I need to download a list of jpegs that run from art0 to art100 in the directory 'art,' I just tell python

for i in range(0,101):
    print "http://somegallery/somedirectory/art", i

So, this is probably a fairly simple operation in Python, and after a find-and-replace to remove whitespace, it's just a matter of using wget -i, but in days before I knew any Python I'd slavishly right-click and save.

Now I've got a bunch of files from Fredericks & Freiser gallery in New York that all go a(1-14), b(1-14), c(1-14), etc., up to the letter g. I could do that in 7 goes, and it would take me less time than it took to write this SO question.

That said, I want to deepen my knowledge of Python. So, given the letters a-g, how do I print a mapping of each letter to the integers 1-14?

© Stack Overflow or respective owner

Related posts about python