Selaa lähdekoodia

Update python.js

Lutz Roeder 2 vuotta sitten
vanhempi
sitoutus
a0b6dea6c0
1 muutettua tiedostoa jossa 8 lisäystä ja 4 poistoa
  1. 8 4
      source/python.js

+ 8 - 4
source/python.js

@@ -1701,13 +1701,17 @@ python.Execution = class {
             return NaN;
         });
         this.registerFunction('builtins.str', function(value) {
-            if (value) {
-                if (value.__str__) {
-                    return value.__str__();
-                }
+            if (value && value.__str__) {
+                return value.__str__();
             }
             return JSON.stringify(value);
         });
+        this.registerType('builtins.complex', class {
+            constructor(real, imaginary) {
+                this.real = real;
+                this.imag = imaginary;
+            }
+        });
         this.registerType('builtins.NoneType', class {});
         this.registerType('builtins.object', class {});
         this.registerType('builtins.tuple', class extends Array {