public static PyObject __xor__(PyObject self, PyObject other) { var orded = extractInt(self) ^ extractInt(other); return(orded > 0 ? PyBool.True : PyBool.False); }
public static PyBool __ne__(PyObject self, PyObject other) { return(extractInt(self) != extractInt(other)); }
public static void append(PyList self, PyObject toAdd) { self.list.Add(toAdd); }
public static PyObject __and__(PyObject self, PyObject other) { var anded = extractInt(self) & extractInt(other); return(anded > 0 ? PyBool.True : PyBool.False); }
public static new PyString __repr__(PyObject self) { return(PyString.Create(((PyString)self).ToString())); }
public PyBool __eq__(PyObject other) { return(Equals(other)); }
public static PyInteger __len__(IInterpreter interpreter, FrameContext context, PyObject self) { var asDict = (PyDict)self; return(PyInteger.Create(asDict.InternalDict.Count)); }
public static PyObject __floordiv__(PyObject self, PyObject other) { var newPyInteger = PyInteger.Create((BigInteger)((decimal)extractInt(self) / PyFloatClass.ExtractAsDecimal(other))); return(newPyInteger); }
public static Task <PyString> __str__(IInterpreter interpreter, FrameContext context, PyObject self) { return(__repr__(interpreter, context, self)); }
public static async Task <PyString> __repr__(IInterpreter interpreter, FrameContext context, PyObject self) { var asDict = (PyDict)self; PyString retStr = PyString.Create("{"); int visited = 0; foreach (var mapping in asDict.dict) { var key_repr = await __visit_repr((PyObject)mapping.Key, interpreter, context); retStr = (PyString)PyStringClass.__add__(retStr, key_repr); retStr = (PyString)PyStringClass.__add__(retStr, PyString.Create(": ")); var val_repr = await __visit_repr((PyObject)mapping.Value, interpreter, context); retStr = (PyString)PyStringClass.__add__(retStr, val_repr); // Appending commas except on last paring if (visited < asDict.dict.Count - 1) { retStr = (PyString)PyStringClass.__add__(retStr, PyString.Create(", ")); } visited += 1; } return((PyString)PyStringClass.__add__(retStr, PyString.Create("}"))); }
public static void __setitem__(PyList self, PyInteger i, PyObject value) { __setitem__(self, (int)i.number, value); }
public static async Task <PyString> __repr__(IInterpreter interpreter, FrameContext context, PyObject self) { var asList = (PyList)self; PyString retStr = PyString.Create("["); for (int i = 0; i < asList.list.Count; ++i) { var pyObj = asList.list[i]; var __repr__ = pyObj.__getattribute__(PyClass.__REPR__); var functionToRun = __repr__ as IPyCallable; var returned = await functionToRun.Call(interpreter, context, new object[0]); if (returned != null) { var asPyString = (PyString)returned; retStr = (PyString)PyStringClass.__add__(retStr, asPyString); } // Appending commas except on last index if (i < asList.list.Count - 1) { retStr = (PyString)PyStringClass.__add__(retStr, PyString.Create(", ")); } } return((PyString)PyStringClass.__add__(retStr, PyString.Create("]"))); }
public static void prepend(PyList self, PyObject toAdd) { self.list.Insert(0, toAdd); }
public static PyObject __lshift__(PyObject self, PyObject other) { var orded = (int)PyBoolClass.extractInt(self) << (int)PyBoolClass.extractInt(other); return(PyInteger.Create(orded)); }
public static PyObject __iter__(PyObject self) { var asDict = self as PyDict; return(PyKeyIterator.Create(asDict)); }
public static PyObject __truediv__(PyObject self, PyObject other) { var newPyFloat = PyFloat.Create((decimal)extractInt(self) / PyFloatClass.ExtractAsDecimal(other)); return(newPyFloat); }
public static PyObject __iter__(PyObject self) { var asDict = self as PyDict_Items; return(PyDictItemsIterator.Create(asDict.Dict)); }
public static new PyString __str__(PyObject self) { return(__repr__(self)); }
public static PyObject __iter__(PyObject self) { var asPyRange = self as PyRange; return(PyRangeIterator.Create(asPyRange)); }
public static PyObject __div__(PyObject self, PyObject other) { // TODO: TypeError: unsupported operand type(s) for /: '[self type]' and '[other type]' throw new Exception("Strings do not support division"); }
public static PyInteger __len__(IInterpreter interpreter, FrameContext context, PyObject self) { var asPyRange = (PyRange)self; return(PyInteger.Create(Math.Abs((asPyRange.Max - asPyRange.Min) / asPyRange.Step))); }
public PyBool __ne__(PyObject other) { return(!Equals(other)); }
public static PyBool __ne__(PyList self, PyObject other) { return(!__eq__(self, other)); }