-
Notifications
You must be signed in to change notification settings - Fork 0
/
python_js_quirks.py
66 lines (38 loc) · 959 Bytes
/
python_js_quirks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 1 Variable scoping
# No Hoisting in python
# def foo():
# print name
# name = "Slim shady"
# print name
# foo()
# 1. a)
# Python has three ways to create a new namespace; functions, classes, and
# modules
# def foo(bar):
# baz = bar * 2
# if bar > 1: # if bar > 1000:
# blitz = baz - 100
# print "blitz value is =>", blitz
# foo(200)
# 3 Class
# class Person(object):
# def __init__(self, name):
# self.name = name
# def print_name(self):
# print "My name is real =>", self.name
# person = Person("Slim Shady")
# person.print_name()
# class Man(Person):
# def __init__(self, name):
# self.name = name
# man = Man("Jay Z")
# man.print_name()
# 4) Bound methods
# class MyKlass:
# def __init__(self):
# self.name = "Slim Shady"
# foo = self.print_me
# foo()
# def print_me(self):
# print "I am real =>", self.name
# MyKlass()