小编Meh*_*ghi的帖子

Is there a way to totally ignore all of the MyPy errors in specific project packages?

Is there a way to ignore all of the errors in certain packages within my project?

Some of the code in my project is compiled Protocol Buffers code which doesn't pass a MyPy check. It all lives within a directory /myproj/generated/proto.

Here's what I have in my mypy config file:

[mypy-myproject.generated]
ignore_missing_imports = True
ignore_errors = True
Run Code Online (Sandbox Code Playgroud)

What can I add to this to make it ignore all error messages generated from an analysis of anything that's inside of myproject.generated? …

python type-hinting mypy

12
推荐指数
1
解决办法
6337
查看次数

如何从.NET CultureInfo类派生自定义文化?

我想将我的应用文化设置为我想要的任何东西,无论操作系统文化是什么.为了获得这个,我使用了"fa-IR"作为文化的CultureInfo类,但它使用"GregorianCalendar"作为默认日历而不是.NET PersianCalendar类.所以我试图从CultureInfo派生一个新类来实现我的客户文化:

/// <summary>
/// Represents culture specific information, Persian calendar and number format info for Iran.
/// </summary>
public class PersianCultureInfo : CultureInfo
{
    private Calendar _calendar = new PersianCalendar();

    public PersianCultureInfo()
        : base("fa-IR", true)
    {
    }

    /// <summary>
    /// Persian calendar with solar system algorithm for Iran.
    /// </summary>
    public override Calendar Calendar
    {
        get
        {
            return this._calendar;
        }
    }

    public static PersianCultureInfo Create()
    {
        PersianCultureInfo culture = new PersianCultureInfo();
        culture.PerpareDateTimeFormatInfo();
        return culture;
    }

    private void PerpareDateTimeFormatInfo()
    { …
Run Code Online (Sandbox Code Playgroud)

c# globalization cultureinfo persian datetime-format

6
推荐指数
2
解决办法
3129
查看次数

如何使readline在python子进程中工作?

我花了很多东西在MacOS Sierra上的pdb中启用了readline支持的子进程,我不明白为什么它失败了,因此问题.

请注意,我有适当的ReadLine支持无需添加.pdbrc在我所有的Python environemnts,包括python2和3个设施也符合pipenv,VENV,或皮尤创建的虚拟环境中的文件.一切正常.

当我想在子进程中放入pdb shell时出现问题.我使用nodejs 程序和一个插件,我用它在本地调用AWS代码.第一个nodejs进程启动第二个,第二个进程启动一个python进程,我有我常用的pdb代码:

import pdb; pdb.set_trace()
Run Code Online (Sandbox Code Playgroud)

但是我得到的pdb shell没有readline支持.我尝试了以下替代方案,但效果不佳:

import ipdb; ipdb.set_trace()
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
readline.parse_and_bind('bind ^I rl_complete')
Run Code Online (Sandbox Code Playgroud)

我还添加.pdbrc了以上内容(减去ipdb导入)的文件无济于事.我还尝试将PYTHONSTARTUP点设置为具有以下内容的文件:

import rlcompleter, readline
readline.parse_and_bind('tab: complete')
Run Code Online (Sandbox Code Playgroud)

它也没有帮助.人们已经报告说这些解决方案对他们有用,但他们没有开始的readline支持(对我来说,没有这些技巧它可以正常工作).

我也尝试修补我的nodejs process.env.PATHprocess.env.PYTHONPATH添加了我有python安装的目录,其中有readline支持无济于事.

我很感激,如果有人能够解释从子子程序启动pdb和直接从终端启动pdb之间是否存在根本区别(在任何情况下它都是子进程).此外,我感谢任何可能帮助我解决这个问题的建议.

更新我

我注意到即使没有pdb我也没有获得readline支持:

import code
code.interact(local=locals())
Run Code Online (Sandbox Code Playgroud)

如果我运行上面的代码,我得到一个没有readline支持的python shell:

Python 3.7.0 (default, Jun 29 2018, 20:13:13)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

>>>
<pointer blinks here which is …
Run Code Online (Sandbox Code Playgroud)

python subprocess readline pdb serverless-framework

5
推荐指数
1
解决办法
261
查看次数

如何查找python模块使用的共享库?

我正在调试基于pygtk的python程序,我想确保程序使用正确的共享库.

pygtkGTK+python 的包装器.我已经GTK+使用jhbuild工具编译了,我想确保我正在调试的python脚本使用来自的编译库jhbuild.

一个人会导入gtkpygtk喜欢这样:

import gtk
import pygtk
print(gtk.__file__)
# /usr/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.pyc
print(pygtk.__file__)
# /usr/lib/python2.7/site-packages/pygtk.pyc
Run Code Online (Sandbox Code Playgroud)

例如,我可以使用gtk显示一个窗口:

w = gtk.Window()
w.show()
Run Code Online (Sandbox Code Playgroud)

这将使用gtk在屏幕上绘制一个窗口.但是我不知道使用哪个共享对象.我安装了很多版本,我需要找到罪魁祸首.

python gtk pygtk shared-libraries jhbuild

3
推荐指数
2
解决办法
2190
查看次数