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 269991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:55:39+00:00 2026-05-11T23:55:39+00:00

I think I want to use pythons built in calendar module to create an

  • 0

I think I want to use pythons built in calendar module to create an HTML calendar with data. I say I think because I’ll probably think of a better way, but right now it’s a little personal. I don’t know if this was intended to be used this way but it seems like it is a little pointless if you can’t at least making the days into a <a hrefs>.

This sets up a calendar for this month with Sunday as the first day.

import calendar
myCal = calendar.HTMLCalendar(calendar.SUNDAY)
print myCal.formatmonth(2009, 7)

it prints

<table border="0" cellpadding="0" cellspacing="0" class="month">\n<tr>
<th colspan="7" class="month">July 2009</th></tr>\n<tr><th class="sun">Sun</th>
<th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th>
<th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th></tr>\n
<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td>
<td class="noday">&nbsp;</td><td class="wed">1</td><td class="thu">2</td><td class="fri">3</td>
<td class="sat">4</td></tr>\n<tr><td class="sun">5</td><td class="mon">6</td><td class="tue">7</td>
<td class="wed">8</td><td class="thu">9</td><td class="fri">10</td>
<td class="sat">11</td></tr>\n<tr><td class="sun">12</td><td class="mon">13</td>
<td class="tue">14</td><td class="wed">15</td><td class="thu">16</td><td class="fri">17</td>
<td class="sat">18</td></tr>\n<tr><td class="sun">19</td><td class="mon">20</td>
<td class="tue">21</td><td class="wed">22</td><td class="thu">23</td><td class="fri">24</td>
<td class="sat">25</td></tr>\n<tr><td class="sun">26</td><td class="mon">27</td>
<td class="tue">28</td><td class="wed">29</td><td class="thu">30</td><td class="fri">31</td>
<td class="noday">&nbsp;</td></tr>\n</table>\n

I would like to insert some data into the HTMLCalendar object before it renders the html string. I just can’t figure out how.

For example

<td class="tue">28<br />[my data]</td>
  • 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-11T23:55:39+00:00Added an answer on May 11, 2026 at 11:55 pm

    You may load html, which seems to be valid XMl into a XML tree, modify it and again output it.
    e.g. this adds <br/> cool to each Tue td node.

    import calendar
    import xml.etree.ElementTree as etree
    
    myCal = calendar.HTMLCalendar(calendar.SUNDAY)
    htmlStr = myCal.formatmonth(2009, 7)
    htmlStr = htmlStr.replace("&nbsp;"," ")
    
    root = etree.fromstring(htmlStr)
    for elem in root.findall("*//td"):
        if elem.get("class") != "tue":
            continue
        elem.text += "!"
    
        br = etree.SubElement(elem, "br")
        br.tail = "cool!"
    
    print etree.tostring(root)
    

    I do not yet know why you need to generate a HTML calendar, but there are better ways of doing that depending on needs and framework you are using.

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

Sidebar

Related Questions

as you can probably think I want to install Android ICS in VirtualBox. I
I think everyone knows this site http://pinterest.com/ and I don't want to create site
I want to use the refactoring enabled by PyDev but think it is a
Our Django site is built using Mako templates. We want to use a third
I want to use some thing unique for a licensing system. i decided to
Simple problem (I think): I want to be able to invoke a click method
A simple question, I think: I want to put a tag into an ASP.NET
I think what I want to do is a fairly common task but I've
In MVVM pattern I don't want to think about the view while creating the
I will start by saying that I don't think what I want can be

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.