J
John Latter
| It may be better just for 'hands-on' experience
| to start with a Basic language such as XBasic/RapidQ/BCX
| but do you know if I'll be able to create win32dll files
| with them? Can I with Python ?
John ...
There are distribution/install methods available
to convert Python source programs to stand-alone executables,
and I think you can also generate win32 DLL files
but I'm not 100% sure about that as I've never done it myself ...
Cousin JanC that often posts here could probably
shed more light on that ...
Python provides a very "basic" , e.g. fundamental, approach
to programming and the following experiment might give you
a better idea of "hands-on" type Python I/O processing ...
Although you've never used Python, I would wager
that you can read and understand the following program
that ...
o Reads an input file line-by-line
o Finds a given search string
o Writes the corresponding line
to an output file if the search string is found
Hi Cousin Stanley,
Before I get onto my understanding of the program I am (as usual)
having problems installing Python. I've posted this message to th
Python newsgroup but haven't had any reply yet:
Hi,
I downloaded Python-2.3.exe but when I used winzip it kept asking me
if I wanted to replace old files with new ones, and in some instances,
new files with old ones.
I've never downloaded/installed Python before, and as something of a
computer novice, would like to know what I may be doing wrong!
This is the link I downloaded from:
which is on this page;
http://www.python.org/2.3/
Hope someone can help!
Now to the program!
# ----------------------------------------------------------
path_in = 'c:/windows/general.txt'
path_out = 'k:/Python/py_Work/file/general_search.txt'
Looks straightforward enough - kind of 'global pointers' to the two
files that are going to be used (although if 'k' is a directory then I
haven't seen it before)
file_in = file( path_in , 'r' )
file_out = file( path_out , 'w' )
Nope - I'm having trouble even expressing why I don't understand it.
I'm looking for something that will read a line at a time, and unless
general.txt contains a number of files (each of 'n' lines) then I
don't get it.
It looks to me that file is an array pointer that goes down the
path_in and r is a command and not a variable. file_in is assigned the
current file (and not a single line as would be the case if
general.txt were one file)
search_str = 'Windows 98'
A command to search for a specified string
for this_line in file_in :
start at the first line in the file
if this_line.find( search_str ) != -1 :
file_out.write( this_line )
search_str returns -1 if the text is found so then you output it
file_in.close()
file_out.close()
these might mean the particular file has been finished so go and get
the next one - I'm not at all sure though!. I'm surprised (in my
ignorance) that there are no loop counters or tests for the last file
- if these are implicitly contained in the syntax then thats just the
way the language works I guess - but it would be nice to use one's own
error handlers if general.txt didn't meet the expected format. Just to
repeat, in case I haven't made myself very clear, the program only
makes sense to me if general_txt contains a number of files - please
show mw where I'm going wrong!
Oh and I ppresume that ! is the variable that search_str puts its
result in.
Thanks for the help Cousin Stanley!
John
# --------------------------------------------------------
Save the code between the lines above as file_find.py ...
To run the program ... python file_find.py
# ---------------------------------------------------------
The example input file, general.txt, used above
is 1354 lines ( ~41 KB ) ...
The ouput file produced 74 lines ( 3.7 KB )
with lines only containing the string 'Windows 98' ...
This program runs in about 1/10th of a second
on the 250 MHz Win98_SE machine that I use ...
--
John Latter
Model of an Internal Evolutionary Mechanism (based on an extension to homeostasis) linking Stationary-Phase Mutations to the Baldwin Effect.
http://members.aol.com/jorolat/TEM.html
'Where Darwin meets Lamarck?' Discussion Egroup
http://groups.yahoo.com/group/evomech