coding-style

c#: difference between “System.Object” and “object”

冷暖自知 提交于 2020-01-08 16:22:05
问题 In C#, is there any difference between using System.Object in code rather than just object , or System.String rather than string and so on? Or is it just a matter of style? Is there a reason why one form is preferrable to the other? 回答1: string is an alias for global::System.String . It's simply syntactic sugar. The two are exactly interchangable in almost all cases, and there'll be no difference in the compiled code. Personally I use the aliases for variable names etc, but I use the CLR type

(Python) Coding style parentheses in ifs, loops, etc [closed]

China☆狼群 提交于 2020-01-07 09:36:09
问题 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 4 years ago . Just your personal preference, which do you prefer? if filename in filesAndFoldersList: while a != "TEST": a = input("Input: ") Or if(filename in filesAndFoldersList): while(a != "TEST"): a = input("Input: ") Either one works, so this is just personal preference I think.

Are all using directives viewed the same way as using namespace std?

一个人想着一个人 提交于 2020-01-07 08:31:56
问题 I've easily gotten myself into the habit of prefixing standard identifiers with std:: instead of sticking in a using namespace std; . However, I've started getting into C# and I've noticed that it's very normal to add in whatever using directives are necessary, i.e., you'd see: using System; Console.Write("foo"); instead of: System.Console.Write("foo"); Apparently, as I found out from a C# question on this topic, that usage comes from the fact that individual system namespaces in C# are much,

A more elegant way to control overwriting with try-except-else in python? or Can I do better than C-style code?

ぐ巨炮叔叔 提交于 2020-01-07 04:38:10
问题 I have code that makes a folder and places output files in it. I want to use a try-except-else block and an overwrite option, which can be set to True or False, so that in the case where the folder already exists and overwrite is set to false it will just print that the folder already exists, and in all other cases it will just execute without comment. The only solution I've come up with so far looks like this: def function( parameters, overwrite = False ): try: os.makedirs( dir ) except

Adding a tab to a fan page does not work… error: (#210) Subject must be a page

喜欢而已 提交于 2020-01-06 14:18:15
问题 I'm trying to add a tab to a fanpage using the graph api/PHP SDK and I'm receiving an error : (#210) Subject must be a page I've tried using both the user access_token AND the page access_token but neither work. I've tried using the page id of numerous accounts and still no go. Here is my code: <?php $path="/PAGE_ID/tabs/"; $access_token="ACCESS_TOKEN"; $params = array( 'app_id' => "APP_ID", 'access_token' => $access_token ); try{ $install = $facebook->api($path, "POST", $params); }catch

Piece of code that compiles with gcc but not g++ [duplicate]

对着背影说爱祢 提交于 2020-01-06 08:38:06
问题 This question already has answers here : Closed 9 years ago . Possible Duplicates: Is this a legitimate C++ code? “C subset of C++” -> Where not ? examples ? Could anybody come up with a piece of code that compiles with gcc or any other C compiler, and doesn't compile g++ or any other C++ compiler? UPDATE: I don't mean just keywords UPDATE2: Thank you All for answers. Apparently moderators were less enthusiastic than I was about subtle differences between C and C++. UPDATE3: to moderators:

The `#=>` convention for expected returns

点点圈 提交于 2020-01-06 03:50:09
问题 It is a Ruby convention to use #=> for describing expected returns. I realized that I use # => (with some space or tabs) myself. This is just a convention, and there is no formal specification, so I would like to ask what the convention is among Ruby programmers. Is #=> the only correct way or is preferred, # => is preferred, or Either is almost equally used? And, would there be any reasons to exclude or prefer one form? 回答1: I wouldn't say it's a convention. At least, I haven't read anywhere

Getting ugly SQL Query to work in C#

偶尔善良 提交于 2020-01-06 02:14:26
问题 I am attempting to get a series of values from a few tables in a database. I currently have this code working: SqlDataReader reader = null; SqlCommand myCommand = new SqlCommand("select * from ods_LN_Master", xavierConnection); reader = myCommand.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader["LMBKNO"].ToString()); } However the SQL query that I really want to do is looks like this: select "T1"."C0" AS "Collateral Type", "T1"."C1" AS "Owner Occuppied", "T1"."C2" AS "County

Activity Launch timeout has expired, giving up wake lock! and timeout for HistoryRecord

谁说胖子不能爱 提交于 2020-01-05 08:48:11
问题 I have some warning in my application and i use JSoup concept,my app is working in another system,i can't do that why ? I am getting following errors 1.03-26 15:11:14.296: WARN/ActivityManager(70): Launch timeout has expired, giving up wake lock! 2.03-26 15:11:14.893: WARN/ActivityManager(70): Activity idle timeout for HistoryRecord{450e4348 com.list/.ListActivity} 3.03-26 15:11:25.831: WARN/System.err(407): java.net.UnknownHostException: Host is unresolved: www.dzone.com:80 and am using api

Returning a Static Local Reference

我的梦境 提交于 2020-01-05 05:47:33
问题 Suppose I have a function that will return a large data structure, with the intention that the caller will immediately copy the return value: Large large() { return Large(); } Now suppose I do not want to rely on any kind of compiler optimizations such as return value optimization etc. Also suppose that I cannot rely on the C++11 move constructor. I would like to gather some opinions on the "correctness" of the following code: const Large& large() { static Large large; large = Large(); return