double-underscore

How use :private-members: to show mangled member value constants in Sphinx

隐身守侯 提交于 2020-07-22 21:35:33
问题 How can I get the value of a constant into my Sphinx documentation? .. automodule:: mymodule :members: :private-members: This is my test module: class Test: """My Test Class""" __MY_TEST_CONSTANT = 98.2 """My test constant docu""" At the moment I get the description of my private constant but the value is "None" and not "98.2". class Test: My Test Class __MY_TEST_CONSTANT = None My test constant docu 回答1: I tested this and I'm pretty sure it's either: an undocumented feature, a bug, or both.

How use :private-members: to show mangled member value constants in Sphinx

☆樱花仙子☆ 提交于 2020-07-22 21:35:00
问题 How can I get the value of a constant into my Sphinx documentation? .. automodule:: mymodule :members: :private-members: This is my test module: class Test: """My Test Class""" __MY_TEST_CONSTANT = 98.2 """My test constant docu""" At the moment I get the description of my private constant but the value is "None" and not "98.2". class Test: My Test Class __MY_TEST_CONSTANT = None My test constant docu 回答1: I tested this and I'm pretty sure it's either: an undocumented feature, a bug, or both.

Why do the c libraries and language define _name and then typedef or pound define _name name?

你。 提交于 2020-06-26 04:14:21
问题 It seems that the C libraries and language has a lot of useless type names. For example, C has a built in type _Bool and there is a macro in stdbool.h , #define bool _Bool . Why didn't C just have bool built in instead of _Bool ? I found more examples in stdio.h and stdlib.h . Like this: # define WEXITSTATUS(status) __WEXITSTATUS (status) # define WTERMSIG(status) __WTERMSIG (status) # define WSTOPSIG(status) __WSTOPSIG (status) # define WIFEXITED(status) __WIFEXITED (status) # define

Why do the c libraries and language define _name and then typedef or pound define _name name?

时光总嘲笑我的痴心妄想 提交于 2020-06-26 04:14:14
问题 It seems that the C libraries and language has a lot of useless type names. For example, C has a built in type _Bool and there is a macro in stdbool.h , #define bool _Bool . Why didn't C just have bool built in instead of _Bool ? I found more examples in stdio.h and stdlib.h . Like this: # define WEXITSTATUS(status) __WEXITSTATUS (status) # define WTERMSIG(status) __WTERMSIG (status) # define WSTOPSIG(status) __WSTOPSIG (status) # define WIFEXITED(status) __WIFEXITED (status) # define

Python double underscore mangling

五迷三道 提交于 2020-01-30 04:50:51
问题 I am a bit confused by this behavior (using python 3.2): class Bar: pass bar = Bar() bar.__cache = None print(vars(bar)) # {'__cache': None} class Foo: def __init__(self): self.__cache = None foo = Foo() print(vars(foo)) # {'_Foo__cache': None} I've read up a bit on how double-underscores cause attribute names to be "mangled", but I would have expected the same name-mangling in both cases above. What is the meaning of a single- and a double-underscore before an object name? Any ideas what's

Ruby variable name with double underscores

混江龙づ霸主 提交于 2020-01-10 19:13:25
问题 Sometimes I see variable names with double underscore in the beginning and the end. For example: Article.__elasticsearch__ Is there some naming convention related to double underscores in Ruby variable names? 回答1: An initial underscore or double underscore basically indicates "special/avoid overwrite" --meaning it's meant to reduce the likelihood that someone else might define a method/attribute of the same name. The most common occurrence is __send__ . From Ruby Forum 回答2: The author of the

Filtering out choiceless polls in the Django tutorial causes polls in the index to duplicate

雨燕双飞 提交于 2019-12-23 02:20:09
问题 I've edited the code from the tutorial for the index view to look like this: class IndexView(generic.ListView): template_name = 'polls/index.html' context_object_name = 'latest_poll_list' def get_queryset(self): """ Return the last five published polls (not including those set to be published in the future, or those without choices). """ return Poll.objects.filter( pub_date__lte=timezone.now(), choice__choice_text__isnull=False ).order_by('-pub_date')[:5] But now my index looks like this:

Using '__progname' instead of argv[0]

梦想的初衷 提交于 2019-12-17 19:57:56
问题 In the C / Unix environment I work in, I see some developers using __progname instead of argv[0] for usage messages. Is there some advantage to this? What's the difference between __progname and argv[0] . Is it portable? 回答1: __progname isn't standard and therefore not portable, prefer argv[0] . I suppose __progname could lookup a string resource to get the name which isn't dependent on the filename you ran it as. But argv[0] will give you the name they actually ran it as which I would find

Why do people use __(double underscore) so much in C++

好久不见. 提交于 2019-12-17 02:09:09
问题 I was having a look through some open source C++ code and notice a lot of double under scores where used in the code, mainly at the start of variable names. return __CYGWIN__; Just wondering is there a reason for this, or is it just some people code styles? I would think that I makes it hard to read. 回答1: From Programming in C++, Rules and Recommendations : The use of two underscores (`__') in identifiers is reserved for the compiler's internal use according to the ANSI-C standard.

Why do some functions have underscores “__” before and after the function name?

空扰寡人 提交于 2019-12-17 02:01:09
问题 This seems to occur a lot, and was wondering if this was a requirement in the Python language, or merely a matter of convention? Also, could someone name and explain which functions tend to have the underscores, and why ( __init__ , for instance)? 回答1: From the Python PEP 8 -- Style Guide for Python Code: Descriptive: Naming Styles The following special forms using leading or trailing underscores are recognized (these can generally be combined with any case convention): _single_leading