Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Month, Day, Year number to day of week and month names in Python - English and Swedish

I had run a program (actually an answer to an exercise from our Lerning to program in Python course) which prints out a day and month number. And my group asked "how do I get the month by name?" and "What day of the week is that?"

Good questions ... and the answer in Python always starts ... "If you're doing something, think if someone's done it before, and if they have, the code probably exists and is available to you". With a common(ish) requirement, there's a probablility that the code you need is supplied as a module with the Python distribution, or is even built in via objects / methods / function calls.

Sample answer ... create a datetime object with the wanted day and month, and you can then enquire. Complete code is [here] ... the vital bits:

  dayinfo = datetime.date(year, moy[dayWanted-1], dom[dayWanted-1])
  print dayinfo.strftime("%B ... %A")


Then "Can you do that in Swedish?". Yes, if I set the locale before I do the formatting:

  import locale as l
  if not person in ("Gavin","Graham","Gary"):
    l.setlocale(l.LC_ALL, 'sv_SE')


(Ensuring that the results remain in English for the tutor, and delegates Gavin and Gary!)
(written 2016-06-23)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Y117 - Python - Already written modules
  [2020] Learning Python - many new example programs - (2009-01-31)
  [2506] Good example of recursion in Python - analyse an RSS feed - (2009-11-18)
  [2890] Dates and times in Python - (2010-07-27)
  [2931] Syncronise - software, trains, and buses. Please! - (2010-08-22)
  [3442] A demonstration of how many Python facilities work together - (2011-09-16)
  [3465] How can I do an FTP transfer in Python? - (2011-10-05)
  [3479] Practical Extraction and Reporting - using Python and Extreme Programming - (2011-10-14)
  [4085] JSON from Python - first principles, easy example - (2013-05-13)
  [4086] Cacheing class for Python - using a local SQLite database as a key/value store - (2013-05-14)
  [4441] Reading command line parameters in Python - (2015-02-23)
  [4452] Binary data handling - Python and Perl - (2015-03-09)
  [4696] Programming with random numbers - yet re-using the same values for testing - (2016-06-22)
  [4708] Scons - a build system in Python - building hello world - (2016-10-29)
  [4710] Searching a Json or XML structure for a specific key / value pair in Python - (2016-10-30)


Back to
Programming with random numbers - yet re-using the same values for testing
Previous and next
or
Horse's mouth home
Forward to
Lisa writes - on the referendum vote today
Some other Articles
Pretty at the station too
Obfurscated code - it might work, but is it maintainable?
Melksham Rail Development Group - a celebration of 20 years
Lisa writes - on the referendum vote today
Month, Day, Year number to day of week and month names in Python - English and Swedish
Melksham Rail Development Group becoming Melksham Rail Users Group
Supported Bus Services in Wiltshire - analysis of written-in comments
Wiltshire supported bus service consultation, early 2016 - interim results published
How are bus support payments currently calculated?
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4697_Mon ... edish.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb