Some questions and answers about Python programming

Source: Internet
Author: User

Some questions and answers about Python programming

About 1 months ago, Oschina.net and the book worked together to do an event: OSC 51st expert Quiz-talk about Python, to promote my participation in the book "Writing High-quality code: Improve the Python program 91 Recommendations" (watercress link). In the course of answering the question, I saw that several questions had been asked, and the idea of finishing the questions after the fact had sprouted, and the following was a question and answer. To simplify the arrangement, the nickname of the questioner has been removed and a simple classification has been made.

The tangled Py2 and the Py3 choice

What does Q:python 3 lead to in Python's foreground? Is the final 3 unified, or is it always split? Each with their own version?

A:py3 since the release, progress is very big, solve a lot of py2 can not solve the problem, so I am convinced that everyone will eventually go to Py3. Now Py3 has a lot of very attractive features, such as yield from, such as Asyncio, such as a more beautiful library structure, and so on. But I admit that Py3 has not a huge attraction let everyone turn around, yield from half, the other half I think it is JIT, imagine Py3 with JIT, running speed is py2 3 to 10 times times, we certainly swarm turn past. I think Py3 is the future, but also endorses the two fragmented version of the impact promotion.

Q: Should beginners learn 2 or 3? Will 2 be abandoned by the Python team?

A: Learn py2, if you want to turn py3 is also very easy. But if the direct study py3, then the project to use Py2, will feel from extravagance into frugality, very painful.

Q: How long do you think python3.x will take to become mainstream?

A: There is a long time, but if py3.5 has an exclusive, reliable, official JIT program, it should accelerate a lot!

How to learn Python

Q:python suitable as a programming entry language.

A: Considering the employment and so on, I think C language is more suitable as a primer.

Q:python Study advanced? How do you learn after you have mastered the basics?

A: If you are already working, then just try to use Python to solve the job needs, if it is a student, then copy the existing site, to get its functions, such as Oschina.

Q: How is high-quality code written, and how to improve the quality of your code?

A: Personal Views: 1, familiar with the details of the language, 2, familiar with the best practice of language and library; 3, see some guide books to improve the quality of code, 4, peer review, 5, learn several languages, absorbing.

Q: Is there any good advice for a Java developer to learn to use Python?

A: Learn it like you did in Java.

Q: Beginner, what good website is recommended to learn?

A: or read books, read manuals, the site's knowledge is too fragmented, not a system, easy to learn wild path programmer.

Q: What can I do to improve my ability to use Python after learning and using a python?

A: My answer is to re-carve some products, such as try to do a watercress, oschina and so on.

Q: "Writing high-quality code: 91 Suggestions for improving the Python program" is this book for other non-Python programmers to see?

A: not suitable. It's positioned to be someone who knows something about python. To the junior high-level Python programmer to advanced, such positioning.

Q: Please recommend some of the more excellent Python open source projects to learn.

A: Excellent Python open source project Ah, I think, well, look at Trac and reviewboard?

Q: What do you think of Python's best books since you learned about Python? Language basics, language design, frameworks, and so on. Thank you, sir.

A: Good question, I think I can answer, because I myself feel that my book is not the "best" level. Recommended "Expert Python programming (high-level programming in Python, translation passable)", "Python Source code analysis."

Q: Hello, I have a question to ask you, how to become a real pythoner. I used to do C + + and now I work with some Python web-related tasks. When I first approached Python, I learned some basic grammar and began to try to write algorithm-related programs, so when I wrote the Python program, the code still had C + + shadow, until now, when I was working to maintain the Python Web program of Others, Find your own Python program is too elegant, many times some features can be more beautiful faster and more efficient way to achieve, but I would like C + + in the same want from the bottom 1.1 grass a wooden build, control my program, and later found that can be a few lines or even shorter code can achieve those functions, And the execution is a little better, so I found that writing a Python program can't use the idea of the previous C + + code, maybe I could try a little bit more pythoner?

A: A very interesting question, personal suggestions are as follows: 1, read through the manual, especially Lib ref and Lang ref, the so-called practice makes perfect, the language itself familiar to write more pythonic;2, more look at the classic Python project documents, such as flask, such as Pip, See what mechanisms they provide, and even explore how such mechanisms are provided; 3. Don't worry, just write some Python code.

Applying the confusion of Python

is Q:python suitable for developing more complex Web projects?

A: In my opinion, Python is suitable for the development of small and medium-size complex projects, because the project can be made, the most critical factor is people. Python is good with web support, there are many third-party libraries, and there is a framework that many people applaud, such as Django/flask.

Q: Which operating system environment is good for getting started python? I just have a little foundation in Windows, but I don't know what the general Real team development environment is, can you introduce? Thank you!

A: We have been using Linux as a production environment, Mac OS X is my development environment, I have used windows for many years, I do not think that using Windows will affect your learning.

Q: Python seems to be mostly used in web orientation, where it can help in the development of C and C + + python.

A: Mainly use the flexibility of dynamic language, the convenience of interpretive language, to solve the problem of the complex and flexible business requirements, rapid deployment, and other aspects of the cost too high or inadequate.

Experience

Q: Is it possible for students to develop only in the direction of PYQT?

A: In the long run, as long as there is a breakthrough, it is possible to have achievements in the back. In the short term, it feels that the employment side is rather narrow.

Q: It feels like Python can do anything, but it's hard to do well. If there is no c/c++/go extension, can python make large throughput, high concurrency and high stability system?

