Posts

Showing posts from April, 2020

Python List, Tuple, Set, and Dictionary Comprehensions

Python is known for its clean, concise, English-like syntax. However, not all code lives up to this expectation. For example, it is common to write things like the following:cats = []
for animal in animals:
    if type(animal) is Cat:
        cats.append(animal)

That works, and gives the expected result, but is a bit long. With a list comprehension (a construct that combines iterator assignment with a for loop), the above code would look more like this:
cats = [ animal for animal in animals if type(animal) is Cat ].

Much more concise.
List comprehensions Here's the format for a list comprehension:
[ output for input_item in input_iterable if condition ]

Here's another example:
>>> squares_of_evens = [ number**2 for number in range(0, 11) if number%2 == 0]
>>> squares_of_evens
[0, 4, 16, 36, 64, 100]

The alternative would be:
>>> squares_of_evens = []
>>> for number in range(0, 11):
...     if number%2 == 0:
...         squares_of_evens.append(numb…

Why app auto-updates (on any platform) are an absolute necessity

I know that many people say that you should disable auto-updates on platform XYZ for reason ABC. However compelling those reasons seem, there is a major reason to allow them, and it really should supersede those arguments: security.

I understand that the update might add a virus, but think about it: Do you think it's more likely that the update contains a virus, or contains a patch to stop a virus? The latter is far more likely.

Also, some people argue that updates can make changes people don't like. I know you loved MyFavoriteFeature in MyFavoriteApp, but the same update that removed MyFavoriteFeature may have also fixed a critical vulnerability. It may have even been that MyFavoriteFeature contained the vulnerability.

Another complaint is that updates can make apps freeze and crash. This does happen, but again, a nonfunctional app is better than a hacked device.

Overall, there are three main issues with auto-updates: "The update might add a virus," "I don'…

Samsung Chromebook Plus V2 Review

This is my first Chromebook. I switched from Linux Mint because of the Android support on Chrome OS. So far, I have almost no complaints.

The display is good enough. Nothing spectacular, but more than sufficient for anyone who isn't a videophile. I don't watch movies or TV on my Chromebook. Most of what I do is text (usually programming), and the screen is great for that.

Screen size is perfect. Not too small for a laptop, not too big for a tablet.

Speakers are mediocre. I use them mostly for Google Assistant, which sounds a little tinny but otherwise fine. It plays music OK, but not the greatest quality. If you don't listen to music much on it, then the audio is fine.

Speaking of Google Assistant, it works greatly. Routines are not supported, which is an issue, but Assistant on Chromebooks is still somewhat new.

Both cameras are pretty good. They're comparable what you'd expect from a phone in the $200-300 range. On a laptop/tablet, cameras aren't that big of a pri…

Welcome!

Hi, I'm Sam. Welcome to my blog!
I like programming, especially in Python. A lot of what you see here will be about Python and other programming languages, but you'll also see other tech-related articles.
In particular, I'll write a lot of intros to Python libraries (including some of my own). If you have any suggestions, mention them in the comments!
I'm hoping to build up a good reference on Python programming, and also to have a few reviews on phones, Chromebooks, and other electronics as I need to replace my devices.
If I'm ever compensated for writing a review, I'll be sure to say it, and I won't let it influence my review.