s1 = "abc„" data = s1.encode() # These are encoded as bytes print(data) # Iteration does not give text characters like string. for x in data: print(x) # Decode to get text representation data.decode() # Interface is same as string - string methods work data.capitalize() # Already can do this a,b,c = [1, 'cool', True] print(a) print(b) print(c) # Now you can do a,b,*c = [1, 'cool', True, 'more'] print(a) print(b) print(c) def weird(a,b,c=False): if c: print("I have deleted everything") else: print("No damage done yet") # Passed True by mistake. Didnt know anything about the keyword arg 'c' weird(1,2,True) def nice_weird(a,b,*k, c=False): if c: print("I have deleted everything") else: print("No damage done yet") nice_weird(1,2,True) nice_weird(1,2,True,False,True,c=False) my_range = range(0,5) type(my_range) for x in range(0,5): print(x) list(my_range) mymap = map(lambda x: x**2, [3,4,5]) type(mymap) list(mymap) # Incorrect raise IOError, "got error" # Correct raise IOError("got error") # Incorrect try: pass except IOError, err: pass # Correct: try: pass except IOError as err: pass [1,2,3] > "hello" # Generator def gen(): for i in [0,1,2]: yield i # To pass on values from generator you have to do this def process_gen(): for j in gen(): yield j list(process_gen()) # Now you can do this def process_gen_new(): yield from gen() list(process_gen_new()) from enum import Enum class Shape(Enum): circle = 0 square = 1 rhombus = 2 print(Shape.circle) print(Shape.circle.name) print(Shape.circle.value) mydict = {Shape.circle:"circular", Shape.square:"squarish"} print(mydict[Shape.circle]) def masquerader(a:int, b:str) -> float: print("I am a Haskell/Ocaml/Scala wannabe") masquerader("doesnt", "matter") from IPython.display import HTML HTML('')