Re: fcntl example

Guido.van.Rossum@cwi.nl
Tue, 03 May 1994 16:26:01 +0200

> > Actually, such a file is already present in the Python distribution in
> > Lib/sgi and Lib/sun4, named FCNTL.py. Versions for other platforms
> > are most welcome!
>
> Why doesn't the fcntl module define things itself.
> Doing:
>
> #ifdef FLAG
> x = newintobject(FLAG);
> dictinsert(d,"FLAG",x);
> #endif
>
> in the initmodule() routine will make it so all these extra processed
> header files not needed. Macros can also be defined as methods.

Clever idea (though boring to implement :-). The only drawback is
that you need to know all the flags that may be used on all systems in
the world -- if your system defines a symbol in its fcntl.h that isn't
defined by my machine I wouldn't know about it and you couldn't use it
unless you told me about it. By putting it in FCNTL.py this can be
avoided -- you simply have to run h2py locally.

This (generating FCNTL.py) isn't done automatically because
occasionally the h2py script lets things pass that aren't valid
Python. Come to think of it, there should be an easy way to fix that
(just test the generated string using exec in a separate environment
and catch the exceptions) -- I'll think of doing this in 1.0.2.

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>