coding-style

Is it possible to format Tooltip-Text (bold, underline… etc)?

▼魔方 西西 提交于 2019-12-19 04:01:55
问题 I want to make some passages of a standard tooltip bold in a WinForms application. Is this possible? If not, is there a (free) tooltip component that allows me to style them (preferably also border and background)? Thanks! 回答1: You can use this type : Balloon tool tip. This let you have some bold title and some color option. You might be able to modify the source to get underline, italic and bold inside the message. Update: You can modify the drawing of the ToolTip (and the FONT object of the

Python: suggestions to improve a chunk-by-chunk code to read several millions of points

这一生的挚爱 提交于 2019-12-19 04:01:02
问题 I wrote a code to read *.las file in Python. *las file are special ascii file where each line is x,y,z value of points. My function read N . number of points and check if they are inside a polygon with points_inside_poly . I have the following questions: When I arrive at the end of the file I get this message: LASException: LASError in "LASReader_GetPointAt": point subscript out of range because the number of points is under the chunk dimension. I cannot figure how to resolve this problem. a

Use of 'super' keyword when accessing non-overridden superclass methods

孤街浪徒 提交于 2019-12-19 02:04:08
问题 I'm trying to get the hang of inheritance in Java and have learnt that when overriding methods (and hiding fields) in sub classes, they can still be accessed from the super class by using the 'super' keyword. What I want to know is, should the 'super' keyword be used for non-overridden methods? Is there any difference (for non-overridden methods / non-hidden fields)? I've put together an example below. public class Vehicle { private int tyreCost; public Vehicle(int tyreCost) { this.tyreCost =

PHP class def: Individual accessors/mutators or __set() with switch()?

烈酒焚心 提交于 2019-12-19 00:15:46
问题 When defining a PHP class, which is preferred/best practice? Are there any key differences I'm overlooking? It seems like it could be more clean, concise, and convenient to write a __set() magic method and put a switch() construct in it with cases for all the private members to which I want to allow access. It wouldn't be called automagically from inside the class, but then again neither would setFoo() , so if I want to use the accessor/mutator internally, I'd have to explicitly call a method

Should I name “makefile” or “Makefile”?

删除回忆录丶 提交于 2019-12-18 18:37:20
问题 Although both names will do the job, what is the correct name for makefiles? GNU `make' homepage uses Makefile , and I guess it is the good way to name it. Any reasons for typing the front M in upper case ? 回答1: What Name to Give Your Makefile chapter of GNU Make manual clarifies it: By default, when make looks for the makefile, it tries the following names, in order: GNUmakefile , makefile and Makefile . Normally you should call your makefile either makefile or Makefile . ( We recommend

python: is it possible to require that arguments to the functions are all keyword?

荒凉一梦 提交于 2019-12-18 15:52:23
问题 To avoid the obvious bugs, I'd like to prevent the use of positional arguments with some functions. Is there any way to achieve that? 回答1: Only Python 3 can do it properly (and you used the python3 tag, so it's fine): def function(*, x, y, z): print(x,y,z) using **kwargs will let the user input any argument unless you check later. Also, it will hide the real arguments names from introspection. **kwargs is not the answer for this problem. Testing the program: >>> function(1,2,3) Traceback

What to put in the IF block and what to put in the ELSE block?

[亡魂溺海] 提交于 2019-12-18 15:03:18
问题 This is a minor style question, but every bit of readability you add to your code counts. So if you've got: if (condition) then { // do stuff } else { // do other stuff } How do you decide if it's better like that, or like this: if (!condition) then { // do other stuff { else { // do stuff } My heuristics are: Keep the condition positive (less mental calculation when reading it) Put the most common path into the first block 回答1: I prefer to put the most common path first, and I am a strong

Rubocop error 'Class definition is too long ruby'

回眸只為那壹抹淺笑 提交于 2019-12-18 14:55:20
问题 I am getting rubocop error 'Class definition is too long. [236/100]'. My class looks like below: class SomeClassName include HelperModule attr_accessor :aaa, :bbb, :ccc .... methods ..... end What might go wrong? The rubocop docs ClassLength says "length of a class exceeds some maximum value". What does it mean? 回答1: This likely means that your class definition takes more than 100 lines of code. 回答2: Yes, this is because the overall lines are considered to be too many by rubucop. I agree

Pythonic: range vs enumerate in python for loop [closed]

蓝咒 提交于 2019-12-18 14:54:04
问题 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 5 years ago . Could you please tell me why it is considered as "not pythonic" when I need the index and the value when looping over a list and use: a = [1,2,3] for i in range(len(a)): # i is the idx # a[i] is the value but rather it is recommended to use for idx, val in enumerate(a): print

'break' statement when using curly braces in switch-case

此生再无相见时 提交于 2019-12-18 13:54:10
问题 I use curly braces with all of my switch case statements in C/Objective-C/C++ I had not, until a few moments ago, considered whether including the break; statement inside the braces was good or bad practice. I suspect that it doesn't matter, but I figure it is still worth asking. switch (foo) { case 1: { // stuff break; } default: { break; } } vs switch (foo) { case 1: { // stuff } break; default: { // stuff } break; } 回答1: Short answer: it doesn't matter. 回答2: Just a give a slightly more