[Python-il] problem in script

Yitzhak Wiener Yitzhak.Wiener at dspg.com
Tue Jan 19 18:14:07 IST 2010

BTW the file I am seeking is attached.



Best Regards,



From: Yitzhak Wiener 
Sent: Tuesday, January 19, 2010 6:11 PM
To: 'Shlomi Fish'; python-il at hamakor.org.il
Cc: Shai Berger; Beni Cherniavsky
Subject: RE: [Python-il] problem in script


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

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_Code at 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 






Best Regards,



-----Original Message-----
From: Shlomi Fish [mailto:shlomif at iglu.org.il] 
Sent: Monday, December 28, 2009 12:39 PM
To: python-il at hamakor.org.il
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

>  the name), which boasted "examples in Python". So I looked. One

>  given there explained how one should overload a method (that is,

>  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

hand you can emulate such behaviour using multimethods:




And the big advantage of Multi-methods is that the multiple dispatch

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

Common Lisp" video:




The video was very insightful and instructive but the corresponding book

available online - at http://www.gigamonkeys.com/book/ ) kinda delves on

details and as a result one cannot see the forest for the trees. It

convinced me that Common Lisp was not very practical. :-).




      Shlomi Fish


>  I remember the

>  second example I checked also had a severe error, but not what it


> That's the only Hebrew book "about" Python I've ever seen.


> Shai.

> _______________________________________________

> Python-il mailing list

> Python-il at hamakor.org.il

> http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il





Shlomi Fish       http://www.shlomifish.org/



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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://hamakor.org.il/pipermail/python-il/attachments/20100119/6cd96c86/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: project_release_out.dump
Type: application/octet-stream
Size: 6271730 bytes
Desc: project_release_out.dump
Url : http://hamakor.org.il/pipermail/python-il/attachments/20100119/6cd96c86/attachment-0001.obj 

More information about the Python-il mailing list