[Tutor] NEWBIE!! pipes

Deirdre Saoirse deirdre@deirdre.net
Thu, 1 Feb 2001 09:56:55 -0800 (PST)

On Wed, 31 Jan 2001 AquaRock7@aol.com wrote:

> What are pipes?  The docs barely touched this subject, it assumed you
> already knew what they are...  From context I am gathering that it is
> a connection to the kernel?  (maybe?)  How can I utilize this?

A pipe connects the output of one Unix process to the input of the next
one. Sort of like "send this data through this pipe to here."

It has nothing to do with the kernel per se and isn't generally used
within a program.

> 1 more quickie:
> >if __name__ == '__main__':
> >     main()
> what is the pourpose if the above code?  It runs the sub main() (duh
> :) but, why not just main() wihtout the if?  what is the conditional
> testing for?  and what are the variables __main__ and __name__?  i
> dont believe they are defined in the program, so just what are they?
> and, what does putting "__"  around a variable actually DO besides
> look cool ?

This means that if the file is invoked directly from the command line, it
knows what to do. Otherwise, if well-designed and all in functions, how's
it going to know which one to call?

The __ around the variable means that it's a built-in function or variable
(as in built-in to Python).