Documentation/Info on this sign

B

Bart Nessux

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
 
P

Peter Hansen

Bart said:
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
 
D

Dennis Lee Bieber

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}

--
 
B

Bart Nessux

Peter said:
What do you mean by this? "Usage would be"... ?



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?
 
P

Peter Hansen

Bart said:
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
 
R

Roel Schroeven

Bart said:
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?
 
P

Peter Otten

Bart said:
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
 
P

Peter Hansen

Peter said:
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/source/misc.shtml#junction
perhaps among other places. Very unlikely the OP has used this...

-Peter
 
P

Peter Otten

Peter said:
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/source/misc.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
 
P

Peter Hansen

Peter said:
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
 
T

Terry Reedy

Peter Otten said:
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
 
F

Frederic G. MARAND

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,200
Messages
2,571,046
Members
47,646
Latest member
xayaci5906

Latest Threads

Top