This seems to crash my program and gives me errors on the #include statements

E

Eric_Dexter

I was trying to add this to my project but I must be missing some
includes or there is a serius error somewhere


Anthra said:
Here's a function that screens out all instrument blocks and puts them into a dictionary keyed on the instrument number:
--------------------------------------------


def get_instruments (file_name):

INSIDE = 1
OUTSIDE = 0

f = file (file_name, 'ra')
state = OUTSIDE
instruments = {}
instrument_segment = ''

for line in f:
if state == OUTSIDE:
if line.startswith ('<CsInstruments'):
state = INSIDE
instrument_segment += line
else:
instrument_segment += line
if line.lstrip ().startswith ('instr'):
instrument_number = line.split () [1]
elif line.startswith ('</CsInstruments'):
instruments [instrument_number] = instrument_segment
instrument_segment = ''
state = OUTSIDE

f.close ()
return instruments
------------------------------------------------


You have received good advice on using parsers: "beautiful soup" or "pyparse". These are powerful tools capable of doing complicated
extractions. Yours is not a complicated extraction. Simon tried it with "beautiful soup". That seems simple enough, though he finds
the data by index leaving open where he gets the index from. There's surely a way to get the data by name.
Contrary to the parser the function will miss if tags take liberties with upper-lower case letters as they are probably
allowed by the specification. A regular expression might have to be used, if they do.
From your description I haven't been able to infer what the final format of your data is supposed to be. So I cannot tell you
how to go on from here. You'll find out. If not, just keep asking.

The SE solution which you said couldn't work out would be the following. It makes the same dictionary the function makes and it is
case-insensitive:
------------------------------------------------

if segment:
instr_line = Instrument_Number (segment)
instrument_number = instr_line.split ()[1]
instruments [instrument_number] = segment
--------------------------------------------------


(If you're on Windows and the CRs bother you, take them out with an additional definition when you make your
Instrument_Block_Filter: (13)= or "\r=")



----- Original Message -----
From: <[email protected]>
Newsgroups: comp.lang.python
To: <[email protected]>
Sent: Wednesday, August 30, 2006 1:51 AM
Subject: Re: newbe question about removing items from one file to another file



...
etc.



I cut and pasted this.. It seems to be crashing my program.. I am not
sure that I have all the right imports.. seems to be fine when I go to

an older version of the file... I uploaded it onto source forge.

https://sourceforge.net/project/showfiles.php?group_id=156455&package...

http://www.dexrow.com
 
S

Steve Holden

I was trying to add this to my project but I must be missing some
includes or there is a serius error somewhere
[...]

I cut and pasted this.. It seems to be crashing my program.. I am not
sure that I have all the right imports.. seems to be fine when I go to

an older version of the file... I uploaded it onto source forge.

https://sourceforge.net/project/showfiles.php?group_id=156455&package...

http://www.dexrow.com

Nobody, or very few people, are going to bother to download code from
sourceforge just to help you debug it.

As far as I can see you haven't yet explained *how* your program fails:
does it give a Python error traceback (in which case we would need to
see that traceback, which will at least tell us where the error occurs)
or something else? "A serious error" tells us effectively nothing except
that your program isn't doing what you want it to do, so even reading
the source probably won't help.

Have you tried reproducing the "serious error" in a smaller program that
you could include as a part of a posting on this list?

You are hiding the very information that is needed to help you solve
your problem.

regards
Steve
 
E

Eric_Dexter

It is giving errors on the import statements.. I will get an error on
the line where I import this routine import csoundroutines and then the
when I import the the program that tried to import csoundroutines I get
an error and on down the chain.. when I go back to where I started in
csoundroutines all the import errors go away.. I can't tell if thier
is a problem with se.py that starts all the errors or if I am not
getting all the right import statements... There is a short file on
sourceforge that gives the csoundroutines library I am trying to debug
and expand..

https://sourceforge.net/project/showfiles.php?group_id=156455&package


Steve said:
I was trying to add this to my project but I must be missing some
includes or there is a serius error somewhere
[...]

I cut and pasted this.. It seems to be crashing my program.. I am not
sure that I have all the right imports.. seems to be fine when I go to

an older version of the file... I uploaded it onto source forge.

https://sourceforge.net/project/showfiles.php?group_id=156455&package...

http://www.dexrow.com

Nobody, or very few people, are going to bother to download code from
sourceforge just to help you debug it.

As far as I can see you haven't yet explained *how* your program fails:
does it give a Python error traceback (in which case we would need to
see that traceback, which will at least tell us where the error occurs)
or something else? "A serious error" tells us effectively nothing except
that your program isn't doing what you want it to do, so even reading
the source probably won't help.

Have you tried reproducing the "serious error" in a smaller program that
you could include as a part of a posting on this list?

You are hiding the very information that is needed to help you solve
your problem.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
 
R

Roberto Bonvallet

It is giving errors on the import statements.. I will get an error on
the line where I import this routine import csoundroutines and then the
when I import the the program that tried to import csoundroutines I get
an error and on down the chain..

Please paste here the errors you get, and paste also the relevant code (not
the whole program) that triggers that error.
 
A

Anthra Norell

Dexter,
Whenever I can I post solutions. And when I do, I run them in an IDLE window and copy my commands plus the output over into
the message. So my posting should be replicable, if you would copy the commands into your IDLE window one by one and hitting return.
Please do this and copy everything in your window back into your message. If we do that it shouldn't be hard to straighten
this out.

Frederic

----- Original Message -----
From: <[email protected]>
Newsgroups: comp.lang.python
To: <[email protected]>
Sent: Monday, September 04, 2006 5:37 PM
Subject: Re: This seems to crash my program and gives me errors on the#include statements
 

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

No members online now.

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top