search

Home  >  Q&A  >  body text

死活看不懂Python的多进程?

threading
今天看了好多个不同的教程,就是不理解具体是为什么。
是因为需要背景知识?
本人的资历很差,我是完全门外汉一路自学Python,也没有人请教。
大概实际的学习从今年2月开始,到现在时间也不短了,(之前时间在学习Linux命令操作,再之前完全0基础不知道一切关于IT的)
现在的水平只能写点简单的静态页面的爬虫,连urllib,urllib2模块都用不好,想高端点实现个多线程,进而去了解所谓的什么分布式,但是我发现自己太笨拙,别人一个月时间就可以写个基于Python的豆瓣FM命令行,我却只能依葫芦画瓢用Django写个功能简单的博客网站,前端用的还是Bootstrap,照搬官网的Demo改了点条条线线。虽然网站部署出来了,自己之前也搞了域名云主机,但是实在不好意思告诉人,因为看着views里面空空如也仅有的一点过程式代码,冗余和几乎无功能,也就是渲染渲染HTML而已。

在Github上看别人写的简单的代码,比如别人的Django博客,views.py里面使用的都是面向对象的方法,自己竟然都不知道该从哪里看起,更别说看懂了。

有时候有一些高级语法也想不起来,要再搜一下才能看懂。比如说 Parent.__init__(self)
其实就是调用父类的__init__ 自己好像也哪里见到过,但就是死活想不起来。连语法的关都没过!网上不少人建议多看别人的项目,但是我发现基本上都看不懂,有的即使有一些注释我也不知道该怎么理清楚它的结构。
这真的是脑子太笨了吗?

ringa_leeringa_lee2806 days ago1146

reply all(12)I'll reply

  • 高洛峰

    高洛峰2017-04-17 15:10:19

    In my opinion, learning anything requires talent. Without talent, hard work alone is useless. Of course, most people have something they are good at. Talent is innate, but it is not obvious and usually requires hard work to discover.

    People who are stupid will definitely not be able to learn python. The grammar of python is simple enough. But having said that, it doesn’t take long for the subject to learn python, and he can still figure out django blog (although I think it’s easy). It shows that you are not too "stupid" to learn python.

    You feel that you are "stupid" not in terms of IQ, but more in terms of programming experience. Learning a language is actually not difficult, but mastering a language to develop an application or even a system still requires a lot of knowledge. On the one hand, this knowledge can be learned systematically, such as reading documents and consulting predecessors. On the other hand, through encountering, solving, summarizing and gradually accumulating in actual development.

    It’s like a martial arts. If you want to improve your skills, you probably have to practice hard or go into actual combat. Others have given you martial arts tips, but if you don't practice them yourself, your internal strength won't grow on its own. Not everyone can directly teach internal skills to masters like Duan Yu and Xu Zhu.

    In short, learn more, do more, think more, summarize more, and share more.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 15:10:19

    Go and write the code for the producer-consumer problem

    reply
    0
  • 迷茫

    迷茫2017-04-17 15:10:19

    I was the same way at the beginning, and I was confused about Python’s threading and multiprocessing libraries.

    It’s a pity that I first found a few relatively simple examples on the Internet to experience it (it still feels different from the style of Java, which is straightforward and easy to understand)

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 15:10:19

    LZ, I am in the same situation as you. I am self-taught in py. With your behavior, I think I am "stupid" than you. But I think it’s more important to understand the concepts and essential aspects of many things

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 15:10:19

    I also want to know what your problem is

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 15:10:19

    Why do you feel like you are talking about me?

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 15:10:19

    The reason is simple.

    To understand multi-processing and distribution, you need to at least understand:
    1. Single process bottleneck.
    2. Multi-process working principle.
    3. Multi-process operation method under Python
    Just wait for a bunch of questions.

    If you go online every day to look for Python multi-process examples, you will definitely not be able to figure them out.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 15:10:19

    1. It’s only four months. You don’t need to ask for so much. The person who “can write a Python-based Douban FM command line in one month” may have been working for more than four years. 2. It’s good to be able to understand it with just a search. Many people don’t know how to search. It’s like this with tools, the more you use them, the more familiar you become.

    In addition, the object-oriented view of Django is only available in later versions of Django. It was also a functional view at the beginning. Python itself is an object-oriented and procedural language. It is enough to solve the problem instead of using objects. The more advanced you can get, the more low-level the process becomes. When you need an object to even write a HelloWorld, you will realize how disgusting it is.

    Finally, I still want to say that a tool is a tool. Doubting your intellectual talent because of a tool makes you feel aggrieved. Hahaha, I just want to laugh when I think about it. . .

    reply
    0
  • 黄舟

    黄舟2017-04-17 15:10:19

    It would be best to post a piece of code as an example. . .

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 15:10:19

    Follow the following steps:

    1. There are several ways to collect python to implement multi-process
    2. Compare the differences between several methods, what technologies are used, and what are the principles
    3. Try to write some consumption code yourself (such as the daemon of the consumption queue)
    4. Go back to 2 and continue trying

    reply
    0
  • Cancelreply