0

THIS TURNED OUT TO BE A SYNTAX ERROR ON MY PART A LINE EARLIER IN THE CODE.

Hello, I'm having some trouble with a nested function I wrote in python. Here is the relevant code.

device = "/dev/sr0"
def burn():  
  global device


  burnaudiotrack(device)
  createiso(device)  
  burntrack2(device)  

I'm confused, because every time I try to run the script, python returns this:

    File "./install.py", line 72
    burnaudiotrack(device)
                 ^
SyntaxError: invalid syntax

I've nested functions before, and done so in a similar manner. I feel like I'm missing something fairly obvious here, but I can't pinpoint it. Thank you for your help/suggestions!.

EDIT:

Full code: (I tried to just post relevant info in the original) http://dpaste.com/hold/291347/

It's a tad messy, and there may be other errors, but this one is vexing me at the moment.

4
  • Can you paste the entire file, possibly to dpaste or similar site? Commented Dec 28, 2010 at 3:16
  • this is valid python, no SyntaxError Commented Dec 28, 2010 at 3:17
  • What version of Python? The above code works for me (with stubs for the burnaudiotrack, createiso and burntrack2 functions) on Python 2.5 and Python 2.6. Commented Dec 28, 2010 at 3:20
  • I'm using python 2.6.5 under a modern Linux Kernel (2.6.33). The full code is in the post. I also thought this syntax was fine, so I'm guessing there's something amiss elsewhere in the code? Commented Dec 28, 2010 at 3:22

2 Answers 2

2

You are missing a close parenthesis on line 61.

Looks like the quote and paren at the end of the line are swapped.

speed = raw_input("Recomended(4);Default(8))"

should be

speed = raw_input("Recomended(4);Default(8)")
Sign up to request clarification or add additional context in comments.

2 Comments

I want to hide away in shameful embarrassment now. Thanks for pointing that out, I probably would've wasted time re-writing sections of the code without purpose otherwise.
No worries; this is why posting the full source is good, get another set of eyes on the problem.
0

The code you have pasted into your question appears to have tabs as well as spaces. You should (according to PEP-8) always use spaces for indenting in Python. Check your text editor settings.

What's probably happened is you have some mix of tabs and spaces that looks correct in your editor, but is being interpreted differently by the Python compiler. The Python compiler sees a different inconsistent indenting, and throws a SyntaxError.

Update: As another answer points out, you are missing a closing parenthesis on a line of code you didn't show in your original question. Nevertheless, my comments about tabs in your source still hold.

1 Comment

That's a good suggestion, but the actual code I'm running was all formatted by the same editor (With tabs). I already made sure that wasn't the issue before posting. Thanks for the suggestion though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.