Live data from Hacker News

Python for Humans

speakerdeck.com

31–40 of 74 posts

Re: Python for Humans

#31

Earlier quoted context omitted.

Some feedback from reading this page: - Why is your example logger named d? It might seem nitpicky but it's hard to read an example with a meaningless single character variable. - "d.close() # stop logging" - what is this? What does it mean to "stop logging" and why do I want to? - "Add a coroutine" - I would wager the lay Python developer doesn't even know what this word means. - lggr.Lggr() - Why not just name the…

Hi jwpeddle, thanks for all of the feedback! All of the changes I've made are on a branch called 'hn-fix' ( https://github.com/peterldowns/lggr/tree/hn-fix ) if you'd like to take a look. > Why is your example logger named d? It might seem nitpicky but > it's hard to read an example with a meaningless single character variable. No particular reason -- you're right, I will change this now. > "d.close() # stop logging"…

I think "close()" is the appropriate name, as it's analogous to closing a file.

Re: Python for Humans

#32

Earlier quoted context omitted.

Some feedback from reading this page: - Why is your example logger named d? It might seem nitpicky but it's hard to read an example with a meaningless single character variable. - "d.close() # stop logging" - what is this? What does it mean to "stop logging" and why do I want to? - "Add a coroutine" - I would wager the lay Python developer doesn't even know what this word means. - lggr.Lggr() - Why not just name the…

Hi jwpeddle, thanks for all of the feedback! All of the changes I've made are on a branch called 'hn-fix' ( https://github.com/peterldowns/lggr/tree/hn-fix ) if you'd like to take a look. > Why is your example logger named d? It might seem nitpicky but > it's hard to read an example with a meaningless single character variable. No particular reason -- you're right, I will change this now. > "d.close() # stop logging"…

Why not just add an atexit trap that automatically cleans up open logs?

http://docs.python.org/2/library/atexit.html

Re: Python for Humans

#33
post #28

Earlier quoted context omitted.

I'm not sure why you feel this niche requirement requires three question marks. The point of modules like this is to make it easier to do the tasks that 95% of developers are likely to need to do regularly, at the cost of not covering all rare use cases.

I think it is a fairly common requirement to use multiple IPs to avoid throttling or for APIs that restrict access to individual IPs. The fact that he was confused by it does not help his credibility when he is trying to tell people how to design their libraries.

I have yet to ever have to use multiple outbound IPs from the same machine for an HTTP request from Python. It might be "fairly common" for whatever you do, but in terms of the general population, it's not.

Re: Python for Humans

#34
post #32

Earlier quoted context omitted.

Hi jwpeddle, thanks for all of the feedback! All of the changes I've made are on a branch called 'hn-fix' ( https://github.com/peterldowns/lggr/tree/hn-fix ) if you'd like to take a look. > Why is your example logger named d? It might seem nitpicky but > it's hard to read an example with a meaningless single character variable. No particular reason -- you're right, I will change this now. > "d.close() # stop logging"…

Why not just add an atexit trap that automatically cleans up open logs? http://docs.python.org/2/library/atexit.html

I am fairly sure that most of the streams and sockets would get closed when the interpreter exited regardless.

Also, in accordance to the principle of "explicit is better than implicit," it's generally better to avoid messing with global state (such as atexit) behind the scenes, and to provide a way to shut down the logs manually.

Re: Python for Humans

#35
post #32

Earlier quoted context omitted.

Hi jwpeddle, thanks for all of the feedback! All of the changes I've made are on a branch called 'hn-fix' ( https://github.com/peterldowns/lggr/tree/hn-fix ) if you'd like to take a look. > Why is your example logger named d? It might seem nitpicky but > it's hard to read an example with a meaningless single character variable. No particular reason -- you're right, I will change this now. > "d.close() # stop logging"…

Why not just add an atexit trap that automatically cleans up open logs? http://docs.python.org/2/library/atexit.html

LeafStorm got to it before me :)

Re: Python for Humans

#36

requests & envoy have saved me a huge amount of hours. I wish I met Kenneth when he was in Toronto this weekend, I would have bought him anything he wanted.

I'm still in Toronto :)

Haha, alright you name the place & time, I will bring said "anything you want" object.

Re: Python for Humans

#38

Earlier quoted context omitted.

Some feedback from reading this page: - Why is your example logger named d? It might seem nitpicky but it's hard to read an example with a meaningless single character variable. - "d.close() # stop logging" - what is this? What does it mean to "stop logging" and why do I want to? - "Add a coroutine" - I would wager the lay Python developer doesn't even know what this word means. - lggr.Lggr() - Why not just name the…

Hi jwpeddle, thanks for all of the feedback! All of the changes I've made are on a branch called 'hn-fix' ( https://github.com/peterldowns/lggr/tree/hn-fix ) if you'd like to take a look. > Why is your example logger named d? It might seem nitpicky but > it's hard to read an example with a meaningless single character variable. No particular reason -- you're right, I will change this now. > "d.close() # stop logging"…

Maybe you want to support python's with statement instead of a close() method?

Re: Python for Humans

#39

A bit off-topic, but I couldn't find this and was very curious: What font are the slides using in the code snippets? It looks very clean--I didn't realize it was monospace at first.

It is Monofur: http://www.dafont.com/monofur.font, IMO it looks better on slides in small doses than in an editor all day long.

Re: Python for Humans

#40

Slightly off topic: in an effort to become a better programmer, and to improve the Python ecosystem, I've tried to write a "for Humans" style logging library. Would anyone mind giving me feedback? http://peterdowns.com/lggr/

your library has no tests! it's a good effort but I honestly wouldn't use it yet.

a few nit picks: i can't imagine a scenario where i'd want my logger to close stdout (or any other file descriptor) for me.

there is a lot of missing error handling, which is really important for something critical like a logger. what happens when disk space runs out? no timeouts on network operations?

also your SMTP and Gmail loggers don't form valid MIME messages (I can't log non-ascii?). you also seem to just swallow exceptions which is totally not what I would want or expect from a logging library.

keep at it though, the logging module's API (inspired by log4j) is fairly painful.

Post reply on HN