Documentation/Info on this sign

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

    Documentation/Info on this sign

    Could someone point me to documentation on this (and similar) signs used
    in Python:

    +=

    Usage would be:

    x = += len(y)

    Literally, that's "variable x equals
    'funky-symbol-that-I-want-to-learn-about' the length of variable y"

    Thank you,

    Bart
  • wes weston

    #2
    Re: Documentation/Info on this sign

    Bart Nessux wrote:[color=blue]
    > Could someone point me to documentation on this (and similar) signs used
    > in Python:
    >
    > +=
    >
    > Usage would be:
    >
    > x = += len(y)
    >
    > Literally, that's "variable x equals
    > 'funky-symbol-that-I-want-to-learn-about' the length of variable y"
    >
    > Thank you,
    >
    > Bart[/color]

    Bart, see http://docs.python.org/ref/augassign.html
    wes

    Comment

    • Bart Nessux

      #3
      Re: Documentation/Info on this sign

      wes weston wrote:[color=blue]
      > Bart Nessux wrote:
      >[color=green]
      >> Could someone point me to documentation on this (and similar) signs
      >> used in Python:
      >>
      >> +=
      >>
      >> Usage would be:
      >>
      >> x = += len(y)
      >>
      >> Literally, that's "variable x equals
      >> 'funky-symbol-that-I-want-to-learn-about' the length of variable y"
      >>
      >> Thank you,
      >>
      >> Bart[/color]
      >
      >
      > Bart, see http://docs.python.org/ref/augassign.html
      > wes
      >[/color]

      Thanks Wes!

      Comment

      • Peter Hansen

        #4
        Re: Documentation/Info on this sign

        Bart Nessux wrote:
        [color=blue]
        > Could someone point me to documentation on this (and similar) signs used
        > in Python:
        >
        > +=[/color]


        [color=blue]
        > Usage would be:
        >
        > x = += len(y)[/color]

        What do you mean by this? "Usage would be"... ?
        [color=blue]
        > Literally, that's "variable x equals
        > 'funky-symbol-that-I-want-to-learn-about' the length of variable y"[/color]

        Huh? This doesn't have meaning... both = and += are assignment
        statements, so you can't put one right after the other.

        What are you trying to do?

        -Peter

        Comment

        • Dennis Lee Bieber

          #5
          Re: Documentation/Info on this sign

          On Thu, 20 May 2004 11:26:20 -0400, Bart Nessux
          <bart_nessux@ho tmail.com> declaimed the following in comp.lang.pytho n:
          [color=blue]
          > Could someone point me to documentation on this (and similar) signs used
          > in Python:
          >
          > +=[/color]

          Python Reference Manual: section 6.3.1 "Augmented Assignment
          Statements"
          [color=blue]
          >
          > Literally, that's "variable x equals
          > 'funky-symbol-that-I-want-to-learn-about' the length of variable y"[/color]

          Literally? That's a syntax error...

          x += len(y)

          is correct usage.

          {var} {operator}= {expr}

          is basically a short-cut for

          {var} = {var} {operator} {expr}

          --[color=blue]
          > =============== =============== =============== =============== == <
          > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
          > wulfraed@dm.net | Bestiaria Support Staff <
          > =============== =============== =============== =============== == <
          > Home Page: <http://www.dm.net/~wulfraed/> <
          > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

          Comment

          • David Goodger

            #6
            Re: Documentation/Info on this sign

            Bart Nessux wrote:[color=blue]
            > Could someone point me to documentation on this (and similar)
            > signs used in Python:
            >
            > +=[/color]


            [color=blue]
            > Usage would be:
            >
            > x = += len(y)[/color]

            No, it would be:

            x = len(y)

            or:

            x += len(y)

            You can't combine them.

            -- David Goodger


            Comment

            • Bart Nessux

              #7
              Re: Documentation/Info on this sign

              Peter Hansen wrote:[color=blue]
              > Bart Nessux wrote:
              >[color=green]
              >> Could someone point me to documentation on this (and similar) signs
              >> used in Python:
              >>
              >> +=[/color]
              >
              >
              > http://docs.python.org/ref/augassign.html
              >[color=green]
              >> Usage would be:
              >>
              >> x = += len(y)[/color]
              >
              >
              > What do you mean by this? "Usage would be"... ?
              >[color=green]
              >> Literally, that's "variable x equals
              >> 'funky-symbol-that-I-want-to-learn-about' the length of variable y"[/color]
              >
              >
              > Huh? This doesn't have meaning... both = and += are assignment
              > statements, so you can't put one right after the other.
              >
              > What are you trying to do?
              >
              > -Peter[/color]

              I'm trying to count files and dirs on a Win XP system... I'm trying to
              do so with a great degree of accuracy. Here's what I've tried:

              def fs_object_count ():
              file_count = 0
              dir_count = 0
              for root, dirs, files in os.walk(/):
              file_count += len(files)
              dir_count += len(dirs)
              print "Number of Files Examined: ", file_count
              print "Number of Folders Examined: ", dir_count
              print "Total number of FS Objects is:", file_count + dir_count

              I've also tried this:

              def fs_object_count ():
              fs_list = []
              for root, dirs, files in os.walk('/'):
              for d in dirs:
              fs_list.append( d)
              for f in files:
              fs_list.append( f)
              print len(fs_list)

              Both functions produce the same results (33,000 files)... the problem:
              the filesystem has twice as many files (66,000) than the actual sums of
              these two counts when doing a virus scan or an adaware scan. To make
              matters more confusing... the IBM Tivoli backup software that I use
              confirms the Python counts when it does a backup. I don't know of a way
              to see what the OS has to say what it thinks is correct. Any ideas on
              how to do this?

              Comment

              • Peter Hansen

                #8
                Re: Documentation/Info on this sign

                Bart Nessux wrote:
                [color=blue]
                > confirms the Python counts when it does a backup. I don't know of a way
                > to see what the OS has to say what it thinks is correct. Any ideas on
                > how to do this?[/color]

                Yes, just open your C: drive (or whatever file system you have)
                in an Explorer window, then select all files and folders by
                doing Ctrl-A (or Select All from the Edit menu), then right-click
                and select Properties. Along with the total storage space
                used, etc, the dialog will show "Contains: xx,xxx files".

                -Peter

                Comment

                • Roel Schroeven

                  #9
                  Re: Documentation/Info on this sign

                  Bart Nessux wrote:[color=blue]
                  > Both functions produce the same results (33,000 files)... the problem:
                  > the filesystem has twice as many files (66,000) than the actual sums of
                  > these two counts when doing a virus scan or an adaware scan. To make
                  > matters more confusing... the IBM Tivoli backup software that I use
                  > confirms the Python counts when it does a backup.[/color]

                  Just an idea... maybe virus scanners and adaware open and scan archives
                  (zip, rar, tar, ...) and include the files in the archives in their counts?

                  --
                  "Codito ergo sum"
                  Roel Schroeven

                  Comment

                  • Peter Otten

                    #10
                    Re: Documentation/Info on this sign

                    Bart Nessux wrote:
                    [color=blue]
                    > Both functions produce the same results (33,000 files)... the problem:
                    > the filesystem has twice as many files (66,000) than the actual sums of
                    > these two counts when doing a virus scan or an adaware scan. To make
                    > matters more confusing... the IBM Tivoli backup software that I use
                    > confirms the Python counts when it does a backup. I don't know of a way
                    > to see what the OS has to say what it thinks is correct. Any ideas on
                    > how to do this?[/color]

                    Maybe you have a symlink (how are they called in windows?) in the root
                    folder. The number of files would vary depending on whether the software
                    follows symlinks or not. That could explain the factor 2.

                    Peter

                    Comment

                    • Peter Hansen

                      #11
                      Re: Documentation/Info on this sign

                      Peter Otten wrote:
                      [color=blue]
                      > Bart Nessux wrote:[color=green]
                      >>Both functions produce the same results (33,000 files)... the problem:
                      >>the filesystem has twice as many files (66,000) than the actual sums of
                      >>these two counts when doing a virus scan or an adaware scan. To make
                      >>matters more confusing... the IBM Tivoli backup software that I use
                      >>confirms the Python counts when it does a backup. I don't know of a way
                      >>to see what the OS has to say what it thinks is correct. Any ideas on
                      >>how to do this?[/color]
                      >
                      > Maybe you have a symlink (how are they called in windows?) in the root
                      > folder. The number of files would vary depending on whether the software
                      > follows symlinks or not. That could explain the factor 2.[/color]

                      While the NTFS does support symbolic link, it doesn't even appear
                      to include a utility to create them, and most people, I suspect
                      don't even know they exist. (I had to check with Google to even
                      find this out.) There is a utility called "junction" which can
                      be had from http://www.sysinternals.com/ntw2k/so...shtml#junction
                      perhaps among other places. Very unlikely the OP has used this...

                      -Peter

                      Comment

                      • Peter Otten

                        #12
                        Re: Documentation/Info on this sign

                        Peter Hansen wrote:
                        [color=blue]
                        > Peter Otten wrote:
                        >[color=green]
                        >> Bart Nessux wrote:[color=darkred]
                        >>>Both functions produce the same results (33,000 files)... the problem:
                        >>>the filesystem has twice as many files (66,000) than the actual sums of
                        >>>these two counts when doing a virus scan or an adaware scan. To make
                        >>>matters more confusing... the IBM Tivoli backup software that I use
                        >>>confirms the Python counts when it does a backup. I don't know of a way
                        >>>to see what the OS has to say what it thinks is correct. Any ideas on
                        >>>how to do this?[/color]
                        >>
                        >> Maybe you have a symlink (how are they called in windows?) in the root
                        >> folder. The number of files would vary depending on whether the software
                        >> follows symlinks or not. That could explain the factor 2.[/color]
                        >
                        > While the NTFS does support symbolic link, it doesn't even appear
                        > to include a utility to create them, and most people, I suspect
                        > don't even know they exist. (I had to check with Google to even
                        > find this out.) There is a utility called "junction" which can
                        > be had from http://www.sysinternals.com/ntw2k/so...shtml#junction
                        > perhaps among other places. Very unlikely the OP has used this...[/color]

                        Oops, I meant plain old shortcuts (the german term used by windows,
                        "Verknüpfun g", translates smoothly to link, shortcut would rather be
                        "Abkürzung" ). The meaning got lost in translation.
                        Upon reflection it seems unlikely that an antivirus tool would resolve
                        shortcuts, but the basic idea that twice as many files being seen is an
                        indication of files being seen twice _somehow_ still seems compelling.

                        Peter

                        Comment

                        • Peter Hansen

                          #13
                          Re: Documentation/Info on this sign

                          Peter Otten wrote:
                          [color=blue]
                          > Oops, I meant plain old shortcuts (the german term used by windows,
                          > "Verknüpfun g", translates smoothly to link, shortcut would rather be
                          > "Abkürzung" ). The meaning got lost in translation.[/color]

                          I've yet to see *anything* other than Windows itself which
                          bothers to resolve shortcuts.
                          [color=blue]
                          > Upon reflection it seems unlikely that an antivirus tool would resolve
                          > shortcuts, but the basic idea that twice as many files being seen is an
                          > indication of files being seen twice _somehow_ still seems compelling.[/color]

                          True. I didn't take the numbers given by the OP as being
                          exact, mind you, but perhaps they were.

                          -Peter

                          Comment

                          • Terry Reedy

                            #14
                            Re: Documentation/Info on this sign


                            "Peter Otten" <__peter__@web. de> wrote in message
                            news:c8mr7d$ueh $06$1@news.t-online.com...[color=blue]
                            > Upon reflection it seems unlikely that an antivirus tool would resolve
                            > shortcuts, but the basic idea that twice as many files being seen is an
                            > indication of files being seen twice _somehow_ still seems compelling.[/color]

                            I have a memory (about a year ago) of (McAfee?) AV scanning every file
                            twice. Not sure why or settings used, but I think it applied two separate
                            algorithms in separate passes. Don't remember if doubled number. More
                            concerned by nasty infection it found;-)

                            tjr




                            Comment

                            • Frederic G. MARAND

                              #15
                              Re: Documentation/Info on this sign

                              eTrust antivirus can scan twice because it uses two different engines. Maybe
                              this is what you are remembering ?

                              "Terry Reedy" <tjreedy@udel.e du> a écrit dans le message de
                              news:mailman.18 1.1085237863.69 49.python-list@python.org ...[color=blue]
                              >
                              > "Peter Otten" <__peter__@web. de> wrote in message
                              > news:c8mr7d$ueh $06$1@news.t-online.com...[color=green]
                              > > Upon reflection it seems unlikely that an antivirus tool would resolve
                              > > shortcuts, but the basic idea that twice as many files being seen is an
                              > > indication of files being seen twice _somehow_ still seems compelling.[/color]
                              >
                              > I have a memory (about a year ago) of (McAfee?) AV scanning every file
                              > twice. Not sure why or settings used, but I think it applied two separate
                              > algorithms in separate passes. Don't remember if doubled number. More
                              > concerned by nasty infection it found;-)
                              >
                              > tjr
                              >
                              >
                              >
                              >[/color]


                              Comment

                              Working...