-
-
Notifications
You must be signed in to change notification settings - Fork 381
Adding context manager into thw-python strings-io introduction #90
Conversation
``` | ||
|
||
Also called "with statement", context manager will be responsible for | ||
opening a file, creating file handle called f, and after a block of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since "f" is the name of a variable in the example will be nice using f
.
What about replace "creating file handle called f" with "creating file handle called, in the example, f
"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creating file handle -> creating a file handle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - I'm updating commit according to your comments.
@czterybity Very nice job. Context manager is very useful and are missing in this tutorial. Just take a look at my comment in line 302. After that this PR have my approve. |
On Mon, Oct 21, 2013 at 02:03:42PM -0700, Leszek Tarkowski wrote:
Hooray context managers :).
I like the content, although there are some grammar mistakes (for On the PR-mechanics front, there is no need to merge your pull request
Where it looks like 7dd72ad and 3756d05 are almost identical, except
replacing In the future, it's also good practice to develop changes in
will create a new If you need help with any of the Git manipulations, or want more help |
@wking and @r-gaia-cs - thanks for the detailed reviews and feedback. @wking - Can I put you in charge of helping this PR get integrated into gh-pages? |
On Mon, Oct 21, 2013 at 06:55:14PM -0700, Aron Ahmadia wrote:
I think per-section maintainers would probably be a better approach |
Context manager | ||
--------------- | ||
|
||
Closing a file is something often neglected in Python, due to a fact that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due to a fact -> due to the fact
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
I made a bunch of minor grammar corrections, I hope it's not too messy! |
The current goal is to get instructor trainees comfortable with writing |
@wking - at this point, we need coaching more than consistency. Thanks for flagging the originators of this material, I'll rely on your best judgement for all of the issues you mentioned. |
On Tue, Oct 22, 2013 at 01:58:21AM -0700, Greg Wilson wrote:
A hit list of documentation shortcomings might be useful to guide |
I'm with @wking, as nice as this syntax is, I don't think it fits in the two-day bootcamp format. |
On Mon, Oct 21, 2013 at 06:21:14PM -0700, W. Trevor King wrote:
@czterybity, it looks like you got this done. Congrats :). For typo
is not generally helpful. Commits that encapulate a single semantic @mattphotonman has pointed out a number of possible improvements, but |
On 2013-10-22 1:29 PM, W. Trevor King wrote:
|
Many thanks for @wking for git usage help and @mattphotonman for language corrections. |
@czterybity - Context managers are an awesome concept, but remember that teaching students the why of them rely on the students (all of them, not just the ones who've taken programming classes) having a concept of:
before we start dealing with the semantics of the |
@ahmadia - my point is that maybe we should use them consistently, as "that's the way you should do it", without detailed explanation. Semantics is trivial, it may be actually easier for someone to grasp this |
@czterybity - Okay, point taken. I think that I (or somebody else) needs to take a more detailed look at how we're using This is @wking's show, so I'll try to take a step back here and let him manage this. You're in good hands :) |
I've always used 'open' because (a) that's still what most Python docs
|
@gvwilson - you got the point about other languages. But - IMHO your example is a But you are probably right. My experience is flawed by a fact that "my" Python courses are lasting at leas three days (usually five). |
I agree with @gvwilson's points and would also add that in my experience Again, I think this is the right thing to use and something we should provide |
On Tue, Oct 22, 2013 at 03:11:03PM -0700, W. Trevor King wrote:
For those following along at home, the difference between the original
Still to go are those mentioned in: |
@wking @czterybity - sorry to interject, but I think the consensus so far is that we should make this lesson available (perhaps even expand it), but not locate it within the base material. I agree that we should get +1 from @scopatz before moving it into the notebook. If he feels that it belongs somewhere else (or you don't want to wait for him), we can create a new top-level [tag]-python/context-managers, where tag could either be [thw], [swc], or [czterybity], depending on whether you'd like to seat it one of the lessons or make it standalone. Either way, I'm going to deprecate the non-notebook form of the Markdown file in a separate issue, since we discussed doing this awhile ago and never did. |
@ahmadia - thanks for clarification. |
With the current c5a75c5, changes are:
That's the change suggested here 1, but after the On Wed, Oct 23, 2013 at 01:53:00PM -0700, W. Trevor King wrote:
These are still missing from c5a75c5. For clarity:
|
@czterybity @wking - Would you like this flagged for review? Do you need any other help here? |
On Sun, Nov 03, 2013 at 05:37:59PM -0800, Aron Ahmadia wrote:
I think we're ok. Outstanding issues with the current c5a75c5 are |
I propose merging this in, then letting @ethanwhite decide if it belongs in the |
@gvwilson - this one still is waiting on fixes from @czterybity. |
@czterybity, will you have a chance to do fixes in the next couple of days? We'd like to tag the repo... (I'm OK with this stuff landing where it is, and being copied/moved to the python/intermediate lesson when it materializes.) |
I'll do it this weekend. Sorry about the delay. |
Thanks Leszek, please have it in by Saturday, if possible. On Thu, Nov 28, 2013 at 3:05 PM, Leszek Tarkowski
|
@czterybity - as far as I can tell, this is still waiting on fixes from you. Please ping back if you have any questions or if I can help in some way. |
Hmm, I thought I had it all fixed yesterday. I'll take a look in the morning. |
@czterybity - It looks like you're suggesting leszektarkowski@e9ca532 as the PR. It's missing (from a cursory scan), the suggested fixes by wking here: #90 (comment) I raised an earlier objection about this landing in our tutorial materials, but since the THW material serves a slightly more advanced audience, I'm okay with landing this in for the tag. |
I closed my pull request by mistake... It's always bad to do something with console being tired. |
Reopened :) |
Magic. I think right now it contains all the requested changes. |
Okay, I'll take a look at bringing this in tonight. |
On Sun, Dec 01, 2013 at 02:58:05PM -0800, Aron Ahmadia wrote:
This looks good to me now, but the file it's landing in is gone since |
Yes, that's what needs to happen :) I was planning on adding a merge commit bringing the changes in and deleting this file. |
On Sun, Dec 01, 2013 at 04:45:56PM -0800, Aron Ahmadia wrote:
Sounds good to me. |
Merged in manually in e74d529 |
Many thanks to all of you. See you next time :) |
Using context managers is a very good general practice, allowing to get rid of many lurking bugs.
I hope this basic introduction will encourage fellow coders to use it more often.