Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Use arg is None when you have a function with an argument defaulting to None. That’s okay, because there’s only oneNone.

In most real cases you want to get out if arg is either None offer any false value, so maybe "if not arg" ?

> For testing whether two classes, functions, or modules are the same object, is is okay. Stylistic choice.

If "is" is not better than = I would advise against it in all cases where it is not necessary: always use = except when you do tricky things. The argument that = can be overridden is wrong: if it really is the case, just use another library or fix it. You should nor write defensive code at this level.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: