问题标签 [fully-qualified-naming]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - XML 注释 - 是否应该看到引用是完全限定的?
基本上,何时真正需要(如果有的话)使用完全限定的 xml,请参阅参考:
此外,如何引用 .NET Framework 对象?
我了解完全合格的项目将始终允许 Microsoft 的 Sandcastle 正确链接事物,但是是否有必要使所有内容都完全合格?
旁注:Microsoft Sandcastle 是否能够链接到 .NET Framework 帮助文件,或者我是否通过引用来浪费时间<see cref="T:System.Collections.Generic.ICollection{T}"/>
?
python - How does the automatic full qualification of class names work, in Python? [relevant to object pickling]
(It is possible to directly jump to the question, further down, and to skip the introduction.)
There is a common difficulty with pickling Python objects from user-defined classes:
In fact, trying to get the object back from another program loader.py
with
results in
In fact, the class is pickled by name ("C"), and the loader.py
program does not know anything about C
. A common solution consists in importing with
However, this solution has a few drawbacks, including the fact that all the classes referenced by the pickled objects have to be imported (there can be many); furthermore, the local namespace becomes polluted by names from the dumper.py
program.
Now, a solution to this consists of fully qualifying objects prior to pickling:
Unpickling with the original loader.py
program above now works directly (no need to do from dumper import C
).
Question: Now, other classes from dumper.py
seem to be automatically fully qualified upon pickling, and I would love to know how this works, and whether this is a reliable, documented behavior:
Now, unpickling with the original loader.py
program also works (no need to do from dumper import C
); print obj.d
gives a fully qualified class, which I find surprising:
This behavior is very convenient, since only the top, pickled object has to be fully qualified with the module name (dumper.C()
). But is this behavior reliable and documented? how come that classes are pickled by name ("D") but that the unpickling decides that the pickled self.d
attribute is of class dumper.D
(and not some local D
class)?
PS: The question, refined: I just noticed a few interesting details that might point to an answer to this question:
In the pickling program dumper.py
, print self.d
prints <__main__.D object at 0x2af450>
, with the first dumper.py
program (the one without import dumper
). On the other hand, doing import dumper
and creating the object with dumper.C()
in dumper.py
makes print self.d
print <dumper.D object at 0x2af450>
: the self.d
attribute is automatically qualified by Python! So, it appears that the pickle
module has no role in the nice unpickling behavior described above.
The question is thus really: why does Python convert D()
into the fully qualified dumper.D
, in the second case? is this documented somewhere?
java - 带有 /etc/hosts 的完全限定机器名 Java
我正在尝试用 Java 获取我的机器(Windows 7 x64)的完全限定名称。在我的机器上,我更新了 c:\Windows\system32\drivers\etc\hosts 文件,使其具有如下条目:
我们所有的系统在 \etc\hosts 文件中都有一个我无法更改的条目(采用上述格式)。
以下代码始终返回“myserver”,我永远无法获得完全限定的名称。
我如何在 Java 中实现这一点?
谢谢,
什雷亚斯
c# - 具有泛型的属性的对象类型(例如“Collection`1”)中的“撇号+数字”是什么意思?
我有一个MyObject
带有属性 ( ) 的对象 ( MyProperty
)。我想得到它的类型名称(即String
等MyClass
)。我用:
简单类型没有问题,但是当MyProperty
是泛型类型时,我在获取它的名称时遇到了问题(例如Collection<String>
)。它打印:
集合`1
System.Collections.ObjectModel.Collection`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
那是什么`1
?我怎样才能获得“ Collection<String>
”?
java - 如何很好地格式化生成的 Java 代码
我正在寻找一种自动缩进java源代码的方法。我有一个从其他语言生成 java 代码的工具。现在,我想缩进生成的代码。请告诉我我该怎么做?在另一种方式中,我怎样才能准确地完成 ctl+shift+m 自动执行的操作?我不能使用 CTRL + SHIFT + F 和 CTRL + SHIFT + M
c++ - 在编写 C++ 成员定义时,是否有任何理由更喜欢将它们放在命名空间块中而不是完全限定它们,反之亦然?
在 C++ 类中,我们可以用两种风格中的任何一种来编写我们的成员。我们可以将它们放在命名空间块内,或者我们可以完全限定每个。
有什么理由更喜欢一种风格而不是另一种风格?
头文件如下所示(bar.h):
样式 1 (bar.cpp) -命名空间块内的声明:
样式 2 (bar.cpp) -完全限定声明:
所以我的问题,再次,是:有什么理由更喜欢一种风格而不是另一种风格?
java - 处理重复的完全限定名称
正如标题所说,有没有办法解决这个问题?我已经导入了两个独立的第三方库,它们有一个完全限定的类名冲突。
现在这两个库都以 jar 形式导入,似乎在某些环境(命令行调用、Eclipse)中找到了正确的类,而在其他环境(Maven)中找到了错误的类,我得到了一个缺少的方法异常。如果找不到解决方案,我可以回退到重构这些库之一并重建 jar,但我宁愿不必在每次库有更新时都重复这项工作。
编辑: 如果以后有人看到这个并且感到困惑,我接受了 Dave Newton 的回答,因为如果你在编写所有代码之前足够勤奋地发现这个问题,这将是正确的方法。正如我所怀疑的,在编写完所有代码后自动修复导入似乎是不可能的。
c# - .NET SMTP 邮件 - 错误 = helo 命令被拒绝需要完全限定的主机名
我正在尝试在 .NET 控制台应用程序中发送电子邮件。我有一个 IP 地址为 XXXX 的 SMTP 服务器(经过消毒以保护无辜者)。
已设置 SMTP 服务器(已配置中继)以允许来自托管 .NET 控制台应用程序的服务器的电子邮件,并将该电子邮件发送到外部世界。
我已经使用托管控制台应用程序的服务器上的 telnet 对此进行了测试。我使用 SMTP 服务器的 IP 地址从托管控制台应用程序的服务器成功发送了一封带有 telnet 控制台的电子邮件。使用 telnet 时不需要身份验证。我没有获得任何连接凭据。
但是当我尝试在 .NET 应用程序中执行此操作时,我收到以下错误:
语法错误,命令无法识别。服务器响应是::Helo 命令被拒绝:需要完全限定的主机名
这是我的代码:
这是函数发送邮件:
python - 为什么 Python 文档测试要求 isinstance 使用匹配的合格/不合格命名?
我知道在大多数情况下isinstance
不需要或应该避免(例如,Isinstance pythonic/"good" 的使用吗?)。但是,有时这正是我所需要的。
然而,在 Python 2.6、2.7 和 3.2 中,我注意到 isinstance
在 doctest 中的执行和正常执行之间的工作方式存在以下不规则性。
例如,我希望出现以下行为,这isinstance
与我使用的是限定名称还是非限定名称是矛盾的:
在 Doctest 中执行的相同代码的工作方式相同。
但是,如果我在名为“isinstanceTest.py”的模块中定义一个类,并在isinstance
用于匹配该类的同一模块中定义一个函数,事情会变得更有趣。以下 doctest 是为了通过而编写的。我正在使用,unittest.TextTestRunner
因为我经常收集并在一个套件中跨多个模块运行我的文档测试和单元测试。
请注意,最后两个 doctest 语句同时使用了限定名称和非限定名称,会产生意想不到的结果。
如果在“isinstanceTest.py”所在的目录中,我打开一个解释器并执行等效命令,结果如预期:
因此,虽然这种行为是一致的并且本地化为在测试套件中运行 doctest(并且我已经根据需要对其进行了编码,并且通常只在 doctests 中使用限定名称),但更大的问题是:这是 doctests 的记录限制吗(我有还没有找到任何提到这一点的文档),或者这是一个错误?
android - Android Play 商店 - 应用标识符区分大小写?
我一直认为一个应用程序的唯一后向域标识符是不区分大小写的,但它看起来,是吗?