coding-style

How to get smart tabs (“indent with tabs, align with spaces”) behavior in Xcode?

放肆的年华 提交于 2019-12-18 13:53:09
问题 I used to use tabs for indentation and spaces for alignment. Like so (arrows show tabs and dots show spaces). In QtCreator you can set such coding style in standard preferences. I can't find the way to achieve the same goal in Xcode. Could you please tell me if it is possible? May be there is a plugin for that? UPDATE: Here is how it can be achieved in QtCreator: P.S. Please, don't try to persuade me that using spaces only/tabs only is better, otherwise this question will turn into another

Python: using sys.exit or SystemExit differences and suggestions

ぃ、小莉子 提交于 2019-12-18 13:52:46
问题 Reading online some programmers use sys.exit , others use SystemExit . Sorry for the basic question: What is the difference? When do I need to use SystemExit or sys.exit inside a function? Example ref = osgeo.ogr.Open(reference) if ref is None: raise SystemExit('Unable to open %s' % reference) or ref = osgeo.ogr.Open(reference) if ref is None: print('Unable to open %s' % reference) sys.exit(-1) 回答1: No practical difference, but there's another difference in your example code - print goes to

How do I apply a style to multiple selections in Word using VBA?

感情迁移 提交于 2019-12-18 13:50:36
问题 I created a macro that will apply a particular style to whatever is selected in the document. However, when in draft view, when the user clicks in the style area pane to select a paragraph and then Ctrl + clicks on an additional paragraph, this additional selection is not applied when this macro is run: Sub BodyTextApply() Selection.Style = ActiveDocument.Styles("Body Text,bt") End Sub What do I need to add to this? Note: The workflow cannot change so that the user selects that actual text in

Is using “NOT EXISTS” considered to be bad SQL practise?

孤人 提交于 2019-12-18 13:33:26
问题 I have heard a lot of people over the years say that: "join" operators are preferred over “NOT EXISTS” Why? 回答1: In MySQL , Oracle , SQL Server and PostgreSQL , NOT EXISTS is of the same efficiency or even more efficient than LEFT JOIN / IS NULL . While it may seem that "the inner query should be executed for each record from the outer query" (which seems to be bad for NOT EXISTS and even worse for NOT IN , since the latter query is not even correlated), it may be optimized just as well as

Pythonic Style for Multiline List Comprehension [duplicate]

[亡魂溺海] 提交于 2019-12-18 12:49:21
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Line continuation for list comprehensions or generator expressions in python What is the the most pythonic way to write a long list comprehension? This list comprehension comes out to 145 columns: memberdef_list = [elem for elem in from_cache(classname, 'memberdefs') if elem.argsstring != '[]' and 'std::string' in null2string(elem.vartype)] How should it look if I break it into multiple lines? I couldn't find

How to assign the same style to a group of edges?

好久不见. 提交于 2019-12-18 12:47:33
问题 I've got a graph that I want graphviz to layout and visualize for me. The graph has 122 edges and 123 nodes. The edges are of 4 different kinds and I want them to be visually distinguishable. However I've not yet decided what would be the best way of doing that, I'd like to play around with the dials a bit. Unfortunately I do not see anything like a "class" or "stylesheet" attribute for edges. I can only set visual attributes individually for every edge (lots of repetition). Perhaps I've

In C#, what's the best way to spread a single-line string literal across multiple source lines?

て烟熏妆下的殇ゞ 提交于 2019-12-18 12:44:59
问题 Suppose that you have a lengthy string (> 80 characters) that you want to spread across multiple source lines, but don't want to include any newline characters. One option is to concatenate substrings: string longString = "Lorem ipsum dolor sit amet, consectetur adipisicing" + " elit, sed do eiusmod tempor incididunt ut labore et dolore magna" + " aliqua. Ut enim ad minim veniam"; Is there a better way, or is this the best option? Edit: By "best", I mean easiest for the coder to read, write,

Using len() and def __len__(self): to build a class

混江龙づ霸主 提交于 2019-12-18 12:07:50
问题 Just curious, Is there any difference (advantages and disadvantages) between using len() or def __len__() when I build a class? And which is the best Python style? class foo(object): def __init__(self,obs=[]) self.data = obs self.max = max(obs) self.min = min(obs) self.len = len(obs) or class foo(object): def __init__(self,obs=[]) self.data = obs self.max = max(obs) self.min = min(obs) def __len__(self): return len(self.data) 回答1: There is a huge difference. The __len__() method is a hook

Out parameters and pass by reference [closed]

随声附和 提交于 2019-12-18 12:05:16
问题 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 . I have joined a new group that has coding guidelines that (to me) seem dated. But just rallying against the machine without valid backup is not going to get me anywhere. So I am turning to SO to see if we can up with rational reasons for/against (hey I may be wrong in my

Public fields in a Data Transfer Object

ⅰ亾dé卋堺 提交于 2019-12-18 11:47:36
问题 In my years of programming I've often made classes that simply group a few variables with their setters and getters. I've seen these types of objects referred to as value objects, domain objects or model objects depending on the context in which they are used. The most fitting term for generic usage seems to be Data Transfer Object (DTO). This describes a POJO that only contains accessors and mutators. I've just written one such object that contains about fifty fields used to set theme