New to Python; what about #include, extern and function prototypes
bo at systemhouse.dk
Sun Mar 7 14:44:09 CET 2004
> > I'm been looking at perl and python, and I really like the strict
> > handling
> > of function parameters etc. Without include and function prototyping
> > will probably have the effect that large source files, with a lot of
> > function
> > definitions at the top, will be generated. Not god.
> Why do you think this is so?
> Have a look at any Python example sourcecode (for that matter,
> at some of the .py files from Python's standard library; for instance
> cgi.py) and you will see that Python's import mechanism is working fine.
> No big source files with lots of definitions at the top.
> Just import the module which contains the definitions you need...
> > Perl on the other hand has it all, including very productive features as
> > built-in
> > regular expressions, file scanning etc.
> Python has the re/sre module for regular expression stuff.
> File scanning is often done like this:
> for line in open("myfile.txt"):
> > . ./filename
> > Is the shell "include/execute" command.
> Python's "include" command is the import statement.
> If you really want (but WHY?) to read in and directly
> execute another source file, use the execfile function.
I'm very new to Phyton (I looked at it for the first time last night), so
you must have me excused.
The "execfile" perfectly solves my worries about prototyping and
As I wrote earlier, I really like the "feeling" of the language, now I
just have to find the time to dig more into it.
By the way, is there an elegant way to read shell program output
into a variable as in bash: var=$(command1 | command2)
More information about the Python-list