~ after script filename?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • presentt

    #1

    ~ after script filename?

    Hello all,

    I just wrote a really simple script and named it helloworld.py. Inside
    was only:

    #!/usr/bin/env
    print "Hello, world"

    I used chmod to set the permissions, and ran it to see what happened (I
    just started learning Python, if you couldn't guess)

    Then, I typed ls in the directory to see what was there, and I noticed
    a new file, namely helloworld.py~ . What is that file (its contents
    are identicle to helloworld.py)? Why the ~?

    Thanks a lot. I'm using Ubuntu Linux 5.04 (Hoary), and wrote the
    script with gedit.

    ~~Ted Present

  • Aldo Cortesi

    #2
    Re: ~ after script filename?

    Thus spake presentt (presentt@gmail .com):
    [color=blue]
    > Hello all,
    >
    > I just wrote a really simple script and named it
    > helloworld.py. Inside was only:
    >
    > #!/usr/bin/env print "Hello, world"
    >
    > I used chmod to set the permissions, and ran it to see
    > what happened (I just started learning Python, if you
    > couldn't guess)
    >
    > Then, I typed ls in the directory to see what was there,
    > and I noticed a new file, namely helloworld.py~ . What is
    > that file (its contents are identicle to helloworld.py)?
    > Why the ~?
    >
    > Thanks a lot. I'm using Ubuntu Linux 5.04 (Hoary), and
    > wrote the script with gedit.[/color]

    It doesn't have anything to do with Python. I'm pretty sure
    you'll find that the file is created by your editor as a
    backup or a running store of some kind. Try just editing a
    random non-python file with the same editor, and see if you
    find the same thing...


    Cheers,


    Aldo



    --
    Aldo Cortesi
    aldo@nullcube.c om

    Off: (02) 9283 1131
    Mob: 0419 492 863

    Comment

    • presentt

      #3
      Re: ~ after script filename?

      Huh, no ~ on other files when I edit them, but at least I don't have to
      worry about it. Thanks Aldo.

      Comment

      • Fredrik Lundh

        #4
        Re: ~ after script filename?

        "presentt" <presentt@gmail .com> wrote:
        [color=blue]
        > Huh, no ~ on other files when I edit them, but at least I don't have to
        > worry about it. Thanks Aldo.[/color]

        according to



        gedit supports backup files, so to figure out how and when they're
        created, and how to control their creation, you probably just have
        to read the documentation (which doesn't seem to exist on the web;
        look in the "help" menu for the bundled version)

        </F>



        Comment

        • Benjamin Niemann

          #5
          Re: ~ after script filename?

          presentt wrote:
          [color=blue]
          > Hello all,
          >
          > I just wrote a really simple script and named it helloworld.py. Inside
          > was only:
          >
          > #!/usr/bin/env
          > print "Hello, world"
          >
          > I used chmod to set the permissions, and ran it to see what happened (I
          > just started learning Python, if you couldn't guess)
          >
          > Then, I typed ls in the directory to see what was there, and I noticed
          > a new file, namely helloworld.py~ . What is that file (its contents
          > are identicle to helloworld.py)? Why the ~?
          >
          > Thanks a lot. I'm using Ubuntu Linux 5.04 (Hoary), and wrote the
          > script with gedit.
          >
          > ~~Ted Present[/color]

          As others have already said: this is not a python issue.

          A ~ suffix is commonly used by editors for backup file. If you save a file
          from the editor, and the file already exists (so it doesn't happen the
          first time you save a new file), the existing version is renamed with the ~
          suffix.

          After some time, you will learn to simply ignore these files ;)
          Many file managers have already learnt this lesson and have options to hide
          such backup files.

          --
          Benjamin Niemann
          Email: pink at odahoda dot de
          WWW: http://www.odahoda.de/

          Comment

          • Steve Horsley

            #6
            Re: ~ after script filename?

            presentt wrote:[color=blue]
            > Hello all,
            >
            > I just wrote a really simple script and named it helloworld.py. Inside
            > was only:
            >
            > #!/usr/bin/env
            > print "Hello, world"
            >
            > I used chmod to set the permissions, and ran it to see what happened (I
            > just started learning Python, if you couldn't guess)
            >
            > Then, I typed ls in the directory to see what was there, and I noticed
            > a new file, namely helloworld.py~ . What is that file (its contents
            > are identicle to helloworld.py)? Why the ~?
            >
            > Thanks a lot. I'm using Ubuntu Linux 5.04 (Hoary), and wrote the
            > script with gedit.
            >
            > ~~Ted Present
            >[/color]

            As others have said, this is a feature of gedit. It can make a
            backup copy of the previous version as you save, and can also
            automatically save periodically (default seems to be 10 minutes).
            From the menus, choose:
            Edit -> Preferences
            and see the section marked File Saving.

            Steve

            Comment

            • presentt

              #7
              Re: ~ after script filename?

              Oh okay. Thank you all.

              Now that you mention it, the ~ makes sense; I know M$ Word uses a ~ in
              the temp files that it autosaves periodically. And I think I've seen
              it with M$ Notepad too.

              Thanks again.

              Comment

              Working...