FAQ
Hi Everyone

I see that python IDLE add ^M as carriage return while programming in
windows machine. How can I set IDLE not to do so. I don't see any option &
neither do I see any option to check for carriage return.

Can anyone help me as I use IDLE & I need to remove ^M from the end of every
line. Though it is not shown while programming but I can see that when I run
my scripts on debian linux environment & thus get errors.

Thanks

--
Regards,
Vineet Kothari
248-821-8105
http://www.vineetkothari.in

-----
Its NICE 2 be IMPORTANT, but whats more IMPORTANT is 2 be NICE.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091011/fb6fd65b/attachment.htm>

Search Discussions

  • Wayne at Oct 12, 2009 at 3:38 am

    On Sun, Oct 11, 2009 at 10:33 PM, Vineet Kothari wrote:

    Hi Everyone

    I see that python IDLE add ^M as carriage return while programming in
    windows machine. How can I set IDLE not to do so. I don't see any option &
    neither do I see any option to check for carriage return.

    Can anyone help me as I use IDLE & I need to remove ^M from the end of
    every line. Though it is not shown while programming but I can see that when
    I run my scripts on debian linux environment & thus get errors.
    That's not an issue with IDLE so much as windows/linux. IIRC, Linux only
    uses a newline, while windows uses a CRLF. There's the dos2unix util:

    http://linuxcommand.org/man_pages/dos2unix1.html

    that may help.
    -Wayne
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/tutor/attachments/20091011/76efd96c/attachment.htm>
  • Kent Johnson at Oct 12, 2009 at 11:58 am

    On Sun, Oct 11, 2009 at 11:38 PM, Wayne wrote:

    That's not an issue with IDLE so much as windows/linux. IIRC, Linux only
    uses a newline, while windows uses a CRLF. There's the dos2unix util:
    http://linuxcommand.org/man_pages/dos2unix1.html
    that may help.
    There is also a crlf.py script distributed with Python (in the scripts
    folder) that removes CR.

    Some version control systems will handle this for you - Subversion,
    Mercurial and git, at least - so you could use a VCS to transfer the
    files and convert the line endings. This would also give the benefit
    of having the files in the VCS.

    Kent
  • Bob gailer at Oct 12, 2009 at 3:38 am

    Vineet Kothari wrote:
    Hi Everyone

    I see that python IDLE add ^M as carriage return while programming in
    windows machine. How can I set IDLE not to do so. I don't see any
    option & neither do I see any option to check for carriage return.

    Can anyone help me as I use IDLE & I need to remove ^M from the end of
    every line. Though it is not shown while programming but I can see
    that when I run my scripts on debian linux environment & thus get errors.
    I don't understand. Please explain.


    --
    Bob Gailer
    Chapel Hill NC
    919-636-4239
  • Alan Gauld at Oct 12, 2009 at 7:52 am
    "Vineet Kothari" <vineet.kothari at gmail.com> wrote
    I see that python IDLE add ^M as carriage return while programming in
    windows machine.
    Thats just the Windows line ending.
    If you want to use the same file on both Windowscand Linux then
    you will need to either get used to it or run the DOS2Unix tool
    (and UNIX2DOS going back to Windows).
    Can anyone help me as I use IDLE & I need to remove ^M from the end of
    every
    line. Though it is not shown while programming but I can see that when I
    run
    my scripts on debian linux environment & thus get errors.
    It shouldn't cause any faults in the programs when they run, it is
    just a nuisance when working in the editor. Some editors are intelligent
    enough to deal with this transparently - eg. I think vim and Scite both do
    this.
    If you regularly edit on both OS then it might be worth moving from IDLE
    to one of those editors.

    HTH,

    --
    Alan Gauld
    Author of the Learn to Program web site
    http://www.alan-g.me.uk/
  • Dave Angel at Oct 12, 2009 at 10:41 am

    Alan Gauld wrote:
    <div class="moz-text-flowed" style="font-family: -moz-fixed">
    "Vineet Kothari" <vineet.kothari at gmail.com> wrote
    I see that python IDLE add ^M as carriage return while programming in
    windows machine.
    Thats just the Windows line ending.
    If you want to use the same file on both Windowscand Linux then
    you will need to either get used to it or run the DOS2Unix tool
    (and UNIX2DOS going back to Windows).
    Can anyone help me as I use IDLE & I need to remove ^M from the end
    of every
    line. Though it is not shown while programming but I can see that
    when I run
    my scripts on debian linux environment & thus get errors.
    It shouldn't cause any faults in the programs when they run, it is
    just a nuisance when working in the editor. Some editors are intelligent
    enough to deal with this transparently - eg. I think vim and Scite
    both do this.
    If you regularly edit on both OS then it might be worth moving from IDLE
    to one of those editors.

    HTH,
    But the other problem I've seen when copying a DOS-formatted python
    script to Unix environment is that the shebang line is misinterpreted.
    (Some?) Unix shell will refuse to find the python interpreter if the
    file name seems to have a 0x0d in it.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouptutor @
categoriespython
postedOct 12, '09 at 3:33a
activeOct 12, '09 at 11:58a
posts6
users6
websitepython.org

People

Translate

site design / logo © 2022 Grokbase