Posts tagged: PYTHON

A use case for Python assignment expressions

Python 3.8 (2019) added “assignment expressions”, aka the “walrus operator”. I generally like things that make Python more expression-oriented, like list comprehensions, but I’m ambivalent about these. It’s pretty easy to impair readability by using them overzealously. Is saving one line of code worth making it harder to notice that an assignment is happening? However, I’ve found a use case I like a lot. I use them in the Django Python shell when doing exploratory ORM queries.
How to port 100,000 lines of Python 2 to Python 3

How to port 100,000 lines of Python 2 to Python 3

TLDR: Use python-future. The Project Last summer I led the conversion of a 100KLOC Python 2 web application to Python 3. The application is called “Accelerate” - the backbone of operations at my employer, MassChallenge, a global startup accelerator. It handles every stage of a running accelerator program: account creation for entrepreneurs and experts (mentors) startup applications online and in-person judging of applications coordination of one-on-one meetings with mentors during the program generation of reports used by judges selecting cash award recipients So, it’s a mission-critical app.

Good Python Interview Questions

When we were growing our team of Python devs at CMG, I was involved in a lot of interviews. I really enjoyed it, meeting and hiring interesting and talented engineers. I’m not a big fan of quizzing people on technical minutiae in interviews. I do think that asking some questions about technical likes and dislikes can be very illuminating though. For example, “What’s your favorite standard library module?” (My favorite answers are itertools or functools, but anything that shows they have hands-on appreciation for the depth of the standard library is good.

Does Python scale?

(This is another thing I found myself writing on Quora and wanted to keep. The question was “Does Python have any scalability limitations?”) “Scalability” is a term people like to throw around, but the less specific you are as to what you mean by it, the less substantial the answers will be. It is not a simple linear measure on which languages can be given some numerical score. Languages and their implementations do have certain inherent performance characteristics, but in order to understand their relevance to your needs you have to get specific about your needs.

Booktools

A little-known bit of trivia about our book, Python Web Development with Django: we wrote the manuscript in Markdown. I think it was my idea. One of the major motivations for using a text-based format – versus the unfortunate de facto standard, Microsoft Word – was integration with good developer tools and workflow. Our manuscript and all our project code was in a Subversion repo, so each author always had the latest updates.

Making your way from PHP to Python and Django

“I’m a PHP programmer and I want to check out this Django thing. What should I do?” I’ve been seeing this kind of question pop up more and more, and I have a few answers. First-hand experience as well as many conversations with developers online have led me to the same conclusion: the curious person behind such a question should be encouraged and assisted. (I’ll call that person “Pat” for the rest of the post, for convenience and conscientious gender-neutrality.