coding-style

How to handle the pylint message: ID:W0612 Unused Variable

时光总嘲笑我的痴心妄想 提交于 2019-12-21 06:50:41
问题 I'm updating some code to PEP 8 standard using pylint. Part of the code is throwing the W0612 unused variable error but it's because it's using a module that returns (x,y) for example when only x is needed in this particular case, this is what's done. (var_1, var_2) = func() def func(): a="a" b="b" return (a,b) var_1 is then returned but var_2 is never used and therefore throws the error. How should I handle this? I'm thinking this var = func()[0] What is the best way to handle it? 回答1: I

Vim: Align continous lines with spaces

天大地大妈咪最大 提交于 2019-12-21 06:36:10
问题 I would like to indent everything in vim with tabs, except a particular case. For example I have this c++ code(where <tab> is a tab character series and <s> is a space character series): <tab>if(true && <tab><s>true) <tab>{ <tab><tab>//code here <tab>} I would like after writing '&&' and press 'o' to jump on the next line and start writing to make vim put a tab and the number of spaces till '(' from the line before. Is it possible to define this coding style in vim? Thanks! 回答1: I think what

C++ getters and setters best style

久未见 提交于 2019-12-21 06:01:07
问题 in Java code convention is simple and obvious, in this style: public: int GetMyAge(){ return myAge; } void SetMyAge(int myAge){ this->myAge = myAge; } private: int myAge; (I know it's "again the same thing", but ) I have read most of related questions on SO and I still don't know "the best one" and "the most official" way to do it in C++. It can't be just a matter of preferences, can it ? EDIT: Seems like it can . 回答1: The best style is the one that allows you and your team to make quality

Emacs mode/function that wraps operators with spaces

随声附和 提交于 2019-12-21 05:25:09
问题 I remember that there was a mode for Emacs, or was it an option, can't recall, that prettified the code by placing space after operators like , , . , wrapped = with spaces, and some other cools stuff that I can't remember. I reckon that this is pretty much language-specific issue, but I usually put space after commas, and wrap = with spaces. Any ideas about this mode? 回答1: You're probably thinking of smart-operator.el. 回答2: How about smartchr.el? This is probably not what you are trying to

Remove styles when pasting from Word or other source

两盒软妹~` 提交于 2019-12-21 05:22:12
问题 I'm trying to set it up so that when I paste text, specifically from Word or another source, all the styling will be stripped. I'm happy to let bold and italic styles stay as well as lists and so forth, but the rest should go. How can I do this? I know there is a plugin that will allow me to do this if I paste via clicking a button but I'm looking for if someone presses CTRL+V or command+V. Any help? 回答1: I am using TinyMCE with the paste plugin an the following setup: paste_create_paragraphs

Is there any C++ style guide that talks about numeric literal suffixes?

隐身守侯 提交于 2019-12-21 04:26:17
问题 In all of the C++ style guides I have read, I never have seen any information about numerical literal suffixes (i.e. 3.14f , 0L , etc.). Questions Is there any style guide out there that talks about there usage, or is there a general convention? I occasionally encounter the f suffix in graphics programming. Is there any trend on there usage in the type of programming domain? 回答1: There is no general style guide that I've found. I use capital letters and I'm picky about using F for float

Fastest/Cleanest way to load a text file in memory

南楼画角 提交于 2019-12-21 04:05:16
问题 I know similar questions have been asked before, but I couldn't find one that answers my exact question. I need a way to read a file as a String with the least code and as simple and as optimal as possible. I'm not looking for: final BufferedReader br = new BufferedReader(new FileReader(file)); String line = null; while ((line = br.readLine()) != null) { // logic } And I know I can write my own helper class that does this. I'm looking for something more along the lines of: final String

Should I Always Fully Qualify Column Names In SQL?

三世轮回 提交于 2019-12-21 04:03:06
问题 Out of interest when working with SQL statements should I always use the fully qualifed column name (tablename.columnname) even if only working with one table e.g. SELECT table.column1, table.column2 FROM table 回答1: It's better if you do - it doesn't add any complexity, and it can prevent errors in the future. But in a well-defined system, you shouldn't have to - it's like namespaces in programming languages. The ideal is not to have conflicts, but it can clutter the code with the superfluous

How does the verbosity of identifiers affect the performance of a programmer?

廉价感情. 提交于 2019-12-21 04:01:15
问题 I always wondered: Are there any hard facts which would indicate that either shorter or longer identifiers are better? Example: clrscr() opposed to ClearScreen() Short identifiers should be faster to read because there are fewer characters but longer identifiers often better resemble natural language and therefore also should be faster to read. Are there other aspects which suggest either a short or a verbose style? EDIT: Just to clarify: I didn't ask: "What would you do in this case?". I

How can I configure Xcode to put '{' where I want it in generated files

帅比萌擦擦* 提交于 2019-12-21 03:57:31
问题 I know this is a fairly contentious issue amongst programmers, but when developing I like my IDE to position the opening curly bracket underneath the method/interface/control declaration, for illustrative purposes: - This is how Xcode automatically generates skeleton methods with the { at the end: - -(void) isTrue:(BOOL)input { if(input) { return YES; } else { return NO; } } This is how I like to lay out my code (which I believe is called the Allman style): - -(void) isTrue:(BOOL)input { if