我使用setuptools来分发我的python包.现在我需要分发额外的数据文件.
从我从setuptools文档中收集到的内容,我需要将我的数据文件放在包目录中.但是,我宁愿将我的数据文件放在根目录的子目录中.
我想避免的:
/ #root
|- src/
| |- mypackage/
| | |- data/
| | | |- resource1
| | | |- [...]
| | |- __init__.py
| | |- [...]
|- setup.py
Run Code Online (Sandbox Code Playgroud)
我想要的是:
/ #root
|- data/
| |- resource1
| |- [...]
|- src/
| |- mypackage/
| | |- __init__.py
| | |- [...]
|- setup.py
Run Code Online (Sandbox Code Playgroud)
如果它不是必需的话,我对拥有这么多子目录感到不舒服.我找不到原因,为什么我/ /将文件放在包目录中.使用如此多的嵌套子目录恕我直言也很麻烦.或者有任何理由可以证明这种限制吗?
我应该实现一个比较两个字符串simliar strcmp但忽略空白字符的函数,所以
strcmpignorews("abc ", " a b c")
Run Code Online (Sandbox Code Playgroud)
应该给出相同的结果.
这是我的实现:
namespace {
void SkipWhitespace(const char *&s) {
for (; std::isspace(*s, std::locale::classic); ++s);
}
}
int strcmpignorews(const char *s1, const char *s2) {
for (; *s1 != '\0' && *s2 != '\0'; ++s1, ++s2) {
SkipWhitespace(s1);
SkipWhitespace(s2);
if (*s1 != *s2) {
break;
}
}
return (*s1 < *s2) ? -1 : ((*s1 == *s2) ? 0 : 1);
}
Run Code Online (Sandbox Code Playgroud)
现在,问题是,内联SkipWhitespace函数是否有意义?我想我已经读过一些inline不应该用于包含循环或开关的函数的地方,但我不记得在哪里以及为什么.
是否有一种简单的方法可以获取SWT StyledText小部件的内容并将其另存为HTML,然后相反地收回保存的HTML以将其加载到StyledText中?
我是一个关于抛出Exceptions的新手,我在使用这个PHP基本方法时没有得到如何抛出异常,DateTime :: createFromFormat()
案例如下:
private function obtainMostRecentFile($fileNamesArray, $start, $lenght) {
foreach ($fileNamesArray as $row) {
$i++;
$format = 'Ymd';
$date = DateTime::createFromFormat($format, substr($row, $start, $lenght));
$date_in_format[$i] = $date->format('Ymd');
}
return (max($date_in_format));
}
Run Code Online (Sandbox Code Playgroud)
我有这个方法,我需要找到一种方法,当DateTime::createFromFormat($format, substr($row, $start, $lenght));没有正确运行时抛出异常.
例如:
如果我调用$this->obtainMostRecentFile("GeoLiteCity_20101201.zip", 12, 8);该函数返回它们应该返回的输出.
如果我调用$this->obtainMostRecentFile("GeoLiteCity_201.zip", 12, 8);该函数返回输出Fatal error: Call to a member function format() on a non-object in C:\xampp\htdocs\testes\testecsv4.php on line 440.
Normaly我做这样的事情:
if (is_null($someVariable)) {
throw new Exception("null variable");
}
Run Code Online (Sandbox Code Playgroud)
你能给我一些关于如何抛出Exception的线索DateTime::createFromFormat()吗?
最好的祝福,
我没有Javascript的经验.页面加载完成后,我需要遍历给定页面的所有URL并执行一些清理.
我怎么做?
就像是
for i = 0 to (number of URLS on the page) {
doSomething (URL(i));
}
Run Code Online (Sandbox Code Playgroud)
谢谢
可能有不同种类的代码生成.例如,在RoR中,Rails可以为模型,控制器等创建骨架.但是开发人员必须完成这些骨架.
现在有时候有些项目会根据一组定义或模型生成许多核心工件.
我主要想知道后一种代码生成的优点和缺点.
我仍然没有得到MySQL的交易?它的优点是什么?我该如何申请?
请简单解释,但不是那么简单.我知道DB是什么..
当我点击右上方的红色X按钮(我不知道它是什么正式调用)时,我想在我的MDI表单中激活一段代码,以便程序很好地关闭.
当发生这种情况时,调用Form中的哪种方法?
在Cython的"Hello World"以及在这里调用C数学库中的函数的例子之后,我真正想做的是在一个单独的文件中使用我自己的C代码并在Cython中使用它.在此之后,我修改setup.py文件:
sourcefiles = ['hello2_caller.pyx', 'hello2.c']
Run Code Online (Sandbox Code Playgroud)
这是hello2.c(主要是单独编译和测试它 - 虽然该测试不存在该产品:
#import <stdio.h>
void f() {
printf("%s", "Hello world!\n");
}
int main(int argc, const char* argv[]) {
f();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是hello2_caller.pyx
cdef extern from "hello2.c":
void f()
cpdef myf():
f()
Run Code Online (Sandbox Code Playgroud)
我明白了:
In file included from hello2_caller.c:219:
hello2.c:3: warning: function declaration isn’t a prototype
Run Code Online (Sandbox Code Playgroud)
所以我想我没有以某种方式提供标题..虽然只是喂了setup.py标准的标题如'hello2.h'不起作用.你能指点我一个工作的例子或解释我做错了什么.谢谢.
看起来NLog不能使用反射GetCurrentClassLogger(),即使我的MVC 3应用程序部署在IIS7上的完全信任环境中.我正在使用StructureMap 2.6.1,并且问题似乎在部署之间偶尔出现.我无法弄清楚为什么,虽然我认为StructureMap没有引起它.
Bootstrapper 类:public static class Bootstrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(Init);
}
private static void Init(IInitializationExpression x)
{
x.AddRegistry(new DBServiceRegistry());
x.AddRegistry(new MyRegistry());
}
}
Run Code Online (Sandbox Code Playgroud)
Registry 类:public class MyRegistry : Registry
{
public MyRegistry()//HttpContext context)
{
For<ILogger>().Use<NLogLogger>();
For<IUserRepository>().Use<SqlUserRepository>();
}
}
Run Code Online (Sandbox Code Playgroud)
我的机器上的一切都很棒.System.NullReferenceException: Object reference not set to an instance of an object部署时为什么会出现错误?
[NullReferenceException: Object reference not set to an instance of an object.]
NLog.LogManager.GetCurrentClassLogger() +84
lambda_method(Closure , IArguments ) …Run Code Online (Sandbox Code Playgroud) structuremap nlog full-trust nullreferenceexception asp.net-mvc-3
c++ ×1
cython ×1
database ×1
exception ×1
full-trust ×1
html ×1
inline ×1
java ×1
javascript ×1
mysql ×1
nlog ×1
php ×1
python ×1
setuptools ×1
strcmp ×1
structuremap ×1
styledtext ×1
swt ×1
transactions ×1
vb6 ×1
whitespace ×1