This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Datetime function with selenium
Type: behavior Stage: resolved
Components: Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jsameer23, steven.daprano
Priority: normal Keywords:

Created on 2018-12-04 12:23 by jsameer23, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg331038 - (view) Author: Sameer Joshi (jsameer23) Date: 2018-12-04 12:23
I have defined 2 variables , 1 for Friday and other for rest of weekdays. However when I match these two with the website date(which is 'today - 3' for Monday and 'today -1' )it shows the error as variable not defined. Below is code for the same.

import datetime


d = datetime.date.today()

if d.weekday() == 0:
    tdelta = datetime.timedelta(days=3)
    friday = d - tdelta
    print(friday)


elif d.weekday() in range(1,5):
    tdelta1 = datetime.timedelta(days=1)
    prev_day = d - tdelta1
    print(prev_day)

data_date = new.date()  # data_date is the date fetched from website
        if data_date == friday:
            print("Data as on", friday, "for Race Horses")
        elif data_date == prev_day:
            print("Data as on", prev_day, "for Race Horses")
        else:
            print("Data update required.")
msg331039 - (view) Author: Sameer Joshi (jsameer23) Date: 2018-12-04 12:25
I have defined 2 variables , 1 for Friday and other for rest of weekdays. However when I match these two with the website date(which is 'today - 3' for Monday and 'today -1' )it shows the error as variable not defined. Below is code for the same.

import datetime


d = datetime.date.today()

if d.weekday() == 0:
    tdelta = datetime.timedelta(days=3)
    friday = d - tdelta
    print(friday)


elif d.weekday() in range(1,5):
    tdelta1 = datetime.timedelta(days=1)
    prev_day = d - tdelta1
    print(prev_day)

data_date = new.date()  # data_date is the date fetched from website
        if data_date == friday:
            print("Data as on", friday, "for page")
        elif data_date == prev_day:
            print("Data as on", prev_day, "for page")
        else:
            print("Data update required.")
msg331044 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2018-12-04 13:21
This is for reporting bugs in the Python interpreter and standard library, not for asking for help with bugs in your own code.

The code you show contains a syntax error (some of the indentation is wrong) and at least one undefined variable, "new". The traceback you got would have shown you that:

py> data_date = new.date()  # data_date is the date fetched from website
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'new' is not defined


You need to define "new" before you can use it. Since this is not a bug in Python, I'm closing this. If you disagree, please read this website:

http://sscce.org/

copy and paste the full exception you get, and be prepared to explain why it is a bug in the interpreter rather than in your code.
History
Date User Action Args
2022-04-11 14:59:08adminsetgithub: 79588
2018-12-04 13:21:23steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg331044

resolution: not a bug
stage: resolved
2018-12-04 12:25:21jsameer23settype: behavior
messages: + msg331039
2018-12-04 12:23:28jsameer23create