At the time this article was published, there are 3 days and 21 hours remaining to get Humble Bundle’s “Ultimate Python Bookshelf” bundle. Depending on how much you’re willing to spend, you can get 3, 8, or 24 books at a deeply discounted price, and some of the money goes to two worthy charities. Read on to find out more…
The books
Depending on how much you pay, you’ll get 3, 8 or 24 books.
If you pay $1 – $9.99, you get these books:
The Python Workshop
The Statistics and Calculus with Python Workshop
Web Development with Django
If you pay $10 – $17.99, you get the books above, along with:
Hands-on Exploratory Data Analysis with Python
Hands-on Machine Learning with scikit-learn and Scientific Python Toolkits
Django 3 by Example
Python Automation Cookbook
Hands-on Genetic Algorithms with Python
And if you pay $18 or more, you get all the books above, plus:
Python Data Cleaning Cookbook
Deep Reinforcement Learning with Python
Data Engineering with Python
Modern Python Cookbook
Applying Math with Python
Python Image Processing Cookbook
Python Feature Engineering
Practical Python Programming for IoT
Python Algorithmic Trading Cookbook
Applied Computational Thinking with Python
Hands-on Python Natural Language Processing
Hands-on Simulation Modeling with Python
Mastering Python Networking
Artificial Intelligence with Python
Python for Finance Cookbook
Quantum Computing with Python and IBM Quantum Experience
All Humble Bundles route some of each bundle’s price to one or more charities. In the case of The Ultimate Python Bookshelf bundle, there are two charities that will benefit:
Doctors Without Borders / Médécins Sans Froniteres: An international, independent medical humanitarian organization that delivers emergency aid to people affected by armed conflict, epidemics, natural and man-made disasters, and exclusion from health care in nearly 70 countries.
Stop AAPI Hate: A national coalition addressing anti-Asian racism across the U.S. The coalition was founded by the Asian Pacific Policy and Planning Council (A3PCON), Chinese for Affirmative Action (CAA) and San Francisco State University’s Asian American Studies Department. Between March 19, 2020 and February 28, 2021, Stop AAPI Hate has received 3,795 reported incidents of racism and discrimination targeting Asian Americans across the U.S..
Wait a minute — there are Packt books. Are they worth getting?
As you were reading this article, you were probably wondering about the issue of the less-than-stellar reputation of Packt’s books and if I was going to raise the issue.
Consider the issue raised, Gentle Reader.
When they were starting out, it seemed that Packt took whatever author they could get to write about the hot tech topics of the moment and rushed those books to market. Over the years, the quality of their authors, review process, and books seems to have improved. I know for a fact that Tampa-based iOS developer Craig Clayton has written some excellent books on iOS development for Packt — because I bought them all.
I decided to buy the bundle. I paid the recommended $25 for these reasons:
Some of the money goes to two good causes.
At $25 for 24 books, that’s less than $1.05 per book.
I’m at the point where I won’t even notice a “missing” $25.
I don’t consider it $25 spent, but $25 invested.
That last point requires a deeper explanation:
If at least a handful of these books are good and provide me with something that I can use at work, in my own programming projects, or in my articles, I will have collected a good return on my investment.
Even if most of them are bad, it will still be a worthwhile investment because the 25 books span a wide array of Python topics, and will give me a better idea of what I don’t know, and better still, what I don’t know I don’t know. I can then look for better sources of information.
As I go through each of these books, I’ll post my findings and opinions here.
How to order the bundle
Once again, Humble Bundle’s “Ultimate Python Bookshelf” bundle is available until Monday, April 26 at 2:00 p.m. EDT (UTC-4). If you wanted to learn Python, sharpen your Python skills, or expand your knowledge of where you can apply Python, this bundle is worth considering.
But it’ll be a little bit more than just Python. It’ll be about using Python to automate certain tasks and assist you in others.
You can learn a lot about a programming language from the coding projects featured in tutorials, but sometimes, that problems tackled in those projects can seem as if they don’t apply to the the kinds of problems that you’d like to tackle with code.
In the upcoming “Coffee and Code”, I’m going to show you how I use Python and Jupyter Notebooks to automate certain tasks to give me more time during the day and make those tasks less error-prone.
In the beginning, there weren’t that many events in the area, and putting the list together would take about an hour. As Tampa Bay’s tech scene grew bigger, more events came up, and creating the list grew into a task that could easily take up two or three hours — sometimes even longer.
That’s when I decided to create a couple of Python scripts to speed up the process. I’ll show you how I put those scripts together, and even give you to the code so that you can tinker with it and create your own tools to automate your life and make it easier.
That’s my plan — to show you how I think when I’m trying to use Python to automate processes and solve problems in my everyday life and work, and give you concrete code examples that you can use, modify, experiment with, and learn from!
Every Friday, I publish the Friday 5, a list of 5 links to useful things for coders.
In this week’s Friday 5: a closer look at JavaScript’s ternary operator, JSON’s interop vulnerabilities, a free Python course on Udemy, reading, editing, and erasing Exif metadata from photos, and questioning a specific kind of interview question.
JavaScript’s version of the ternary operator — ?:, also known as the “conditional operator”, is examined very thoroughly in this article. It goes beyond the standard “avoid it; it makes your code hard to read” advice, and shows cases where it does make your code easier to read, reason about, and maintain.
“TL;DR: The same JSON document can be parsed with different values across microservices, leading to a variety of potential security risks. If you prefer a hands-on approach, try the labs and when they scare you, come back and read on.”
For a limited time only — that is, until Sunday, April 4, you can get the Udemy course based on the book Automate the Boring Stuff with Python for free! The book, and hence the course, is quite good; in fact, I used it as one of the texts for the Python courses I taught last year. Just click the link above or use the coupon code APR2021FREE at checkout.
I’ll admit it — this article’s mine; I wrote it for work. It covers the use of the Piexifjs JavaScript library to read, edit, and erase the Exif metadata in digital photos.
It doesn’t happen often in interviews for front-end developers, but I have been asked linked list questions in interviews for native mobile and back-end positions. Mind you, I haven’t actually needed to build a linked list for anything work-related — ever. So why do interviewers ask linked list questions?
Every Friday, I publish the Friday 5, a list of 5 links to useful things for coders.
In this week’s Friday 5: a site that catalogs VS Code’s surprising capabilities, a look at the darker corners of Go, background processing in Android, a full-text search in 150 lines of Python, and generating brighter and darker versions of color in JS.
Visual Studio Code is a far more capable editor than you might suspect, and the VS Code Can Do That?! can help you discover tips, tricks, and techniques to help you get the most out of this editor.
Each tip/trick/technique comes with a video showing the tip/trick/technique in action and a link to a more detailed description of the tip/trick/technique.
While simplicity is at the core of Go philosophy you’ll find in further text it nevertheless enables numerous creative ways of shooting yourself in a foot.
Since now I have used Go for production applications for several years and on the account of the many holes in my feet I thought I’d put together a text for the fellow noob students of Go.
My goal is to collect in one place various things in Go that might be surprising to new developers and perhaps shed some light on the more unusual features of Go. I hope that would save the reader lots of Googling and debugging time and possibly prevent some expensive bugs.
Here’s an article from the Auth0 Developer Blog, where I’m one of the writers/editors:
Android apps use the main thread to handle UI updates and operations (like user input). Running long-running operations on the main thread can lead to app freezes, unresponsiveness and thus, poor user experience. To mitigate this, long-running operations should be run in the background. Android has several options for running tasks in the background and in this article, we’ll look at the recommended options for running different types of tasks.
If you’ve wondered how full-text search engines work and thought about building your own, this basic implementation in Python is worth trying out. In this article, you’ll build an engine that searches Wikipedia’s article abstracts and ranks them for relevance, and it’ll do so in milliseconds!
The article covers these major topics:
Collecting and formatting the data
Indexing the collected data (which includes stemming the words in the data to their basic forms)
TinyColor is a fantastic JavaScript library that can help you out with a whole bunch of tasks when you’re working with colors. This article takes a quick look at this more-useful-than-you-might-think library.
Once again, it’s time to list Tampa Bay podcasts that you, the Global Nerdy reader, might find informative, interesting, and illuminating!
In the last list, I listed the podcasts from longest-running to newest. This time, I’m doing two things:
I’m listing them from newest to longest-running, and
I’m adding a new podcast to the list: Space and Things, a space news, history, and science podcast. It may not be directly software developer-related, but it’s definitely software developer-adjacent, and it’s a fun listen!
Space and Things is the newest podcast on this list, and it has the distinction of being the only one here that isn’t about software development. Instead, it’s about…well, you get three guesses. Just read its name.
Space and Things features two hosts:
Emily Carney: A veteran of the United States Navy, Carney became a freelance writer back in 2008 and started a blog called This Space Available, which is hosted by the National Space Society.In 2011, Carney founded a facebook group Space Hipsters, of which I am a member. Originally intended to be a place to share news and insights amongst friends, this community has now grown to close to 20,000 members including astronauts, engineers, scientists, historians and space flight enthusiasts from around the globe.
Dave Giles: Giles is a singer/songwriter from London, England who has always had a passion for space flight. Since his early years he’s been looking skyward and though he ended up wielding a guitar for a living, space exploration is alway on his mind and one of his most popular songs is about astronaut Gene Cernan, ‘The Last Man On The Moon’.In 2019 to celebrate the 50th anniversary of Apollo 11, Giles visited all of the crewed space vehicles flown by NASA from Freedom 7 to the Space Shuttle Orbiters.
Here are Space and Things’ podcasts from this year. They’ve been busy:
STP 29 – This week we talk to author, historian and curator of the Project Apollo collection at the Smithsonian National Air and Space Museum to discuss her new book, ‘Operation Moonglow: A Political History of Project Apollo’.
STP 28 – This week Emily teaches Dave about the existence of possibly the worst space movie of all time… We’d love to know if you’ve seen it, or if you have other films which would qualify for that title.
STP 27 – This week we break away from our normal scheduling to bring you a panel to discuss how to best support woman in the space community. Next week we’ll catch up on all the news we’ve missed this week, but we feel that this is a discussion worth having. If you have anything you’d like to contribute to the discussion please do get in touch.We asked three time space shuttle astronaut Mike Mullane and astronaut wrangler Christina Korp to join us to discuss this topic. The full video can be seen on our facebook page.
STP 26 – What a week. Two amazing stories this week which we hope will inspire you as much as they have us!
STP 25 – This week we preview the brand new season of Apple TV’s ‘For All Mankind’ which premiers on Friday 19th February. We were lucky to be able to talk to show’s creator Ronald D. Moore and we hope you enjoy the interview. ‘For All Mankind’ is an alternative history show which starts with the idea that the Soviet Union were the first to walk on the moon.
STP 24 – This month is well and truly Mars month with three separate missions from three different countries arriving at the red planet, so we asked Elizabeth Howell and Nicholas Booth to join us. The pair have recently released a fantastic book ‘The Search for Life on Mars: The Greatest Scientific Detective Story of All Time’ which is well worth checking out!
STP 23 – An action packed show for you. Loads to talk about. Chinese rockets, bio fuel rockets, space walks, SN9, mission announcements, private astronauts, Ham the astrochimp, the Apollo 14 50th anniversary, the Apollo 11 Quarantine film, the Mobile Quarantine Facility and a new Apollo 16 movie…. how do we fit it in? Well we just about did it! We hope we’ve done everything justice here.
STP 22 – This week we have a very special interview with Ben Feist, the technical consultant for the Apollo 11 movie and the new Apollo 11 Quarantine movie. He also started the Apollo Real Time website and now works for NASA. It’s an amazingly inspiring interview. We hope you enjoy.
STP 21 – It’s been another very busy week in the world of space flight and we do our best to bring you up to date, but we also pay tribute to Dr. William Thornton, former NASA astronaut who died aged 91 last week.
STP 20 – We love pondering what might have happened if events transpired slightly differently, and it turns out that there are plenty of great authors who have delivered us some fantastic pieces about these very ideas. So this week we have a talk about some of our favourite alternative space histories.
STP 19 – In our first podcast of 2021 we spend some time talking about two people from the world of space who we think have been over looked. There are obviously thousands of people who fit this bill, but this podcast isn’t going anywhere soon, so we’ll do our best!
Friends That Code is hosted by Mike Traverso, whom locals may know from the Tampa Bay Google Developers Group meetup and other Google-y events. In this podcast, he showcases…
…some amazing people I know that just happen to write code for a living. Whether they started off intending to code or just happened into it, we get to hear about the types of people you’ll meet, things you’ll get to do, jobs you’ll have along the way, and advice from some awesome coders along the way!
27 – How to learn by teaching with Nate Ebel — Developer, Instructor, Teacher, Author, Conference Speaker, Google Developer Expert, YouTuber, Podcaster and man with a voice totally suited for crime solving serial podcasts… Ladies and gentlemen, today’s guest is Nate Eble.
The Mike Dominick Show is the second-newest of the podcasts in this list, and it has an open source focus.
His most recent podcasts:
40 – Monica Ayhens-Madon
Mike sits down with Monica Ayhens-Madon to discuss the People Powered Book Club, fostering open-source and their eclectic educational backgrounds. This is an amazingly varied and fun chat!
…a show dedicated to helping developers to grow their career. Topics include Test Driven Development, Clean Code, Professionalism, Entrepreneurship, as well as the latest and greatest programming languages and concepts.
Episode 187 – Agile Conversations with Fredrick & Squirrel — Douglas Squirrel has been coding for 40 years and has led software teams for 15 of them. He is an executive coach and consulting CTO in London, making use of his extensive experience growing teams and advising startup founders and senior managers. His previous roles included founding CTO at TIM Group and VP Engineering at e-commerce startup Secretsales. He has consulted with a wide variety of London startups including Geckoboard, Lostmy.name, DueDil, Kano, and MarketInvoice.Jeffrey Fredrick is an internationally recognized expert in software development and has over 25 years’ experience covering both sides of the business/technology divide. An early adopter of XP and Agile practices, Jeffrey has been a conference speaker in the US, Europe, India and Japan. Through his work on the pioneering open-source project CruiseControl, and through his role as co-organizer of the Continuous Integration and Testing Conference (CITCON), he has had a global impact on software development. Jeffrey’s Silicon Valley experience includes roles as Vice President of Product Management, Vice President of Engineering, and Chief Evangelist. He has also worked as an independent consultant on topics including corporate strategy, product management, marketing, and interaction design. Jeffrey is currently Chief Technology Officer and Head of Product & Marketing in London at TIM, an Acuris Company. He also runs the London Organisational Learning Meetup and is a CTO mentor through CTO Craft.
Episode 186 – GitOps with Kelsey Hightower — Kelsey is a seven figure developer and Principle Engineer for Google Cloud. On this episode we discuss the latest with GitOps, what it is and how it can help your organization.
Episode 185 – Game Development with Lana Lux — Lana Lux joined us to talk about Game Development with Unity. Lana is a UX Designer and Game Developer based in Toronto. Currently she’s working on Strain: An apocalyptic, pandemic survival game.
Episode 184 – Cloud Native with Facundo and Faheem — Faheem Memon and Facundo Gauna join us to talk about transitioning into Cloud-Native (Kubernetes/Docker) as a .NET Developer.Faheem is a seasoned architect with hands-on experience in application engineering, cloud, containerization, automation, and mobile technologies. Facundo is a solutions architect specializing in Kubernetes on Azure.
Episode 183 – Developer Velocity with Amanda Silver — Amanda Silver is CVP of Product for Developer Tools at Microsoft. She was one of the primary designers on the LINQ project (Language INtegrated Query) which incorporates query expressions and XML as a first-class types in .NET. She has been involved with Chakra, the JavaScript engine that powers Edge, since 2009 which was open sourced earlier this year. In 2012, her team launched TypeScript – a cross-platform, typed, superset of JavaScript that compiles to plain JavaScript. Her team delivers the Visual Studio platform and Visual Studio Code. Unleashing the creativity of developers is her unrelenting passion.
Episode 181 – Marten DB with Jeremy D. Miller — Jeremy Miller is a Senior Software Architect at Calavista Software. Jeremy began his software career writing “Shadow IT” applications to automate his tedious engineering documentation, then wandered into software development because it looked like more fun. Jeremy is heavily involved in open source .NET development as the author of StructureMap, Storyteller, and as the lead developer of Marten. Jeremy occasionally manages to write about various software topics at http://jeremydmiller.com.
Episode 180 – Felienne Hermans: The Programmer’s Brain — Felienne (/Fay-lee-nuh/) is a scientist working at Leiden University as an associate professor. Her book, “The Programmer’s Brain” is out now as an Manning Books Early Access Program.The Programmer’s Brain covers everything that programmers should know about how their brains work, to make their work more effective and emphatic. The book teaches techniques for speed reading code, understanding highly complex code and choosing better variable names.
Episode 179 – Uno Platform with Jérôme Laban — Jérôme is the CTO of the open-source Uno Platform, and a 4x recipient of the Microsoft MVP award.The Uno Platform is a framework that aims to improve the development cycle of cross-platform apps using Windows, iOS, Android, and WebAssembly using Mono and Xamarin. It is also Open Source (Apache 2.0) and available on GitHub.
Of the podcasts in this roundup, Thunder Nerds — “A conversation with the people behind the technology, that love what they do… and do tech good” — has been around the longest, with 274 episodes over five seasons to date. You’ve probably seen the hosts at local meetups and conferences; they’re Sarrah Vesselov, Frederick Philip Von Weiss, and Brian Hinton.
278 – 🚀 Building a Community with Kent C. Dodds — In this episode, we get to speak with software engineer educator, Kent C. Dodds. We discuss community, giving back, and future technology.
277 – 🤖 How to Build a HomeLab with Jared Rhodes — In this episode, we get to speak with Jared Rhodes: Microsoft MVP, and Pluralsight Author. We discuss what it takes to build a HomeLab. We review the technology, hardware, software, and economic logistics to get you started.
276 – 🧭 Build a Safer & More Compassionate Web with Lisa Welchman & Andy Vitale — In this episode, we get to speak with Lisa Welchman & Andy Vitale. We discuss their new podcast and how we can build a safer and more compassionate web. We also chat about digital governance and how companies can own their accountability.
275 – 🦇 Build a Better Bat Cave with Jeffrey Zeldman — In this episode, we get to speak with King of Web Standards, Jeffrey Zeldman. We discuss the current situation with COVID and how it is impacting our lives at work. We also dive into Jeffrey’s background and lessons from his career journey. Then we chat about believing in yourself, making your own opportunities, and building a better bat cave.
What happened at the first Programmers of Portables meetup?
The first Programmers of Portables meetup took place last night, and we made our first steps towards making our first videogame. We met over Zoom, where I shared my screen and led the group in a “code along with me” exercise as we started writing a simple videogame from scratch.
This article covers what we did last night, complete with the code that we wrote. If you were there, you can use this for review. If you weren’t, you should still be able to look at what we did and follow along.
This article is primarily a collection of the code we wrote and the recording of the session. In later articles, I’ll go over Pygame programming in more detail. In the meantime, if you’ve like to learn more about Pygame, here are a couple of resources:
The first part of the session was devoted to downloading and installing the prerequisites for writing videogames with Python.
A code editor (such as Visual Studio Code)
Any application that calls itself a code editor will do.
I tend to use Visual Studio Code these days, because I’ve already done my time using earlier versions of vim (in the late ’80s, I used a variant called ivi, short for “improved vi”) and Emacs (back when the joke name was “Eight megs and constant swapping”). VS Code is pretty much the same across all the platforms I use — macOS, Windows, Linux, and Raspberry Pi OS — and it feels like a present-day app, and not leftovers from the 1970s.
A distribution of Python 3 (such as Anaconda Python)
We’re programming in Python (preferably Python 3.7 or later), so any reasonably recent Python distribution will do.
I like the Anaconda Python distribution because iy includes a lot of useful libraries and other tools that you’ll need when using Python for things such as data science, and the experience is pretty much the same across macOS, Windows, and Linux.
The final prerequisite is Pygame, a cross-platform set of packages that supports game development in Python. It’s been around for 20 years (its was first release in the fall of 2000), and it’s a fun, fantastic 2D game programming platform.
To install it, you’ll need to go to the command line:
macOS and Linux users: Open a terminal and enter the command pip install pygame
Windows users using Anaconda Python: Open the Start Menu, select the Anaconda Python folder, and run Anaconda Command Prompt, where you’ll enter the command pip install pygame
The first version: A blank black screen
With the prerequisites gathered and installed on our computers, it was time to start working on the game. We worked on it in steps, each time producing an improved version of the game.
The first version of the game wasn’t terribly impressive, as it ended up being a blank black window that did nothing. Still, it was a working program, and the code we wrote would function as a framework on which we’d eventually build the rest of the game:
Here’s its code:
# The first version of the game:
# An 800-by-600 black window
# (Don’t worry; it gets better)
import pygame
# Constants
# =========
# Screen dimensions and refresh rate
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
FRAMES_PER_SECOND = 60
# Colors
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
# Initialization
# ==============
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
# Game loop
# =========
running = True
while running:
# This method should be called once per frame.
# It calculates the number of milliseconds since the last
# call to clock.tick() in order to limit the game’s framerate
# to a maximum of FRAMES_PER_SECOND.
clock.tick(FRAMES_PER_SECOND)
# Handle events
for event in pygame.event.get():
# Check to see if the user has closed the window
# or hit control-c on the command line
# (i.e. Has the user quit the program?)
if event.type == pygame.QUIT:
running = False
# Draw game objects to the screen surface
screen.fill(BLACK)
# Update the screen with the contents of the screen surface
pygame.display.flip()
# Exit the game
pygame.quit()
The second version: A rightward-moving green square
The second version of the game built upon the code from the first, and was slightly more impressive. It featured an actual image on the screen, complete with animation: a green square, travelling from left to right across the screen, and “wrapping around” back to the left side after it disappears from the right side of the screen.
Here’s its code:
# The second version of the game:
# An 800-by-600 black window,
# now with a rightward-moving green square!
import pygame
# Constants
# =========
# Screen dimensions and refresh rate
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
FRAMES_PER_SECOND = 60
# Colors
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
# Sprites
# =======
class Player(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((50, 50))
self.image.fill(GREEN)
self.rect = self.image.get_rect()
self.rect.center = (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
def update(self):
self.rect.x = self.rect.x + 5
if self.rect.left > SCREEN_WIDTH:
self.rect.right = 0
# Initialization
# ==============
# Initialize screen and framerate
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
# Create sprites and sprite groups
all_sprites = pygame.sprite.Group()
player = Player()
all_sprites.add(player)
# Game loop
# =========
running = True
while running:
# This method should be called once per frame.
# It calculates the number of milliseconds since the last
# call to clock.tick() in order to limit the game’s framerate
# to a maximum of FRAMES_PER_SECOND.
clock.tick(FRAMES_PER_SECOND)
# Handle events
for event in pygame.event.get():
# Check to see if the user has closed the window
# or hit control-c on the command line
# (i.e. Has the user quit the program?)
if event.type == pygame.QUIT:
running = False
# Update the game state
all_sprites.update()
# Draw game objects to the screen surface
screen.fill(BLACK)
all_sprites.draw(screen)
# Update the screen with the contents of the screen surface
pygame.display.flip()
# Exit the game
pygame.quit()
The third version: The green square, now under user control!
The final version of the game was one where we made the green square interactive. Instead of continuously travelling from left to right on the screen, the square stays put until the user presses one of the arrow keys. When that happens, the square moves in the appropriate direction. The square is constrained so that it can’t go offscreen.
Here’s its code:
# The third version of the game:
# The green square, now under user control!
import pygame
# Constants
# =========
# Screen dimensions and refresh rate
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
FRAMES_PER_SECOND = 60
# Colors
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
# Sprites
# =======
class Player(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((50, 50))
self.image.fill(GREEN)
self.rect = self.image.get_rect()
self.rect.center = (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
def update(self):
# Get the state of all the keys
keys = pygame.key.get_pressed()
# Check the retrieved state to see if any
# arrow keys have been pressed
# =======================================
# Is the user pressing the left-arrow key,
# and is the sprite’s left edge NOT flush
# with the screen’s left edge?
if keys[pygame.K_LEFT] and self.rect.x > 0:
self.rect.x = self.rect.x - 5
# Is the user pressing the right-arrow key,
# and is the sprite’s right edge NOT FLUSH
# with the screen’s right edge?
if keys[pygame.K_RIGHT] and self.rect.x < SCREEN_WIDTH - self.rect.width:
self.rect.x = self.rect.x + 5
# Is the user pressing the up-arrow key,
# and is the sprite’s top edge NOT FLUSH
# with the screen’s top edge?
if keys[pygame.K_UP] and self.rect.y > 0:
self.rect.y = self.rect.y - 5
# Is the user pressing the down-arrow key,
# and is the sprite’s bottom edge NOT FLUSH
# with the screen’s bottom edge?
if keys[pygame.K_DOWN] and self.rect.y < SCREEN_HEIGHT - self.rect.height:
self.rect.y = self.rect.y + 5
# Initialization
# ==============
# Initialize screen and framerate
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
# Create sprites and sprite groups
all_sprites = pygame.sprite.Group()
player = Player()
all_sprites.add(player)
# Game loop
# =========
running = True
while running:
# This method should be called once per frame.
# It calculates the number of milliseconds since the last
# call to clock.tick() in order to limit the game’s framerate
# to a maximum of FRAMES_PER_SECOND.
clock.tick(FRAMES_PER_SECOND)
# Handle events
for event in pygame.event.get():
# Check to see if the user has closed the window
# or hit control-c on the command line
# (i.e. Has the user quit the program?)
if event.type == pygame.QUIT:
running = False
# Update the game state
all_sprites.update()
# Draw game objects to the screen surface
screen.fill(BLACK)
all_sprites.draw(screen)
# Update the screen with the contents of the screen surface
pygame.display.flip()
# Exit the game
pygame.quit()
In addition to picture data, photos taken with smartphones and modern digital cameras contain metadata, which is additional information about the photo. This metadata is stored in a format called EXIF, which is short for EXchangeable Image File format, which is a continually evolving standard for information added to digital image and sound recordings.
In photos, EXIF can include information such as:
The dimensions and pixel density of the photo
The make and model of the device used to take the photo
Zoom, aperture, flash, and other camera settings when the photo was taken
The orientation of the device when the photo was taken
When the photo was taken
Where the photo was taken
Which direction the camera was facing
The altitude at which the photo was taken
My article will show you how to use Python’s exif module to access this information, as well as how to alter it (I show you how to tag your photos so it seems as if they were taken at Area 51) or erase it.
EXIF data was recently in the spotlight as a result of the January 6th riots in Washington, DC. Many of the rioters posted photos to Parler, which did not strip EXIF data from photos uploaded to it.
While Parler’s sloppy security was by and large good news, there’s still good reason to follow good security practices, and part of that is managing EXIF data in photographs. That’s what my article covers, and in a fun way as well!