我在看内部Python如何实现属性描述符.根据property()描述符协议实现文档,为方便起见,在此处复制它:
class Property(object):
"Emulate PyProperty_Type() in Objects/descrobject.c"
def __init__(self, fget=None, fset=None, fdel=None, doc=None):
self.fget = fget
self.fset = fset
self.fdel = fdel
if doc is None and fget is not None:
doc = fget.__doc__
self.__doc__ = doc
def __get__(self, obj, objtype=None):
if obj is None:
return self
if self.fget is None:
raise AttributeError("unreadable attribute")
return self.fget(obj)
def __set__(self, obj, value):
if self.fset is None:
raise AttributeError("can't set attribute")
self.fset(obj, value)
def __delete__(self, obj):
if self.fdel is …Run Code Online (Sandbox Code Playgroud) 作为问题的后续问题:从Directive到Parent元素发出事件:Angular2
看起来当结构指令发出事件时,父组件不会接收它.
@Directive({ selector: '[appWidget]' })
export class WidgetDirective implements OnInit{
@Output() wdgInit: EventEmitter<any> = new EventEmitter();
@Input() set appWidget (wdg: any) {
//display stuff
}
ngOnInit {
this.wdgInit.emit();
}
Run Code Online (Sandbox Code Playgroud)
widget.component.html:
<ng-container *ngFor="let wdg of widgets">
<div *appTwitterWidget="wdg" >
<ng-container>
Run Code Online (Sandbox Code Playgroud)
widgetContainer.component.html:
<app-widget [widgets]="widgetList" (wdgInit)="containerDoSomthing()"></app-widget>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我发现从不调用containerDoSomthing().
有没有办法指定在pip中安装模块所需的最小python版本?
我正在尝试将包发布到pypi.
python setup.py sdist upload -r pypi
Run Code Online (Sandbox Code Playgroud)
是我正在使用的命令.但是在setup.py中没有办法指定运行此模块需要最小的python版本(在我的例子中是python 3.5).
python ×2
angular ×1
inheritance ×1
javascript ×1
mutators ×1
pip ×1
properties ×1
pypi ×1
typescript ×1