Python Refresher for Returning Coders
Catch up on modern Python quickly if you coded years ago or come from another language.
A taste of a lesson
I mostly write JavaScript. What Python habits will bite me first?
Three come up quickly. First, truthiness differs: an empty list or empty dict is falsy in Python, while in JavaScript an empty array is truthy, so if items: means the list is non empty. Second, dicts are not objects: use d['key'], not d.key. Third, a default argument like def f(acc=[]) is created once and shared across calls, unlike JavaScript defaults, which are evaluated each call. Quick test: what does bool([]) return in Python?
Written by the teacher as an example. In your lesson the tutor answers your own questions, and like any AI it can be wrong.
What you will be able to do
- Use modern idioms such as f-strings, pathlib, comprehensions and dataclasses
- Set up projects with virtual environments and pyproject based configuration
- Avoid Python specific traps that catch programmers from other languages
- Read and write type hinted code that others on an AI team can follow
Lesson plan
- 1 What changed and what did not Update your mental model of Python syntax and built in behaviour. Start
- 2 Idioms that replace index loops Write loops the way experienced Python programmers do. Start
- 3 Traps from other languages Recognise behaviour that differs from the languages you already know. Start
- 4 Records, types and context managers Model data clearly with dataclasses and type hints and manage resources with with. Start
- 5 Modern project setup Create a project the way current Python teams expect. Start
- 6 Putting it together on an AI task Write a short, idiomatic script that summarises a file of model outputs. Start
Try asking
About this tutor
For people who wrote some Python long ago, or who know another language such as JavaScript, Java, C# or R, and now need Python for AI work. Instead of starting from zero, the tutor maps what you already know to modern Python habits: f-strings, pathlib, type hints, dataclasses, comprehensions, context managers, virtual environments and pyproject based projects. Lessons are quick and comparative, with short exercises that use AI style tasks such as reading JSON results or batching texts. Beginners can follow, while experienced programmers can skip ahead to the parts that changed most.
Reviews
4.0
3 ratingsSample
- Grace E.Sample
Coming from R, the 0 based indexing and slice ends were drilled in properly. The dataclass exercise was a nice touch. Some JavaScript comparisons went over my head.
- Pablo D.Sample
Useful but brisk. Fine for experienced programmers, though I would have liked more practice exercises on the traps section.
- Nikolai V.Sample
Last touched Python years ago. It skipped the basics and went straight to f-strings, pathlib and pyproject. Exactly the catch up I needed.
About the teacher
Python teacher for people starting AI work from zero, patient with setup, files and first scripts
9 tutors 377 lessons taught Sample
I teach Python to people who want to build with AI but have never written much code, or who tried once and got stuck on setup. My background is in teaching adult evening coding classes and later writing data scripts for small research teams, so I know where beginners lose an afternoon: the wrong interpreter, a confusing traceback, a file...
See Efua's profile and tutorsMore like this
Other tutors on the same or nearby topics.