Did you have python today? In order to improve your production efficiency, quickly pay attention to the growth of the python! Don't think of Python as your hobby, she can do almost all the work for you, and can do better, and let you think of writing code as a real pleasure. Why do we have to focus only on the so-called Orthodox languages of C + +, Java, C #? Is our goal not to be a pragmatic programmer? C + +, Java, and even C # can all be considered to be the same type of language: C + + is flexible, but the complexity of the syntax makes production inefficient, Java improves production efficiency, but loses flexibility; C # is good for productivity and flexibility, but it's not enough, The father of Boo's language is not to be angry and Boo.
Python is first of all a dynamic type and a strongly typed language, and dynamic typing means that you no longer have to make countless declarations for the type of each variable, because the compiler will help you make type judgments, and it will determine the type of the variable based on the 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 very compact, because space in C + +, Java, C # is ignored, and there is "{}" to define code block, then if you like, you can write all the code on one line, how to write how confusing. But this is not possible in Python, because there is only one delimiter in Python, which is the colon ":, and by narrowing the code block, you may be a little bit unaccustomed to this in the first, but then you will find that this is a very good way to benefit you because you have developed a great code style.
Don't think of Python as a very academic language, although many people think it's a great way to learn to program as an introductory language. In fact, Python is not only suitable for beginners to learn programming, but also a powerful language that you can use to do anything other languages can do. Python itself is almost ubiquitous, and Python-written programs can run in a variety of mainstream operating systems, even palm. Oh, almost forgot, Eric Raymond also told us that hackers have to master four languages, and the first push is python.
Speaking of which, there seems to be nothing to do with the productivity of the relationship Oh. Well, what you see is what you get. Download Python, of course, if you are not allowed to leave for a day. NET, start learning Python from IronPython. Install complete and run Python or ironpythonconsole, when you see the Python-specific interactive method prompt >>>, enter print "Hello,world" and press ENTER, Hello, World is on the screen and your first Python program is written and executed. Is it much faster to write and execute this classic program in Python than in C + +, Java, and even C #? Hehe ~ ~ ~ If I now make a statement, Python production efficiency is very high, you already scold me to deceive. OK, just a little bit, let's have some more practical code. But before you do, you have to download two well-known class libraries: Wxpython and twisted. Are you finished downloading and installing? OK, let's start enjoy Python with your in ten minutes tour (don't like the word teach, hehe ~ ~ ~).
First is Wxpython, if everyone has to look at me in front of the post, you will know the Wxpython of the story. It is the famous Wxwidget implementation in Python, do not know what Wxwidget is? No, see more of my blog do not know (I really smug ah, in fact, I also know that soon.) Don't hit me, hehe ~ ~ ~)? In short, the GUI can be developed easily using Wxpython. Just find a handy editor, type the following code, and co-exist as a file you like, but the suffix is. PY:
From wxpython.wx import Wxpysimpleapp, Wxframe
App = Wxpysimpleapp ()
frame = Wxframe (None,-1, "Hello World")
Frame. Show (1)
App. Mainloop ()
This code is then run through the Python *.py under the console. Oh, a window appears on the screen. Is it a bit of a sense of accomplishment? Take a look at the code, as concise as WinForm, but don't forget that Wxpython is not limited by the. NET Platform. At the same time you from Wxsimpleapp and wxframe such a class name is not associated with the MFC frame class, App class and Doc class it? Yes, Wxpython also implemented MVC in the same way, making the entire GUI code clearer and easier to maintain. If you're not enjoying it, it's too easy, so get 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 the 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 ()
The MainWindow class in the code above inherits the Wxframe and adds a Wxtextctrl control to the frame, adding a menu and event handling for the item. Does its brevity make you wonder? Hurry to Wxpython's website to get more information. The above code is quoted from the Wxpython website getting Started.
In addition to developing the GUI in this way, leveraging the collaboration capabilities of the IronPython and the CLR, you can easily develop the GUI, or even an interactive development, by invoking the WinForms API. Detailed information can refer to IronPython's dad Jim's blog, which has a very interesting post.
Did you have python today? On