Q: What steps will reproduce the problem?
1. Import any Python code that prints to file (version 3.2.3)
2. Sample code:
def censor(text):
s_words = ['crap','damn','shit','fuck']
for i in range(len(s_words)):
text = text.replace(s_words[i],'****')
return text
def main():
infilename = "C:\\test_files\\censor_test.txt"
outfilename = "C:\\test_files\\censor_test_output.txt"
infile = open(infilename, "r")
outfile = open(outfilename, "w")
print("{0}".format(censor(infile.read())), file=outfile)
infile.close
outfile.close
if __name__ == '__main__': main()
#########################
Q: What is the expected output? What do you see instead?
A: I thought that the module would import and show a UML layout.
I saw:
Setting virtual size to 20,20
Importing... [u'C:\\Python32\\TestApps\\data_collections-ch11-prgexc11-file_cens
or.py']
Traceback (most recent call last):
File "__main__pyNsourceGui__.py", line 456, in OnFileImport
File "app/controller.py", line 44, in cmd_invoker_f
File "common/command_pattern.py", line 101, in run
File "app/cmds/filemgmt.py", line 64, in execute
File "app/cmds/filemgmt.py", line 27, in execute
File "parsing/api.py", line 25, in new_parser
File "parsing/api.py", line 21, in ast_parser
File "ast.py", line 37, in parse
File "<unknown>", line 19
print("{0}".format(censor(infile.read())), file=outfile)
^
SyntaxError: invalid syntax
Q: What version of the product are you using? On what operating system?
A: I am using Python version 3.2.3. I am on Windows XP.
Q: Please provide any additional information below.
A: Thanks for PyNSource, it's a great resource!
I get this error when importing any code that has file=local_variable used with
the print built-in function. The syntax works well when executing the modules.
Thanks,
Sean
Original issue reported on code.google.com by FCUdeve...@gmail.com on 25 Oct 2013 at 3:43
Original issue reported on code.google.com by
FCUdeve...@gmail.com
on 25 Oct 2013 at 3:43