Skip to content

Commit a9af4b6

Browse files
author
Spencer.Luo
committed
Refactor file path.
1 parent cb59363 commit a9af4b6

File tree

3 files changed

+153
-8
lines changed

3 files changed

+153
-8
lines changed

Draft.py

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# class A(object): # -> don't forget the object specified as base
2+
#
3+
# def __new__(cls):
4+
# print("A.__new__ called")
5+
# return super(A, cls).__new__(cls)
6+
# # return 20
7+
#
8+
# def __init__(self):
9+
# print("A.__init__ called")
10+
# return 22
11+
#
12+
# print(A())
13+
#
14+
# class B:
15+
# __instance = None
16+
#
17+
# def __new__(cls, name):
18+
# if cls.__instance is None:
19+
# cls.__instance = super().__new__(cls)
20+
# cls.name = name
21+
# return cls.__instance;
22+
#
23+
# def __init__(self, name):
24+
# self.name = name
25+
#
26+
#
27+
# # def get
28+
#
29+
# @classmethod
30+
# def getInstance(cls, name):
31+
# if B.__instance is None:
32+
# B.__instance = B(name)
33+
# return B.__instance
34+
#
35+
# # b1 = B("B1")
36+
# # print("id:", id(b1), " name:", b1.name)
37+
# # b2 = B("B2")
38+
# # print("id:", id(b2), " name:", b2.name)
39+
#
40+
# # b = B("B")
41+
42+
43+
44+
class Foobar(object):
45+
# pass
46+
def __init__(self, name):
47+
self.name = name
48+
49+
print( type(Foobar) )
50+
print(Foobar)
51+
foo = Foobar("Test")
52+
print( type(foo) )
53+
print(foo.name)
54+
foo2 = type(foo)("Text2")
55+
print(foo2.name)
56+
# print("Hello")
57+
print(isinstance(foo, Foobar))
58+
print(isinstance(Foobar, type))
59+
print(isinstance(Foobar, object))
60+
61+
62+
63+
MyClass = type('MyClass', (), {})
64+
print(MyClass)
65+
66+
# T = type
67+
print(type("Test", (), {}))
68+
69+
70+
# class MetaAAA(type):
71+
# pass
72+
# # def __prepare__(metacls, name, bases):
73+
# # pass
74+
#
75+
#
76+
# print(MetaAAA)
77+
#
78+
#
79+
# class MyClassA(metaclass=MetaAAA):
80+
# pass
81+
#
82+
# def test(self):
83+
# b = 5
84+
# b = True
85+
#
86+
# print(type(MyClassA))
87+
#
88+
#
89+
#
90+
# print("=====================")
91+
# class B:
92+
# pass
93+
#
94+
# class C(B):
95+
# pass
96+
#
97+
# c = C()
98+
# print(C.__bases__)
99+
#
100+
#
101+
# print("Base===============")
102+
# print(object.__bases__)
103+
# print(type.__bases__)
104+
# print(type(object))
105+
# print(object.__class__)
106+
# print(type(C))
107+
# print(C.__class__)
108+
#
109+
# print("Callable:")
110+
# print(callable(type))
111+
# print(callable(object))
112+
# print(type(object))
113+
#
114+
#
115+
# print("DD====================")
116+
# class DD:
117+
#
118+
# def __call__(self, *args, **kwargs):
119+
# print("DD.__call__")
120+
# # print(args)
121+
# return self.__class__
122+
#
123+
# def __init__(self, name):
124+
# self.name = name
125+
# #
126+
# # d = DD()
127+
# # d("This is test")
128+
# # DD("This is test")
129+
# # id(d)
130+
#
131+
# # DD = DD()
132+
# # DD("This is test")
133+
# d = DD("Test")
134+
# print(d)
135+
# print(d.name)
136+
# print(callable(DD))
137+
# print(callable(d))
138+
callable()
139+

pattern/DataType.py renamed to StartPython.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,14 @@ def testPerson():
119119
"测试方法"
120120
tony = Person("Tony", 25, 1.77)
121121
tony.showInfo()
122-
print();
122+
print()
123123

124-
jenny = Teacher("Jenny", 34, 1.68);
125-
jenny.setTitle("教授");
126-
jenny.showInfo();
124+
jenny = Teacher("Jenny", 34, 1.68)
125+
jenny.setTitle("教授")
126+
jenny.showInfo()
127127

128-
testPerson()
129128

130-
# testDataType()
129+
testDataType()
131130
# testList()
132131
# testTuple()
133132
# testDictionary()

Test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
##!/usr/bin/python
22

33
#////////////////////////////////////////////////////////////////////////////
4+
import StartPython
45

56
# import pattern.Observer
67
# import pattern.State
@@ -11,11 +12,10 @@
1112
# import pattern.Decorator
1213
# import pattern.SimpleFactory
1314
# import pattern.Iterator
14-
# import pattern.DataTyped
1515
# import pattern.Composite
1616
# import pattern.Clone
1717
# import pattern.Builder
18-
import pattern.Adapter
18+
# import pattern.Adapter
1919
# import pattern.Strategy
2020
# import pattern.Command
2121
# import pattern.Memento
@@ -31,4 +31,11 @@
3131
# import advanced_pattern.Callback
3232

3333
# import application.ImageProcessing
34+
# import application.GameCommand
35+
# import application.TerminalMonitor
36+
3437
# import principle.Principle
38+
39+
# import Draft
40+
# import advanced_programming.MagicMethod
41+
# import advanced_programming.Metaclass

0 commit comments

Comments
 (0)