A: To say that Python can do anything, or overestimate, but that Python is very difficult to do very well, it depends on the word "very good" how to define, estimating the standards of each person is not the same. I'm sorry, but I don't think I can use go to extend Python. At present I experience the net swims, the website aspect, I thought can also make the big throughput high concurrency system, only possibly the hardware cost will be slightly higher, as for the stability, the decisive factor is the developer's quality, with the language relations is not big, even the C + + is easier to develop the unstable system.

Q:python class Library, library is huge, how can quickly find their own needs of the class library?

A: This is a problem, and many languages have the same problem. Why don't you take a look at the Awesome-python project first?

Q:python Programmer Income

A: It seems that the annual income has been seen from tens of thousands of to hundreds of thousands of, but millions of me have not seen it. Generally speaking, I think it is similar to other languages, but the proportion of high salary may be more forward.

Q: I was a ruby programmer, and later I saw Python has a lot of modules, such as Ipython, Ipython notebook and other very cool Python applications, in fact, in the flexibility of python far less than Ruby (method_missing, etc.), Design philosophy is not the same, want to ask why Python is more than the application of Ruby? In particular scientific calculations (Numpy) and cartography (Matplot)?

A: The reason Python will be so popular in the scientific community is said to be because those scientists are not computer professionals, that Python is easy to learn, so use this, anyway, just write a script to run the test data.

Q: I would like to ask, Python used to write the game, we do not all say that Python is relatively run slower than c++/c, and now most of the game engine is C + +, see that cocos2d, the first seemingly Python version, and then the C/s rewrite, Although the Python version is now updated, in addition, the mobile side of the various software game development is also more popular, python in this respect seems to be a little bit of a feeling.

A: Yes, in the hands of the era, Python is not suitable for writing clients. You can try to use it on the server side, or it's good.

Q: I have so many questions to ask: 1. Multi-frame, multi-module implementation language represents the cost of learning more than 2. The existence of glue language is now mainly used to do what, other aspects of how the application of 3. UNIX-like Systems management, how to learn them 4. What is the difference between the Web and Ruby, or the pros and cons 5. Write a text crawler, feel the character set and platform differences slightly strange, how do you avoid

A:1. I don't quite understand what the multi-frame, multi-module means, I can understand that there are many frameworks for Python? If it is, I do not think that represents more study costs, you look at the Quick-start, look at the examples, look at the doc in the extension and split mechanism, you know this framework, module is suitable for your technical concept, suitable for the line, not suitable for not learn, do not learn will not have the cost; 2 . The problem of glue language, I think "UNIX programming Art" This book is much better than I say, recommended to see; 3. About SA this piece, I do not know much, suggest consult monograph; 4. The advantage of Ruby is that there are ror such unification solutions, Python is more choice, more trouble, 4. Text processing, in the coding problem is many, very difficult, the proposal uses the Chardet and so on the proposal, but all is the strong cannot and the place, proposed accepts partial question is unable to solve the reality.

Q: Here are a few questions to ask: (1) How to achieve efficient Python coder, I am also nearly 2 years to start using Python, but feel that there are many improvements in the efficiency of culture, and relative to the company's internal Java group. (2) Python One of the things I prefer is relatively clear, what are compared to the original ecology, The equivalent of. NET packaging, this is its advantage, if ready-made Lib can also be found, what usually commonly used things, is to make Lib good, or directly with others to write a good lib? Thank you (3) is Python a better choice for writing web or better? Compared to the domestic environment, Python is really less, of course, there is Google to take the lead in foreign countries, it is a lot of projects are very good, I now do a Web project, choose Bottle, it and flask more similar, Speed will be better, found that the project encountered a lot of technical aspects of the problem, can find less information to solve the problem is very difficult.

A:1. How to do efficient python coder, I think with other languages no two, anyway, read the official document must have a lot of gain, this is my experience. 2. I generally directly use other people to write the Lib, if there is and use it cool; 3. It is recommended to choose the larger and more active framework of Flask/django and other communities.

Coding Line

Q: Personal feeling Python does not have a mature IDE, writing programs are constantly flipping, do not want to write C + + or with Eclipse, are automatically prompted + documents, I would like to know is I really caishuxueqian or Python development common problem?

A: Well, there is no particularly strong ide,pycharm is better, and there is free Community Edition, used to use E to remember, you can try Pydev.

Q: Would you like to ask if Python will instantiate or share an instance of each import module in memory?

A: The default is to share one.

Q: What tools did you use to package Python projects? After I use Pyinstaller to package a program that contains GTK, the file that is packaged will be reported as _glib module does not exist. I don't know if there's any better tool. It's best to be cross-platform.

A: We generally do not play the installation package, we generally use setuptools.

The return value type of the Q:python "function" is not in the statement's syntax declaration, using a Python development project, because the return value type is not so clear, how to ensure that there is no mistake in the software iteration?

A: On the one hand, there are some best practices, such as guaranteed return values of the same type, and a full unit test; The third is to use a newer version of Python, which already supports type declarations for parameters and return values.

Q: What good library to use for Python's co-process

A: Must be gevent.

Q: Does Python have a mature tool chain like Ruby Community RVM, bundler, rake?

A: Yes, pypi.python.org, you can go up and look. I have also mentioned the use of these toolchain in my book.

Some questions and answers about Python programming

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.