Naoko Suga·Jul 25, 2018SQLAlchemy’s “Lazy” ParameterSQLAlchemy is one of the object-relational mapping softwares — it lets us map python classes to SQL databases and allows us to talk to the… — SQLAlchemy is one of the object-relational mapping softwares — it lets us map python classes to SQL databases and allows us to talk to the databases using python. …Programming3 min read
Pedro Alvarado·4 days agoHow to code the Game Of Life in Python without PygameA must do game for every programmer — The Game Of Life, devised by the mathematician John Horton Conway, shows that simple rules can make complex and beautiful behaviors. I think that is a must do game for every programmer because it’s strikingly to build something that drives itself, in other words, a cellular automaton. We can see…Python6 min read
Yeray Diaz·May 9, 2018What the mock? — A cheatsheet for mocking in PythonA cheatsheet for mocking in Python — It’s just a fact of life, as code grows eventually you will need to start adding mocks to your test suite. What started as a cute little two class project is now talking to external services and you cannot test it comfortably anymore. That’s why Python ships with unittest.mock, a…Unit Testing10 min read
AHMAD SACHALinRed Buffer·Jul 5, 2021Python: Production-Level Coding PracticesThis article focuses on the Production-Level Coding Practices in Python… — The purpose of this article is to share what I have learned while working on production-level projects. I am keeping it Python-centric but the same practices apply to all coding languages and generally in all software development work. When I started working, there were a lot of flaws in my…Production9 min read
Simon HaweinTowards Data Science·Nov 24, 2021How to Write Awesome Python ClassesIt’s a kind of magic — Python is the go-to language for most data science and machine learning projects. However, not every data scientist is necessarily a seasoned Python developer who knows and exploits all the nice features the language offers. This is of course understandable but also unfortunate at the same time. Why? Because knowing…Python6 min read
Victoria DrakeinBetter Programming·Sep 28, 2020Django Project Best Practices to Keep Your Developers HappyUsing Makefiles, pre-commit hooks, and GitHub Actions to help create a happy development team — Do you want your team to enjoy your development workflow? Do you think building software should be fun and existentially fulfilling? If so, this is the article for you! I’ve been developing with Django for years, and I’ve never been happier with my Django project setup than I am right…Programming5 min read
Kamran AhmadinBetter Programming·Feb 16, 2021In Python, Don’t Look Before You LeapAdvice for cleaner and better Python code — In this article, we’ll be taking a look at two common coding styles that programmers use to handle scenarios where a piece of code might fail: “Look Before You Leap” (LBYL) and “Easier To Ask for Forgiveness Than Permission” (EAFP). If you aren’t familiar with the LBYL vs. EAFP debate…Programming4 min read
Khuyen TraninTowards Data Science·Jan 13, 2021Stop Using Print to Debug in Python. Use Icecream InsteadAre you Using Print or Log to Debug your Code? Use Icecream instead. — Motivation If you are using print to debug your code, you might find it confusing to look at many lines of output on your terminal and then try to figure out which code each output belongs to. For example, running the script below will give you 30 40 Which one…Python4 min read
Khuyen TraninTowards Data Science·Oct 27, 2021Write Clean Python Code Using PipesA Short and Clean Approach to Processing Iterables — Motivation map and filter are two efficient Python methods to work with iterables. However, the code can look messy if you use both map and filter at the same time. Wouldn’t be nice if you can use pipes | to apply multiple methods on an iterable like below?Pipeline5 min read
Emmett BoudreauinTowards Data Science·Sep 24, 202112 Of My Favorite Python Practices For Better FunctionsIt is easy to write bad functions, much harder to write exemplary ones — here are some of the ways I improve mine! — Introduction Writing code can be a seriously difficult and challenging gig. This is especially the case when some problems are difficult to solve, and have multiple solutions. It is not always easy to keep your code in tip-top, perfect shape. This is especially the case when there are multiple solutions to…Programming14 min read
Peter GleesoninWe’ve moved to freeCodeCamp.org/news·Aug 28, 2018An A-Z of useful Python tricksPython is one of the world’s most popular, in-demand programming languages — Python is one of the world’s most popular, in-demand programming languages. This is for many reasons: it’s easy to learn it’s super versatile it has a huge range of modules and libraries I use Python daily as an integral part of my job as a data scientist. …Python9 min read
Kamal ChouhbiinTowards Data Science·Mar 6, 2020I Thought I Was Mastering Python Until I Discovered These TricksPython best practices and tips that will make you code quickly and efficiently — Python is one of the most popular programming languages for beginners, making it the most widely taught language in schools around the world. However, learning Python is not an easy thing. To get started, you first need to find the best online way to get there, which is difficult in…Python9 min read
Martin ThomainBetter Programming·Mar 4, 20216 Alternatives to Classes in PythonSpeed of development, execution time, (de)serialization, and maintainability all play a role in making your code shine — As developers, we throw a lot of data around. The representation of data matters a lot and we need to be able to keep track of which variables represent which attributes. Configuration is a prime example of complex data. In the following article, I will use location as an example…Programming8 min read
Raimi KariminBetter Programming·Sep 13, 20214 Anti-Patterns in Python (And How to Avoid Them)Know the few idioms and their alternatives — Changelogs: 5 Jan 2022 — Fix typos and improve clarity Ranked as number one in top programming languages 2021 in IEEE Spectrum, Python is one of the easier languages to pick up, and very popular among the machine learning community. However, there are some common idioms and patterns that deviate…Python5 min read
Abhay ParasharinLevel Up Coding·May 18, 202110 Advanced Python Concepts To Level Up Your Python SkillsConcepts that help to increase your Python knowledge — In this blog, we will see some of the advanced concepts of Python that help us master it. 1. Exception Handling An exception is a condition that occurs during the execution of the program and interrupts the execution. It can occur due to many reasons. Suppose you are writing a program for division…Python8 min read
Nik PiepenbreierinBetter Programming·Mar 16, 20214 Ways To Level Up Your Python CodeAvoid unnecessary for loops, access dictionary items more effectively, and more — One of the nice things about Python is that it’s easy to get stuff working. Another nice thing is that there are a number of hidden treasures in Python to make your code cleaner, easier to read, and easier to write. In this article, you’ll learn four easy ways to…Python3 min read
Pralabh SaxenainLevel Up Coding·Jul 25, 2021Python Refactoring Tips to Write Code in Pythonic WayPython refactoring tips for cleaner code — Code refactoring is one of the most interesting and important parts of your code. Refactoring your code not only makes your code more readable but also reduces the number of unnecessary lines. Whether it is Software Development or some coding competition, code refactoring is needed everywhere. It’s your responsibility to…Python4 min read
Bruce H. Cottman, Ph.D.inBetter Programming·Apr 6, 202111 Refactoring Patterns To Elevate Your Python CodeLet’s expand the definition of refactoring to include new functionalities — Different Kind of Refactoring I plan to increase stability and performance and to decrease the cost of maintenance in the Photonai code base. I add clustering functionality to the original code base and change the architecture. A small code refactoring task is usually fixing bugs. …Programming7 min read
Abhay ParasharinThe Pythoneers·Jul 6, 2021Best Practices To Follow While Creating Classes In PythonUseful Code Practices For Python Developers — Object-Oriented Programming Is a programming paradigm based on the concepts of classes and objects. The Concept of oop First Introduced in 1967. The First-ever programming language that has the primary features of OOP is Simula Created by Alan Kay. A Class in oop Works as a blueprint for the object…Python8 min read