Jagadeesh Katla

Why Python Developers Work Different in the Projects.

Why Python Developers Work Different in the Projects. Jan 1, 2021
Python and Java are two beasts in the programming world. these programming developers also work differently in each project because they think differently.

Here We can Discuss why python developers have a different mindset and why they work differently in the projects. the data structures, oop rules the almost same in all programming languages but other methods are different. so we will discuss 5 points here why python developers work differently in the projects.

 - Python Developers Highly Adopted Lazy Evolution Techniques.
 - Python Developers don't interest repeat the code.
 - Python Developers are Build Their own Code from Design Patterns.
 - Python Developers are Always Interest in new Techniques and Technologies. 
 - And the Last Thing, Python Developers are lazy, so they write Quality and Minimal code.

Here we can Discuss the Above 5 sentence,

1. Python Developers Highly Adopted Lazy Evolution Techniques.

Yes, like C, Ruby but use differently in python. suppose we need to write a simple code like convert one list value lower to upper and joining it is length to a hashable dictionary as key, values. . so this problem in python look like this.


    cities = ["hyderabad", "london", "new york", "Sydney"]
    print(cities)

    new_cities = { i.upper(): len(i) for i in cities }
    print(new_cities)

    >> ['hyderabad', 'london', 'new york', 'Sydney', 'New york']
    >> {'HYDERABAD': 9, 'LONDON': 6, 'NEW YORK': 8, 'SYDNEY': 6}

do you understand what we write in the program....? this is one of the lazy evolution techniques. that's why Python Developers always love Lazy Evolution. Here we can see an explanation of the above code.

  • First, we iterate the objects with for loop
  • Second, we convert the object lower to upper and calculated string length
  • Final, joined lower string and its length into a hashable dictionary.

To your basic understanding, we re-write the logical program here.
    cities = ["hyderabad", "london", "new york", "Sydney"]
    print(cities)

    new_cities = { }
    for i in cities:
        new_cities[i.upper()] = len(i)
    print(new_cities)    

    >> ['hyderabad', 'london', 'new york', 'Sydney', 'New york']
    >> {'HYDERABAD': 9, 'LONDON': 6, 'NEW YORK': 8, 'SYDNEY': 6}

2. Python Developers don't interest repeat the code.

Yes, almost every Developer Follows DRY (Don't repeat yourself) and KISS (keep it simple stupid) rules in their development time. but in most situations, developers break these rules. but in python, we can do everything customizable so python developers don't interest in Repeat their code.

Here we can write a simple code in python to don't repeat some tasks.

we have a cart data like this our data:

cart_items = [
    {'id': 3, 'product_name': "Apples", 'qunatity': 10, 'each_price': 25.0},
    {'id': 4, 'product_name': "Oranges", 'qunatity': 5, 'each_price': 10.0},
    {'id': 5, 'product_name': "Potato",'qunatity': 4, 'each_price': 12.0}
]


class Cart:
    def __init__(self, items_list):
        self.items_list = items_list
        self.qty = 0
        self.price = 0
        self.items = 0

    def count_total_price(self):
        total = sum([i['qunatity']*i['each_price'] for i in  self.items_list])
        print(total)
        return total

    def count_total_items(self):
        total = sum([i["qunatity"] for i in self.items_list])
        print(total)
        return total
    
    def add_Cart_item(self, item):
        self.items_list.append(item)
        print(self.items_list)
    
    def remove_cart_item(self, cart_id):
        for i in self.items_list:
            if i["id"] == cart_id:
                self.items_list.remove(i)
        print(self.items_list)


# Intial Cart Values
c = Cart(cart_items)
c.count_total_price()
c.count_total_items()

# Adding Cart Item in Cart
c.add_Cart_item({'id': 5, 'product_name': "Potato",'qunatity': 4, 'each_price': 12.0})

# After Update Cart Item 
c.count_total_price()
c.count_total_items()

# Remvoe Cart Item
c.remove_cart_item(4)

# After Remove Cart Item
c.count_total_price()
c.count_total_items()

See Above Code. we write our own class based on cart data. we can use this class always and don't repeat it again. we can't use this class in mobile API endpoints and front end templates without any changes. so we don't repeat again our code. Like this method, All python Developers don't repeat their code. they are lazy and write once and highly customizable code. we simply call it is cart model.


3. Python Developers are Build Their own Code from Design Patterns.

Yes, almost Every Python Developer Build Their own code from scratch and third-party libraries. so two python developers code not always the same. they build their own structure using design patterns. if a developer is a python beginner then they do copy and paste. we can build a sample design pattern here

# this code simple explanation command line pattern by Andrei Boyanov in Toptal.
# https://www.toptal.com/python/python-design-patterns

import os

class RenameFile(object):
    def __init__(self, from_name, to_name):
        self._from = from_name
        self._to = to_name

    def execute(self):
        os.rename(self._from, self._to)

    def undo(self):
        os.rename(self._to, self._from)


class History(object):
    def __init__(self):
        self._commands = list()

    def execute(self, command):
        self._commands.append(command)
        command.execute()

    def undo(self):
        self._commands.pop().undo()

history = History()
history.execute(RenameFileCommand('docs/cv.doc', 'docs/cv-en.doc'))
history.execute(RenameFileCommand('docs/cv1.doc', 'docs/cv-bg.doc'))
history.undo()
history.undo()

So in Above Code, Andrei Boyanov builds his one code from design patterns. so we can easily undo and execute file rename operation without any conflicts. so python developers are Build Their own Code from Design Patterns.


4. Python Developers are Always Interest in new Techniques and Technologies.

one of the greatest assets of python developers, they always use new technologies and techniques, and they always use the latest libraries. PIP tool gives many advantages to them. and when they explain new technologies, old goats and black sheeps not understandable their terminology. so why they interset and use technology always. we see in 5 sentences from PEP 20.

...
Simple is better than complex.
Complex is better than complicated.
...
Although practicality beats purity.
...
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.

see every python developer keep these lines in their mind. they can't violate these rules because they can understand the problem deeply. so they don't interest complicate the things in work, and they can't interest explain the hard implementations. so don't force python developers with your ugly ideas. they can write always beautiful and simple code.

5. Python Developers are lazy, so they write Quality and Minimal code.

Hmm, Yeah Almost Every Python Developer is lazy. Because they can't interest write the long code and they think always customizable high-quality code. like some python developers write all python code in a single file. 🤗 . but the code quality is the same. so python Developers are lazy.

I can share my personal experience here with my boss and co-workers. when I explain a new technique and technology my boss always asks continuos questions till the complete understanding. and my co-team always asks need modifications in code every time. that's is not code fault, I am just improving everything in my domain. and sometimes always argue with them about code performance and security.

I give a simple example here, we need to store the cart values but don't save them in the database. In this case, if we store cart values like in regular in the relational database. it is a bad idea. so we have many alternatives here, store and retrieve the cart values in sessions, store cart values in local storage, or store cart values in-memory database. so in these methods, we can't violate the rule. and this is a new technique right. so python developers interest-only write minimal code with quality.

we discuss here 5 sentences, these five reasons can make a python developer different from others. so that's why they have different mindest and work differently on the projects.