Python Forum
difference between today, and today variables
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
difference between today, and today variables
#2
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.

cursor.fetchone is returning a tuple of length 1. By using today = (no comma), you just get the tuple. But using today, = (with a comma) is using tuple assignment. As in:

>>> nums = (1, 2)
>>> one, two = nums
>>> one
1
>>> two
2
And they are not the same type. You are just checking the type of the second today twice. If you had check the type of the first today before reassigning it, you would see it was equal to datetime. Here's an example:

>>> one = (1,)
>>> one
(1,)
>>> uno, = (1,)
>>> uno
1
>>> type(one)
<class 'tuple'>
>>> type(uno)
<class 'int'>
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: difference between today, and today variables - by ichabod801 - Nov-25-2018, 03:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  i tried to install python for the first time today and pretty certain im being remote brianlj 2 616 Oct-03-2023, 11:15 AM
Last Post: snippsat
  Need to identify only files created today. tester_V 5 4,782 Feb-18-2021, 06:32 AM
Last Post: tester_V
  Make list of dates between today back to n days Mekala 3 2,451 Oct-03-2020, 01:01 PM
Last Post: ibreeden
  Store Previous date to calculate delta from today Captain_Wolf 7 3,415 May-08-2020, 06:08 PM
Last Post: SheeppOSU
  Substracting today's date from a date in column of dates to get an integer value firebird 1 2,178 Jul-04-2019, 06:54 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020