Lets re-learn Python!


OK: here we go. I learned enough Python to write some, and to follow a lot of Jesse & Co’s at VMware. But I didn’t write all that much, I couldn’t check in anything, because there was not way to  test check-in candidates BEFORE going live. Or, at least, I couldn’t find one. And when I asked for help, I didn’t get what I needed.

But now I’m re-learning, since everyone says they want want proficiency in Python in their new hires. Better brush up on it then. .

So step one.  The canonical program in any Python book goes something like:

print (‘Lesson_1.py with single quote’)
print (2 ** 902)

to show off the easy familiarity Python has with very large numbers.

So I expanded on that. More print statements and if else and elif, Adding a demo of indents being isolated – The block for “if” must be all the same indent, the block for  else need to all be the same. But nothing requires the “if” block to match the “else” block. All they have to be is the same within themselves. Parseable.

Next, since we’re always printing things, what does “print()” return? Not-1, according to the if-then. If we print it, its “None”.  And we can test that it equals “None” (string equals is “==”. It does equal “None”.

But not only does it NOT not equal “none”, you can’t ask that question, without declaring/creating a “none”.  But its not a compile time call. The power of late binding is that nobody has checked “none” (or “NoNe”) until the “==” gets it.

And we get a lovely error:

“what comes back when we print one char
None
no char indent
None = print returned 1 or thereabouts
Traceback (most recent call last):
File “lesson_1.txt”, line 40, in <modul
if none == print(” no char indent”):
NameError: name ‘none’ is not defined”

And now our canonical program has an error, so we can canonically use the “try”, “except”, “finally”  statents.

And if we’re  really lucky, the response will have an error and we’ll get a SECOND TRIP through the error handler!

C:\Users\wabbott\python\Lesson_1>python lesson_1.txt
Lesson_1.py with double quote
Lesson_1.py with single quote
3381084999268257576654974623465706281720622886631177741618948537770712976363039
one char indent
else four char indent
elif six char indent
no char indent
print returned not-1 or thereabouts
what comes back when we print one char indent
None
None == print()
None == print returned 1 or thereabouts
we always do this, but don’t make any mistakes!
Traceback (most recent call last):
File “lesson_1.txt”, line 57, in <module>
if none == print(“none == print()”):
NameError: name ‘none’ is not defined

and there we go.

 

# Lesson_1.py
# picking-up the Python thread again, 5 years later.
# All the recruiters hope I know it, better look into that and perhaps I can find a job.
#

#!/usr/bin/python – ha!

try:

print (“Lesson_1.py with double quote”)
print (‘Lesson_1.py with single quote’)
print (2 ** 902)

# Python uses indentation instead of curly braces to identify blocks. Kind of a nice idea.

if 1:
print( ” one char indent”) # this one prints
else:
print( ” two char indent”)
if 0:
print( ” if three char indent”)
else:
print( ” else four char indent”) # this one prints

 

if 0:
print( ” if five char indent”)
elif 1:
print( ” elif six char indent”) # This one prints
elif 0:
print( ” elif seven char indent”)
elif 1:
print( ” elif eight char indent”)

 

 

if print(“no char indent”):
print(” print returned 1 or thereabouts”)
else:
print(”  print returned not-1 or thereabouts”)

print ( print (” what comes back when we print one char indent”))

 

if (None == print(“None == print()”)):
print(” None == print returned 1 or thereabouts”)
else:
print(” None != print returned not-1 or thereabouts”)

 

if none == print(“none == print()”):
print(” none == print returned 1 or thereabouts”)
else:
print(” none != print returned not-1 or thereabouts”)

 

if NoNe == print(“NoNe == print()”):
print(” NoNe ==44 print returned 1 or thereabouts”)
else:
print(” NoNe != print returned not-1 or thereabouts”)

#  except Argument:
# print(“The argument is>”, Argument, “< ” )

print(“And look, now it fell through!”)

finally:

print(“we always do this, but don’t make any mistakes!”)

# ———-X———-X———-X———-X———-X———-X———-X———-X———-X———-X

Advertisements

For Fire Season: Just enough about particle masks


 

http://blog.pksafety.com/respiratory-basics-n95-vs-p100/

I am shocked! Shocked! Common, racist, assertions, don’t appear to be supported by facts:


I was wading through comments on poorly edited, badly structured, opinion piece in the online New York Times and I found this familiar line of baloney in a comment.

“Me”, below, claims: “whites do NOT commit the majority of car jackings, robberies, muggings, murders”.

So I ran a quick look at real data from the FBI. No surprise, 2 of these 4 claims are hard to credit, the statement about robbery appears to be true, and, for murders, no group commits the majority. Blacks are the majority of murder victims. All in 2015. I’m going to check some other years learn more, and will post more here.

There are no discrete “car jacking” or “mugging” statistics, but Assault, Motor Vehicle Theft and Kidnapping would seem a fair approximation. The vast majority of all three are committed by whites.

Here’s my comment in context: Response to racist baloney . Or you can read it here:

“For 2015: https://ucr.fbi.gov/nibrs/2015/resource-pages/nibrs-2015_summary_final-1… 

The majority of murder VICTIMS are black. and a plurality of killers. I expect whites are the majority of killers of other whites.
Homicides:
of whites: 2101; of blacks: 2254; of other/unknown: 152
by whites: 2104; by blacks: 2507; by other/unknown (rounded) 603

Whites are NOT the majority of robbers, and blacks are:
Robbery:
of whites: 45,812; of blacks: 26,861; of other/unk (rnd): 5000
by whites: 26,369 of blacks 64,636; by other/unknown (rounded) 9,850

Assaults: Majority white and white
against whites: 799,095, against blacks, 352,449, against other/unk (rnd): 58,000
by white: 678,428 by blacks 413,872; by other/unknown (rounded) 81,000

Motor vehicle theft: Majority white and white
against whites: 118,314; against blacks 35,644, other/unk: (rnd) 14,000
by whites: 45,791 by blacks 21,544; by other/unknown (rounded) 37,000

Kidnapping/abduction: Majority white and white
of whites, 11,883, of blacks 4,175; by other/unk (rounded) 850
by white: 10,188 by blacks 6,299; by other/unknown 1,175

“Me” also claims “Mass shootings are extremely rare” – depends on how you define “mass shooting” and “rare”. We have a LOT of shootings and multiple victims are often hit.”

 

For thoughts on the original piece, “White Nationalism Is Destroying the West”, in general, see: Somebody has to say these things… or read it here:

“There are steps, small or large, still steps, between anti-immigrant positions, anti-Muslim positions and white nationalism. What, then, is the point of this poorly edited opinion piece? That anti-immigrant movements are a fertile recruiting ground for white nationalists? True, and hardly worth this much close reasoning. That Muslims are the stated, rejected, “Other”, but that white nationalism threatens Western liberalism in general? We’re past that point when discussing anti-Semitic advertising in Hungary. Asserted and accepted. Please go on. 

The last three paragraphs probably should be the first three, and then some support for the assertions in those paragraphs mustered as the body of the piece. As it stands ‘Western” variously means Europe, or Europe and America, and that is probably Europe and the United States of America. Canada dismissed as just more Europeans and Mexico omitted entirely.

Or, is “West” shorthand for “Western Democracy”? What about all the other democracies in the world that aren’t in Europe or even North America? Brazil? South Africa? Japan? South Korea? ( added after submitting to NYT: India? Pakistan? Australia? New Zealand? Argentina? Ghana? etc. etc. etc. )

Since the writer takes their definition of “West” and “White Nationalism” seriously, perhaps they could state and defend their definition, on the way to broader points. Supporting “White nationalism is in many ways a mirror image of radical Islamism.” would be a good start.”

 

 

 

Top 10 Bookstores in the East Bay


A nice write-up on a key subject! Omits “Dan Webb Books”, doesn’t mention “The Booktree” right across the street from “A Great Good Place For Books” but my picks belong in my list. This is theirs and I’m glad to have found it!

The writer mentions the Montclair Egg Shop as a pairing with A Great Good Place for Books. Absolutely yes! Best place I can think of to take a new book or an old friend or both.

Source: Top 10 Bookstores in the East Bay

Has anyone else seen this problem? Here’s a link to a web site:


link to list of fake news sources

https://docs.google.com/document/d/10eA5-mCZLSS4MQY5QGb5ewC3VAL6pLkT53V_81ZyitM/preview

It messes up mightily in Facebook.

Ms Trump’s speech, Ms Obama’s speech, discuss.


Here you go, then. The beginning of Ms. Trump’s speech from last night, and Ms. Obama’s speech from 8 years ago. The repeated parts are the beginning and end of a nice paragraph, in Ms. Trump’s first page, Ms. Obama’s 2nd page (3.5 vs 6 pages, total).  I note that Ms. Trump describes what her parents taught her, without reference to her spouse, while Ms. Obama describes something she and her spouse have in common. There’s also a desirable sentence in Ms. Obama’s original which Ms. Trump, significantly, does not claim. Giving credit to people you don’t know or don’t agree with isn’t really Mr. Trump’s “thing”. Ms. Trump might claim it for her parents or herself, but bringing it up in the context of her husband doesn’t do him any favors.

I’ve included Ms. Trump’s 2nd page because I found the her remark about Mr. Trump’s loyalty rather, uh, unexpected. With all due respect, nobody’s 3rd spouse, after 2 divorces, can really attest to someone else’s “loyalty”. IMHO.

Both speeches are worth reading, what you get here is the context for the sound bytes that are easy to find tonight. Go watch or listen to the complete works, they’re worth your time.

Ms Trump: Thank you very much. Thank you. You have all been very kind to Donald and me, to our young son Barron, and to our whole family. It’s a very nice welcome and we’re excited to be with you at this historic convention. I am so proud of your choice for President of the United States, my husband, Donald J. Trump. And I can assure you, he is moved by this great honor. The 2016 Republican primaries were fierce and started with many candidates, 17 to be exact, and I know that Donald agrees with me when I mention how talented all of them are. They deserve respect and gratitude from all of us. However, when it comes to my husband, I will say that I am definitely biased, and for good reason. I have been with Donald for 18 years and I have been aware of his love for this country since we first met. He never had a hidden agenda when it comes to his patriotism, because, like me, he loves this country so much. I was born in Slovenia, a small, beautiful and then communist country in Central Europe. My sister Ines, who is an incredible woman and a friend, and I were  raised by my wonderful parents. My elegant and hard-working mother Amalia introduced me to fashion and beauty. My father Viktor instilled in me a passion for business and travel. Their integrity, compassion and intelligence reflect to this day on me and for my love of family and America. From a young age, my parents impressed on me the

values that you work hard for what you want in life: that your word is your bond and you do what you say and keep your promise; that you treat people with respect. They taught and showed me values and morals in their daily life. That is a lesson that I continue to pass along to our son, and we need to pass those lessons on to the many generation to follow. Because we want our children — and all children in this nation — to know that the only limit to the height of your achievements is the reach of your dreams and your willingness to work for them. (Ms Trump repeated this about here. It’s not in the transcript.)

I travelled the world while working hard in the incredible arena of fashion. After living and working in Milan and Paris, I arrived in New York City twenty years ago, and I saw both the joys and the hardships of daily life. On July 28th, 2006, I was very proud to become a citizen of the United States — the greatest privilege on planet Earth. I cannot, or will not take the freedoms this country offers for granted. But these freedoms have come with a price so many times. The sacrifices made by our veterans are reminders to us of this. I would like to take this moment to recognize an amazing veteran, the great Senator Bob Dole. And let us thank all of our veterans in the arena today, and those across our great country. We are all truly blessed to be here. That will never change.

I can tell you with certainty that my husband has been concerned about our country for as long as I have known him. With all of my heart, I know that he will make a great and lasting difference. Donald has a deep and unbounding determination and a never-give-up attitude. I have seen him fight for years to get a project done — or even started — and he does not give up! If you want someone to fight for you and your country, I can assure you, he is the ‘guy’. He will never, ever, give up. And, most importantly, he will never, ever, let you down. Donald is, and always has been, an amazing leader. Now, he will go to work for you. His achievements speak for themselves, and his performance throughout the primary campaign proved that he knows how to win. He also knows how to remain focused on improving our country — on keeping it safe and secure. He is tough when he has to be but he is also kind and fair and caring. This kindness is not always noted, but it is there for all to see. That is one reason I fell in love with him to begin with. Donald is intensely loyal. To family, friends, employees, country. (A 3rd wife would know…) He has the utmost respect for his parents, Mary and Fred, to his sisters Maryanne and Elizabeth, to his brother Robert and to the memory of his late brother Fred. His children have been cared for and mentored to the extent that even his adversaries admit they are an amazing testament to who he is as a man and a father.   [snip]

 

Ms Obama: As you might imagine, for Barack, running for president is nothing compared to that first game of basketball with my brother, Craig. I can’t tell you how much it means to have Craig and my mom here tonight. Like Craig, I can feel my dad looking down on us, just as I’ve felt his presence in every grace-filled moment of my life.

At 6-foot-6, I’ve often felt like Craig was looking down on me too … literally. But the truth is, both when we were kids and today, he wasn’t looking down on me. He was watching over me. And he’s been there for me every step of the way since that clear February day 19 months ago, when — with little more than our faith in each other and a hunger for change — we joined my husband, Barack Obama, on the improbable journey that’s brought us to this moment. But each of us also comes here tonight by way of our own improbable journey.

I come here tonight as a sister, blessed with a brother who is my mentor, my protector and my lifelong friend. I come here as a wife who loves my husband and believes he will be an extraordinary president. I come here as a mom whose girls are the heart of my heart and the center of my world — they’re the first thing I think about when I wake up in the morning, and the last thing I think about when I go to bed at night. Their future — and all our children’s future — is my stake in this election. And I come here as a daughter — raised on the South Side of Chicago by a father who was a blue-collar city worker and a mother who stayed at home with my brother and me. My mother’s love has always been a sustaining force for our family, and one of my greatest joys is seeing her integrity, her compassion and her intelligence reflected in my own daughters.

My dad was our rock. Although he was diagnosed with multiple sclerosis in his early 30s, he was our provider, our champion, our hero. As he got sicker, it got harder for him to walk, it took him longer to get dressed in the morning. But if he was in pain, he never let on.

He never stopped smiling and laughing — even while struggling to button his shirt, even while using two canes to get himself across the room to give my mom a kiss. He just woke up a little earlier and worked a little harder.

He and my mom poured everything they had into me and Craig. It was the greatest gift a child can receive: never doubting for a single minute that you’re loved, and cherished, and have a place in this world. And thanks to their faith and hard work, we both were able to go on to college. So I know firsthand from their lives — and mine — that the American dream endures.

And you know, what struck me when I first met Barack was that even though he had this funny name, even though he’d grown up all the way across the continent in Hawaii, his family was so much like mine. He was raised by grandparents who were working-class folks just like my parents, and by a single mother who struggled to pay the bills just like we did. Like my family, they scrimped and saved so that he could have opportunities they never had themselves. And Barack and I were raised with so many of the same

values: that you work hard for what you want in life; that your word is your bond and you do what you say you’re going to do; that you treat people with dignity and respect, even if you don’t know them, and even if you don’t agree with them.

And Barack and I set out to build lives guided by these values, and pass them on to the next generation. Because we want our children — and all children in this nation — to know that the only limit to the height of your achievements is the reach of your dreams and your willingness to work for them. 

And as our friendship grew, and I learned more about Barack, he introduced me to the work he’d done when he first moved to Chicago after college. Instead of heading to Wall Street, Barack had gone to work in neighborhoods devastated when steel plants shut down and jobs dried up. And he’d been invited back to speak to people from those neighborhoods about how to rebuild their community.
The people gathered together that day were ordinary folks doing the best they could to build a good life. They were parents living paycheck to paycheck; grandparents trying to get by on a fixed income; men frustrated that they couldn’t support their families after their jobs disappeared. Those folks weren’t asking for a handout or a shortcut. They were ready to work — they wanted to contribute. They believed — like you and I believe — that America should be a place where you can make it if you try.

Barack stood up that day, and spoke words that have stayed with me ever since. He talked about “The world as it is” and “The world as it should be.” And he said that all too often, we accept the distance between the two, and settle for the world as it is — even when it doesn’t reflect our values and aspirations. But he reminded us that we know what our world should look like. We know what fairness and justice and opportunity look like. And he urged us to believe in ourselves — to find the strength within ourselves to strive for the world as it should be. And isn’t that the great American story?

It’s the story of men and women gathered in churches and union halls, in town squares and high school gyms — people who stood up and marched and risked everything they had — refusing to settle, determined to mold our future into the shape of our ideals. [snip]

 

 

Gavin Green remembers CAR journalist Russell Bulgin by CAR Magazine


Gavin Green remembers CAR journalist Russell Bulgin by CAR Magazine.

Russell Bulgin was a terrific automotive writer who also covered bicycles beautifully. A graceful and wide ranging writer, he died at a very young age, in 2002. If you’ve never read his stuff, search it out. I found out about him when his work started appearing in Autoweek, but he’d been in CAR and other publications years before that.

A sad loss, but someone I was glad to have shared the planet with.

You could do worse than starting with Mr. Green’s write up, but do search out Bulgin’s cycling work too!

Bill