Learn Python the Hard Way

From Hackerspace.gr
Revision as of 13:17, 11 July 2015 by Ebal (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Learn python the hard way.jpg

external link
Starts Organizer
Mon 06 Jul 2015 18:00
Ends Event Owner
Mon 06 Jul 2015 20:00 User:Ebal
  • Κάθε Δευτέρα, 18:00-20:00
  • Συναντήσεις για εκμάθηση προγραμματισμού σε python.

Θα είναι υπό την μορφή study group, δηλαδή όλοι θα μαθαίνουμε παρέα και δεν θα υπάρχει κάποιος "δάσκαλος". Οι συναντήσεις είναι ανοιχτές σε όλες και όλους - αρκεί να φέρεις το laptop σου! Απευθύνονται σε ανθρώπους που θέλουν να ξεκινήσουν με python κι άρα θα είναι αρκετά εισαγωγικές. Η μοναδική δέσμευση είναι να τηρηθεί αυστηρά το ωράριο (δηλαδή εάν κάποιος ή κάποια αργήσει, να μην μας ζητήσει να γυρίσουμε πίσω για να καλύψουμε κάτι που έχουμε ήδη πει).

Έλα εγκαίρως/νωρίς αν θες να βρεις ελεύθερη θέση :)


  • Στις προηγούμενες συναντήσεις έχουμε καλύψει μέχρι και την:

Exercise 17: More Files


Η σελίδα της προηγούμενης συνάντησης με μερικές σημειώσεις:

https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_05



  • Every Monday at 18.00-20:00
  • python enthusiasts will try to learn programming "the hard way" !

The meetings will be in study group format, meaning that we will all learn together and there won't be a tutor. Meetings are open to everyone - just bring your laptop! They are for people that want to start learning python, so we will cover some introductory material. The only requirement is to be punctual (so if a person comes later than 18:00 please don't ask us to cover material that we have already gone through).

Come early if you want to ensure that you'll find a space to place your laptop :)


  • We have previously covered exercises till 17 (including Exercise 17: More Files)


The page for the previous meeting with some notes:

https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_05

These events are based on peer2peer education


These are the notes from Lesson 06

#!/usr/bin/python2.7

from sys import argv

list1 = [] 
list2 = [ 'a' , [ 1 , 2, [ 'str', 'int', 'float'] , 4 ,5 ], 'b', 'c', 'd' ]
## argv = [ argv[0], argv[1], ....  ]

print "The length of the arguments are: %d " % len ( argv )

print ""
print "The arguments are: "
print ""

for argument in argv:
    print "argument: %r" % argument

print ""

terminal


>>> type ( 1 ) 
<type 'int'>
>>> type ( 'text' ) 
<type 'str'>
>>> type ( 1.9 ) 
<type 'float'>
>>> type ( [1,2,3] ) 
<type 'list'>
>>> type ( True  ) 
<type 'bool'>
>>> type ( False ) 
<type 'bool'>
>>> 
>>> fd = open('/tmp/1.py')
>>> type (fd)
<type 'file'>



Terminal notes:


#pydoc2 type

#pydoc2 type

#pydoc2 raw_input  

#
#argv[0] --> the_script_itself
bash: argv[0]: command not found
## argv[0] --> the_script_itself
## argv[1] --> 1st argumenta
## argv[2] --> 2nd argument
#vim /tmp/1.py 
#python2 /tmp/1.py one two three four five six seven 
Traceback (most recent call last):
  File "/tmp/1.py", line 3, in <module>
    print argv[0]
NameError: name 'argv' is not defined
#python2 /tmp/1.py one two three four five six seven 
/tmp/1.py
one
two
three
four
#python2 /tmp/1.py one two three four five six seven 
8
/tmp/1.py
one
two
three
four
#python2 /tmp/1.py one two three four five six seven 
8
/tmp/1.py
one
two
three
four
five
six
seven


