Home  >  Article  >  Backend Development  >  Description about the Python programming language

Description about the Python programming language

黄舟
黄舟Original
2016-12-16 16:16:131198browse

A few days ago, I took a look at django in the Python programming language. As experts and scholars said, if you want to be a successful developer, you must first master another language, so I chose the Python programming language. Take action.

From these few days of study, I have indeed discovered that other languages ​​and their frameworks do have a unique feel. Below I will briefly summarize what I have seen over the past few days. This article is not a tutorial on Django, but some of ahuaxuan's own understanding of Django. It may be immature. I hope everyone will not be stingy with the bricks in their hands.

Orm of Python programming language If someone asks me what I like most about Django, I will tell you without hesitation that it is Django’s ORM. This idea comes entirely from my “dissatisfaction” with hibernate that I have accumulated over a long time. Although Look at it from an intellectual standpoint.

What hibernate does is very correct, because it is not just for the Internet. Its main market should still be in enterprise applications, but it is not impossible to use it on the Internet. It's just that people more often choose ibatis and the like, because people who don't know hibernate will always say that hibernate is not as fast as ibatis (actually, this bothers me the most, and one-sided comparisons are meaningless).

It is hibernate's goal to build an all-round and versatile ORM framework in the Java world, so its learning curve and complexity of use are increasing day by day. It is not easy to fully master hibernate (don't tell me you can click crud, just know how to click lazy load and you will master hibernate).

Talk in detail about the wide range of Python enterprise applications

A glance at clear and transparent Python applications

How to innovate Python virtual machine threads

Research and discuss Python main thread issues

Study and research on Python thread operation issues


Looking back at Django's ORM, if it takes an 800-page book to explain hibernate clearly, then 200 pages is enough to explain Django's ORM clearly (in fact, its official document only has a dozen pages). Here's an example of what I'm doing.

There is a self-related object here (in fact, Django's ORM is based on model, which is different from ROR. Someone told me that ROR is a database driver). This object has a parent object. Usually our menu will定义成这样的对象,这样的菜单可以无限级向下扩展:

class Category(models.Model):         id = models.AutoField('id', primary_key=True)         name = models.CharField(maxlength=50) code = models.CharField(maxlength=50) parentCategory = models.ForeignKey('self', 'id', null=True) enable = models.BooleanField() def __str__(self): return self.name class Admin: list_display = ('id', 'name', 'code', 'parentCategory')

Admin defined in the Python programming language serves the Admin module of django. The domain model we define only requires these codes, and models.Model is the parent object. All model objects need to inherit this object. This object provides many commonly used database methods, but it is not based on SQL, but still based on objects, like Criteria. Listed below are some commonly used methods for querying Category.

Of course, Django's ORM provides many very commonly used functions. I won't give examples one by one here. Note that what I am talking about here is that it provides many very commonly used functions. As for the more complex mapping strategies in hibenate. I didn't see it in django.

But I'm actually happy that I didn't find this function in django, because django itself is positioned for rapid Internet development, and it doesn't need to pay too much attention to things that rarely appear in this field. The advantage of this is the learning curve. Reduce and improve development efficiency.

The above is the description of the Python programming language. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn