mac

 

3h
awarded Nice Question
Mar
26
awarded Nice Answer
Mar
24
awarded Notable Question
Mar
20
awarded Curious
Mar
10
comment How to test or mock "if __name__ == '__main__'" contents
If you have any logic in the block indented under if __name__ ... then you are doing it wrong and should refactor. The only line of code under if __name__... should read: main().
Mar
9
comment How to test or mock "if __name__ == '__main__'" contents
I appreciate the creativity and perseverance in finding a solution, but if you were in my team, I would veto this way of coding. One of the strenghts of Python is its being highly idiomatic. if __name__ == ... is the way to let a module script. Any pythonista will recognise that line and understand what it does. Your solution it's just obfuscating the obvious for no good reason other than scratching an intellectual itch. As I said: a clever solution, but clever does not always equate to correct.
Mar
6
awarded Notable Question
Mar
6
awarded Popular Question
Feb
19
awarded Enlightened
Feb
15
awarded Favorite Question
Jan
25
awarded Notable Question
Jan
21
awarded Famous Question
Jan
20
awarded Popular Question
Jan
14
awarded Good Answer
Jan
7
comment How to run untrusted code serverside?
Docker is not designed as an isolation tool. It is designed for easing "packaging" and distribution of application. That is not to say that is totally insecure (see here for example), but rather that security is not part of their design principles, and it is just plain wrong to indicate it as a "sanboxing tool". To the best of my knowledge the standard way to sandboxing untrusted code is using Virtual Machines or - for those interpreted languages that support it (e.g.: pypy) - the interpreter "sandboxing option"...
Dec
15
comment Better way to write this "double-barreled list" in Python
This (the random.choice example) is pretty much a superior (read: more pythonic) way of doing it. Part of Python's philosophy is "There should be one-- and preferably only one --obvious way to do it" and this relies heavily on having "batteries included" (and using them!!!)
Dec
5
comment How to use Google calendar API with python
@elexhobby - bit.ly/1vV8hpK
Dec
4
comment Accessing Google Contacts Api via OAuth 2.0 and private key aka Service Account
I tried this approach before finding this answer but for me it doesn't work. I am using - as a scope - https://www.google.com/m8/feeds (contacts R/W) but without joy. I noticed that scopes for services get "secognised" and their human-friendly name is displayed beside the URI, but that does not happen with the above one. I suspect it is simply unsupported.
Dec
3
awarded Supporter
Dec
3
awarded Autobiographer
1 2 3 4 5