443,272 Members | 1,733 Online
Need help? Post your question and get tips & solutions from a community of 443,272 IT Pros & Developers. It's quick & easy.

# Documentation/Info on this sign

 P: n/a 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 Jul 18 '05 #1
14 Replies

 P: n/a Bart Nessux wrote: 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 Bart, see http://docs.python.org/ref/augassign.html wes Jul 18 '05 #2

 P: n/a wes weston wrote: Bart Nessux wrote: 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 Bart, see http://docs.python.org/ref/augassign.html wes Thanks Wes! Jul 18 '05 #3

 P: n/a Bart Nessux wrote: Could someone point me to documentation on this (and similar) signs used in Python: += http://docs.python.org/ref/augassign.html Usage would be: x = += len(y) What do you mean by this? "Usage would be"... ? Literally, that's "variable x equals 'funky-symbol-that-I-want-to-learn-about' the length of variable y" 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 Jul 18 '05 #4

 P: n/a On Thu, 20 May 2004 11:26:20 -0400, Bart Nessux declaimed the following in comp.lang.python: Could someone point me to documentation on this (and similar) signs used in Python: += Python Reference Manual: section 6.3.1 "Augmented Assignment Statements" Literally, that's "variable x equals 'funky-symbol-that-I-want-to-learn-about' the length of variable y" 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} -- ================================================== ============ < wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < ================================================== ============ < Home Page: < Overflow Page: < Jul 18 '05 #5

 P: n/a Bart Nessux wrote: Could someone point me to documentation on this (and similar) signs used in Python: += http://www.python.org/doc/current/ref/augassign.html Usage would be: x = += len(y) No, it would be: x = len(y) or: x += len(y) You can't combine them. -- David Goodger Jul 18 '05 #6

 P: n/a Peter Hansen wrote: Bart Nessux wrote: Could someone point me to documentation on this (and similar) signs used in Python: += http://docs.python.org/ref/augassign.html Usage would be: x = += len(y) What do you mean by this? "Usage would be"... ? Literally, that's "variable x equals 'funky-symbol-that-I-want-to-learn-about' the length of variable y" 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 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? Jul 18 '05 #7

 P: n/a Bart Nessux wrote: 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? 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 Jul 18 '05 #8

 P: n/a Bart Nessux wrote: 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. 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 Jul 18 '05 #9

 P: n/a Bart Nessux wrote: 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? 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 Jul 18 '05 #10

 P: n/a Peter Otten wrote: Bart Nessux wrote:Both functions produce the same results (33,000 files)... the problem:the filesystem has twice as many files (66,000) than the actual sums ofthese two counts when doing a virus scan or an adaware scan. To makematters more confusing... the IBM Tivoli backup software that I useconfirms the Python counts when it does a backup. I don't know of a wayto see what the OS has to say what it thinks is correct. Any ideas onhow to do this? 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. 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 Jul 18 '05 #11

 P: n/a Peter Hansen wrote: Peter Otten wrote: Bart Nessux wrote:Both functions produce the same results (33,000 files)... the problem:the filesystem has twice as many files (66,000) than the actual sums ofthese two counts when doing a virus scan or an adaware scan. To makematters more confusing... the IBM Tivoli backup software that I useconfirms the Python counts when it does a backup. I don't know of a wayto see what the OS has to say what it thinks is correct. Any ideas onhow to do this? 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. 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... Oops, I meant plain old shortcuts (the german term used by windows, "Verknüpfung", 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 Jul 18 '05 #12

 P: n/a Peter Otten wrote: Oops, I meant plain old shortcuts (the german term used by windows, "Verknüpfung", translates smoothly to link, shortcut would rather be "Abkürzung"). The meaning got lost in translation. I've yet to see *anything* other than Windows itself which bothers to resolve shortcuts. 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. True. I didn't take the numbers given by the OP as being exact, mind you, but perhaps they were. -Peter Jul 18 '05 #13

 P: n/a "Peter Otten" <__*******@web.de> wrote in message news:c8*************@news.t-online.com... 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. 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 Jul 18 '05 #14

 P: n/a eTrust antivirus can scan twice because it uses two different engines. Maybe this is what you are remembering ? "Terry Reedy" a écrit dans le message de news:ma*************************************@pytho n.org... "Peter Otten" <__*******@web.de> wrote in message news:c8*************@news.t-online.com... 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. 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 Jul 18 '05 #15

### This discussion thread is closed

Replies have been disabled for this discussion.