'Why is the init argument being presented with an unexpected keyword?
I am trying to use the datefinder module with UK settings (i.e. day first in dates). I can see from the code that __init__ contains an option for first, defaulting to "month" (see below). This, I wish to change.
class DateFinder(object):
"""
Locates dates in a text
"""
def __init__(self, base_date=None, first="month"):
...
Source: datefinder GitHub repo
I have tried the below code, but it returns an error. Any thoughts where I am going wrong?
from datefinder import DateFinder
testString = 'here is some random text with a date of 2/11/1985 sat in the middle'
matches = DateFinder(first="day").find_dates(testString,index=True,source=True)
for match in matches:
print(match)
TypeError: __init__() got an unexpected keyword argument 'first'
Solution 1:[1]
The version from PyPi (i.e.
pip install datefinder) seems to be out of date from the GitHub src you linked. When I runhelp(DateFinder.__init__)I see__init__(self, base_date=None)note that there is indeed nofirstkwarg like in the linked src. Specifically that kwarg was added on Aug 2, 2020 github.com/akoumjian/datefinder/commit/... and the most recent Release was v0.7.1 on May 27, 2020 so there have been no recent releases that include that change
-- comment by Cory Kramer
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
