Take the 2-minute tour ×


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


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

    File "./install.py", line 72
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!.


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.

share|improve this question
Can you paste the entire file, possibly to dpaste or similar site? –  Adam Vandenberg Dec 28 '10 at 3:16
this is valid python, no SyntaxError –  Jochen Ritzel Dec 28 '10 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. –  Brian Clapper Dec 28 '10 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? –  Insomaniacal Dec 28 '10 at 3:22

2 Answers 2

up vote 2 down vote accepted

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)")
share|improve this answer
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. –  Insomaniacal Dec 28 '10 at 3:27
No worries; this is why posting the full source is good, get another set of eyes on the problem. –  Adam Vandenberg Dec 28 '10 at 3:31

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.

share|improve this answer
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! –  Insomaniacal Dec 28 '10 at 3:24

Your Answer