#python2 /tmp/1.py one two three four five six seven 
The length of the arguments are: 8 
The arguments are: 
/tmp/1.py
one
two
three
four
five
six
seven
#python2 /tmp/1.py one two three four five six seven 
The length of the arguments are: 8 
The arguments are: 
argument: '/tmp/1.py'
argument: 'one'
argument: 'two'
argument: 'three'
argument: 'four'
argument: 'five'
argument: 'six'
argument: 'seven'
#python2 /tmp/1.py one two three four five six seven 
The length of the arguments are: 8 

The arguments are: 

argument: '/tmp/1.py'
argument: 'one'
argument: 'two'
argument: 'three'
argument: 'four'
argument: 'five'
argument: 'six'
argument: 'seven'

#python2 /tmp/1.py one two three four five six seven 
#python2 /tmp/1.py one two three four five six seven 
The length of the arguments are: 8 

The arguments are: 

argument: '/tmp/1.py'
argument: 'one'
argument: 'two'
argument: 'three'
argument: 'four'
argument: 'five'
argument: 'six'
argument: 'seven'



#python2
Python 2.7.10 (default, May 26 2015, 04:16:29) 
[GCC 5.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> raw_input("? ") 
? 5
'5'
>>> 
>>> raw_input("string ")
string 3
'3'
>>> a = "? " 
>>> raw_input(a)
? a = "> " 
'a = "> " '
>>> raw_input(a)
? a
'a'
>>> a = "> " 
>>> 
>>> 
>>> raw_input(a)
> 4
'4'
>>> 
>>> a = "> <> <> > > >> << $ " 
>>> raw_input(a)
> <> <> > > >> << $ blue
'blue'
>>> 
>>> quit()



#python2
Python 2.7.10 (default, May 26 2015, 04:16:29) 
[GCC 5.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> 
>>> type ( variable ) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'variable' is not defined
>>> variable = "something" 
>>> type ( variable ) 
<type 'str'>
>>> 
>>> dir (variable )
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> id ( variable ) 
140636782192848
>>> type ( variable ) 
>>> type ( 1 ) 
<type 'int'>
>>> type ( 'text' ) 
<type 'str'>
>>> type ( 1.9 ) 
<type 'float'>
>>> type ( [1,2,3] ) 
<type 'list'>
>>> type ( True  ) 
<type 'bool'>
>>> type ( False ) 
<type 'bool'>
>>> 
>>> fd = open('/tmp/1.py')
>>> type (fd)
<type 'file'>
>>> 
>>> dir ( 1) 
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
>>> dir ( 1 ) 
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
>>> 1.__add__(1) 
  File "<stdin>", line 1
    1.__add__(1) 
            ^
SyntaxError: invalid syntax
>>> 1.__add__() 
  File "<stdin>", line 1
    1.__add__() 
            ^
SyntaxError: invalid syntax
>>> 1.real()     
  File "<stdin>", line 1
    1.real()
         ^
SyntaxError: invalid syntax
>>> 1.numerator()
  File "<stdin>", line 1
    1.numerator()
              ^
SyntaxError: invalid syntax
>>> dir ( 1 ) 
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
>>> dir ( True ) 
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
>>> dir ( fd ) 
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']
>>> something = fd.read() 
>>> type something 
  File "<stdin>", line 1
    type something 
                 ^
SyntaxError: invalid syntax
>>> type ( something )
<type 'str'>
>>> print something

code

#!/usr/bin/python2.7

from sys import argv

list1 = [] 
list2 = [ 'a' , [ 1 , 2, [ 'str', 'int', 'float'] , 4 ,5 ], 'b', 'c', 'd' ]
## argv = [ argv[0], argv[1], ....  ]

print "The length of the arguments are: %d " % len ( argv )

print ""
print "The arguments are: "
print ""

for argument in argv:
    print "argument: %r" % argument

print ""

terminal


>>> type ( 1 ) 
<type 'int'>
>>> type ( 'text' ) 
<type 'str'>
>>> type ( 1.9 ) 
<type 'float'>
>>> type ( [1,2,3] ) 
<type 'list'>
>>> type ( True  ) 
<type 'bool'>
>>> type ( False ) 
<type 'bool'>
>>> 
>>> fd = open('/tmp/1.py')
>>> type (fd)
<type 'file'>



>>> type something 
  File "<stdin>", line 1
    type something 
                 ^
SyntaxError: invalid syntax
>>> print something

code


#!/usr/bin/python2.7

from sys import argv

list1 = [] 
list2 = [ 'a' , [ 1 , 2, [ 'str', 'int', 'float'] , 4 ,5 ], 'b', 'c', 'd' ]
## argv = [ argv[0], argv[1], ....  ]

print "The length of the arguments are: %d " % len ( argv )

print ""
print "The arguments are: "
print ""

for argument in argv:
    print "argument: %r" % argument

print ""


terminal


>>> type ( 1 ) 
<type 'int'>
>>> type ( 'text' ) 
<type 'str'>
>>> type ( 1.9 ) 
<type 'float'>
>>> type ( [1,2,3] ) 
<type 'list'>
>>> type ( True  ) 
<type 'bool'>
>>> type ( False ) 
<type 'bool'>
>>> 
>>> fd = open('/tmp/1.py')
>>> type (fd)
<type 'file'>

<pre>

>>> print something
#!/usr/bin/python2.7

from sys import argv

list1 = [] 
list2 = [ 'a' , [ 1 , 2, [ 'str', 'int', 'float'] , 4 ,5 ], 'b', 'c', 'd' ]
## argv = [ argv[0], argv[1], ....  ]

print "The length of the arguments are: %d " % len ( argv )

print ""
print "The arguments are: "
print ""

for argument in argv:
    print "argument: %r" % argument

print ""

>>> type ( 1 ) 
<type 'int'>
>>> type ( 'text' ) 
<type 'str'>
>>> type ( 1.9 ) 
<type 'float'>
>>> type ( [1,2,3] ) 
<type 'list'>
>>> type ( True  ) 
<type 'bool'>
>>> type ( False ) 
<type 'bool'>
>>> 
>>> fd = open('/tmp/1.py')
>>> type (fd)
<type 'file'>



>>> dir ( something ) 
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> dir ( fd ) 
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']
>>> print something.upper() 

#!/USR/BIN/PYTHON2.7

FROM SYS IMPORT ARGV

LIST1 = [] 
LIST2 = [ 'A' , [ 1 , 2, [ 'STR', 'INT', 'FLOAT'] , 4 ,5 ], 'B', 'C', 'D' ]
## ARGV = [ ARGV[0], ARGV[1], ....  ]

PRINT "THE LENGTH OF THE ARGUMENTS ARE: %D " % LEN ( ARGV )

PRINT ""
PRINT "THE ARGUMENTS ARE: "
PRINT ""

FOR ARGUMENT IN ARGV:
    PRINT "ARGUMENT: %R" % ARGUMENT

PRINT ""



>>> TYPE ( 1 ) 
<TYPE 'INT'>
>>> TYPE ( 'TEXT' ) 
<TYPE 'STR'>
>>> TYPE ( 1.9 ) 
<TYPE 'FLOAT'>
>>> TYPE ( [1,2,3] ) 
<TYPE 'LIST'>
>>> TYPE ( TRUE  ) 
<TYPE 'BOOL'>
>>> TYPE ( FALSE ) 
<TYPE 'BOOL'>
>>> 
>>> FD = OPEN('/TMP/1.PY')
>>> TYPE (FD)
<TYPE 'FILE'>



>>> type ( something ) 
<type 'str'>
>>> 
>>> dir ( something ) 
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> print something.center() 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: center() takes at least 1 argument (0 given)
>>> print something.swapcase() 
#!/USR/BIN/PYTHON2.7

FROM SYS IMPORT ARGV

LIST1 = [] 
LIST2 = [ 'A' , [ 1 , 2, [ 'STR', 'INT', 'FLOAT'] , 4 ,5 ], 'B', 'C', 'D' ]
## ARGV = [ ARGV[0], ARGV[1], ....  ]

PRINT "tHE LENGTH OF THE ARGUMENTS ARE: %D " % LEN ( ARGV )

PRINT ""
PRINT "tHE ARGUMENTS ARE: "
PRINT ""

FOR ARGUMENT IN ARGV:
    PRINT "ARGUMENT: %R" % ARGUMENT

PRINT ""



>>> TYPE ( 1 ) 
<TYPE 'INT'>
>>> TYPE ( 'TEXT' ) 
<TYPE 'STR'>
>>> TYPE ( 1.9 ) 
<TYPE 'FLOAT'>
>>> TYPE ( [1,2,3] ) 
<TYPE 'LIST'>
>>> TYPE ( tRUE  ) 
<TYPE 'BOOL'>
>>> TYPE ( fALSE ) 
<TYPE 'BOOL'>
>>> 
>>> FD = OPEN('/TMP/1.PY')
>>> TYPE (FD)
<TYPE 'FILE'>



>>> dir ( something ) 
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> print something.strip() 
#!/usr/bin/python2.7

from sys import argv

list1 = [] 
list2 = [ 'a' , [ 1 , 2, [ 'str', 'int', 'float'] , 4 ,5 ], 'b', 'c', 'd' ]
## argv = [ argv[0], argv[1], ....  ]

print "The length of the arguments are: %d " % len ( argv )

print ""
print "The arguments are: "
print ""

for argument in argv:
    print "argument: %r" % argument

print ""



>>> type ( 1 ) 
<type 'int'>
>>> type ( 'text' ) 
<type 'str'>
>>> type ( 1.9 ) 
<type 'float'>
>>> type ( [1,2,3] ) 
<type 'list'>
>>> type ( True  ) 
<type 'bool'>
>>> type ( False ) 
<type 'bool'>
>>> 
>>> fd = open('/tmp/1.py')
>>> type (fd)
<type 'file'>
>>> dir ( something ) 
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> dir ( fd ) 
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']
>>> 
>>> id (fd)
140636782470176
>>> new_fd='/tmp/1.py' 
>>> id (new_fd)
140636782193328
>>> fd='/tmp/1.py' 
>>> id (new_fd)
140636782193328
>>> id (fd)
140636782193376
>>> new_fd=fd
>>> id (fd)
140636782193376
>>> id (new_fd)
140636782193376
>>> fd == new_fd 
True
>>> a = 1 
>>> id ( a 0 
  File "<stdin>", line 1
    id ( a 0 
           ^
SyntaxError: invalid syntax
>>> id ( a ) 
140636785697112
>>> b = 1 
>>> id ( b ) 
140636785697112
>>> a ==  b 
True
>>> id ( a ) == id ( b)  
True
>>> id ( a ) == id ( b )  
True
>>> a = 1 
>>> b = 1 
>>> id ( a ) == id ( b )  
True
>>> a = 1024 
>>> b = 1024 
>>> id ( a ) == id ( b )  
False
>>> b = 255  
>>> a = 255
>>> id ( a ) == id ( b )  
True
>>> a = 256
>>> b = 255
>>> b = 256
>>> a = 256
>>> id ( a ) == id ( b )  
True
>>> b = 257
>>> a = 257
>>> id ( a ) == id ( b )  
False
>>> a == b 
True
>>> a is b 
False
>>> a = 256 
>>> b = 256 
>>> a is b 
True
>>> a = a 
>>> b = a 
>>> a is b 
True
>>> id ( a ) == id ( b ) 
True
>>> fd =   
  File "<stdin>", line 1
    fd = 
        ^
SyntaxError: invalid syntax
>>> 
>>> 
>>> 
>>> 
>>> fd = '/tmp/1.py'
>>> new_fd = '/tmp/1.py'
>>> 
>>> fd is new_fd 
False
>>> fd == new_fd 
True
>>> id ( fd ) 
140636782193184
>>> id ( new_fd ) 
140636782193424
>>> 
>>> 
>>> 
>>> 
>>> var1 == var2             
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'var1' is not defined
>>> 
>>> 
>>> 
>>> dir ( fd ) 
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']