answersLogoWhite

0

Standard File Objects

Like many other languages, there are built-in file objects representing standard input, output, and error. These are in the sys module and are called stdin, stdout, and stderr. There are also immutable copies of these in __stdin__, __stdout__, and __stderr__. This is for IDLE and other tools in which the standard files have been changed.

You must import the sys module to use the special stdin, stdout, stderr I/O handles.

import sys

For finer control over input, use sys.stdin.read(). In order to implement the UNIX 'cat' program in Python, you could do something like this:

import sys for line in sys.stdin: print line,

Note that sys.stdin.read() will read from standard input till EOF. (which is usually Ctrl+D.)

Also important is the sys.argv array. sys.argv is an array that contains the command-line arguments passed to the program.

python program.py hello there programmer!

This array can be indexed,and the arguments evaluated. In the above example, sys.argv[2] would contain the string "there", because the name of the program ("program.py") is stored in argv[0]. For more complicated command-line argument processing, see the "argparse" module.

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

Is a reticulated python and a regular python the same?

Reticulated pythons are one type of python. They are the biggest pythons in the world.


What are python's babies called?

The answer is baby pythons.


What is the bermess python?

Burmese pythons are large pythons from Southeast Asia.


What are the names of pythons?

There are many python species - including... Burmese Pythons, Reticulated Pythons, Royal Pythons, Carpet Pythons, Childrens Pythons, Blood Pythons, & Indian Pythons


What does a rock python eat?

There is no such species as an american rock python. If there are rock pythons in america - they are either African rock pythons (Python sebae) or Burmese pythons (aka Asian rock python) (Python molurus) - which have been released into the wild by incompetent owners !


What is the difference in a blood python and ball python?

A blood python is a completely different type of snake Ball pythons are easier to take care. Blood pythons are known to be aggressive and you need high humidity for blood pythons, Blood pythons also need a place to soak in there enclosure. Ball pythons are a lot more docile then blood pythons. If your a beginner get a ball python. Blood pythons get to 4-6 foot while ball around get around 4 foot. Hope this helped.


What are all the names of Pythons?

the name of a ball python is royal python,dwarl


Is a python snake poisonist?

No - Pythons are constrictors.


Is a woma python venomous?

No. Pythons are nonvenomous.


What is a python related to?

Python? 'Python' is a category of snakes, not a specific snake in case you didn't know (diamond python, children's python, carpet python, etc.). Pythons are related to other restricting snakes such as boas. Boas are basically pythons that give birth to live young.


Does Python snakes eat eggs?

it depends on the type of python. not all pythons eat eggs so i can't say yes or no to all pythons.


How many do pythons lay?

from 6 of the Royal python to 100 plus of the reticulated python.