我无法找到正确的方法的例子来使用NSError,UIAlertView和NSErrorRecoveryAttempting一起在iOS.我能找到的大多数文档和示例都涵盖了OS X上的等效功能,其中相关行为由Cocoa集成.但是在iOS中,似乎有必要"手工"做到这一点,而且我找不到它如何完成的好例子.
我非常感谢使用NSError中的信息来支持从NSErrors报告给用户的恢复尝试的一些最佳实践示例.
可能重复:
如何以编程方式阻止Mac进入睡眠状态?
当前版本的OS X(10.7)在应用程序或进程运行时防止睡眠的正确方法是什么?
特别是,IOCancelPowerChange仍然(或曾经)曾为此目的服务吗?我打电话IOCancelPowerChange回应kIOMessageCanSystemSleep,但这并没有成功.
我给Python包中单个模块的名称是否与包的名称相匹配?
例如,如果我有一个带有结构的单个模块的包
super-duper/
super/
__init.py___
mycode.py
...
Run Code Online (Sandbox Code Playgroud)
我可以super-duper在PyPi上创建一个包,安装后会有两个site-packages名称不匹配的文件夹:
super/
super_duper-1.2.3.dist-info/
Run Code Online (Sandbox Code Playgroud)
这意味着要导入我使用的项目
import super
Run Code Online (Sandbox Code Playgroud)
而不是实际的包名(super_duper)
这似乎违反了常规做法(从我看到的每个其他包的文件夹判断site-packages)遵循该模式
same_name/
same_name-1.2.3.dist-info/
Run Code Online (Sandbox Code Playgroud)
用于PyPi包same-name.
我应该(总是)构建我的项目
super-duper/
super_duper/
__init.py___
mycode.py
...
Run Code Online (Sandbox Code Playgroud)
确保包名称和模块导入名称"匹配":
import super_duper
Run Code Online (Sandbox Code Playgroud)
我应该遵循相关的最佳做法或规则吗?
我使用Homebrew作为我的软件包总经理,并使用它的Python和pip进行软件开发,以及virtualenvs.出于各种原因,我想继续使用这种结构,但我需要一些(显然)使用Conda更容易安装的软件.
我可以继续使用Homebrew + pip + virtualev并将Conda添加到混音中,理想情况下是在virtualenv中,以便它不会影响我的整个系统吗?如果是这样,我如何以这种方式设置和使用Conda?
(Python:2.7.11(Homebrew); pip:8.1.1; setuptools:20.6.7; OS X:10.11.4(x86_64))
一些软件包(Haddock文档,例如Data.String.Utils)有一个菜单栏,其中包含一个"样式"菜单,允许在用于显示文档的样式中进行选择:
如何在我自己的软件包的文档中获取此菜单?我应该使用什么设置来包含它,以及如何指定提供哪些样式?
我尝试过类似的东西
haddock
-- ...
css: /path/to/mystuff.css, Default, Ocean
-- ...
Run Code Online (Sandbox Code Playgroud)
和
haddock
-- ...
css: Default
css: Ocean
css: /path/to/mystuff.css
-- ...
Run Code Online (Sandbox Code Playgroud)
在我的~/.cabal/config; 但是前者失败了,后者只是使用最后列出的css条目进行格式化,没有"样式"菜单.
在更新到3.1之后,PyCharm在包的"索引"期间永远挂起(在OSX 10.9.1,Python 2.7.5上).
对我来说,这是在索引时发生的scipy(0.13.3).如果我unistall scipy,索引似乎完成,但然后再次挂起"pythonstubs".用户界面变得反应迟钝,CPU使用率最高,我无法做任何事情,不得不强制退出应用程序.
如果我重新安装scipy,PyCharm会再次在scipy扫描中的相同位置挂起(请参阅对话框的屏幕截图):

FWIW,我可以从系统命令行运行Python脚本(包括一些使用scipy和最近更新或安装的许多其他软件包)没有问题,因此Python安装是合理的.
有没有人有类似的问题或找到解决这个问题的方法?
我有
data Foo = X (String, Int) | A String | B String | C String | D String -- ...
Run Code Online (Sandbox Code Playgroud)
并已定义
f (X (s, _)) =s
f (A s) = s
f (B s) = s
f (C s) = s
f (D s) = s
-- ...
Run Code Online (Sandbox Code Playgroud)
但我宁愿能写出类似的东西
f (X (s, _)) =s
f (_ s) = s
Run Code Online (Sandbox Code Playgroud)
但似乎没有办法做到这一点(我得到了与之相关的"解析错误" _).
有没有办法在Haskell中匹配数据构造函数通配符?
我想换我围绕如何Haskell的头Control.Arrow的&&&我的作品,但怕我在迷路的边缘.
具体来说,我很困惑(作为初学者)如何从类型签名中理解其行为
(&&&) :: a b c -> a b c' -> a b (c, c')
Run Code Online (Sandbox Code Playgroud)
在
import Control.Arrow
(negate &&& (+5)) <$> [1,2,3]
Run Code Online (Sandbox Code Playgroud)
甚至只是
(negate &&& (+5)) 5
Run Code Online (Sandbox Code Playgroud)
例如,第一个参数是"失踪" b和c,而第二个是缺少公正c',结果看起来对我来说(c, c'),不是a b (c, c').
&&&在某种类型的背景下,有人可以告诉我如何运作吗?
在我的代码中,我已经执行了
ax.plot(x, y, 'b.-', ...)
Run Code Online (Sandbox Code Playgroud)
并且需要能够在事后设置相应行的标签,以获得与我相同的效果
ax.plot(x, y, 'b.-', label='lbl', ...)
Run Code Online (Sandbox Code Playgroud)
有没有办法在Matplotlib中这样做?
线条
# Output prompt. '\#' will be transformed to the prompt number
c.PromptManager.out_template = '{color.Green}Out[{count}]{color.Green} : {color.LightGray}'
# Continuation prompt.
c.PromptManager.in2_template = '{color.Yellow} .\\D.{color.Green} : {color.LightGray}'
# If True (default), each prompt will be right-aligned with the preceding one.
c.PromptManager.justify = True
# Input prompt. '\#' will be transformed to the prompt number
c.PromptManager.in_template = '{color.Green}In [{count}]{color.LightGreen} : {color.DarkGray}'
Run Code Online (Sandbox Code Playgroud)
在我的ipython_config.py给予
usr/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py:440: UserWarning: As of IPython 5.0 `PromptManager` config will have no effect and has been replaced by TerminalInteractiveShell.prompts_class …Run Code Online (Sandbox Code Playgroud)