Re: Changing calling sequence

2022-05-15 Thread Greg Ewing
On 16/05/22 1:20 am, 2qdxy4rzwzuui...@potatochowder.com wrote: IMO, classmethods were/are a bad idea (yes, I'm probably in the minority around here, but someone has to be). I don't think class methods are a bad idea per se, but having them visible through instances seems unnecessary and confusi

Re: Changing calling sequence

2022-05-15 Thread 2QdxY4RzWzUUiLuE
On 2022-05-15 at 14:44:09 +1000, Chris Angelico wrote: > On Sun, 15 May 2022 at 14:27, dn wrote: > > > > On 15/05/2022 11.34, 2qdxy4rzwzuui...@potatochowder.com wrote: > > > On 2022-05-15 at 10:22:15 +1200, > > > dn wrote: > > > > > >> That said, a function which starts with a list of ifs-buts-

Re: Changing calling sequence

2022-05-14 Thread Chris Angelico
On Sun, 15 May 2022 at 14:27, dn wrote: > > On 15/05/2022 11.34, 2qdxy4rzwzuui...@potatochowder.com wrote: > > On 2022-05-15 at 10:22:15 +1200, > > dn wrote: > > > >> That said, a function which starts with a list of ifs-buts-and-maybes* > >> which are only there to ascertain which set of argumen

Re: Changing calling sequence

2022-05-14 Thread dn
On 15/05/2022 11.34, 2qdxy4rzwzuui...@potatochowder.com wrote: > On 2022-05-15 at 10:22:15 +1200, > dn wrote: > >> That said, a function which starts with a list of ifs-buts-and-maybes* >> which are only there to ascertain which set of arguments have been >> provided by the calling-routine; obscu

Re: Changing calling sequence

2022-05-14 Thread 2QdxY4RzWzUUiLuE
On 2022-05-15 at 10:22:15 +1200, dn wrote: > That said, a function which starts with a list of ifs-buts-and-maybes* > which are only there to ascertain which set of arguments have been > provided by the calling-routine; obscures the purpose/responsibility > of the function and decreases its reada

Re: Changing calling sequence

2022-05-14 Thread dn
On 12/05/2022 01.33, Michael F. Stemper wrote: > I have a function that I use to retrieve daily data from a > home-brew database. Its calling sequence is; > > def TempsOneDay( year, month, date ): > > After using it (and its friends) for a few years, I've come to > realize that there are times wh

Re: Changing calling sequence

2022-05-13 Thread Martin Di Paola
You probably want something like overload/multiple dispatch. I quick search on PyPI yields a 'multipledispatch' package. I never used, however. On Wed, May 11, 2022 at 08:36:26AM -0700, Tobiah wrote: On 5/11/22 06:33, Michael F. Stemper wrote: I have a function that I use to retrieve daily dat

Re: Changing calling sequence

2022-05-12 Thread Michael F. Stemper
On 11/05/2022 14.58, anthony.flury wrote: Why not do :   def TempsOneDayDT(date:datetime.date): return TempsOneDay(date.year, date.month, date.day) No repeat of code - just a different interface to the same functionality. Yeah, a one-line wrapper around the original functi

RE: Changing calling sequence

2022-05-12 Thread David Raymond
>>def TempsOneDay(*dateComponents): >>if len(dateComponents) == 3: >>year, month, date = dateComponents >>elif len(dateComponents) == 1 and isinstance(dateComponents[0], >> datetime.date): >>year, month, date = (dateComponents[0].year, dateComponents[0].month, >> dateCompo

Re: Changing calling sequence

2022-05-11 Thread anthony.flury via Python-list
python.org Sent: Wednesday, 11 May, 22 At 14:33 Subject: Changing calling sequence I have a function that I use to retrieve daily data from a home-brew database. Its calling sequence is; def TempsOneDay( year, month, date ): After using it (and its friends) for a few years, I've come to realize

Re: Changing calling sequence

2022-05-11 Thread Grant Edwards
On 2022-05-11, David Raymond wrote: > Maybe not the prettiest, but you could also define it like this, > which also wouldn't require changing of any existing calls or the > main body of the function past this if block. > > def TempsOneDay(*dateComponents): > if len(dateComponents) == 3: >

RE: Changing calling sequence

2022-05-11 Thread David Raymond
>> I have a function that I use to retrieve daily data from a >> home-brew database. Its calling sequence is; >> >> def TempsOneDay( year, month, date ): >> >> After using it (and its friends) for a few years, I've come to >> realize that there are times where it would be advantageous to >> invok

Re: Changing calling sequence

2022-05-11 Thread 2QdxY4RzWzUUiLuE
On 2022-05-11 at 08:33:27 -0500, "Michael F. Stemper" wrote: > I have a function that I use to retrieve daily data from a > home-brew database. Its calling sequence is; > > def TempsOneDay( year, month, date ): > > After using it (and its friends) for a few years, I've come to > realize that th

Re: Changing calling sequence

2022-05-11 Thread Tobiah
On 5/11/22 06:33, Michael F. Stemper wrote: I have a function that I use to retrieve daily data from a home-brew database. Its calling sequence is; def TempsOneDay( year, month, date ): After using it (and its friends) for a few years, I've come to realize that there are times where it would be

Changing calling sequence

2022-05-11 Thread Michael F. Stemper
I have a function that I use to retrieve daily data from a home-brew database. Its calling sequence is; def TempsOneDay( year, month, date ): After using it (and its friends) for a few years, I've come to realize that there are times where it would be advantageous to invoke it with a datetime.da