小编eco*_*coe的帖子

在Sublime Text 3中运行Python调试器(pdb)

如何在Sublime Text 3中设置python调试器(pdb)断点?

无论SublimeREPLPython的断点失败,默认的Python构建系统:

print "hello"
# code runs fine without this breakpoint
import pdb; pdb.set_trace()
print "bye"

>>>File "C:\Python27\lib\bdb.py", line 49, in trace_dispatch
>>>return self.dispatch_line(frame)
    >>>File "C:\Python27\lib\bdb.py", line 68, in dispatch_line
    >>>if self.quitting: raise BdbQuit
Run Code Online (Sandbox Code Playgroud)

上述问题出现在文档中,但没有明显的修复.或者答案一直盯着我看?

python breakpoints sublimerepl sublimetext3 sublime-text-plugin

25
推荐指数
3
解决办法
3万
查看次数

Python模块/包名称的Sphinx apidoc部分标题

当我运行sphinx-apidoc然后make html它产生doc页面时,在目录(TOC)中的每个模块/包名称的末尾都有"Subpackages"和"Submodules"部分以及"module"和"package".如何在不编辑Sphinx源代码的情况下阻止编写这些额外的标题?

这是我想要制作的示例文档页面(注意TOC):

http://selenium.googlecode.com/svn/trunk/docs/api/py/index.html#documentation

据我所知,这是由于sphinx源代码中的apidoc.py文件(第88行):

https://bitbucket.org/birkenfeld/sphinx/src/ef3092d458cc00c4b74dd342ea05ba1059a5da70/sphinx/apidoc.py?at=default

我可以手动编辑每个单独的.rst文件来删除这些标题,或者只是从脚本中删除那些代码行,但是我必须编译Sphinx源代码.有没有手动编辑Sphinx源的自动方式?

html python title python-sphinx api-doc

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

如何在Windows上安装M2crypto

安装OpenSSL时,下载的预建痛饮可执行文件,并确保OpenSSL库位于默认 c:\pkg,pip install m2crypto结果:

...
C:\Program Files (x86)\gfortran\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Pyth
on27\include -IC:\Python27\PC -Ic:\pkg\include -Ic:\users\evbo\appdata\local\tem
p\pip_build_evbo\m2crypto\SWIG -c SWIG/_m2crypto_wrap.c -o build\temp.win32-2.7\
Release\swig\_m2crypto_wrap.o -DTHREADING

gcc: error: unrecognized command line option '-mno-cygwin'

error: command 'gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

似乎M2crypto二进制安装程序解决方案已不再可用,我没有看到我基于M2crypto安装文档所犯的任何错误.

我该如何解决此安装问题?是否依赖旧版本的GCC?

python windows swig openssl m2crypto

11
推荐指数
1
解决办法
1万
查看次数

使用 useMemo 在渲染期间更新 React Hooks 状态

useMemo被用来只是以避免额外的参考平等检查代码设置状态时/瓦尔期间渲染?

示例:从这个罕见的记录用例中获取useMemosetState期间渲染:

function ScrollView({row}) {
  let [isScrolling, setIsScrolling] = useState(false);

  const lessCodeThanCheckingPrevRow = useMemo(
    () => {
      // Row changed since last render. Update isScrolling.
      setIsScrolling(true); // let's assume the simplest case where prevState isn't needed here
    },
    [row]
  );

  return `Scrolling down: ${isScrolling}`;
}
Run Code Online (Sandbox Code Playgroud)

以上大大减少了代码和额外的变量,仅用于相等性检查,那么为什么文档暗示应该手动进行引用相等性检查?

render memoization reactjs react-hooks

10
推荐指数
1
解决办法
5947
查看次数

Django 中 DEBUG = True 和 False 之间的功能区别是什么?

DEBUG在 Django 应用程序的 settings.py 文件中切换设置之间的功能差异究竟是什么?

我一开始以为DEBUG=True只是打开了 Django 的日志记录功能和中间件来报告错误,但现在我意识到我太天真了。了解 Django 内部系统在两种布尔设置下的工作方式有何不同,有助于在处理难以调试的普通状态 500 错误时形成假设

python django

7
推荐指数
2
解决办法
9286
查看次数

如何在页面加载之间调暗 Chrome 加载屏幕(以遮蔽白色闪光)?

由于调暗/变暗解决了Chrome 页面加载之间臭名昭著的白色闪烁问题,如何利用小的默认加载通知(如下)来覆盖整个屏幕?

换句话说,是否可以在页面加载之间创建一整面文本墙,以便高对比度扩展可以使整个屏幕变暗,就像它使此处的一小部分变暗一样?: 在此输入图像描述

这确实很老套,但有充分的理由。所有其他解决方案不再适用于 Chrome 40+:

  1. https://superuser.com/questions/580228/prevent-white-screen-before-loading-page-in-chromium
  2. Google Chrome - 覆盖网页加载之间的白色空白页
  3. https://superuser.com/questions/831742/how-do-you-change-chromes-background-color

html background google-chrome google-chrome-extension high-contrast

6
推荐指数
1
解决办法
4955
查看次数

为什么收益率可​​以被编入索引?

我以为我可以通过直接访问传递给生成器的值的索引来使我的python(2.7.10)代码更简单send,并且对代码运行感到惊讶.然后我发现应用的索引yield并没有真正做任何事情,也没有抛出异常:

def gen1():
    t = yield[0]
    assert t
    yield False

g = gen1()
next(g)
g.send('char_str')
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试索引yield三次或更多,我得到一个例外:

def gen1():
    t = yield[0][0][0]
    assert t
    yield False

g = gen1()
next(g)
g.send('char_str')
Run Code Online (Sandbox Code Playgroud)

哪个扔了

