Hi Charles, I have added some comments below explaining why you are not getting the results you expect:
>>> 4+4 8 The above is an expression, when you hit enter python will evaluate it and give the answer. >>> 3+3=4 SyntaxError: can't assign to operator >>> 3=1 SyntaxError: can't assign to literal > I thought the last 2 lines should return False This is an assignment statement, the single '=' means when you hit enter python will try to set the value of one side to the other. Hence the assignment error. Instead try: >>> 3+3==4 False >>> 3==1 False -------- lot=('1'+'6'+'8') print(lot) a=open("acc","w") a.write(lot) a.close b=open("acc","r") b.read() print (b) b.close returns >>> 168 <open file 'acc', mode 'r' at 0xb6f9a650> >>> Firstly your <file>.close methods need to have parens to actually call the method. So instead of a.close we need a.close() Then your b.read() line will work, I get the output '168' when I call b.read(). Lastly, the line b = open("acc", "r") creates a new file object (b). From the docs: "Open a file, returning an object of the file type." Therefore when you print(b) python will call the __repr__() method of the file object which is why you see the line <open file 'acc', mode 'r' at 0xb6f9a650>. John
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor