Another Python Week

Okay, not just Python, but a lot of it.

My happiest time was spent working thorough Adam J. Crymble and William J. Turkel’s Python lessons on Programming Historian at Thanks to Adam Crymble and William J. Turkel, and a shout-out to Twitter and CLIR colleague Miriam Posner, who tested lessons to ensure they worked… I also prepared a spec for what my UTC conversion routines need to do.

I’ve gotten pretty comfortable with switching between Python 2.7 and Python 3.4 in my Anaconda and iPython Notebook environment. I’ve also spent a few hours with Al Sweigert’s Automating the Boring Stuff with Python and several hours reading Mark Lutz’s Learning Python. Also, I recently started going over Mark Summerfield’s Programming in Python 3. Library Safari Online books are really helping. Think I’m finally making my way out of my For Dummies phase. One of my struggles has been with sticking a variable counter in a replacement routine. So you have no idea how happy this code snippet (from chapter 2 of Summerfield’s book) has made me:

>>> element = "Silver"
>>> number = 47
>>> "Element {number} is {element}".format(**locals())
'Element 47 is Silver'

Cause I edited it as follows:

for paranumber in range(50):
    "Paragraph number is {paranumber}".format(**locals())

Almost started crying. After I recovered, tried again, alternate way:

for paranumber in range(4):
    print("Paragraph number is {paranumber}".format(**locals()))

Not sure why you need ** before locals. Still trying to figure that out.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s