TypeError: 'int' object has no attribute '__getitem__'
Run Code Online (Sandbox Code Playgroud)

这是异常不一致的行为,我想知道是否有一个直观的解释,索引产量实际上是做什么的?

python indexing yield generator python-2.7

6
推荐指数
1
解决办法
101
查看次数

如何将 Future 作为函数参数传递?

我习惯了 Scala 的类型,在这种类型Future中,您可以包装要返回的任何对象来指定它。Future[..]

我的 Rust 函数hello返回Query,但我似乎无法将该结果作为 type 的参数传递Future<Output = Query>。为什么不呢?我应该如何更好地输入它?

当我尝试将未来作为参数传递时,就会发生失败:

use std::future::Future;

struct Person;
struct DatabaseError;

type Query = Result<Vec<Person>, DatabaseError>;

async fn hello_future(future: &dyn Future<Output = Query>) -> bool {
    future.await.is_ok()
}

async fn hello() -> Query {
    unimplemented!()
}

async fn example() {
    let f = hello();
    hello_future(&f);
}

fn main() {}
Run Code Online (Sandbox Code Playgroud)

编译失败并出现以下错误:

error[E0277]: `&dyn Future<Output = Result<Vec<Person>, DatabaseError>>` is not a future
 --> src/main.rs:9:5
  |
9 | …
Run Code Online (Sandbox Code Playgroud)

future rust rust-tokio tokio-postgres

6
推荐指数
1
解决办法
3202
查看次数

如何使用 Pyinstaller 捆绑 .jar 文件

您如何让pyinstaller将 .jar 文件捆绑为使用它们的 python 项目的存档?

例如,要制作一个 exe(我使用pyjnius来处理sikuli-standalone jar):

# test.py
import os
import sys

# set the classpath so java can find the code I want to work with
sikuli_jar = '/sikuli-api.standalone-1.0.3-Pre-1.jar'
jarpath = os.path.dirname(os.path.realpath(__file__)) + sikuli_jar
os.environ['CLASSPATH'] = jarpath

# now load a java class
from jnius import autoclass
API = autoclass('org.sikuli.api.API')
Run Code Online (Sandbox Code Playgroud)

Pyisntaller 使用以下命令创建(一个文件夹)exe:

pyinstaller -d test.py

但据我所知,jar 没有捆绑并且 exe 无法访问,除非您手动将它放在 Pyinstaller 生成的文件夹中

根据Pyinstaller 手册

“CArchive 包含您想要的任何内容。它非常像一个 …

python specifications jar pyinstaller pyjnius

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

将Django开发数据库(.sql3)迁移到Heroku

如何将Django .sql3开发数据库迁移到heroku?

django项目突出显示了必须迁移的重要数据库

在这里,并在这里我想:heroku pg:psql --app sblic < database.sql3但我的Django管理显示没有新的上传(甚至执行syncdb /迁移/或collectstatic后

sqlite django postgresql migrate amazon-s3

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

Google Cloud 抢占式实例抢占的频率(大致)是多少?

我看到 Google Cloud 可能随时终止抢占式实例,但是是否有任何非官方的独立研究报告显示“抢占率”(每小时抢占的虚拟机数量),可能是在几个不同的区域进行采样的?

鉴于我发现的信息很少(与类似的问题一样),即使是轶事,例如:“回顾过去 6 个月,我通常看到 uswest1 每小时有 3% - 5% 的实例抢占”也会有用(我认为这个可以与 AWS 中的实例计数指标类似地进行监控)。

客户偶尔希望将现有的、非容错的代码以“便宜”的方式推入云中(尽管有最佳实践),并且在没有预期的失败率的情况下,他们经常被抢占式的廉价所蒙蔽,因此我想分享 G​​CP 社区的一些典型经验,即使人们的经验可能有所不同,以帮助传达安全期望。

google-compute-engine

4
推荐指数
1
解决办法
1609
查看次数

如何在 Spring Boot 中强制执行特定的 Spring Security 版本依赖

如何确保按照此记录错误使用 Spring Security >3.2.1 ?:

class path resource [org/springframework/security/config/annotation/authentication/configurers/GlobalAuthenticationConfigurerAdapter.class] 
cannot be opened because it does not exist
Run Code Online (Sandbox Code Playgroud)

我尝试在我的系统中升级它POM.xml,但没有成功(Intellij抱怨该版本不存在):

在此输入图像描述

我在 Intellij Maven 设置中的本地存储库路径是正确的。我将鼠标悬停在其投诉上并选择“更新 Maven 索引”。它尝试更新我的本地存储库,仅返回依赖项不存在。

那么,我还能如何确保找到GlobalAuthenticationConfigurerAdapter.class呢?

java spring spring-mvc intellij-idea maven

3
推荐指数
1
解决办法
1万
查看次数

如何在matplotlib图文中使用(新样式)字符串格式

是否可以使用matplotlib的figure.text()命令使用(新样式)python字符串格式?

我尝试创建2列数据作为文本(它们意味着整齐地对齐)

import matplotlib.pyplot as plt

txt = '{0:50} {1:.4e}'.format('Row1:', 0.1542457) + '\n' + \
      '{0:50} {1:.4e}'.format('Row2:', 0.00145744) + '\n' + \
  '{0:50} {1:.4e}'.format('Long name for this row):', 0.00146655744) + '\n' + \
  '{0:50} {1}'.format('medium size name):', 'some text')

fig = plt.figure()
ax1 = fig.add_axes((0.1, 0.3, 0.8, 0.65))
ax1.plot(range(10),range(10))
fig.text(0.17, 0.07,txt)
plt.show()
Run Code Online (Sandbox Code Playgroud)

当我将txt变量打印到屏幕时看起来很好看:

对齐文本

但是在我的情节中没有对齐

文本错位

python string format text matplotlib

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