当我需要处理我的一个宠物项目时,我只是像往常一样克隆存储库(git clone <url>
),编辑我需要的东西,运行测试,更新setup.py
版本,提交,推送,构建包并将它们上传到PyPI.
使用有什么好处pip install -e
?我应该使用它吗?它将如何改善我的工作流程?
如果这有帮助,这是我目前打包并发送给PyPI的两个宠物项目,但从未使用过pip install -e
.一个是纯Python,另一个是Django包.
如何通过使用来改善项目的工作流程或结构pip install -e
?
鉴于数组的名称实际上是指向数组的第一个元素的指针,以下代码:
#include <stdio.h>
int main(void)
{
int a[3] = {0, 1, 2};
int *p;
p = a;
printf("%d\n", p[1]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
1
按预期打印.
现在,鉴于我可以创建一个指向指针的指针,我写了以下内容:
#include <stdio.h>
int main(void)
{
int *p0;
int **p1;
int (*p2)[3];
int a[3] = {0, 1, 2};
p0 = a;
p1 = &a;
p2 = &a;
printf("p0[1] = %d\n(*p1)[1] = %d\n(*p2)[1] = %d\n",
p0[1], (*p1)[1], (*p2)[1]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我希望它能够编译和打印
p0[1] = 1
(*p1)[1] = 1
(*p2)[1] = 1
Run Code Online (Sandbox Code Playgroud)
但相反,它在编译时出错,说:
test.c: In function ‘main’:
test.c:11:5: …
Run Code Online (Sandbox Code Playgroud) 我一直在使用UVa Online Judge解决一些编程挑战,并且在提交我的解决方案时,我被告知法官将使用以下参数将我的代码编译为GCC/G ++,我不知道:-lm -lcrypt -pipe -DONLINE_JUDGE
.
他们在做什么?非常感谢你提前!
人.
我试图理解这三个声明之间的差异:
char p[5];
char *p[5];
char (*p)[5];
Run Code Online (Sandbox Code Playgroud)
我试图通过做一些测试来找到它,因为阅读声明和类似的东西的每个指南到目前为止都没有帮助我.我写了这个小程序并且它不起作用(我已经尝试了其他类型的第三个声明的使用,我已经用完了选项):
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
char p1[5];
char *p2[5];
char (*p3)[5];
strcpy(p1, "dead");
p2[0] = (char *) malloc(5 * sizeof(char));
strcpy(p2[0], "beef");
p3[0] = (char *) malloc(5 * sizeof(char));
strcpy(p3[0], "char");
printf("p1 = %s\np2[0] = %s\np3[0] = %s\n", p1, p2[0], p3[0]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
第一个和第二个工作没问题,我已经明白他们做了什么.第三个声明的含义是什么,使用它的正确方法是什么?
谢谢!
我正在尝试定义一个类,该类将另一个类作为属性_model
并将实例化该类的对象。
from abc import ABC
from typing import Generic, TypeVar, Any, ClassVar, Type
Item = TypeVar("Item", bound=Any)
class SomeClass(Generic[Item], ABC):
_model: ClassVar[Type[Item]]
def _compose_item(self, **attrs: Any) -> Item:
return self._model(**attrs)
Run Code Online (Sandbox Code Playgroud)
self._model(**attrs)
我认为返回 , 的实例应该是显而易见的Item
,因为_model
被显式声明为Type[Item]
并被attrs
声明为Dict[str, Any]
。
但我从中得到的mypy 0.910
是:
test.py: note: In member "_compose_item" of class "SomeClass":
test.py:11: error: Returning Any from function declared to return "Item"
return self._model(**attrs)
^
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在尝试./manage.py dumpdata --natural-foreign --natural-primary
我的课程,它们是:
class SuperClassManager(Manager):
def get_by_natural_key(self, identifier):
return self.get(identifier=identifier)
class SuperClass(Model):
objects = SuperClassManager()
identifier = CharField(max_length=31, unique=True)
def natural_key(self):
return (self.identifier, )
class Class(SuperClass):
pass
Run Code Online (Sandbox Code Playgroud)
但转储的数据是:
[
{
"model": "app.superclass",
"fields": {
"identifier": "identifier"
}
},
{
"model": "app.class",
"fields": {}
}
]
Run Code Online (Sandbox Code Playgroud)
在这种情况Class
下,无法将SuperClass
实例与实例相关联。我错过了什么?为什么不superclass_ptr
存在 in Class
(指向SuperClass
)被序列化,以便可以关联实例?
问题是:我的超类有多个子类以及每个子类的许多实例。所以我需要这种关系发生,这样我的固定装置才会有意义。
我输入了以下程序:
#include <stdio.h>
int main(void) {
int a = 3;
int b = 42;
printf("a = %d\nb = %d\n", a, b);
printf("Exchanging values.\n");
a ^= b ^= a ^= b;
printf("a = %d\nb = %d\n", a, b);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
没关系 当我尝试编译它时,我得到了这个:
$ gcc test.c -o test -Wall -Wextra -ansi -pedantic-errors
test.c: In function ‘main’:
test.c:11: warning: operation on ‘a’ may be undefined
Run Code Online (Sandbox Code Playgroud)
这几乎是标准代码,不是吗?
为什么会触发警告?据我所知,int
只要您使用C的标准实现,就会默认实现按位XOR .
非常感谢你.
在谈到irc.freenode.net上## C的链接之后,我去测试了一些我学到的概念,并提出了这种情况.
我有这个名为main.c的文件:
int main(void) {
func();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这个名为test.c的文件:
#include <stdio.h>
void func(void) {
printf("Hello.\n");
}
Run Code Online (Sandbox Code Playgroud)
没有test.h文件.
我这样做:
$ gcc -c main.c
$ gcc -c test.c
$ gcc main.o test.o
$ ./a.out
Hello.
$
Run Code Online (Sandbox Code Playgroud)
这很有效.不应该在第一次调用时抱怨gcc不知道在main.c文件中调用的函数func()吗?我没有包含任何文件及其原型或实现,但gcc可以编译目标代码并生成一个合理的可执行文件.那里发生了什么,我失踪了?
谢谢.
c ×5
declaration ×2
gcc ×2
pointers ×2
python ×2
arrays ×1
c++ ×1
dereference ×1
django ×1
g++ ×1
header-files ×1
linker ×1
mypy ×1
packaging ×1
parameters ×1
pip ×1
type-hinting ×1