0

Cannot solve indentation error

I'm having an indentation error on line 67 of my main.py code. if you have a solution pls explain my error. thanks.

28th Sep 2017, 4:25 AM
jason :)
23 Answers
+ 2
This may help: https://stackoverflow.com/questions/8598228/f-write-vs-print-f https://stackoverflow.com/questions/15860372/in-JUMP_LINK__&&__python__&&__JUMP_LINK-can-i-redirect-the-output-of-print-function-to-stderr You'll also need to keep in mind what print was also adding to the statement such as spacing frim the comma and a return character for the end line. try this: print ("Unknown output format: {}".format(args.output_format), file=sys.stderr)
28th Sep 2017, 5:17 PM
ChaoticDawg
ChaoticDawg - avatar
+ 5
There are still a few more to fix. line 65 wrong print " {:12s}: {}".format("auto", "Auto-detect") correct print (" {:12s}: {}".format("auto", "Auto-detect")) there's more like above and also you can't just do print for a newline you must do print()
28th Sep 2017, 4:36 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
You need to change all your print statements so they are python 3 compatible. print() not print Your string arguments should be within the parantheses
28th Sep 2017, 4:28 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
Fix that first so the code can be properly parsed. Most likely your indentation error will resolve itself once done.
28th Sep 2017, 4:31 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
If you look at the error you can see that even though it says line 67 it's not actually pointing to the code from line 67, but code that is farther up. I did not upvote myself. You can check in the app by clicking on the number between the up and down arrows. I'll take a closer look at your code when I can get to my computer here in a few minutes. In the meantime if there are still known issues within your code please fix them first.
28th Sep 2017, 4:57 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
So, after looking through it (keep in mind I can't do much as I don't have the remaining portions of the modules to import), the only issues I see are still with your print statements. The code also will not run within the playground as parts of it can not be resolved. For some reason it seems that most of the curly braces have some hidden characters ('\n' or '\r') before or after them. See below: def list_support(): # List model translators print ("Models:") print (" {:12s}: {}".format("none", "Disable header translation") ) for trans in ModelTranslator.implementations(): print (" {:12s}: {}".format(trans.model, trans.description) ) print () # List slicers print ("Slicers:" ) print (" {:12s}: {}".format("auto", "Auto-detect") ) for slicer in Slicer.implementations(): print(" {:12s}: {}".format(slicer.name, slicer.description) ) print () print ("Output formats:") for t in sorted(FilePath.Types): print (" {}".format(t.replace(".", "")) ) print () Should look more like this: def list_support(): # List model translators print("Models:") print(" {:12s}: {}".format("none", "Disable header translation")) for trans in ModelTranslator.implementations(): print(" {:12s}: {}".format(trans.model, trans.description)) print() # List slicers print("Slicers:") print(" {:12s}: {}".format("auto", "Auto-detect")) for slicer in Slicer.implementations(): print(" {:12s}: {}".format(slicer.name, slicer.description)) print() print("Output formats:") for t in sorted(FilePath.Types): print(" {}".format(t.replace(".", ""))) print() Also I don't know what it is you intend to do with this line (currently 106), but it is not currently valid and is also missing the parentheses. print >> sys.stderr, "Unknown output format: {}".format(args.output_format) It looks like you're trying to bit shift a print statement.
28th Sep 2017, 5:37 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
After fixing the print statements from my previous post the indentation error is gone and the new error pertains to the imports, as I would expect: Traceback (most recent call last): File "..\Playground\", line 4, in <module> from . import slicers #intra-package references" SystemError: Parent module '' not loaded, cannot perform relative import
28th Sep 2017, 5:51 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
I'm not sure how your answer got upvoted you must have upvoted yourself. I mean it sounds good but I still don't have a functional code through line 67. it's usually bad edicate to upvoted yourself.
28th Sep 2017, 4:51 AM
jason :)
+ 1
Just got a chance to view the suggestion you made. it took me a few minutes to see what you meant, but it looks like I had an extra space after print. I'm not sure why I started doing that, but it really made a difference. thanks.
28th Sep 2017, 2:53 PM
jason :)
+ 1
I'm glad you noticed line 106. It is written in python 2.7 format. now that print is a function instead of a statement, I'm not sure how to go about rewriting this part.
28th Sep 2017, 4:59 PM
jason :)
+ 1
Check the edit in my last post. I think that you probably saw it before the edit. The way I have the code is how I think it should be based on the python documentation, but you should probably test it to make sure.
28th Sep 2017, 5:30 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Actually you have it as a second argument in your format() call. Yes, I think the file= is also necessary.
28th Sep 2017, 5:40 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
I added it after I made the comment. Thank you. You helped out alot. I had found a different similar post on stackexchange that had me going in a different direction with that line.
28th Sep 2017, 6:53 PM
jason :)
0
I was working on that. I guess this particular line confuses me a bit.
28th Sep 2017, 4:29 AM
jason :)
0
updated code with what made sense to me. still indent error same line
28th Sep 2017, 4:32 AM
jason :)
0
Thanks for spotting line 65 but I'm running the code after each correction. I cannot figure out line 67. it still gives an indent error despite adding parentheses.
28th Sep 2017, 4:42 AM
jason :)
0
I apologise if I was rude. i guess you can't teach an old dog new tricks. I'm just a bit confused as to where I went wrong. I've tried many variations. I m stuck here.
28th Sep 2017, 5:12 AM
jason :)
0
could I instead us sys.stderr.write()? It not quite the same as print though. I don't think it creates a new line. Maybe there is a way to append?
28th Sep 2017, 5:14 PM
jason :)
0
I've commented out the old line and rewrote it based off of the info in the link. this should do the same thing, I hope. what do you think?
28th Sep 2017, 5:25 PM
jason :)
0
I can't run it and debug till I get home. Is file= needed? I would think print assumes this already if sys.stderr is in the second argument. Your rewrite was identical to mine except for file=
28th Sep 2017, 5:37 PM
jason :)