示例#1
0
 def add_ctrl(self, grid, panel):
     # 添加表格
     for i in range(var.row * var.column):
         MyClass.cellList.append(MyClass.cell(panel, i))
         行号 = i // var.column
         列号 = i % var.column
         MyClass.cellList[i].box = wx.StaticText(panel,
                                                 label=str(i + 1),
                                                 size=var.size)
         grid.Add(MyClass.cellList[i].box, pos=(行号 + 3, 列号), border=10)
示例#2
0
文件: main.py 项目: kalehub/kh-OOP-py
def main():

    # making an object
    obj = MyClass('teguh', 22)
    obj_2 = MyClass('satya', 21)

    # printing object attribute
    print(obj.name, obj.age, obj_2.name, obj_2.age)

    # modifying attribute
    obj_2.name = 'Dharma'
    print(obj.name, obj.age, obj_2.name, obj_2.age)

    # accessing methods
    print(obj.get_description())
    print(obj.speak('why so lonely'))
    print(obj.__str__())

    # inheritance
    obj_3 = InheritClass('dog', 2)
    print(obj_3.__str__())
    print(obj_3.speak())
示例#3
0
import sys, MyClass
from PyQt5.QtWidgets import QApplication  # 导入相应的包

if __name__ == '__main__':

    app = QApplication(sys.argv)
    w = MyClass.MyClass()
    sys.exit(app.exec_())
示例#4
0
import MyClass

SamuelRecord = MyClass.MyClass()
AnnieRecord = MyClass.MyClass("Annie", 44)

print(SamuelRecord.GetAge())
SamuelRecord.SetAge(33)

print(AnnieRecord.GetName())
AnnieRecord.SetName("Sophie")

print(SamuelRecord)
print(AnnieRecord)
示例#5
0
import MyClass

MyClass.hello_world("Spam")
示例#6
0
print("-------------------------------")
print("     My First Class")
print("-------------------------------")
print("\n")

x = float()
y = float()
print("Set the real and imagined parts!")
print("Real part: ")
x = input()
print("Imagined part: ")
y = input()
print("\n")
#Object = MyClass.Complex()
#Object = MyClass.Complex(-3.1, 2.5)
Object = MyClass.Complex(x, y)
#print(Object.re)
#print(Object.im)
################################
Object_Function = Object.foo()
print(Object_Function)
################################
Object_Function = Object.Get_Real_Part()
print("Real part: ", Object_Function)
################################
Object_Function = Object.Get_Imagined_Part()
print("Imagined part: ", Object_Function)
################################
print("\n")

#Add_To_Array = Object.Add_To_Array()
示例#7
0
import MyClass

SamsRecord = MyClass.MyClass()
AmysRecord = MyClass.MyClass("Amy", 44)

print(SamsRecord.GetAge())
SamsRecord.SetAge(33)

print(AmysRecord.GetName())
AmysRecord.SetName("Aimee")

print(SamsRecord)
print(AmysRecord)
def test_myclass() -> None:
    classy = MyClass("classy")
    assert classy.name == "classy"
示例#9
0
    print('loading existing data...')
    with open('train_data.pkl', 'rb') as fr:
        train_data = pickle.load(fr)
    with open('test_data.pkl', 'rb') as fr:
        test_data = pickle.load(fr)
        test_size = len(test_data)
vocab_path = os.path.join('.', args.train_data, 'word2id.pkl')
tag_path = os.path.join('.', args.train_data, 'tag2id.pkl')
id2tag_path = os.path.join('.', args.train_data, 'id2tag.pkl')
if not os.path.exists(vocab_path):
    MyData.vocab_build(vocab_path, tag_path, id2tag_path, train_data, 5)
cn2id, en2id, id2en = MyData.read_dictionary(vocab_path, tag_path, id2tag_path)

if args.mode == 'train':
    print('start training...')
    encoder1 = MyClass.EncoderRNN(len(cn2id), args.embedding_size,
                                  args.hidden_size).to(device)
    attn_decoder1 = MyClass.AttnDecoderRNN(args.hidden_size,
                                           len(en2id),
                                           dropout_p=0.1).to(device)
    trainIters(encoder1,
               attn_decoder1,
               train_data,
               args.epoch_num,
               print_every=64)  #75000:训练预料条数 5000:每5000次输出一次损失情况
    torch.save(encoder1, 'model/encoder.pkl')
    torch.save(attn_decoder1, 'model/decoder.pkl')

else:
    encoder = torch.load('model/encoder.pkl')
    decoder = torch.load('model/decoder.pkl')
    evaluateTest(encoder, decoder, test_data, cn2id, id2en)
示例#10
0
#from MyClass import Student
import MyClass
s = MyClass.Student('Heim', 20)
s.sayHi()
示例#11
0
 def test_subTogether(self):
     self.assertEqual(MyClass.subNumbers(62, 17), 45)
示例#12
0
 def test_addTogether(self):
     self.assertEqual(MyClass.addNumbers(45, 17), 62)
示例#13
0
import MyClass
# from MyClass import User # I could have done this, so I don't have to type 'MyClass.User() everytime'

# if I had instanciated MyClass, I could do user1 = User('Lucas', 'Costa')
user1 = MyClass.User('Lucas', 'Costa')
user2 = MyClass.User('Jeff', 'Lname')

print user1.getName()
user1.test()
# createUser(b)
示例#14
0
 def test_calc_square(self):
     result = MyClass.calc_square(10, 10, 10)
     self.assertTrue(result > 40, 'Error result')
import MyClass

myCar1 = MyClass.car()

print(myCar1.getColor())