Esempio n. 1
0
 public static PyBool __contains__(PyTuple self, PyObject v)
 {
     if (Array.IndexOf(self.Values, v) >= 0)
     {
         return(PyBool.True);
     }
     else
     {
         return(PyBool.False);
     }
 }
Esempio n. 2
0
 public static object __getitem__(PyTuple self, PyInteger i)
 {
     try
     {
         return(self.Values[(int)i.InternalValue]);
     }
     catch (IndexOutOfRangeException)
     {
         // TODO: Represent as a more natural Python exception;
         throw new Exception("IndexError: tuple index out of range");
     }
 }
Esempio n. 3
0
        public static object __next__(PyObject self)
        {
            var asKeyIterator = self as PyDictItemsIterator;

            if (!asKeyIterator.Keys.MoveNext())
            {
                throw new StopIterationException();
            }
            else
            {
                var key = (object)asKeyIterator.Keys.Current;
                return(PyTuple.Create(new object[] { key, PyDictClass.__getitem__(asKeyIterator.Dict, key) }));
            }
        }
Esempio n. 4
0
        public static PyBool __eq__(PyTuple self, PyObject other)
        {
            var otherList = other as PyTuple;

            if (otherList == null)
            {
                return(PyBool.False);
            }

            if (otherList.Values.Length != self.Values.Length)
            {
                return(PyBool.False);
            }

            for (int i = 0; i < self.Values.Length; ++i)
            {
                if (self.Values[i].__eq__(otherList.Values[i]).boolean == false)
                {
                    return(PyBool.False);
                }
            }
            return(PyBool.True);
        }
Esempio n. 5
0
 public static PyBool __ne__(PyTuple self, PyObject other)
 {
     return(!__eq__(self, other));
 }