[Tutor] Assigning function keywords dynamically
Charlie Clark
charlie@begeistert.org
Mon Jan 6 12:40:17 2003
On 2003-01-06 at 17:00:49 [+0100], Tim Peters wrote:
> r =3D RelativeDateTime
> _name2dur =3D {"monatlich": r(months=3D+1),
> "w=F6chentlich": r(weeks=3D+1).
> "t=E4glich": r(days=3D+1),
> }
That seems like a good compromise. Repeatedly typing "RelativeDateTime"
means typos and copy + paste leads to different errors. Will see if I can
amend this in the function which where I would like it - keep the mapping
compact and maintain functional visibility.
> > I also have three questions: why do you use the "_" in the name?
>
> That's a convention for names private to a module. It tells the reader
> that _name2dur isn't part of the module's public API. If you would
> rather make it public, that's fine too.
name-mangling. I've heard of it but I've never read anything about when to
use it and when not to use it.
> > And is .get() becoming standard for dictionaries?
>
> Unclear what you're asking; dict.get() has been in Python a long time.
I know that but I'm more used to dict['item']. I guess it has more to with
class/functional duality and programming style in Python. Could you please
explain the difference and the relevance to TOWTDT for this.
> > how close is the upcoming "datetime" module to mx.DateTime.
>
> They're different designs. datetime is aimed more at efficient field
> extraction, mxDateTime more at efficient arithmetic. A detailed
> comparison would take more time than I can make.
That's all I need to know. Seeing as Marc-Andr=E9 lives close to me I can
ask him the next time we meet for a beer.
> > ...
> > <OT>
> > I remember you once made a remark about it has long been possible to
> > make real digital computers as opposed to our current binary ones.
>
> Sorry, doesn't ring a bell; binary sounds pretty digital to me <wink>.
Base2 !=3D Base10 the last time I checked.<nudge>
It was in connection with floating point and something along the lines of
"real digital computers have been possible for a long time now and would
make all of this [floating point] mess unnecessary".
Charlie