Hi Guys,
May I ask you a question?
I am trying to write a script that looking for some string expression
(expression A) in a file, and after it finds it, it searches for 2 other
expressions (B & C) which are located few lines after the fist
expression.
These 2 expressions appear few times in this file, that's why I need to
search for expression A first, and the next time B & C appears this is
what I search for.
I attached the script I use for finding expression A, but now I don't
know how to tell the script to start searching for expression B & C from
point A.
Can you advice please how it should be done?
from array import array
import os, stat, re
#get coff file size
file_size = os.stat("project_release.dump")[stat.ST_SIZE]
a = array('H')
f = open("project_release.dump","rb")
f2 = open("project_release_out.dump","wb")
a.fromfile( f,(file_size/2) )
s = a.tostring()
#search in coff for beggining of "MultiProgPage_Code" code section in
coff file.
#We need the beggining adress and size of this section
pattern = re.compile ("multiprogpage_c...@c0 - SECTION HEADER")
result = pattern.search(s)
#result is MatchObject, and therefore result.start() holds the location
of exression A in the file.
#now we need to find the value of the first time s_paddr , and s_size
are found after exression A
Thanks.
Best Regards,
Yitzhak
-----Original Message-----
From: Shlomi Fish [mailto:[email protected]]
Sent: Monday, December 28, 2009 12:39 PM
To: [email protected]
Cc: Shai Berger; Beni Cherniavsky; Yitzhak Wiener
Subject: Re: [Python-il] problem in script
On Sunday 27 Dec 2009 18:43:27 Shai Berger wrote:
> > On Sunday 27 Dec 2009 16:53:10 Yitzhak Wiener wrote:
> > > BTW what is the best user documentation for Python? And do you
know if
> > > there is good Hebrew documentation?
>
> First of all, what Shlomi said.
>
> I ran into a Hebrew book about Object Oriented Programming (can't
remember
> the name), which boasted "examples in Python". So I looked. One
example
> given there explained how one should overload a method (that is,
provide
> different definitions with different arguments, where the compiler is
> supposed to pick the right definition for every call according to
> arguments provided). Python does not have overloading.
Python indeed does not have such overloading like C++ does, but on the
other
hand you can emulate such behaviour using multimethods:
http://en.wikipedia.org/wiki/Multiple_dispatch#Python
And the big advantage of Multi-methods is that the multiple dispatch
happens
at *run-time* instead of in C++'s compile time so it is more flexible.
For more about the motivation for multimethods I can recommend the
"Practical
Common Lisp" video:
http://video.google.com/videoplay?docid=448441135356213813#
The video was very insightful and instructive but the corresponding book
(also
available online - at http://www.gigamonkeys.com/book/ ) kinda delves on
many
details and as a result one cannot see the forest for the trees. It
kinda
convinced me that Common Lisp was not very practical. :-).
Regards,
Shlomi Fish
> I remember the
> second example I checked also had a severe error, but not what it
was.
>
> That's the only Hebrew book "about" Python I've ever seen.
>
> Shai.
> _______________________________________________
> Python-il mailing list
> [email protected]
> http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il
>
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
http://www.shlomifish.org/humour/ways_to_do_it.html
Bzr is slower than Subversion in combination with Sourceforge.
( By: http://dazjorz.com/ )
______________________________________________________________________
DSP Group, Inc. automatically scans all emails and attachments using
MessageLabs Email Security System.
_____________________________________________________________________
______________________________________________________________________
DSP Group, Inc. automatically scans all emails and attachments using
MessageLabs Email Security System.
____________________________________________________________________________________________________________________
Python-il mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il