Mostly Linux & Python syntax notes and hyperlinks.

Wednesday, April 29, 2015

python: scope error - from Amir Rachum's newbie mistakes, Part 2

Slightly rephrasing the examples in http://blog.amir.rachum.com/blog/2013/07/09/python-common-newbie-mistakes-part-2/: 
>>> bar=42
>>> bar
42
>>> def foo():
...     print bar
...   
>>> foo()
42
>>> def foo():
...     print bar
...     bar=2
...   
>>> bar
42
>>> foo()
Traceback (most recent call last):
  File "< input >", line 1, in
  File "< input >", line 2, in foo
UnboundLocalError: local variable 'bar' referenced before assignment
>>> def foo():
...     global bar
...     print bar
...     bar=14
...   
>>> bar
42
>>> foo()
42
>>> bar
14

Friday, April 24, 2015

MS Word - Copying a format from one picture to another

I'm creating a document with many small screenshots. I surrounded one of them with a thick blue line, and wanted to do the same for the others. It's very tiresome to right-click, select Format Picture, select Line Style, select Line Color over and over, so I googled: The search for "ms word copy picture format line" led me to support.office.com, specifically: Use the Format Painter which was a feature of which I was unaware.

Apparently, the little whisk broom icon named "Format Painter" on the top-left section of the toolbar can be used to copy formatting from one object to another. I don't know why they didn't name it "Copy Format"--then I would have guessed at its function.

Of course, now that I know that it is something, I mouse over it and see a Tooltip telling me about it, but there are so many dang things associated with MS Word that one doesn't have time to learn or much occasion to use... Anyway..

To use it:
  1. Select the object whose format you want to copy.
  2. Double-click on the Format Painter paintbrush.
  3. Move the cursor back onto your document: the cursor becomes a paint-brush.
  4. Click on as many target objects to which you want to copy the format.
  5. Click "Escape" to stop copying. The cursor returns to normal.