[Tutor] Assigning function keywords dynamically

alan.gauld@bt.com alan.gauld@bt.com
Tue Jan 7 18:00:40 2003


I can't resist....

> > _name2dur =3D {"monatlich": RelativeDateTime(months=3D+1),
> >              "w=F6chentlich": RelativeDateTime(weeks=3D+1).
> >              "t=E4glich": RelativeDateTime(days=3D+1),
> >             }
> >dur =3D _name2dur.get(interval)
>=20
> mm, okay I understand the mapping thing but this doesn't seem=20
> much more efficient (in terms of typing)=20

It is if you have to add more entries later since you only need=20
update the dictionary, no modification and potential breaking=20
of existing function code involved.

> compared with the subsequent SQL calls... But the mapping should be=20
> {"monatlich": "months"...} with an intermediary function (lambda()?,=20
> exec()?) magically inserting the keyword in a RelativeDateTime() =
call.

Why? Surely we are just generating a fixed period(month, week etc?)=20
Or is the call clever enough to work out the month length depending=20
on the current date? If the latter then yes a function reference would
be necessary(either by lambda or def f...). But you don't need the=20
intermediate step, just put the function reference into the =
dictionary...)

> I also have three questions: why do you use the "_" in the=20
> name?=20

It prevents external(to the module users) seeing it.

> I remember you once made a remark about it has long been=20
> possible to make real digital computers as opposed to our=20
> current binary ones.=20

An interesting distinction. What does it mean? I've seen an
experimental three state computer once, and some early computers=20
did actually work in octal, but the complexity meant they=20
were slower than binary machines...

> ("Baby" at the Museum of Science and Industry in Manchester)=20

Heh, I saw a film on Baby once - 1956/8 or thereabouts? :-)

> Can anybody point me to a reasonable reference as to why so=20
> much time, energy has been spent "developing" Linux over=20
> the last 10 years in order to come up essentially with a=20
> new 4.4 BSD lite?=20

Have you read Neal Stephenson's history of the command line?
Grep google for Stephenson command line...

Initially it was just for kicks, plus the fact that Unix was=20
at the time(c1991) not free for the PC. Minix and Coherent=20
were available for about $100 each but neither was fully=20
featured. The Hurd was stagnating fast. There were some=20
tentative free BSD developments but they weren't aimed at=20
the PC market.

Then people realised how good Unix on a PC was compared=20
to the alternatives and flocked to it.

> wheel and repeating the mistakes and lessons of the previous=20
> 20 years.=20

But they didn't. Quite a few of the mitakes were learnt from=20
and improved upon. Linux code is/was much better than thhe early=20
Unix stuff from AT&T and even Berkely(sockets aside). It was=20
a modern Unix not an historical one - a trend that continues.

And since Unix is still the best mid range OS what else should=20
they do? Pan 9 from AT&T bombed in the market(it was never=20
really expected to be huge) and BeOS seems to have died a death=20
with only niche support.

> wondering: how much innovation occurs when the commercial=20
> imperative is removed?=20

Quite a lot. There are many open source type software projects=20
that are a long way ahead of any commercial competitor - X Windows=20
itself is probably the best example! Or the GNU emacs editor. Or gcc...

Alan G.