FAQ
Hi all,

I wrote a program to read some data through standard input and write in a
file.
the following code works fine in linux.
but its giving ArgumentError in windows.

Code:
import sys

orig_source = sys.stdin.read()

file=open('data.txt','w')

file.write(orig_source)
file.close()

please post some solution .
and what is the command in windows for EOF (like Cntrl D in linux)


thanks in advance
Siva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091205/c263d3c4/attachment.htm>

Search Discussions

  • Chris Rebert at Dec 5, 2009 at 6:24 am

    On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote:
    Hi all,

    I wrote a program to read some data through standard input and write in a
    file.
    the following code works fine in linux.
    but its giving ArgumentError in windows.
    There's no such error in Python; you're thinking of Ruby.
    Unless you give the /actual/ error (with message) and full traceback,
    there's not much we can do to help you besides just guess.

    <snip>
    file=open('data.txt','w')
    Don't use `file` as a variable name, you're shadowing the built-in type.
    and what is the command in windows for EOF (like Cntrl D in linux)
    http://tinyurl.com/yggsby3
    The *very first result* has the answer in its 6th sentence.

    Cheers,
    Chris
  • Siva B at Dec 5, 2009 at 7:13 am
    Hi Chris,
    Thanks for you reply.
    The error log is here for my above program in windows:

    Traceback (most recent call last):
    File "C:\Documents and Settings\user\Desktop\t1.py", line 3, in <module>
    orig_source = sys.stdin.read()
    AttributeError: read


    Regards,
    Siva
    On Sat, Dec 5, 2009 at 11:54 AM, Chris Rebert wrote:
    On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote:
    Hi all,

    I wrote a program to read some data through standard input and write in a
    file.
    the following code works fine in linux.
    but its giving ArgumentError in windows.
    There's no such error in Python; you're thinking of Ruby.
    Unless you give the /actual/ error (with message) and full traceback,
    there's not much we can do to help you besides just guess.

    <snip>
    file=open('data.txt','w')
    Don't use `file` as a variable name, you're shadowing the built-in type.
    and what is the command in windows for EOF (like Cntrl D in linux)
    http://tinyurl.com/yggsby3
    The *very first result* has the answer in its 6th sentence.

    Cheers,
    Chris
    --
    http://blog.rebertia.com
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20091205/d36ddcad/attachment.htm>
  • Chris Rebert at Dec 5, 2009 at 7:27 am

    On Sat, Dec 5, 2009 at 11:54 AM, Chris Rebert wrote:
    On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote:
    Hi all,

    I wrote a program to read some data through standard input and write in
    a
    file.
    the following code works fine in linux.
    but its giving ArgumentError in windows.
    There's no such error in Python; you're thinking of Ruby.
    Unless you give the /actual/ error (with message) and full traceback,
    there's not much we can do to help you besides just guess.

    <snip>
    file=open('data.txt','w')
    Don't use `file` as a variable name, you're shadowing the built-in type.
    and what is the command in windows for EOF (like Cntrl D in linux)
    http://tinyurl.com/yggsby3
    The *very first result* has the answer in its 6th sentence.
    On Fri, Dec 4, 2009 at 11:13 PM, Siva B wrote:
    Hi Chris,
    Thanks for you reply.
    The error log is here for my above program in windows:

    Traceback (most recent call last):
    File "C:\Documents and Settings\user\Desktop\t1.py", line 3, in <module>
    orig_source = sys.stdin.read()
    AttributeError: read
    Okay, that Shouldn't Be Happening (tm). Add the following before line
    3 and post the output:

    print type(sys.stdin), sys.stdin

    And while we're at it, what version of Python are your running?

    Cheers,
    Chris
  • Siva B at Dec 5, 2009 at 9:20 am
    for the line of code you given,

    print type(sys.stdin), sys.stdin

    the output is:
    <class 'idlelib.rpc.RPCProxy'> <idlelib.rpc.RPCProxy object at 0x00BE8090>

    there is no change.
    I have tried it in python2.6 on windows platform.

    Thanks,
    Siva

    On Sat, Dec 5, 2009 at 12:57 PM, Chris Rebert wrote:
    On Sat, Dec 5, 2009 at 11:54 AM, Chris Rebert wrote:
    On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote:
    Hi all,

    I wrote a program to read some data through standard input and write
    in
    a
    file.
    the following code works fine in linux.
    but its giving ArgumentError in windows.
    There's no such error in Python; you're thinking of Ruby.
    Unless you give the /actual/ error (with message) and full traceback,
    there's not much we can do to help you besides just guess.

    <snip>
    file=open('data.txt','w')
    Don't use `file` as a variable name, you're shadowing the built-in type.
    and what is the command in windows for EOF (like Cntrl D in linux)
    http://tinyurl.com/yggsby3
    The *very first result* has the answer in its 6th sentence.
    On Fri, Dec 4, 2009 at 11:13 PM, Siva B wrote:
    Hi Chris,
    Thanks for you reply.
    The error log is here for my above program in windows:

    Traceback (most recent call last):
    File "C:\Documents and Settings\user\Desktop\t1.py", line 3, in <module>
    orig_source = sys.stdin.read()
    AttributeError: read
    Okay, that Shouldn't Be Happening (tm). Add the following before line
    3 and post the output:

    print type(sys.stdin), sys.stdin

    And while we're at it, what version of Python are your running?

    Cheers,
    Chris
    --
    http://blog.rebertia.com
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20091205/b5b6487b/attachment.htm>
  • Rami Chowdhury at Dec 5, 2009 at 10:14 am

    On Saturday 05 December 2009 01:20:12 Siva B wrote:
    for the line of code you given,

    print type(sys.stdin), sys.stdin

    the output is:
    <class 'idlelib.rpc.RPCProxy'> <idlelib.rpc.RPCProxy object at
    0x00BE8090>

    there is no change.
    I have tried it in python2.6 on windows platform.

    Thanks,
    Siva
    How did you run this on Linux? How did you run it on Windows? It looks
    like you're running it from within IDLE. I don't know IDLE at all, and
    don't know how to pass data to its standard input -- can you let us know
    what arguments you're using?

    I've tried sys.stdin.read() from inside IDLE on Linux, and it gives me
    the same error.


    ----
    Rami Chowdhury
    "Any sufficiently advanced incompetence is indistinguishable from
    malice." -- Grey's Law
    408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
  • Bujji at Dec 5, 2009 at 11:40 am
    what is the problem you faced in running it on Linux or windows
    we'll use IDLE only

    on linux platform like this also you can run see below
    ubuntu at siva:~/Desktop$ python
    Python 2.6.2 (r262:71600, Oct 7 2009, 11:27:27)
    [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    import sys
    data=sys.stdin.read()
    hello world
    this is a test (give Cntrl D to exit)
    print data
    hello world
    this is a test

    >>>

    (I can put data into some other file as well)
    This is working very well on my PC

    It should work same on the windows too.
    but I don't know why its is failing, and thats what i want to know.
    If any other solution is there let know to get it work on windows ( python
    IDLE)
    welcome


    Thanks,
    Siva
    On Sat, Dec 5, 2009 at 3:44 PM, Rami Chowdhury wrote:
    On Saturday 05 December 2009 01:20:12 Siva B wrote:
    for the line of code you given,

    print type(sys.stdin), sys.stdin

    the output is:
    <class 'idlelib.rpc.RPCProxy'> <idlelib.rpc.RPCProxy object at
    0x00BE8090>

    there is no change.
    I have tried it in python2.6 on windows platform.

    Thanks,
    Siva
    How did you run this on Linux? How did you run it on Windows? It looks
    like you're running it from within IDLE. I don't know IDLE at all, and
    don't know how to pass data to its standard input -- can you let us know
    what arguments you're using?

    I've tried sys.stdin.read() from inside IDLE on Linux, and it gives me
    the same error.


    ----
    Rami Chowdhury
    "Any sufficiently advanced incompetence is indistinguishable from
    malice." -- Grey's Law
    408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20091205/8b950cc5/attachment.htm>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedDec 5, '09 at 5:37a
activeDec 5, '09 at 11:40a
posts7
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase