I’m learning Python these days. The reason is that there are two domains I want to explore and play with — finance and artificial intelligence — and everything I want to use is built in Python. Being Ruby my go-to language, a recurring problem I’ve suffered for years is building my own infrastructure for most things I wanted to do in this space. This strategy has been fun but not quite productive, so I decided to become a Python-native for these experiments.
Coming from Ruby, I knew there was a path where I could get comfortable enough with Python pretty quickly. I briefly explored available books, courses, and online resources and decided to go with the official tutorial. As an exercise, I decided to go exclusively with ChatGPT to clarify further questions I had. Here are some of the questions I asked:
- can you write this python line in a more idiomatic way:
squares = list(map(lambda x: x**2, range(10)))
I just wanted to see if it was smart enough to suggest using list comprehensions, as the tutorial did. It was.
- can you create multiline strings indicating the language in Python?
- is this idiomatic in Python?
text = (‘Put several strings within parentheses ‘ ‘to have them joined together.’)
- how to show the type of an identifier in Python?
- what is the difference between dict and dict_items?
- how to iterate in Python with index
- how to convert object to string?
- how do you document code in Python?
- can you print a table with the most common methods for a list in Python
- how can I define equality logic for set elements?
- can you use objects in boolean expressions?
- how to convert object to boolean?
- naming convention for files?
- how can I print values with string interpolation?
- do you need to pass self to every method definition?
- python conventions for naming constants in classes
- can you declare private methods in Python
- but can you provide custom implementations for operators in a custom class?
- Generate code for a class that encapsulates a list of ingredients. It must include a custom iterator. Also, please include an example of how to use it.
- basic examples of regular expressions in Python
- how to convert string to date?
- what’s the equivalent of Ruby’s Gemfile in Python?
The results were mind-blowing. It always provided great responses. Answers both directly addressed my questions and elaborated on the reasons, including examples of code clarifying the answer. For example:
My previous workflow would have been relying on Google, which would have found a good article or Stack Overflow answer. I didn’t miss Google a single time. Actually, the Google path would have slowed me down compared to just asking ChatGPT.
I’m very wary of making predictions in tech, but you don’t have to be Nostradamus to realize that a major change will happen, and it will be fast.
Many years ago, I was puzzled by the “what can I help you with?” prompt from the infamous Microsoft Office Clippit. Of course, it couldn’t help you with anything — the free-text input would just trigger a quite terrible documentation search — but the initial idea where you could ask a computer for help by just speaking human was as intriguing as appealing. With all the advancements since then, ChatGPT is the first system I see that doesn’t feel like a thin facade on top of a search engine.
Because the scene felt somehow mature, it’s fascinating to see a disruptive technology appear out of nowhere. I think lots of well-established actors in the space will either have to adapt fast or face the consequences, because their moats have been demolished. ChatGPT makes current Google, Alexa, or Siri look like seriously outdated products. And it’s hard not to think of all sorts of new products leveraging AGI in ways we can’t imagine.
The next years should be fascinating.