Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3333350
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:47:13+00:00 2026-05-17T23:47:13+00:00

SMALL VERSION OF THE QUESTION : I need a lib for python or program

  • 0

SMALL VERSION OF THE QUESTION: ” I need a lib for python or program (pref. for Linux) that receives a list of urls for images and gives me the hmtl for a table (maybe easy to configure(rows and look))

LONG VERSION OF THE QUESTION:
I have and array with a list of url’s for images, and I want to make a table (I don’t know if this is the best practice, but I think it’s the easiest).
I don’t care if the thumbs are the same file as the big one (just forced to be small). And I don’t need to copy the images to anywhere.

I use the following code( d= [“http://…..jpg”,”http://…..jpg”,”http://…..jpg”,”http://…..jpg”]):

def  stupidtable(d):
    d = list(set(d))
    antes=' <tr> <td><a href="'
    dp11='"><img src="'
    dp12= '" width="100%" /></a></td> <td><a href="'
    dp21= '"><img src="'
    dp22='" width="100%" /></a></td>'
    bb=['<table border="0"> ']
    ii=len( d)
    i=0
    while i<ii-1:
        bb.append(antes)
        bb.append(d[i])
        bb.append(dp11)
        bb.append(d[i])
        bb.append(dp12)
        bb.append(d[i+1])    
        bb.append(dp21)
        bb.append(d[i+1])
        bb.append(dp22)
        i=i+2
    return bb

(I know the code is shady and it skips the last one if it’s an odd number… but it’s caffeine fueled code and I just needed to get it done… nothing I’m proud of:)
I know there must be a better way(and prettier.. ‘cus this looks really ugly), and a way that I can specify the number of columns, and other options.

I couldn’t find a gallery generator for my case (all I tested copied the files to new directory).
Should I learn a templating lang? Is it worth it?

Or Should I use an HTML Generator?

Or should I look into better coding HTML?

What Would you do if you had my problem?

This is the solution I came up with (after adpting the code from kind Mr MatToufoutu):

from jinja2 import Template

my_template = Template("""
<html>
<style type="text/css">
   img {border: none;}
</style>
<body>
<table border="0" cellpadding="0" and cellspacing="0">
<tr>
{% for url in urls %}
<td><a href="{{ url }}"><img width="100%" src="{{ url }}"/></td>
{% if loop.index is divisibleby cols %}
</tr><tr>
{% endif %}
{% endfor %}
</tr>
</table>
""")

cols=3
urls =["./a.jpg","./a.jpg","./a.jpg","./a.jpg","./a.jpg","./a.jpg","./a.jpg"]
html = my_template.render(cols=cols,urls=urls)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:47:13+00:00Added an answer on May 17, 2026 at 11:47 pm

    I think the easiest way to achieve this would be to use a template language like Mako, Cheetah or Jinja. Personally i’d choose Jinja, because it is very similar to the Django template language, but they are all very powerful.

    A very simple example of what you want, using Jinja, would look like this:

    from jinja2 import Template
    
    my_template = Template("""
    <html>
    <body>
    <table border="0">
    <tr>
    {% for url in urls %}
    <td><a href="{{ url }}">{{ url }}</td>
    {% endfor %}
    </tr>
    </table>
    """)
    
    urls = ["http://.....jpg","http://.....jpg","http://.....jpg","http://.....jpg"]
    rendered_html = my_template.render(urls=urls)
    

    Which is way more readable than building the html by hand like you did.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small VB.NET application that I'm working on using the full version
One small function of a large program examines assemblies in a folder and replaces
I am creating a small modal form that is used in Winforms application. It
I have a small JS function that does Ajax for me and another like
I have a fairly small MySQL database (a Textpattern install) on a server that
I have a small utility that I use to download an MP3 file from
I have a small application I am working on that at one point needs
I have a small project where I need just part of boost library, boost::regex
I am starting a small project with one other developer and need to setup
This might seem like a stupid question I admit. But I'm in a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.