pythonキーワードの使い方


#pythonキーワードの使い方
#! /use/bin/env python
# coding = UTF-8

from keyword import kwlist as All_KeyWords  # from -import- as
print(list(All_KeyWords))

print(True and 1+1 == 2)  #True
print(False or not None)  # not None    

print(2 in {1,2,3})
print(None is False)  # is           
for i in range(3,-3,-1): #range             
    if i >= 0:
        pass   #    
    elif i == -1:
        print(abs(i))
        continue
    else:
        break
    print(i,end = " ")
else:       #        break      
    print("final")
    a = 3
while a > 0:
    f = lambda x:x**3  #    
    print(f(a-1))
    a -=1

def fun():
    print("********")
    return str(1234578)
print(fun())

with open("file.1.5.txt","r") as f: #         f.close()
    print(f.read())
y = input("Integer:")
try:
    x = int(y)
    assert x >= 10,"no error"  #     
    raise ValueError   #    
except AssertionError:
    print("  10")
except ValueError:
    print("not SyntexError")
finally:
    print("over")
    
count = 3
def goto():
    global count  #            
    count = 5
    return (count,"")
print(goto())

def outer():
    variable = 6
    def inner():
        nonlocal variable  #            
        variable +=4
        return variable
    return inner
print(outer()(),end = "

")
class A:
    def sidefun():
         t =12
         for n in range(1,13,2):
             t += n 
             yield t  #              
    b = sidefun()  # b       ,        
    for i in "generator":  #  6   
        try:
            print (next(b))
        except StopIteration:
            pass