I’ll fly to Salt Lake City on Thursday to set up the booth for Auth0 by Okta at PyCon US 2023, and I’ll be doing demos, answering questions, and playing the accordion in the expo hall on Friday, Saturday, and Sunday!
Drop by the Auth0 booth and check out what we’ve got, which includes the Badger 2040 e-badge, a nifty combination of Python (which we at Auth0 love) and identity (which is Auth0’s business)!
Join us! I’m ready to talk about all sorts of topics, including:
How I got started with mobile development, and how you can get started
The differences between native iOS, native Android, and cross-platform mobile development tools such as Flutter and React Native, and choosing among them
See that diagram above? That’s a state machine (or more specifically, a finite state machine), which is a model of a program’s behavior. This state machine describes the behavior of an enemy non-player character in a game. Each “box” in the diagram is a state (the status of the program) and each arrow connecting two states is a transition (a change from one state to another). The italicized text for each transition is an input (some change in conditions) that causes the transition to happen.
Want to get a head start on the artificial intelligence wave? Among other things, you’ll need to get a solid understanding of Python and machine learning, and the $10 level of Humble Bundle’s “Cookbooks for Coders” bundle has three great books to get you started:
Plus, you get seven other books covering a number of topics. I personally would benefit from the React, PowerShell, Raspberry Pi, and Regular Expression cookbooks.
I love the “cookbook” format, since it lives in the space between reference books, which are often too dry and provide no usage examples, and tutorials, which can often be a little too directed at solving one problem. Cookbooks give you just enough information to learn how to use a particular language or framework feature so that you can apply that knowledge to solving your particular problem or building the app that you have in mind. I find that I learn the most about a language or framework when I use material from cookbooks and other people’s code in building my own application ideas.
The “Cookbooks for Coders” Humble Bundle is available for another 13 days at the time of this writing. For ten dollars, it’s a pretty sweet deal. I’ve already picked it up, and if you want to get in on some of the machine learning opportunities that are already coming in fast and furious, you should too!
The 5th annual Python Web Conf— an online conference for mid-level to advanced Python developers — takes place next week, from Monday, March 13th through Friday, March 17th. Not only is Auth0 by Okta (where I work) one of the sponsors, but I’ll be in attendance!
My teammate, Jessica Temporal, will deliver one of the keynotes on Monday, March 13th at 1:00 p.m. EDT (UTC-4, and yes, we’ll have just moved to Daylight Saving Time). Her keynote is titled Go With the Flow, and it’s about authentication and authorization flows, which happens to be something that we in Okta and Auth0 are pretty good at.
Juan Cruz Martinez and I will also be in attendance and available for chats throughout each conference day and during the Zoom Breakout Rooms sessions at the end of each of days 1 through 4 — Monday, March 13th through Thursday, March 16th.
Want to find out more about Python Web Conf 2023?How about checking out these 90 videos from Python Web Conf 2022? You’ll find all sorts of topics covered, from the nuts and bolts of the Python programming language, libraries, and tools, but also subjects such as CI/CD, data science, machine learning, better processes, writing documentation, and how to be a better programmer.
As for this year’s conference, Python Web Conf 2023 has 5 tracks:
US$199 if you’d like to attend live, be able to join tutorial sessions, partake int he online social events and have exclusive access to the recordings for 90 days.
US$100 if you only want post-conference videos available to you for 90 days after the event.
There’s also a grant program if you need assistance.
Videos of the sessions will be posted publicaly on YouTube following the 90-day period.
The conference takes place from Wednesday, April 19th through Friday, April 21, with workshops on Wednesday and the main conference taking place Thursday and Friday. Here’s the agenda.
I haven’t been able to find out more about this conference, but you might be able to glean more from the following Twitter accounts:
Teaching a person how to spell out numbers involves a lot of repetition. Tampa Bay’s own Jack Hartmann, whose children’s educational YouTube channel has over a million subscribers and 300 million views, knows this. He’s got a video that teaches kids the words for the numbers 0 through 10:
Don’t underestimate the power of videos for kids — Jack’s laughing all the way to the bank. This online estimator says that his YouTube channel should be earning about $70,000 every month, and keep in mind that his particular line of work has probably benefited from everyone being stuck at home. I may have to do something similar with the accordion when this software fad passes.
If you just wanted to be able to convert any number from 0 through 10 into word form in Python, you could use a list…
…and if you wanted the number 3 in word form, you’d use this:
# This is in the Python REPL
>>> number_words[3]
'three'
You wouldn’t want to take this approach for a larger set of numbers, and you probably wouldn’t want to code it yourself. Luckily, you don’t have to do this in Python, thanks to the inflect.py module.
Using inflect.py
inflect.py is a module that does all sorts of processing to make your programs’ text output grammatically correct. If you hate seeing output like this…
You have 1 items in your cart.
…or this…
You have a egg in your inventory.
…you can use inflect.py to automatically use the correct singular or plural form, use “a” or “an” when appropriate, and so much more.
(I’ll cover inflect.py in greater detail in a future article.)
In addition to all these grammatical goodies, inflect.py can also be used to convert numbers to words.
To use inflect.py, you’ll need to install it first. The simplest way to do so is with pip:
pip install inflect
Once installed, you can use it in your Python programs. Here’s an example:
import inflect
inflector = inflect.engine()
words = inflector.number_to_words(54321)
print(words)
It produces this output:
fifty-four thousand, three hundred and twenty-one
The number_to_words() method has a number of optional parameters that are useful in certain circumstances. For instance, there’s the boolean wantlist parameter, which causes the word output to be broken into “chunks”:
words = inflector.number_to_words(54321, wantlist=True)
It produces this output:
[‘fifty-four thousand’, ‘three hundred and twenty-one’]
Suppose you want the number to be converted into its individual digits as words. You’d use the group parameter:
# This is in the Python REPL
>>> inflector.number_to_words(54321, group=1)
'five, four, three, two, one'
>>> inflector.number_to_words(54321, group=2)
'fifty-four, thirty-two, one'
>>> inflector.number_to_words(54321, group=3)
'five forty-three, twenty-one'
What if you’re using the group parameter set to 1, but want to get all UK English and have it use the word “naught” for zero? Or maybe you want your program to sound like a film noir gangster and say “zip” instead? Or you want it recite a phone number and say “oh”? That’s what the zero parameter is for:
# This is in the Python REPL
>>> inflector.number_to_words(13057, group=1, zero='naught')
'one, three, naught, five, seven'
>>> inflector.number_to_words(13057, group=1, zero='zip')
'one, three, zip, five, seven'
>>> inflector.number_to_words(8675309, group=1, zero='oh')
'eight, six, seven, five, three, oh, nine'
The one parameter does the same thing, but for the digit 1:
# This is in the Python REPL
>>> inflector.number_to_words(13057, group=1, one='unity')
'unity, three, zero, five, seven'
Want to get all Star Trek? Use the decimal parameter to change the default decimal word to “mark”.
# This is in the Python REPL
>>> coordinates = inflector.number_to_words(123.789, group=1, decimal='mark')
>>> print(f"Ensign Crusher, set course to {coordinates}. Engage.")
Ensign Crusher, set course to one, two, three, mark, seven, eight, nine. Engage.
A lot of style guides tell you to spell out the numbers zero through ten, and use the number form for numbers 11 and greater. The threshold parameter makes this easy:
# This is in the Python REPL
>>> inflector.number_to_words(9, threshold=10)
'nine'
>>> inflector.number_to_words(10, threshold=10)
'ten'
>>> inflector.number_to_words(11, threshold=10)
'11'
Go ahead — import inflect.py and play with it. There’s a lot of power in that module, and it goes way beyond just converting words to numbers!