[Tutor] How do I use the os.open module?

Tim Peters tim_one@email.msn.com
Wed, 13 Oct 1999 00:02:51 -0400

[Alexandre Passos]
> I've tried to use the os.open module theese ways:
> #Command prompt
> command = raw_input("[shell]")
> import os
> os.open(command)
> and the error message was:
> 0 arguments needed 1 given

Please don't type in code or error msgs from memory -- cut and paste!  The
error msg for this one was much more likely:

   TypeError: function requires at least 2 arguments; 1 given


> #Command Prompt
> command = raw_input("[shell]")
> import os
> os.open() command
> error:
> Call of non function

Ditto.  This one is a SyntaxError, as written.

> and finally
> #Command prompt
> command = raw_input("[shell]")
> import os
> os.open command
> and I obtained the following message:
> <builtin function open>

This is another syntax error.

> what shall I do??

What do you want to do?  I can't tell from the above what you think
os.open() should do, but it clearly doesn't do what you think it does.
os.open() is a low-level function used (very rarely) to open files.  It
seems more that you're trying to execute a command.  If so, os.system() or
os.popen() are what you're looking for.

Make sure too that you're running Python 1.5.2 and have up-to-date