Пример #1
0
        public static object fromkeys(CodeContext context, PythonType cls, object seq, object value)
        {
            XRange xr = seq as XRange;

            if (xr != null)
            {
                int    n   = xr.__len__();
                object ret = PythonContext.GetContext(context).CallSplat(cls);
                if (ret.GetType() == typeof(PythonDictionary))
                {
                    PythonDictionary dr = ret as PythonDictionary;
                    for (int i = 0; i < n; i++)
                    {
                        dr[xr[i]] = value;
                    }
                }
                else
                {
                    // slow path, user defined dict
                    PythonContext pc = PythonContext.GetContext(context);
                    for (int i = 0; i < n; i++)
                    {
                        pc.SetIndex(ret, xr[i], value);
                    }
                }
                return(ret);
            }
            return(fromkeysAny(context, cls, seq, value));
        }
Пример #2
0
        public bool MoveNext()
        {
            if (_position >= _xrange.__len__())
            {
                return(false);
            }

            _position++;
            _value = _value + _xrange.Step;
            return(true);
        }