当我输入git clean -f我得到以下错误信息:
> Removing .__afs043
> warning: failed to remove .__afs043
> Removing .__afs0F7D
> warning: failed to remove .__afs0F7D
> Removing .__afs1359
> warning: failed to remove .__afs1359
> Removing .__afs1421
> warning: failed to remove .__afs1421
> Removing .__afs243A
> warning: failed to remove .__afs243A
> Removing .__afs2745
> warning: failed to remove .__afs2745
> Removing .__afs3454
> warning: failed to remove .__afs3454
> Removing .__afs3D12
> warning: failed to remove .__afs3D12
> Removing .__afs4A5E …Run Code Online (Sandbox Code Playgroud) 我希望我知道参考或文档告诉我这是在 Perl 中创建新对象的最佳方法:
sub new {
my $package = shift;
my $class = ref($package) || $package
Run Code Online (Sandbox Code Playgroud)
这就是我多年来创建对象的方式,但现在我想知道为什么要麻烦?除了一些边缘情况,为什么不简单地执行以下操作:
sub new {
shift; # get rid of the object or package name
my $class = __PACKAGE__;
Run Code Online (Sandbox Code Playgroud)
当没有特殊原因试图检测“新”方法被调用的命名空间时,简单地使用 __PACKAGE__ 是否有任何问题?
我偶然发现了这条蟒蛇:
__builtin__.__dict__['N_'] = lambda x: x
class X:
doc = N_('some doc for class X')
Run Code Online (Sandbox Code Playgroud)
我从概念上知道这是做什么的,但我不知道为什么?更准确地说,该代码与此之间的区别是什么:
class X:
doc = 'some doc for class X'
Run Code Online (Sandbox Code Playgroud)