473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

I was trying to add this to my project but I must be missing some
includes or there is a serius error somewhere
Anthra Norell wrote:
Dexter,
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:
------------------------------------------------
>Instrument_Segment_Filter = SE.SE ('<EAT"~(?i)<CsInstruments>(.|\n)*?</CsInstruments>~==\n\n" ')
instrument_segments= Instrument_Segment_Filter ('file_name', '')
print instrument_segments
(... see all instrument segments ...)
>Instrument_Number = SE.SE ('<EAT~instr.*~==\n')
instruments ={}
for segment in instrument_segments.split ('\n\n'):
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=")
Regards
Frederic
----- Original Message -----
From: <Eric_Dex...@msn.com>
Newsgroups: comp.lang.python
To: <python-l...@python.org>
Sent: Wednesday, August 30, 2006 1:51 AM
Subject: Re: newbe question about removing items from one file to another file
Anthra Norell wrote:
Dexter,
I looked at the format specification. It contains an example:
-----------------------------------------------
<CsoundSynthesizer>;
; test.csd - a Csound structured data file
<CsOptions>
-W -d -o tone.wav
</CsOptions>
...
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/show...156455&package...

http://www.dexrow.com

Sep 4 '06 #1
5 1529
Er*********@msn.com wrote:
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/show...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

Sep 4 '06 #2
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/show...156455&package
Steve Holden wrote:
Er*********@msn.com wrote:
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/show...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
Sep 4 '06 #3
Er*********@msn.com wrote:
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.

--
Roberto Bonvallet
Sep 4 '06 #4
#import se

# se available at http://cheeseshop.python.org/pypi/SE/2.2%20beta

looks like it is the se beta.. I didn't get any kind of error or
traceback that would tell me that though..


Roberto Bonvallet wrote:
Er*********@msn.com wrote:
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.

--
Roberto Bonvallet
Sep 4 '06 #5
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: <Er*********@msn.com>
Newsgroups: comp.lang.python
To: <py*********@python.org>
Sent: Monday, September 04, 2006 5:37 PM
Subject: Re: This seems to crash my program and gives me errors on the#include statements

#import se

# se available at http://cheeseshop.python.org/pypi/SE/2.2%20beta

looks like it is the se beta.. I didn't get any kind of error or
traceback that would tell me that though..


Roberto Bonvallet wrote:
Er*********@msn.com wrote:
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.

--
Roberto Bonvallet

--
http://mail.python.org/mailman/listinfo/python-list
Sep 4 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Juho Saarikko | last post by:
The program attached to this message makes the Python interpreter segfault randomly. I have tried both Python 2.2 which came with Debian Stable, and self-compiled Python 2.3.3 (newest I could find...
9
by: PG | last post by:
Hi gurus, I have AIX visual age C++ compiler version 5.0.2.3. I have a simple hello world program that gives compilation errors. Any help will be appreciated. Thanks PG ***test.cpp**** ...
5
by: tindog | last post by:
I seem to be caught in a bit of a conundrum with C#. First of all getting books on VS 2003.net then VS 2005 comes out and further a book I have bought to just learn just the language C# (in 21...
7
by: Daniel Rudy | last post by:
Hello, I have a peice of code that I'm making an attempt to code. The problem is that I need to return an arbitrary number of char strings. int function(char *fname, int *dcount, char *data)...
34
by: NewToCPP | last post by:
Hi, Why does a C/C++ programs crash? When there is access to a null pointer or some thing like that programs crash, but why do they crash? Thanks.
16
by: linq936 | last post by:
Hi, It could be a very simple problem, but i can not see it... Here is the code: char* lower(char* str){ char* p = str; while ( *str ) { *str = tolower(*str); <=====crash! str++;
4
by: mike3 | last post by:
Hi. I seem to have made some progress on finding that bug in my program. I deactivated everything in the bignum package that was used except for the returning of BigFloat objects. I even...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
12
by: Franz Hose | last post by:
the following program, when compiled with gcc and '-std=c99', gcc says test.c:6: error: jump into scope of identifier with variably modified type that is, it does not even compile. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.