@@ -105,7 +105,7 @@ procedure TMain.btnTestIntegersClick(Sender: TObject);
105
105
// check that operation did not change the content of operands.
106
106
Assert(Integer(a) = 2 );
107
107
Assert(Integer(b) = 3 );
108
- // now with a litteral
108
+ // now with a literal
109
109
c := a + b + 1 ;
110
110
Assert( Integer(c) = 6 );
111
111
c := a + 1 + b;
@@ -116,7 +116,7 @@ procedure TMain.btnTestIntegersClick(Sender: TObject);
116
116
// substraction
117
117
c := b - a;
118
118
Assert( Integer(c) = 1 );
119
- // now with a litteral
119
+ // now with a literal
120
120
c := b - a - 1 ;
121
121
Assert( Integer(c) = 0 );
122
122
c := b - 1 - a;
@@ -127,7 +127,7 @@ procedure TMain.btnTestIntegersClick(Sender: TObject);
127
127
// multiplication
128
128
c := a * b;
129
129
Assert( Integer(c) = 6 );
130
- // now with a litteral
130
+ // now with a literal
131
131
c := a * b * 2 ;
132
132
Assert( Integer(c) = 12 );
133
133
c := a * 2 * b;
@@ -302,7 +302,7 @@ procedure TMain.btnTestFloatsClick(Sender: TObject);
302
302
// check that operation did not change the content of operands.
303
303
Assert(Double(a) = dbl_a);
304
304
Assert(Double(b) = dbl_b);
305
- // now with a litteral
305
+ // now with a literal
306
306
c := a + b + 1 ;
307
307
Assert( Double(c) = (dbl_a+dbl_b+1 ) );
308
308
c := a + 1 + b;
@@ -313,7 +313,7 @@ procedure TMain.btnTestFloatsClick(Sender: TObject);
313
313
// substraction
314
314
c := b - a;
315
315
Assert( Double(c) = (dbl_b - dbl_a) );
316
- // now with a litteral
316
+ // now with a literal
317
317
c := b - a - 1 ;
318
318
Assert( Double(c) = (dbl_b-dbl_a-1 ) );
319
319
c := b - 1 - a;
@@ -325,7 +325,7 @@ procedure TMain.btnTestFloatsClick(Sender: TObject);
325
325
c := a * b;
326
326
dbl_c := dbl_a * dbl_b;
327
327
Assert( Double(c) = dbl_c );
328
- // now with a litteral
328
+ // now with a literal
329
329
c := a * b * 2 ;
330
330
dbl_c := dbl_a * dbl_b * 2 ;
331
331
Assert( Double(c) = dbl_c );
@@ -427,7 +427,7 @@ procedure TMain.btnTestStringsClick(Sender: TObject);
427
427
// check that operation did not change the content of operands.
428
428
Assert(String(a) = ' abc' );
429
429
Assert(String(b) = ' def' );
430
- // now with a litteral
430
+ // now with a literal
431
431
c := a + b + ' !' ;
432
432
Assert( String(c) = ' abcdef!' );
433
433
c := a + ' !' + b;
@@ -583,7 +583,7 @@ procedure TMain.btnTestSequencesClick(Sender: TObject);
583
583
// check that operation did not change the content of operands.
584
584
Assert(String(a) = ' [1, 2, 3]' );
585
585
Assert(String(b) = ' [4, 5, 6]' );
586
- // now with a litteral : note that with D6 SP1, we can't concatenate a custom variant with an var array of variants
586
+ // now with a literal : note that with D6 SP1, we can't concatenate a custom variant with a var array of variants
587
587
c := a + b + VarPythonCreate([' Hello' , ' World!' , 3.14 ]);
588
588
Assert( String(c) = ' [1, 2, 3, 4, 5, 6, u'' Hello'' , u'' World!'' , 3.1400000000000001]' );
589
589
c := a + VarPythonCreate([' Hello' , ' World!' , 3.14 ]) + b;
@@ -642,7 +642,7 @@ procedure TMain.btnTestSequencesClick(Sender: TObject);
642
642
643
643
// sequence methods:
644
644
c := b + a;
645
- c.sort(); // note that you must you the parenthesis to distinguish the call between a method or a property.
645
+ c.sort(); // note that you must use the parenthesis to distinguish the call between a method or a property.
646
646
Assert( c = (a+b) );
647
647
648
648
c := NewPythonList; // facility for building sequences
@@ -770,8 +770,8 @@ procedure TMain.btnTestMappingsClick(Sender: TObject);
770
770
Assert( VarIsSame(c, a) ); // checks if 2 variants share the same Python object.
771
771
772
772
// dict methods
773
- Assert( Boolean(a.has_key (string(' a' ))) );
774
- Assert( not Boolean(a.has_key (' abc' )) );
773
+ Assert( Boolean(a.get (string(' a' ))) );
774
+ Assert( not Boolean(a.get (' abc' )) );
775
775
keys := a.keys();
776
776
keys.sort();
777
777
Assert( keys = VarPythonCreate(VarArrayOf([' a' , ' b' , ' c' ])));
@@ -780,7 +780,7 @@ procedure TMain.btnTestMappingsClick(Sender: TObject);
780
780
Assert( values = VarPythonCreate(VarArrayOf([1 , 2 , 3 ])));
781
781
c := a;
782
782
c.DeleteItem(string(' a' ));
783
- Assert( not Boolean(c.has_key (string(' a' ))) );
783
+ Assert( not Boolean(c.get (string(' a' ))) );
784
784
785
785
// test string values
786
786
a := NewPythonDict;
@@ -831,7 +831,7 @@ procedure TMain.btnTestDatesClick(Sender: TObject);
831
831
Assert( b.GetItem(6 ) = a.GetItem(6 ) );
832
832
Assert( b.GetItem(7 ) = a.GetItem(7 ) );
833
833
// don't test the 9th item of the tuple, because it's the daylight saving,
834
- // and it's not computed by the Python for Delphi.
834
+ // and it's not computed by Python for Delphi.
835
835
// Assert( b.GetItem(8) = a.GetItem(8) );
836
836
837
837
_date2 := b;
@@ -986,7 +986,7 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
986
986
Assert( VarIsPythonModule(_main) );
987
987
Assert( VarIsPythonModule(SysModule) );
988
988
Assert( Import (' sys' ).version = SysModule.version );
989
- Assert( Boolean(SysModule.modules.has_key (GetPythonEngine.ExecModule)) ); // if __main__ in sys.modules
989
+ Assert( Boolean(SysModule.modules.get (GetPythonEngine.ExecModule)) ); // if __main__ in sys.modules
990
990
Assert( VarIsSameType(_main, SysModule) );
991
991
Assert( _type(_main).__name__ = ' module' );
992
992
Assert( BuiltinModule.type (_main).__name__ = ' module' );
@@ -1013,7 +1013,7 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
1013
1013
Assert( not VarIsSubclassOf(_main.Foo, _main.Bar) );
1014
1014
Assert( VarIsInstanceOf(_main.b, _main.Foo) );
1015
1015
Assert( not VarIsInstanceOf(_main.f, _main.Bar) );
1016
- Assert( VarIsTrue( BuiltinModule.vars(_main).has_key (string(' f' )) ) );
1016
+ Assert( VarIsTrue( BuiltinModule.vars(_main).get (string(' f' )) ) );
1017
1017
Assert( VarIsTrue( BuiltinModule.dir(_main).Contains(string(' f' )) ) );
1018
1018
1019
1019
f := _main.Foo(); // new instance of class Foo
@@ -1037,10 +1037,10 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
1037
1037
Log(' Test -> a, b, c : ' + a.Value + ' , ' + b.Value + ' , ' + c.Value );
1038
1038
// cascading calls
1039
1039
Assert( f.GetSelf().GetSelf().GetSelf().GetSelf().GetValue() = _main.f.GetValue() );
1040
- Assert( Boolean(f.__dict__.has_key (' Value' )) );
1040
+ Assert( Boolean(f.__dict__.get (' Value' )) );
1041
1041
Assert( VarIsTrue( BuiltinModule.hasattr(f, ' Value' ) ) );
1042
1042
_str := ' Value' ;
1043
- Assert( Boolean(f.__dict__.has_key (_str)) ); // check with a string var
1043
+ Assert( Boolean(f.__dict__.get (_str)) ); // check with a string var
1044
1044
Assert( Boolean( BuiltinModule.hasattr(f, _str) ) );
1045
1045
val := f.Value ;
1046
1046
f.Add(f); // passing itself as an argument
@@ -1119,7 +1119,7 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
1119
1119
Assert( _myModule.Add(2 , 2 ) = 4 );
1120
1120
// delete module var f
1121
1121
_main.__dict__.DeleteItem(string(' f' ));
1122
- Assert( _main.__dict__.has_key (string(' f' )) = False );
1122
+ Assert( _main.__dict__.get (string(' f' )) = False );
1123
1123
// open a file using Python
1124
1124
if FileExists(' MyModule.py' ) then
1125
1125
begin
0 commit comments