Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 09 Jun 2000
Offline Last Active Today, 04:45 AM

Posts I've Made

In Topic: Cooking!

02 July 2015 - 08:51 PM

I love to cook. It's winter here in NZ, so I'm all about slow cooking things at the moment. 


Never cooked ramen, but I do some pretty mean yakitori and teppanyaki in summer.

In Topic: Python Immutable member variables?

02 July 2015 - 08:19 PM

Yep, the closest thing to immutability in Python is a property member with a setter that does nothing.

Well, in version 3 you don't even need a setter

>>> class Test:
	def __init__(self, x):
		self.__x = x
	def X(self):
		return self.__x

>>> t = Test(2)
>>> t.X
>>> t.X = 4
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    t.X = 4
AttributeError: can't set attribute

Note that even access control doesn't really exist in Python; you can always introspect the object to determine all of its members. The double leading underscore just excludes it from default name resolution, but dumping the object dictionary shows it plain as day.

yep, and you can modify it too

>>> t.__dict__
{'_Test__x': 2}
>>> t._Test__x = 3
>>> t.X

In Topic: Why The 'Flag Mania' ?

01 July 2015 - 04:37 PM

When Jon Stewart is against you, you've already lost :D

In Topic: If-else coding style

01 July 2015 - 03:21 PM

I have no experience with static code tools for C#, but I will assume that they are basically the same as the tools for Java, in which case I don't recall a single time any suggestion was actually helpful.  I worked one place that used these tools, and I suspect it was because the other programmers were so bad it was the only way they could get their code to run.  I didn't stay there long enough to find out.

I use resharper, mostly for it's refactoring, unit test and navigations tools (go to implementation, I love you!), but it's static analysis is surprisingly good.
It warns about things like access to modified closures or fields that should be read only, but it can go a bit overboard in converting loops to LINQ expressions.
FWIW, resharper will suggest converting 

        if (somecondition) 
            return something; 
            return null; 


return somecondition ? something : null;

Even if you don't like the analysis, I highly recommend it for it's refactoring capabilities.

note: I'm not associated with jetbrains in any way, I just like the tool

In Topic: If-else coding style

30 June 2015 - 05:06 PM


It failed review, because what I had done caused our static code analysis tool to break.

I'm curious, what was the actual issue the tool reported? Or is that confidential?


Probably, NDAs etc. 


But more likely, it was over a decade ago, and I really can't remember the details. :D