当前位置: 首页>>代码示例>>C#>>正文


C# PythonLanguageVersion.Is3x方法代码示例

本文整理汇总了C#中PythonLanguageVersion.Is3x方法的典型用法代码示例。如果您正苦于以下问题:C# PythonLanguageVersion.Is3x方法的具体用法?C# PythonLanguageVersion.Is3x怎么用?C# PythonLanguageVersion.Is3x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PythonLanguageVersion的用法示例。


在下文中一共展示了PythonLanguageVersion.Is3x方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Expression

 /// <summary>
 /// Returns a sequence of all keywords usable in an expression in a
 /// particular version of Python.
 /// </summary>
 public static IEnumerable<string> Expression(PythonLanguageVersion version = PythonLanguageVersion.None) {
     yield return "and";
     yield return "as";
     if (version.IsNone() || version >= PythonLanguageVersion.V35) {
         yield return "await";
     }
     yield return "else";
     if (version.IsNone() || version.Is3x()) {
         yield return "False";
     }
     yield return "for";
     if (version.IsNone() || version >= PythonLanguageVersion.V33) {
         yield return "from";
     }
     yield return "if";
     yield return "in";
     yield return "is";
     yield return "lambda";
     yield return "None";
     yield return "not";
     yield return "or";
     if (version.IsNone() || version.Is3x()) {
         yield return "True";
     }
     yield return "yield";
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:30,代码来源:PythonKeywords.cs

示例2: Parser

        private Parser(Tokenizer tokenizer, ErrorSink errorSink, PythonLanguageVersion langVersion, bool verbatim, bool bindRefs, string privatePrefix) {
            Contract.Assert(tokenizer != null);
            Contract.Assert(errorSink != null);

            tokenizer.ErrorSink = new TokenizerErrorSink(this);

            _tokenizer = tokenizer;
            _errors = errorSink;
            _langVersion = langVersion;
            _verbatim = verbatim;
            _bindReferences = bindRefs;
            
            if (langVersion.Is3x()) {
                // 3.x always does true division and absolute import
                _languageFeatures |= FutureOptions.TrueDivision | FutureOptions.AbsoluteImports;
            }

            Reset(FutureOptions.None);

            _privatePrefix = privatePrefix;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:21,代码来源:Parser.cs

示例3: Statement

 /// <summary>
 /// Retuns a sequence of all keywords usable as a statement in a
 /// particular version of Python.
 /// </summary>
 public static IEnumerable<string> Statement(PythonLanguageVersion version = PythonLanguageVersion.None) {
     yield return "assert";
     if (version.IsNone() || version >= PythonLanguageVersion.V35) {
         yield return "async";
         yield return "await";
     }
     yield return "break";
     yield return "continue";
     yield return "class";
     yield return "def";
     yield return "del";
     if (version.IsNone() || version.Is2x()) {
         yield return "exec";
     }
     yield return "if";
     yield return "elif";
     yield return "except";
     yield return "finally";
     yield return "for";
     yield return "from";
     yield return "global";
     yield return "import";
     if (version.IsNone() || version.Is3x()) {
         yield return "nonlocal";
     }
     yield return "pass";
     if (version.IsNone() || version.Is2x()) {
         yield return "print";
     }
     yield return "raise";
     yield return "return";
     yield return "try";
     yield return "while";
     yield return "with";
     yield return "yield";
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:40,代码来源:PythonKeywords.cs

示例4: ShouldUseUnicodeLiterals

 protected virtual bool ShouldUseUnicodeLiterals(PythonLanguageVersion version) {
     return version.Is3x();
 }
开发者ID:RussBaz,项目名称:PTVS,代码行数:3,代码来源:BaseAnalysisTest.cs

示例5: FallbackBuiltinPythonType

 public FallbackBuiltinPythonType(PythonLanguageVersion version, BuiltinTypeId typeId) {
     DeclaringModule = version.Is3x() ? FallbackBuiltinModule.Instance3x : FallbackBuiltinModule.Instance2x;
     Name = SharedDatabaseState.GetBuiltinTypeName(typeId, version.ToVersion());
     TypeId = typeId;
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:5,代码来源:KnownTypes.cs

示例6: GetConstantRepr

        public string GetConstantRepr(PythonLanguageVersion version, bool escape8bitStrings = false) {
            if (_value == null) {
                return "None";
            } else if (_value is AsciiString) {
                StringBuilder res = new StringBuilder();
                if (!version.Is2x()) {
                    res.Append("b");
                }
                AppendEscapedString(res, ((AsciiString)_value).String, escape8bitStrings);
                return res.ToString();
            } else if (_value is string) {
                StringBuilder res = new StringBuilder();
                if (!version.Is3x()) {
                    res.Append("u");
                }
                AppendEscapedString(res, (string)_value, escape8bitStrings);
                return res.ToString();
            } else if (_value is Complex) {
                Complex n = (Complex)_value;
                string real = NegativeZeroAwareToString(n.Real);
                string imag =  NegativeZeroAwareToString(n.Imaginary);
                if (n.Real != 0) {
                    if (!imag.StartsWith("-")) {
                        imag = "+" + imag;
                    }
                    return "(" + real + imag + "j)";
                } else {
                    return imag + "j";
                }
            } else if (_value is BigInteger) {
                if (!version.Is3x()) {
                    return _value.ToString() + "L";
                }
            } else if (_value is double) {
                double n = (double)_value;
                string s = NegativeZeroAwareToString(n);
                // If there's no fractional part, and this is not NaN or +-Inf, G format will not include the decimal
                // point. This is okay if we're using scientific notation as this implies float, but if not, add the
                // decimal point to indicate the type, just like Python repr() does.
                if ((n - Math.Truncate(n)) == 0 && !s.Contains("e")) {
                    s += ".0";
                }
                return s;
            } else if (_value is IFormattable) {
                return ((IFormattable)_value).ToString(null, CultureInfo.InvariantCulture);
            }

            // TODO: We probably need to handle more primitives here
            return _value.ToString();
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:50,代码来源:ConstantExpression.cs


注:本文中的PythonLanguageVersion.Is3x方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。