-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop in Unidata datetime intro materials notebook #38
Conversation
🚀 📚 Preview for git commit SHA: 276c1d9 at: https://607f5a578f8ed000dc5259a9--pythia-foundations.netlify.app |
I'll work on massaging this to the template during today's hackathon. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Ok, I've done my best to adapt this to the template. A few issues that I see:
|
🚀 📚 Preview for git commit SHA: 44088ff at: https://60c10a6e17a1510de2fcdc54--pythia-foundations.netlify.app |
🚀 📚 Preview for git commit SHA: 566d7f6 at: https://60c10d5b8923870f2fc17b52--pythia-foundations.netlify.app |
I agree about METAR and the function. Just too many things going on. Honestly, I don't even remember when that got added. |
🚀 📚 Preview for git commit SHA: 10e2bbb at: https://60c1128abdc7741a41fce2fa--pythia-foundations.netlify.app |
Looks great, @dcamron. I just had a few minor suggestions. |
Based on this comment and my own fairly strong feelings about this, I went ahead and removed this section. It leaves behind a cleaner, quicker introductory tutorial. |
🚀 📚 Preview for git commit SHA: 153282e at: https://60c27af5a378a900b8dfc78e--pythia-foundations.netlify.app |
This is looking great! With regard to the inclusion of the "30-second intro to OOP", my sense is that this ultimately belongs elsewhere in the Foundations content, ideally as a later section of the Intro to Python chapter. But it's really good! How about we include it as is in this notebook for now, and later on we can replace it in this notebook with a "reminder about OOP as it relates to datetime" link to where it will ultimately go? |
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.
Looks great!
I will open an issue about this when we merge this PR so we don't forget about it entirely. |
@@ -0,0 +1,617 @@ | |||
{ |
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.
Instead of directly using strftime
, would it be easier for the learner to instead do something like:
print(f'{strike_time: %Hh %Mm %Ss}')
for symmetry with the other string formatting we're using?
Reply via ReviewNB
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.
Wow, I'm actually surprised that that works?
Like, to me it's not intuitive that passing strike_time
as an f-string would let you use things like %H
and have it be interpreted properly.
But then, I only learned about f-strings a few weeks ago!
As far as symmetry, I think the existing content goes for symmetry between strftime()
and strptime()
.
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.
Well, an fstring is just syntactic sugar for format
, which uses an object's __format__
; for a datetime
object, __format__
uses the same code as strftime
.
from datetime import datetime
dt = datetime.now()
# All the same
print(f'{dt:%Y%m%d}')
print('{0:%Y%m%d}'.format(dt))
print(dt.strftime('%Y%m%d'))
It's nice because the %Y
, etc. work the same way as you would '{:6.2f}'.format(1.23)
to format a floating point value.
I'd honestly argue that strftime
is more a relic of the C way of doing things and using f''
/format
is the Pythonic way. But I also find the strptime
and strftime
pair convincing, so I'm not really arguing 😉. It's fine to leave as is.
@@ -0,0 +1,617 @@ | |||
{ |
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.
Would it be good to point out that timezone.utc
is now a thing that exists in the standard library? Basically, you now have a UTC (and only UTC) timezone in the standard library. This was added since the original material was created.
Reply via ReviewNB
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.
Cool, thanks! I will add a little more elaboration here. I think the original was a bit mysterious about why you need a third-party library here.
🚀 📚 Preview for git commit SHA: 6e89dd5 at: https://60c7e31453caca3751ab671e--pythia-foundations.netlify.app |
Ha ha, apparently GitHub Actions works in UTC, which kind of wrecks my new example :-( |
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.
I agree with earlier comments that the "Into to OO" ultimately should be moved elsewhere, but it looks like there are already plans to address this in the future.
This notebook looks great to me!
I added some extra explanation to the UTC example, since it looked funny after executing on the server where local time = UTC. I'll merge this tomorrow in case @dopplershift wants to respond to any of the edits. |
🚀 📚 Preview for git commit SHA: 0c70084 at: https://60c815986aeb136b361930d5--pythia-foundations.netlify.app |
This is a drop-in of this notebook from some of Unidata's introductory python materials that lives alongside our workshop materials. Mostly content-unmodified.
There were some headaches getting this to play nicely with jupyter-book including some hidden rogue
widget
andname
metadata that totally broke the process. Mentioning that for myself and anyone else that might run into similar issues, as the tracebacks weren't particularly helpful.Notes:
datetime