[Tutor] 2 basic problems

charles benoit feather.duster.kung.fu at gmail.com
Wed May 29 23:23:46 CEST 2013


1:Python 2.7.4 (default, Apr 19 2013, 18:32:33)
[GCC 4.7.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> 4+4
8
>>> 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


2:
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>
>>>

I thought I was saving a string to a file and reading and printing the
string. The output looks like a description of the IO textwrapper at some
location. I'm sure this is a syntax/format problem.but this like the other
examples I saw. I ran this using python 2.6.7 on ubuntu 13.0  Thank you for
any help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130529/095bcd67/attachment.html>


More information about the Tutor mailing list