coding-style

As a language, is Python limited due to no end statement?

女生的网名这么多〃 提交于 2019-12-10 13:27:48
问题 Since Python uses tabs spacing to indicate scope (and as such, has no end of } symbols), does that limit the language in any way from having particular functionality? Note: I'm not talking about personal preferences on coding-style, I'm talking about real language limitation as a direct result of not having an end statement? For example, it appears by a post directly from Guido that the lack of multi-line lamba's due to Python not having a terminating end / } symbol? If so, what other Python

When should I not split my code into header and source files?

瘦欲@ 提交于 2019-12-10 13:22:42
问题 I know this maybe quite subjective, but are there any general rules for situations when it is not necessary for code to be split into two files? For example is the class is extremely small, or if the file simply holds some global definitions or static functions? Also, in these cases, should the single file be a .cpp file or a .h file? 回答1: On the technical side, whenever you need to obey the one definition rule you have to separate declarations from definitions, since you will need to include

Do you add information to the top of each .hpp/.cpp file? [closed]

余生长醉 提交于 2019-12-10 13:15:25
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . When creating a new C++ header/source file, what information do you add to the top? For example, do you add the date, your name, a description of the file, etc.? Do you use a structured format for this information? e.g. // Foo.cpp - Implementation of the Foo class // Date:

Python function parameter: tuple/list

只愿长相守 提交于 2019-12-10 13:08:00
问题 My function expects a list or a tuple as a parameter. It doesn't really care which it is, all it does is pass it to another function that accepts either a list or tuple: def func(arg): # arg is tuple or list another_func(x) # do other stuff here Now I need to modify the function slightly, to process an additional element: def func(arg): #arg is tuple or list another_func(x + ['a']) # etc Unfortunately this is not going to work: if arg is tuple, I must say x + ('a',) . Obviously, I can make it

Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

本小妞迷上赌 提交于 2019-12-10 12:56:44
问题 Style guides for various languages recommend a maximum line length range of 80–100 characters for readability and comprehension. My question is, how do people using tabs for indentation comply with the line length limits? Because, if the length of a tab is set to 2 in your editor, the same code could be over 80 characters long in someone else's editor with tab length set to 3/4/6/8. Some suggest that I mentally see my tab length at 8 characters. This isn't realistic and won't let me focus on

Are there coding standards for XML files?

感情迁移 提交于 2019-12-10 12:46:02
问题 I would like to know if there are any xml coding standards. <?xml version="1.0"?> <overlay id="tutorboy-toolbar-Overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <toolbox id="navigator-toolbox"> <toolbar id="tutorboy-toolbar-Toolbar" toolbarname="TutorBoy Toolbar" accesskey="T" class="chromeclass-toolbar" context="toolbar-context-menu" hidden="false" persist="hidden"> <toolbarbutton label="TutorBoy" id="tutorboy-toolbar-button-home" accesskey="d" image="chrome:/

html convention - self-close tag, > or />, in other way <br> or <br/>

谁说我不能喝 提交于 2019-12-10 12:37:19
问题 When take some tutorial from web, I see many people leaves tags open like <link ..> , <img ..> . But when I use Netbeans to edit them (the HTML/JSP pages), it show a red background on those tags until I add the slash into them. <br> --> <br/> . Which is the correct way to write HTML-based code? 回答1: Both are fine for HTML. Though not for XHTML which is an XML dialect. Some elements do not need a closing ( /> ) tag - in particular empty elements (those that do not have content). Examples are

Using a generic type argument in place of an argument of type System.Type. Is it a smell? [closed]

断了今生、忘了曾经 提交于 2019-12-10 12:32:41
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 7 months ago . I often see (in many mocking libraries for example) methods where a generic type argument is used in place of an argument of type System.Type . I am specifically talking about cases where generic type is only being used in typeof(T) operation (i.e. no instance of type T is

Removing new lines before empty blocks in Eclipse

大兔子大兔子 提交于 2019-12-10 12:28:24
问题 I prefer Allman-style braces, for example: if (foo) { // magical prancing unicorn stuff } rather than: if (foo) { // unmagical boring pony things } The Java formatter in Eclipse handles this pretty well, except for empty code blocks, which it formats like this: SomeDefaultCtor() {} I'd like to use this special format for empty blocks instead: SomeDefaultCtor() {} Is there any way to tell Eclipse to leave braces on the same line when the braces surround an empty code block? So far, I can't see

jQuery programming style?

醉酒当歌 提交于 2019-12-10 11:29:54
问题 I was recently asked to fix something on a site which I haven't worked on before. I haven't really worked with jQuery that much, but I figured I'd take a look and see if I could fix it. I've managed to mostly clear up the problem, but I'm still horrified at the way they chose to build this site. On document load, they replace the click() method of every anchor tag and form element with the same massive function. When clicked, that function then checks if the tag has one of a few different