Python lesson please
gene heskett
gheskett at wdtv.com
Mon Nov 7 15:00:49 EST 2011
On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine:
> On 11/07/2011 11:40 AM, gene heskett wrote:
> > On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine:
> > Back on the list..
> >
> >> On 11/07/2011 06:22 AM, gene heskett wrote:
> >>> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine:
> >>> <SNIP>
> >>>
> >>>> Are you talking about this one?
> >>>>
> >>>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPat
> >>>> te rns .py
> >>>
> >>> Yes. My save as renamed it, still has about 30k of tabs in it. But
> >>> I pulled it again, using the 'raw' link, saved it, no extra tabs.
> >>>
> >>> But it still doesn't work for linux. My python is 2.6.6
> >>
> >> To start with, what's the md5 of the file you downloaded and are
> >> testing? I get c4592a187f8f7880d3b685537e3bf9a5
> >
> > [root at coyote Download]# md5sum DuquDriverPatterns.py
> > c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as
> > yours.
> >
> >> from md5sum. If you get something different, one of us changed the
> >> file, or you got it before today.
> >>
> >> The whole tab issue is a red-herring in this case. But I don't see
> >> how you can find 30k tabs in a thousand lines. And if I were going
> >> to detab it, I'd pick 4 spaces, so the code doesn't stretch across
> >> the page.
> >
> > Down toward the bottom of the file, the tab indentations were as high
> > as 33 leading tabs per line. Each stanza of the data was tab
> > indented 2 additional tabs from the one above it in the original
> > file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely
> > reasonable guess.
>
> What program are you using to read the file and support that claim?
vim. But remember, this first one started out as a copy/paste from the
firefox-7.0.1 screen.
> Neither emacs nor gedit shows more than one leading tab on any line I
> looked. And if you set tabs to 4 columns, the file looks quite
> reasonable. Doing a quick scan I see max of 5 tabs on any single line,
> and 1006 total.
I have no tabs left in the operative code, the python interpreter was
having a cow if even one was in that last 30-35 lines of code.
>
>
> maxtabs = 0
> totaltabs = 0
> f = open("DuquDriverPatterns.py", "r")
> for line in f:
>
> cline = line.replace("\t", "")
> tabs = len(line) - len(cline)
> if tabs:
> print tabs
> maxtabs = max(maxtabs, tabs)
> totaltabs += tabs
>
> print "max=", maxtabs
> print "total=", totaltabs
>
> >>> <SNIP>
> The only way I've been able to make it "silent and instant" was to give
> it the name of an empty directory, or a typo representing no directory
> at all.
>
[...]
> >> line ? Or putting a print len(files) just after it (indented, of
> >> course) ?
> >
> > No, I did try to print the value of rootdir though, indented the same,
> > and got a null printout, not even a line feed.
Indented the same as the rootdir statement itself, which in python would
seem to make it immediately sequential to the roodir = statement.
> If you had put the print I suggested, it would at least print the words
> "Hello World". Since it did not, you probably didn't actually add the
> line where I suggested.
>
> > Thanks Dave.
> >
> > Cheers, Gene
>
> In another message you said it doesn't work on absolute file paths. But
> it does. You can replace any relative directory name with the absolute
> version, and it won't change the behavior. I suspect you were caught up
> by a typo for the absolute path string.
I am gene, running as gene, what could be wrong with giving it /home/gene
as the argument?
I have another dir in /home/amanda, that I build the alpha and beta amanda
stuff in. Let me try that. And again, this works but I forgot about the
.ccache directory, so it will take a while to finish.
Now, as a python lesson to me, I will do a blink compare between the 2
files this evening & see what I munged. ATM, I am working on a gunstock
for as long as my feet and back can stand the standing, so sitting here is
a 'break' from that. Yeah, I occasionally call myself a JOAT. ;-)
Thanks Dave.
Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene>
Experience is that marvelous thing that enables you recognize a mistake
when you make it again.
-- Franklin P. Jones
More information about the Python-list
mailing list