Are you using Python today? (On), Python? (
Are you using Python today? To improve your production efficiency, please pay attention to the growth of the python! Don't think of Python as your hobby any more. She can do almost all the work at hand for you and do better, it also makes writing code a real pleasure. Why should we focus only on the so-called orthodox languages C ++, Java, and C? Isn't our goal a pragmatic programmer? C ++, Java, and even C # can all be seen as the same type of language: C ++ is flexible, but complicated syntax makes production efficiency low, and Java improves production efficiency, however, flexibility is lost. C # is a good balance between production efficiency and flexibility, but it is still not enough. Otherwise, the father of Boo language will not be angry with Boo.
Python is a dynamic type and a strong type language. A dynamic type means that you no longer need to make numerous declarations for the type of each variable, because the compiler will help you make type judgments, it will determine the type of the Variable Based on the Value assignment of the variable. A strong type means that you cannot use a string as an int unless you explicitly convert it.
Python itself is compact, because space is ignored in C ++, Java, C #, and "{}" to define code blocks, if you like it, you can write all the code on one line, so you can write it as dizzy as possible. However, this is not possible in Python, because there is only one Separator in Python, that is, colon":"At the same time, you may be a bit unaccustomed to this method by indentation to differentiate code blocks. But later, you will find that this method will benefit you a lot, because you have developed a good code style.
Don't think that Python is a very academic language, although many people think it is very suitable as an entry-level language for learning programming. In fact, Python is not only suitable for beginners to learn programming, but also a powerful language. You can use it to do anything other languages can do. Python itself is almost everywhere, and programs written in Python can run in various mainstream operating systems, even Palm. Oh, I almost forgot. Eric Raymond also told us that hackers must master four languages. The first step is Python.
Speaking of this, it seems that there is no link with production efficiency. Well, let's look at what we see is what we get. Download Python. Of course, if you cannot leave. NET in a day, you should start learning Python from IronPython. After installing Python or IronPythonConsole, enter print "Hello, world" and press Enter, world appears on the screen. Now your first Python program has been compiled and executed. Compared with C ++, Java, and even C #, is it much faster to write and execute this classic program in Python? Haha ~~~ If I make up my mind to say that Python is highly productive, you will already scold me for being a lie. Well, it's easy. Let's try some practical code. But before that, you have to download two very famous class libraries: wxPython and Twisted. Is the download and Installation complete? Well, let's start our tour of Enjoy Python with you in ten minutes (don't like the word Teach, huh ~~~).
The first is wxPython. If you have read the Post above, you will know the header of wxPython. It is a well-known wxWidget implementation in Python. I don't know what wxWidget is? No, I don't know how to read my Blog. (It's pretty bad, but I did know it soon. Don't hit me, huh ~~~)? In short, wxPython can be used for GUI development easily. Find a handy Editor, type the following code, and save it as a file with your favorite name, but the suffix is. py:
From wxPython. wx import wxPySimpleApp, wxFrame
App = wxPySimpleApp ()
Frame = wxFrame (None,-1, "Hello World ")
Frame. Show (1)
App. MainLoop ()
Then run the code in python *. py on the console. Oh, a window appears on the screen. Is it a sense of accomplishment? Let's take a look at the code. It's as simple as WinForm, but don't forget that wxPython has no restrictions on the. NET platform. At the same time, do you think of Frame, App, and Doc classes in MFC from the names of wxSimpleApp and wxFrame? Yes, wxPython implements MVC in the same way, making the entire GUI code clearer and easier to maintain. If you are not addicted to it, it is too simple, then let's look at a richer one:
From wxPython. wx import *
ID_ABOUT = 101
ID_EXIT = 110
Class MainWindow (wxFrame ):
Def _ init _ (self, parent, id, title ):
WxFrame. _ init _ (self, parent, wxID_ANY, title, size = (400,200), style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
Self. control = wxTextCtrl (self, 1, style = wxTE_MULTILINE)
Filemenu = wxMenu ()
Filemenu. Append (ID_ABOUT, "& About", "Information about this program ")
Filemenu. AppendSeparator ()
Filemenu. Append (ID_EXIT, "E & xit", "Terminate the program ")
MenuBar = wxMenuBar ()
MenuBar. Append (filemenu, "& File") # Adding the "filemenu" to the MenuBar
Self. SetMenuBar (menuBar) # Adding the MenuBar to the Frame content.
EVT_MENU (self, ID_ABOUT, self. OnAbout)
EVT_MENU (self, ID_EXIT, self. OnExit)
Self. Show (true)
Def OnAbout (self, e ):
D = wxMessageDialog (self, "A sample editor"
"In wxPython", "About Sample Editor", wxOK)
D. ShowModal ()
D. Destroy ()
Def OnExit (self, e ):
Self. Close (true) # Close the frame.
App = wxPySimpleApp ()
Frame = MainWindow (None,-1, "Sample editor ")
App. MainLoop ()
In the above Code, the MainWindow class inherits wxFrame and adds a wxTextCtrl Control for this frame. It also adds a menu and event processing for the menu item. Is it concise? Go to the wxPython website to get more information. The above code is derived from the Getting Started of the wxPython website.
In addition to the GUI development, IronPython and CLR can also be used to call WinForms APIs for easy GUI development or even interactive development. For details, refer to IronPython's dad Jim's blog. The above is an interesting Post.
Python beginners installed python today, but cannot correctly execute the helloworld command.
Python is optimistic about the version number of your textbook. Currently, python is in the coexistence stage of 2.4, 2.5, 2.6, and 3.x. There are many differences between python 2.4 and 2.5.2.6, and a small part of python 2.5 is different from python 2.6. x is the same as 2. x is quite different.
What is Python?
Perhaps the people who initially designed the Python language did not expect that today Python will be so widely used in industry and scientific research. Eric Raymond, a famous free software author, listed Python as one of the four programming languages that hackers should learn in his article "How To Be a hacker, we recommend that you start learning programming from Python. This is indeed a pertinent suggestion. Python is one of the best choices for programming learners who have never learned programming or are not computer professional. Python learned Python for the first time. In less than 20 minutes, I stood in the bookstore and rummaged through a book that taught beginners to learn Python. Since then, I have been attracted by this magical language. Python can be used to develop things on symbian. The perfect combination of ease of use and speed Python is a very easy-to-use language. Many beginners of Java will be confused by the Java CLASSPATH, it took more than half a day to figure out that CLASSPATH had a wrong Hello World before it could run. This problem does not occur when Python is used. It can be directly used if it is installed. Python is a scripting language that can run directly after being written, saving the trouble of compiling links. For beginners who need more hands-on practices, there is no chance of errors. In addition, Python also has an interactive mode. If it is a simple small program, the editor can be saved and can be run simply by clicking in. Python is a clear language. using indentation to express the nested relationship of a program is a pioneering task. It upgrades the soft programming style of the past to hard syntax. There is no need to choose between different styles or dispute over different styles. Unlike Perl, Python does not have any obscure abbreviations and does not need to remember the meanings of various strange symbols. A program written in Python is easy to understand. This is the consensus of many people. Python is an object-oriented language, but its object-oriented language does not emphasize concepts as C ++ does, but focuses more on practicality. It is not to make the language complex to reflect the complete support for the concept, but to make programmers enjoy the benefits of object-oriented with the simplest method, this is one of the reasons why Python attracts many supporters like Java and C. Python is a language with rich functions. It has a powerful basic class library and a large number of third-party extensions, so that Python programmers do not need to envy Java JDK. Python provides a rich set of basic functions for programmers, so that people do not need to write the program at the bottom layer. Speaking of this, people usually use a worry: The scripting language is usually slow. The speed of running the script language is indeed slower, but the speed of Python is much faster than people think. Although Python is a scripting language, it can also be compiled, just like compiling a Java program, to compile a Python program into a special ByteCode, the execution is ByteCode, saving the analysis and interpretation of the program text, which naturally improves the speed. In Java programming, people advocate a method of Pure Java, except that everything on the virtual machine is written in Java. No matter the basic data structure or graphical interface, Pure Java's SWING, it has become a nightmare for countless Java application developers. Python advocates practicality. Its overall environment is written in C. Many basic functions and extended modules are written in C/C ++, when executing this part of code, the speed is the speed of C. The startup speed of a common desktop program written in Python is not much different from that written in C. In addition, through some third-party software packages, the source code written in Python can also be run in a JIT-like way, which can greatly improve the speed of running Python code, for different types of code, there will be a speed increase of 2 to 100 times. Python is the most perfect combination of ease of use and speed in the languages I have seen. It achieves higher programming efficiency by losing a little bit of speed that is often negligible, this is why I chose Python. Extract the full text of the Final ......>