diff --git a/zh-CN/Appendix.po b/zh-CN/Appendix.po new file mode 100644 index 0000000..2cf4aba --- /dev/null +++ b/zh-CN/Appendix.po @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:12\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-xml2pot; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "Revision History" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Publican" +msgstr "" diff --git a/zh-CN/Author_Group.po b/zh-CN/Author_Group.po new file mode 100644 index 0000000..11985c6 --- /dev/null +++ b/zh-CN/Author_Group.po @@ -0,0 +1,32 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: firstname +#, no-c-format +msgid "Kushal" +msgstr "" + +#. Tag: surname +#, no-c-format +msgid "Das" +msgstr "" + +#. Tag: orgdiv +#, no-c-format +msgid "Linux User Group of Durgapur" +msgstr "" + +#~ msgid "Kushal Das Linux User Group of Durgapur kushal@fedoraproject.org" +#~ msgstr "Kushal Das Linux User Group of Durgapur kushal@fedoraproject.org" diff --git a/zh-CN/Book_Info.po b/zh-CN/Book_Info.po new file mode 100644 index 0000000..455822f --- /dev/null +++ b/zh-CN/Book_Info.po @@ -0,0 +1,30 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, fuzzy, no-c-format +msgid "Python for you and me" +msgstr "你我的python" + +#. Tag: para +#, no-c-format +msgid "This book is for the python newbies" +msgstr "这本书主要的读者对象是python语言的入门者。" + +#~ msgid "Python for you and me" +#~ msgstr "写给入门者的python" + +#~ msgid "Logo" +#~ msgstr "标志" diff --git a/zh-CN/Chapter.po b/zh-CN/Chapter.po new file mode 100644 index 0000000..4a17a29 --- /dev/null +++ b/zh-CN/Chapter.po @@ -0,0 +1,39 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "Test" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "This is a test paragraph" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Section 1 Test" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Test of a section" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Section 2 Test" +msgstr "" + diff --git a/zh-CN/LegalNotice.po b/zh-CN/LegalNotice.po new file mode 100644 index 0000000..99525a8 --- /dev/null +++ b/zh-CN/LegalNotice.po @@ -0,0 +1,169 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: para +#, no-c-format +msgid "Permission is granted to copy, distribute, and/or modify this document under the terms of the Open Publication Licence, Version 1.0, or any later version. The terms of the OPL are set out below." +msgstr "" + +#. Tag: bridgehead +#, no-c-format +msgid "REQUIREMENTS ON BOTH UNMODIFIED AND MODIFIED VERSIONS" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Open Publication works may be reproduced and distributed in whole or in part, in any medium physical or electronic, provided that the terms of this license are adhered to, and that this license or an incorporation of it by reference (with any options elected by the author(s) and/or publisher) is displayed in the reproduction." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Proper form for an incorporation by reference is as follows:" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Copyright (c) <year> by <author's name or designee>. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, vX.Y or later (the latest version is presently available at )." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The reference must be immediately followed with any options elected by the author(s) and/or publisher of the document (see section VI). Commercial redistribution of Open Publication-licensed material is permitted. Any publication in standard (paper) book form shall require the citation of the original publisher and author. The publisher and author's names shall appear on all outer surfaces of the book. On all outer surfaces of the book the original publisher's name shall be as large as the title of the work and cited as possessive with respect to the title." +msgstr "" + +#. Tag: bridgehead +#, no-c-format +msgid "COPYRIGHT" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The copyright to each Open Publication is owned by its author(s) or designee." +msgstr "" + +#. Tag: bridgehead +#, no-c-format +msgid "SCOPE OF LICENSE" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The following license terms apply to all Open Publication works, unless otherwise explicitly stated in the document." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Mere aggregation of Open Publication works or a portion of an Open Publication work with other works or programs on the same media shall not cause this license to apply to those other works. The aggregate work shall contain a notice specifying the inclusion of the Open Publication material and appropriate copyright notice." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "SEVERABILITY. If any part of this license is found to be unenforceable in any jurisdiction, the remaining portions of the license remain in force." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "NO WARRANTY. Open Publication works are licensed and provided "as is" without warranty of any kind, express or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose or a warranty of non-infringement." +msgstr "" + +#. Tag: bridgehead +#, no-c-format +msgid "REQUIREMENTS ON MODIFIED WORKS" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "All modified versions of documents covered by this license, including translations, anthologies, compilations and partial documents, must meet the following requirements:" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The modified version must be labeled as such." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The person making the modifications must be identified and the modifications dated." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Acknowledgement of the original author and publisher if applicable must be retained according to normal academic citation practices." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The location of the original unmodified document must be identified." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The original author's (or authors') name(s) may not be used to assert or imply endorsement of the resulting document without the original author's (or authors') permission." +msgstr "" + +#. Tag: bridgehead +#, no-c-format +msgid "GOOD-PRACTICE RECOMMENDATIONS" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In addition to the requirements of this license, it is requested from and strongly recommended of redistributors that:" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "If you are distributing Open Publication works on hardcopy or CD-ROM, you provide email notification to the authors of your intent to redistribute at least thirty days before your manuscript or media freeze, to give the authors time to provide updated documents. This notification should describe modifications, if any, made to the document." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "All substantive modifications (including deletions) be either clearly marked up in the document or else described in an attachment to the document." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Finally, while it is not mandatory under this license, it is considered good form to offer a free copy of any hardcopy and CD-ROM expression of an Open Publication-licensed work to its author(s)." +msgstr "" + +#. Tag: bridgehead +#, no-c-format +msgid "LICENSE OPTIONS" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The author(s) and/or publisher of an Open Publication-licensed document may elect certain options by appending language to the reference to or copy of the license. These options are considered part of the license instance and must be included with the license (or its incorporation by reference) in derived works." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "A. To prohibit distribution of substantively modified versions without the explicit permission of the author(s). "Substantive modification" is defined as a change to the semantic content of the document, and excludes mere changes in format or typographical corrections." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To accomplish this, add the phrase 'Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder.' to the license reference or copy." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "B. To prohibit any publication of this work or derivative works in whole or in part in standard (paper) book form for commercial purposes is prohibited unless prior permission is obtained from the copyright holder." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To accomplish this, add the phrase 'Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.' to the license reference or copy." +msgstr "" + diff --git a/zh-CN/Preface.po b/zh-CN/Preface.po new file mode 100644 index 0000000..194527d --- /dev/null +++ b/zh-CN/Preface.po @@ -0,0 +1,19 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "Preface" +msgstr "" + diff --git a/zh-CN/Python_for_you_and_me.po b/zh-CN/Python_for_you_and_me.po new file mode 100644 index 0000000..8789975 --- /dev/null +++ b/zh-CN/Python_for_you_and_me.po @@ -0,0 +1,14 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + diff --git a/zh-CN/Revision_History.po b/zh-CN/Revision_History.po new file mode 100644 index 0000000..da5d402 --- /dev/null +++ b/zh-CN/Revision_History.po @@ -0,0 +1,29 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: firstname +#, no-c-format +msgid "Kushal" +msgstr "" + +#. Tag: surname +#, no-c-format +msgid "Das" +msgstr "" + +#. Tag: member +#, no-c-format +msgid "First release" +msgstr "" + diff --git a/zh-CN/acknowledgment.po b/zh-CN/acknowledgment.po new file mode 100644 index 0000000..6ff8571 --- /dev/null +++ b/zh-CN/acknowledgment.po @@ -0,0 +1,121 @@ +# SOME DESCRIPTIVE TITLE. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "Acknowledgment" +msgstr "感谢" + +#. Tag: para +#, no-c-format +msgid "I would like to thank the following people who have helped me make it through this book. Specially #fedora-docs in irc.freenode.net and also #fedora-art . Names are in alphabetic order:" +msgstr "我感谢下面的人们,他们对这本书的帮助很大,尤其是IRC站点irc.freenode.net上的频道#fedora-docs 和#fedora-art,名字按照字母顺序排列: " + +#. Tag: para +#, no-c-format +msgid "Jared Smith" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Marco Mornati" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Nicu Buculei" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Paul W. Frields" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Pradeepto K Bhattacharya" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Sankarshan Mukhopadhyay" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Sayamindu Dasgupta" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Stephanie Whiting" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Prashad J. Pandit" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "I am missing some names in the above list, will add them soon" +msgstr "在以上列表中落下了一些人,我将在不久的将来会补上" + +#. Tag: para +#, no-c-format +msgid "I also took help from the following sites" +msgstr "我从以下站点获得许多帮助" + +#. Tag: para +#, no-c-format +msgid "http://docs.python.org" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "http://en.wikipedia.org" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Few books or sites I would recommend to read" +msgstr "一些我推荐的书和站点" + +#. Tag: para +#, no-c-format +msgid "Byte of Python" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Dive into Python" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Python Tutorial" +msgstr "" + +#~ msgid "Byte of Python" +#~ msgstr "Byte of Python" + +#~ msgid "Dive into Python" +#~ msgstr "Dive into Python" + +#~ msgid "Python Tutorial" +#~ msgstr "python教程" diff --git a/zh-CN/classes.po b/zh-CN/classes.po new file mode 100644 index 0000000..a6642ad --- /dev/null +++ b/zh-CN/classes.po @@ -0,0 +1,312 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "Class" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "What is a class? In our daily life, we come across many objects which are similar kind or in words which are basically same. For example we can think about a car. There are different brands , color, look, style, parts, but basically they all are cars. All them of are made by different companies but with similar kind of components." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We can say all of them are different instances of the class car. They all belongs to the car class. Every instance is known as an object in computer world. A class can contain variables or methods to access those variables.In Python everything is an object. Even if you create an integer, that is an object of the Integer class. In C++ this is different." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Your first class" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Before writing your first class, you should know the syntax. We define a class in the following way.." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"class nameoftheclass:\n" +" statement1\n" +" statement2\n" +" statement3\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "in the statements you can write any python statement, you can define functions (which we call methods of a class)." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> class MyClass:\n" +"... a = 90\n" +"... b = 88\n" +"...\n" +">>> p = MyClass()\n" +">>> p\n" +"<__main__.MyClass instance at 0xb7c8aa6c>\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the above example you can see first we are declaring a class called MyClass, writing some random statements inside that class. After the class definition, we are creating an object p of the class MyClass.If you do a dir on that..." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> dir(p)\n" +"['__doc__', '__module__', 'a', 'b']\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can see the variables a and b inside it." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "__init__ method" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "__init__ is a special method in python classes, it is the constructor method for a class. In the following example you can see how to use it" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> class Student:\n" +"... def __init__(self, name, branch, year):\n" +"... self.name = name\n" +"... self.branch = branch\n" +"... self.year = year\n" +"... print "A student object is created"\n" +"... def getName(self):\n" +"... return self.name\n" +"... def setName(self, name):\n" +"... self.name = name\n" +"...\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "__init__ is called when ever an object of the class is constructed.That means when ever we will create a student object we will see the message "Creating a new student" in the prompt. You can see the first argument to the method is self. It is a special variable which points to the current object (like `this` in C++). The object is passed implicitly to every method available in it , but we have to get it explicitly in every method while writing the methods. Example shown below." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> std1 = Student()\n" +"Traceback (most recent call last):\n" +" File "<stdin>", line 1, in <module>\n" +"TypeError: __init__() takes exactly 4 arguments (1 given)\n" +">>> std1 = Student('Kushal','CSE','2005')\n" +"A student object is created\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this example at first we tried to create a Student object with passing any argument and python interpreter complained that it takes exactly 4 arguments but received only one (self). Then we created an object with proper argument values and from the message printed, one can easily understand that __init__ method was called as the constructor method." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now we are going to call getName() and setName() methods." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> std1.getName()\n" +"'Kushal'\n" +">>> std1.setName()\n" +"Traceback (most recent call last):\n" +" File "<stdin>", line 1, in <module>\n" +"TypeError: setName() takes exactly 2 arguments (1 given)\n" +">>> std1.setName('Shreyank Gupta')\n" +">>> std1.getName()\n" +"'Shreyank Gupta'\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "First we called getName on the object we created, then tried to call setName without any arguments and we got an error. Next we again called setName with argument 'Shreyank Gupta'. Now calling getName gives 'Shreyank Gupta' as the output." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Inheritance" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In general we human beings always know about inheritance. In programming it is almost the same. When a class inherits another class it inherits all features(like variables and methods) of the parent class. This helps in reusing codes." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the next example we first create a class called Person and create two sub-classes Student and Teacher. As both of the classes are inherited from Person class they will have all methods of Person and will have new methods and variables for their own purpose." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "student_teacher.py" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"\n" +"class Person:\n" +" def __init__(self,name):\n" +" self.name = name\n" +"\n" +" def getDetails(self):\n" +" return self.name\n" +"\n" +"\n" +"class Student(Person):\n" +" def __init__(self,name,branch,year):\n" +" Person.__init__(self,name)\n" +" self.branch = branch\n" +" self.year = year\n" +"\n" +" def getDetails(self):\n" +" return (self.name, self.branch, self.year)\n" +"\n" +"\n" +"class Teacher(Person):\n" +" def __init__(self,name,papers):\n" +" Person.__init__(self,name)\n" +" self.papers = papers\n" +"\n" +" def getDetails(self):\n" +" return (self.name, self.papers)\n" +"\n" +"\n" +"person1 = Person('Rahul')\n" +"student1 = Student('Kushal','CSE',2005)\n" +"teacher1 = Teacher('Prashad',['C','C++'])\n" +"\n" +"print person1.getDetails()\n" +"print student1.getDetails()\n" +"print teacher1.getDetails()\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output:" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"[kdas@kdas code]$ ./student_teacher.py\n" +"Rahul\n" +"('Kushal', 'CSE', 2005)\n" +"('Prashad', ['C', 'C++'])\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this example you can see how we called the __init__ method of the class Person in both Studentা and Teacher classes' __init__ method. We also reimplemented getDetails() method of Person class in both Student and Teacher class. So, when we are calling getDetails() method on the teacher1 object it returns based on the object itself (which is of teacher class) and when we call getDetails() on the student1 or person1 object it returns based on getDetails() method implemented in it's own class." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Multiple Inheritance" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "One class can inherit more than one classes. It gets access to all methods and variables of the parent classes. The general syntax is:" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"class MyClass(Parentclass1, Parentclass2,...):\n" +" def __init__(self):\n" +" Parentclass1.__init__(self)\n" +" Parentclass2.__init__(self)\n" +" ...\n" +" ...\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Deleting an object" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "As we already know how to create an object , now we are going to see how to delete an python object. We use del for this." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "I love you"\n" +">>> del s\n" +">>> s\n" +"Traceback (most recent call last):\n" +" File "<stdin>", line 1, in <module>\n" +"NameError: name 's' is not defined\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "del actually decreases reference count by one. When the reference count of an object becomes zero the garbage collector will delete that object." +msgstr "" + diff --git a/zh-CN/datastructure.po b/zh-CN/datastructure.po new file mode 100644 index 0000000..ab6cc09 --- /dev/null +++ b/zh-CN/datastructure.po @@ -0,0 +1,718 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "Data Structures" +msgstr "数据结构" + +#. Tag: para +#, no-c-format +msgid "Python is having a few built-in data structure. If you are still wondering what is a data structure, then it is nothing a but a way to store data and the having particular methods to retrieve or manipulate it. We already saw lists before, now we will go in depth." +msgstr "Python有许多内建的数据结构。如果你还想知道什么是数据结构,其实她除了存储数据和一些特殊的操作技巧之外什么也不是。我们在以前已经见过列表了,现在我们来深入的了解一下。" + +#. Tag: title +#, no-c-format +msgid "Lists" +msgstr "列表" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = [23, 45, 1, -3434, 43624356, 234]\n" +">>> a.append(45)\n" +">>> a\n" +"[23, 45, 1, -3434, 43624356, 234, 45]\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "At first we created a list a. Then to add 45 at the end of the list we call a.append(45) method. You can see that 45 added at the end of the list. Sometimes it may require to insert data at any place within the list, for that we have insert() method." +msgstr "首先我们建立了一个列表 a. 然后添加元素 45 到列表的末尾,我们调用函数 a.append(45)。 你可以看到元素 45 已经添加到列表的末端了。 有时候我们需要将数据插入到列表的任何位置,这时我们使用函数insert()。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a.insert(0, 1) # 1 added at the 0th position of the list\n" +">>> a\n" +"[1, 23, 45, 1, -3434, 43624356, 234, 45]\n" +">>> a.insert(0, 111)\n" +">>> a\n" +"[111, 1, 23, 45, 1, -3434, 43624356, 234, 45]\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "count(s) will return you number of times s is in the list. Here we are going to check how many times 45 is there in the list." +msgstr "count(s)将返回出现在列表中 s 的次数。这里我们将检验在此列表中出现45 的次数。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a.count(45)\n" +"2\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "If you want to any particular value from the list you have to use remove() method." +msgstr "如果你想从列表中去掉一些元素,那么请使用函数remove()。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a.remove(234)\n" +">>> a\n" +"[111, 1, 23, 45, 1, -3434, 43624356, 45]\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now to reverse the whole list" +msgstr "将整个列表反转后输出" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a.reverse()\n" +">>> a\n" +"[45, 43624356, -3434, 1, 45, 23, 1, 111]\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We can store anything in the list, so first we are going to add another list b in a , then we will learn how to add the values of b into a ." +msgstr "我们可以在列表里存储任何数据,现在我们来将一个列表b 添加到列表a 中,呵呵,你看到了吧!我们接着学习如何将b 中的值添加到a 中。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> b = [45, 56, 90]\n" +">>> a.append(b)\n" +">>> a\n" +"[45, 43624356, -3434, 1, 45, 23, 1, 111, [45, 56, 90]]\n" +">>> a[-1]\n" +"[45, 56, 90]\n" +">>> a.extend(b) #To add the values of b not the b itself\n" +">>> a\n" +"[45, 43624356, -3434, 1, 45, 23, 1, 111, [45, 56, 90], 45, 56, 90]\n" +">>> a[-1]\n" +"90\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Above you can see how we used a.extend() method to extend the list. To sort any list we have sort() method." +msgstr "如上,你可以看到我们用a.extend()方法来扩展列表的了。要是为列表排序,我们使用sort()方法。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a.sort()\n" +">>> a\n" +"[-3434, 1, 1, 23, 45, 45, 45, 56, 90, 111, 43624356, [45, 56, 90]]\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can also delete element at any particular position of the list using the del keyword." +msgstr "你也可以用关键字del来删除列表中的任何元素。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> del a[-1]\n" +">>> a\n" +"[-3434, 1, 1, 23, 45, 45, 45, 56, 90, 111, 43624356]\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Using lists as stack and queue" +msgstr "将列表用作栈和队列" + +#. Tag: para +#, no-c-format +msgid "Stacks are often known as LIFO (Last In First Out) structure. It means the data will enter into it at the end , and the last data will come out first. The easiest example can be of couple of marbles in an one side closed pipe. So if you want to take the marbles out of it you have to do that from the end where you entered the last marble. To achieve the same in code" +msgstr "栈是我们通常所说的一种LIFO(Last In First Out)数据结构。它的意思是数据在最后的位置上进入,并且最后进入的数据第一个出来。最简单的例子洗一打盘子,如果你想让最下边的那个盘子,你必须将上面的一一拿走,最先拿走的就是最上面的那个盘子。代码同样可以达到目标" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a\n" +"[1, 2, 3, 4, 5, 6]\n" +">>> a.pop()\n" +"6\n" +">>> a.pop()\n" +"5\n" +">>> a.pop()\n" +"4\n" +">>> a.pop()\n" +"3\n" +">>> a\n" +"[1, 2]\n" +">>> a.append(34)\n" +">>> a\n" +"[1, 2, 34)\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We learned a new method above pop(). pop(i) will take out the ith data from the list." +msgstr "我们刚学到一新的方法,如上pop().pop(i)方法,可以从列表中将第i个元素踢出来。" + +#. Tag: para +#, no-c-format +msgid "In our daily life we have to encounter queues many times, like in ticket counters or in library or in the billing section of any supermarket. Queue is the data structure where you can append more data at the end and take out data from the beginning. That is why it is known as FIFO (First In First Out)." +msgstr "在我们每天的生活中都可以遇到队列多次,比如售票窗口、图书馆、超市的结帐出口。队列是一种你可以在后面追加数据但只能从开始拿出数据的数据结构,这就是为什么它是FIFO(First In First Out)." + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = [1, 2, 3, 4, 5]\n" +">>> a.append(1)\n" +">>> a\n" +"[1, 2, 3, 4, 5, 1]\n" +">>> a.pop(0)\n" +"1\n" +">>> a.pop(0)\n" +"2\n" +">>> a\n" +"[3, 4, 5, 1]\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To take out the first element of the list we are using a.pop(0)." +msgstr "欲从列表中踢出第一个元素,我们用方法a.pop(0)" + +#. Tag: title +#, no-c-format +msgid "List Comprehensions" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "List comprehensions provide a concise way to create lists. Each list comprehension consists of an expression followed by a for clause, then zero or more for or if clauses. The result will be a list resulting from evaluating the expression in the context of the for and if clauses which follow it." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "For example if we want to make a list out of the square values of another list, then" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = [1, 2, 3]\n" +">>> [x ** 2 for x in a]\n" +"[1, 4, 9]\n" +">>> z = [x + 1 for x in [x ** 2 for x in a]]\n" +">>> z\n" +"[2, 5, 10]\n" +"\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Above in the second case we used two list comprehensions in a same line." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Tuples" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Tuples are data separated by comma." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = 'Fedora', 'Debian', 'Kubuntu', 'Pardus'\n" +">>> a\n" +"('Fedora', 'Debian', 'Kubuntu', 'Pardus')\n" +">>> a[1]\n" +"'Debian'\n" +">>> for x in a:\n" +"... print x,\n" +"...\n" +"Fedora Debian Kubuntu Pardus\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can also unpack values of any tuple in to variables, like" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> divmod(15,2)\n" +"(7, 1)\n" +">>> x, y = divmod(15,2)\n" +">>> x\n" +"7\n" +">>> y\n" +"1\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Tuples are immutable, that means you can not del/add/edit any value inside the tuple. Here is another example" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = (1, 2, 3, 4)\n" +">>> del a[0]\n" +"Traceback (most recent call last):\n" +" File "<stdin>", line 1, in <module>\n" +"TypeError: 'tuple' object doesn't support item deletion\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Above you can see python is giving error when we are trying to delete a value in the tuple." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To create a tuple which contains only one value you have to type a trailing comma." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = (123)\n" +">>> a\n" +"123\n" +">>> type(a)\n" +"<type 'int'>\n" +">>> a = (123, ) #Look at the trailing comma\n" +">>> a\n" +"(123,)\n" +">>> type(a)\n" +"<type 'tuple'>\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Using the buitin function type() you can know the data type of any variable. Remember the len() function we used to find the length of any sequence ?" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> type(len)\n" +"<type 'bulletin_function_or_method'>\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Sets" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Sets are another type of data structure with no duplicate items. We can also mathematical set operations on sets." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = set('abcthabcjwethddda')\n" +">>> a\n" +"set(['a', 'c', 'b', 'e', 'd', 'h', 'j', 't', 'w'])\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "And some examples of the set operations" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = set('abracadabra')\n" +">>> b = set('alacazam')\n" +">>> a # unique letters in a\n" +"set(['a', 'r', 'b', 'c', 'd'])\n" +">>> a - b # letters in a but not in b\n" +"set(['r', 'd', 'b'])\n" +">>> a | b # letters in either a or b\n" +"set(['a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'])\n" +">>> a & b # letters in both a and b\n" +"set(['a', 'c'])\n" +">>> a ^ b # letters in a or b but not both\n" +"set(['r', 'd', 'b', 'm', 'z', 'l'])\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To add or pop values from a set" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a\n" +"set(['a', 'c', 'b', 'e', 'd', 'h', 'j', 'q', 't', 'w'])\n" +">>> a.add('p')\n" +">>> a\n" +"set(['a', 'c', 'b', 'e', 'd', 'h', 'j', 'q', 'p', 't', 'w'])\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Dictionaries" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Dictionaries are unordered set of key: value pairs where keys are unique. We declare dictionaries using {} braces. We use dictionaries to store data for any particular key and then retrieve them." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> data = {'kushal':'Fedora', 'kart_':'Debian', 'Jace':'Mac'}\n" +">>> data\n" +"{'kushal': 'Fedora', 'Jace': 'Mac', 'kart_': 'Debian'}\n" +">>> data['kart_']\n" +"'Debian'\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We can add more data to it by simply" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> data['parthan'] = 'Ubuntu'\n" +">>> data\n" +"{'kushal': 'Fedora', 'Jace': 'Mac', 'kart_': 'Debian', 'parthan': 'Ubuntu'}\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To delete any particular key:value pair" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> del data['kushal']\n" +">>> data\n" +"{'Jace': 'Mac', 'kart_': 'Debian', 'parthan': 'Ubuntu'\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To check if any key is there in the dictionary or not you can use has_key() or in keyword." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> data.has_key('Soumya')\n" +"False\n" +">>> 'Soumya' in data\n" +"False\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You must remember that no mutable object can be a key, that means you can not use a list as a key." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "dict() can create dictionaries from tuples of key,value pair." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> dict((('Indian','Delhi'),('Bangladesh','Dhaka')))\n" +"{'Indian': 'Delhi', 'Bangladesh': 'Dhaka'}\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "If you want to loop through a dict use iteritems() method." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> data\n" +"{'Kushal': 'Fedora', 'Jace': 'Mac', 'kart_': 'Debian', 'parthan': 'Ubuntu'}\n" +">>> for x, y in data.iteritems():\n" +"... print "%s uses %s" % (x, y)\n" +"...\n" +"Kushal uses Fedora\n" +"Jace uses Mac\n" +"kart_ uses Debian\n" +"parthan uses Ubuntu\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "If you want to loop through a list (or any sequence) and get iteration number at the same time you have to use enumerate()." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> for i, j in enumerate(['a', 'b', 'c']):\n" +"... print i, j\n" +"...\n" +"0 a\n" +"1 b\n" +"2 c\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You may also need to iterate through two sequences same time, for that use zip() function." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = ['Pradeepto', 'Kushal']\n" +">>> b = ['OpenSUSE', 'Fedora']\n" +">>> for x, y in zip(a, b):\n" +"... print "%s uses %s" % (x, y)\n" +"...\n" +"Pradeepto uses OpenSUSE\n" +"Kushal uses Fedora\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "students.py" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this example , you have to take number of students as input , then ask marks for three subjects as 'Physics', 'Maths', 'History', if the total number for any student is less 120 then print he failed, or else say passed." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"n = int(raw_input("Enter the number of students:"))\n" +"data = {} # here we will store the data\n" +"languages = ('Physics', 'Maths', 'History') #all languages\n" +"for i in range(0, n): #for the n number of students\n" +" name = raw_input('Enter the name of the student %d: ' % (i + 1)) #Get the name of the student\n" +" marks = []\n" +" for x in languages:\n" +" marks.append(int(raw_input('Enter marks of %s: ' % x))) #Get the marks for languages\n" +" data[name] = marks\n" +"for x, y in data.iteritems():\n" +" total = sum(y)\n" +" print "%s 's total marks %d" % (x, total)\n" +" if total < 120:\n" +" print "%s failed :(" % x\n" +" else:\n" +" print "%s passed :)" % y\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./students.py\n" +"Enter the number of students:2\n" +"Enter the name of the student 1: Babai\n" +"Enter marks of Physics: 12\n" +"Enter marks of Maths: 45\n" +"Enter marks of History: 40\n" +"Enter the name of the student 2: Ria\n" +"Enter marks of Physics: 89\n" +"Enter marks of Maths: 98\n" +"Enter marks of History: 40\n" +"Babai 's total marks 97\n" +"Babai failed :(\n" +"Ria 's total marks 227\n" +"Ria passed :)\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "matrixmul.py" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this example we will multiply two matrix's. First we will take input the number of rows/columns in the matrix (here we assume we are using n x n matrix). Then values of the matrix's." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"n = int(raw_input("Enter the value of n: "))\n" +"print "Enter values for the Matrix A"\n" +"a = []\n" +"for i in range(0, n):\n" +" a.append([int(x) for x in raw_input("").split(" ")])\n" +"print "Enter values for the Matrix B"\n" +"b = []\n" +"for i in range(0, n):\n" +" b.append([int(x) for x in raw_input("").split(" ")])\n" +"c = []\n" +"for i in range(0, n):\n" +" c.append([a[i][j] * b[j][i] for j in range(0,n)])\n" +"print "After matrix multiplication"\n" +"print "-" * 10 * n\n" +"for x in c:\n" +" for y in x:\n" +" print "%5d" % y,\n" +" print ""\n" +"print "-" * 10 * n\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./matrixmul.py\n" +"Enter the value of n: 3\n" +"Enter values for the Matrix A\n" +"1 2 3\n" +"4 5 6\n" +"7 8 9\n" +"Enter values for the Matrix B\n" +"9 8 7\n" +"6 5 4\n" +"3 2 1\n" +"After matrix multiplication\n" +"------------------------------\n" +" 9 12 9\n" +" 32 25 12\n" +" 49 32 9\n" +"------------------------------\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Here we have used list comprehensions couple of times. [int(x) for x in raw_input("").split(" ")] here first it takes the input as string by raw_input(), then split the result by " ", then for each value create one int. We are also using [a[i][j] * b[j][i] for j in range(0,n)] to get the resultant row in a single line." +msgstr "" diff --git a/zh-CN/file.po b/zh-CN/file.po new file mode 100644 index 0000000..e077433 --- /dev/null +++ b/zh-CN/file.po @@ -0,0 +1,409 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "File handling" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "A file is some information or data which stays in the computer storage devices. You already know about different kinds of file , like your music files, video files, text files. Python gives you easy ways to manipulate these files. Generally we divide files in two categories, text file and binary file. Text files are simple text where as the binary files contain binary data which is only readable by computer." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "File opening" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To open a file we use open() function. It requires two arguments, first the file path or file name, second which mode it should open. Modes are like" +msgstr "" + +#. Tag: member +#, no-c-format +msgid ""r" -> open read only, you can read the file but can not edit / delete anything inside" +msgstr "" + +#. Tag: member +#, no-c-format +msgid ""w" -> open with write power, means if the file exists then delete all content and open it to write" +msgstr "" + +#. Tag: member +#, no-c-format +msgid ""a" -> open in append mode" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The default mode is read only, ie if you do not provide any mode it will open the file as read only. Let us open a file" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open("love.txt")\n" +">>> f\n" +"<open file 'love.txt', mode 'r' at 0xb7f2d968>\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Closing a file" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "After opening a file one should always close the opened file. We use method close() for this." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open("love.txt")\n" +">>> f\n" +"<open file 'love.txt', mode 'r' at 0xb7f2d968>\n" +">>> f.close()\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Important" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Always make sure you *explicitly* close each open file, once its job is done and you have no reason to keep it open. Because" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "There is an upper limit to the number of files a program can open. If you exceed that limit, there is no reliable way of recovery, so the program could crash." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Each open file consumes some main-memory for the data-structures associated with it, like file descriptor/handle or file locks etc. So you could essentially end-up wasting lots of memory if you have more files open that are not useful or usable." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Open files always stand a chance of corruption and data loss." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Reading a file" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To read the whole file at once use the read() method." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open("sample.txt")\n" +">>> f.read()\n" +"'I love Python\n" +"Pradeepto loves KDE\n" +"Sankarshan loves Openoffice\n" +"'\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "If you call read() again it will return empty string as it already read the whole file. readline() can help you to read one line each time from the file." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open("sample.txt")\n" +">>> f.readline()\n" +"'I love Python\n" +"'\n" +">>> f.readline()\n" +"'Pradeepto loves KDE\n" +"'\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To read all the all the lines in a list we use readlines() method." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open("sample.txt")\n" +">>> f.readlines()\n" +"['I love Python\n" +"', 'Pradeepto loves KDE\n" +"', 'Sankarshan loves Openoffice\n" +"']\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can even loop through the lines in a file object." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open("sample.txt")\n" +">>> for x in f:\n" +"... print x,\n" +"...\n" +"I love Python\n" +"Pradeepto loves KDE\n" +"Sankarshan loves Openoffice\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Let us write a program which will take the file name as the input from the user and show the content of the file in the console." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"name = raw_input("Enter the file name: ")\n" +"f = open(name)\n" +"print f.read()\n" +"f.close()\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the last line you can see that we closed the file object with the help of close() method." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"[kd@kdlappy book]$ ./showfile.py\n" +"Enter the filename: sample.txt\n" +"I love Python\n" +"Pradeepto loves KDE\n" +"Sankarshan loves Openoffice\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Writing in a file" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Let us open a file then we will write some random text into it by using the write() method." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open("ircnicks.txt", 'w')\n" +">>> f.write('powerpork\n" +"')\n" +">>> f.write('indrag\n" +"')\n" +">>> f.write('mishti\n" +"')\n" +">>> f.write('sm|CPU')\n" +">>> f.close()\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now read the file we just created" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open('ircnicks.txt')\n" +">>> s = f.read()\n" +">>> print s\n" +"powerpork\n" +"indrag\n" +"mishti\n" +"sm|CPU\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "copyfile.py" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this example we will copy a given file to another file." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"import sys\n" +"if len(sys.argv) < 3:\n" +" print "Wrong parameter"\n" +" print "./copyfile.py file1 file2"\n" +" sys.exit(1)\n" +"f1 = open(sys.argv[1])\n" +"s = f1.read()\n" +"f1.close()\n" +"f2 = open(sys.argv[2], 'w')\n" +"f2.write(s)\n" +"f2.close()\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can see we used a new module here sys. sys.argv contains all command line parameters. Remember cp command in shell, after cp we type first the file to be copied and then the new file name." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The first value in sys.argv is the name of the command itself." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"import sys\n" +"print "First value", sys.argv[0]\n" +"print "All values"\n" +"for i, x in enumerate(sys.argv):\n" +" print i, x\n" +"\n" +"" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"[kd@kdlappy book]$ ./argvtest.py Hi there\n" +"First value ./argvtest.py\n" +"All values\n" +"0 ./argvtest.py\n" +"1 Hi\n" +"2 there\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Here we used a new function enumerate(iterableobject), which returns the index number and the value from the iterable object." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Random seeking in a file" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can also randomly move around inside a file using seek() method. It takes two arguments , offset and whence. To know more about it let us read what python help tells us" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "seek(...) seek(offset[, whence]) -> None. Move to new file position. Argument offset is a byte count. Optional argument whence defaults to 0 (offset from start of file, offset should be >= 0); other values are 1 (move relative to current position, positive or negative), and 2 (move relative to end of file, usually negative, although many platforms allow seeking beyond the end of a file). If the file is opened in text mode, only offsets returned by tell() are legal. Use of other offsets causes undefined behavior. Note that not all file objects are speakable." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Let us see one example" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> f = open('tempfile', 'w')\n" +">>> f.write('0123456789abcdef')\n" +">>> f.close()\n" +">>> f = open('tempfile')\n" +">>> f.tell() #tell us the offset position\n" +"0L\n" +">>> f.seek(5) # Goto 5th byte\n" +">>> f.tell()\n" +"5L\n" +">>> f.read(1) #Read 1 byte\n" +"'5'\n" +">>> f.seek(-3, 2) # goto 3rd byte from the end\n" +">>> f.read() #Read till the end of the file\n" +"'def'\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Count spaces, tabs and new lines in a file" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Let us try to write an application which will count the spaces , tabs, and new lines in any given file." +msgstr "" + diff --git a/zh-CN/functions.po b/zh-CN/functions.po new file mode 100644 index 0000000..74d4e13 --- /dev/null +++ b/zh-CN/functions.po @@ -0,0 +1,293 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "Functions" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Reusing the same code is required many times within a same program. Functions help us to do so. We write the things we have to do repeatedly in a function then call it where ever required. We already saw build in functions like len(), divmod()." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Defining a function" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We use def keyword to define a function. general syntax is like" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"def functionname(params):\n" +" statement1\n" +" statement2\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Let us write a function which will take two integers as input and then return the sum." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> def sum(a, b):\n" +"... return a + b\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the second line with the return keyword, we are sending back the value of a + b to the caller. You must call it like" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> res = sum(234234, 34453546464)\n" +">>> res\n" +"34453780698L\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Remember the palindrome program we wrote in the last chapter. Let us write a function which will check if a given string is palindrome or not, then return True or False." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"def palindrome(s):\n" +" z = s\n" +" z = [x for x in z]\n" +" z.reverse()\n" +" if s == "".join(z):\n" +" return True\n" +" else:\n" +" return False\n" +"s = raw_input("Enter a string: ")\n" +"if palindrome(s):\n" +" print "Yay a palindrome"\n" +"else:\n" +" print "Oh no, not a palindrome"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now run the code :)" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Local and global variables" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To understand local and global variables we will go through two examples." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"def change(b):\n" +" a = 90\n" +" print a\n" +"a = 9\n" +"print "Before the function call ", a\n" +"print "inside change function",\n" +"change(a)\n" +"print "After the function call ", a\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"[kd@kdlappy book]$ ./local.py\n" +"Before the function call 9\n" +"inside change function 90\n" +"After the function call 9\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "First we are assigning 9 to a, then calling change function, inside of that we are assigning 90 to a and printing a. After the function call we are again printing the value of a. When we are writing a = 90 inside the function, it is actually creating a new variable called a, which is only available inside the function and will be destroyed after the function finished. So though the name is same for the variable a but they are different in and out side of the function." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"def chvariable ange(b):\n" +" global a\n" +" a = 90\n" +" print a\n" +"a = 9\n" +"print "Before the function call ", a\n" +"print "inside change function",\n" +"change(a)\n" +"print "After the function call ", a\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Here by using global keyword we are telling that a is globally defined, so when we are changing a's value inside the function it is actually changing for the a outside of the function also." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Default argument value" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In a function variables may have default argument values, that means if we don't give any value for that particular variable it will assigned automatically." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> def test(a , b = -99):\n" +"... if a > b:\n" +"... return True\n" +"... else:\n" +"... return False\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the above example we have written b = -99 in the function parameter list. That means of no value for b is given then b's value is -99. This is a very simple example of default arguments. You can test the code by" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> test(12, 23)\n" +"False\n" +">>> test(12)\n" +"True\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Important" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Remember that you can not have an argument without default argument if you already have one argument with default values before it. Like f(a, b=90, c) is illegal as b is having a default value but after that c is not having any default value." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Also remember that default value is evaluated only once, so if you have any mutable object like list it will make a difference. See the next example" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> def f(a, data=[]):\n" +"... data.append(a)\n" +"... return data\n" +"...\n" +">>> print f(1)\n" +"[1]\n" +">>> print f(2)\n" +"[1, 2]\n" +">>> print f(3)\n" +"[1, 2, 3]\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Keyword arguments" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> def func(a, b=5, c=10):\n" +"... print 'a is', a, 'and b is', b, 'and c is', c\n" +"...\n" +">>> func(12, 24)\n" +"a is 12 and b is 24 and c is 10\n" +">>> func(12, c = 24)\n" +"a is 12 and b is 5 and c is 24\n" +">>> func(b=12, c = 24, a = -1)\n" +"a is -1 and b is 12 and c is 24\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the above example you can see we are calling the function with variable names, like func(12, c = 24), by that we are assigning 24 to c and b is getting its default value. Also remember that you can not have without keyword based argument after a keyword based argument. like" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> def func(a, b=13, v):\n" +"... print a, b, v\n" +"...\n" +" File "<stdin>", line 1\n" +"SyntaxError: non-default argument follows default argument\n" +"\n" +"" +msgstr "" + diff --git a/zh-CN/ifelse.po b/zh-CN/ifelse.po new file mode 100644 index 0000000..6ec3351 --- /dev/null +++ b/zh-CN/ifelse.po @@ -0,0 +1,140 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "If-else , the control flow" +msgstr "if-else,控制流程的关键字" + +#. Tag: para +#, no-c-format +msgid "While working on real life of problems we have to make decisions. Decisions like which camera to buy or which cricket bat is better. At the time of writing a computer program we do the same. We make the decisions using if-else statements, we change the flow of control in the program by using them." +msgstr "我们处理现实生活中的问题时会作出决定。决定买那种照相机或者怎么击打棒球较好。同样写计算机程序我们作一样的决定。我们用if-else声明来决定事情,我们用它们可以改变程序运行的流程。" + +#. Tag: title +#, no-c-format +msgid "If statement" +msgstr "if 声明" + +#. Tag: para +#, no-c-format +msgid "The syntax looks like" +msgstr "语法如下" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"if expression:\n" +" do this\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "If the value of expression is true (anything other than zero), do the what is written below under indentation. Please remember to give proper indentation, all the lines indented will be evaluated on the True value of the expression. One simple example is to take some number as input and check if the number is less than 100 or not." +msgstr "如果expression的值为真(不是零的任何数),程序将执行缩排后的内容。记住缩排,在表达式为真的情况下所有行都要被执行。一个简单的例子,接受用户输入一个并且检查它小于100还是不小于100。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"number = int(raw_input("Enter a number: "))\n" +"if number < 100:\n" +" print "The number is less than 100"\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Then we run it" +msgstr "然后我们运行它" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./number100.py\n" +"Enter a number: 12\n" +"The number is less than 100\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Else statement" +msgstr "Else声明" + +#. Tag: para +#, fuzzy, no-c-format +msgid "Now in the above example we want to print "Greater than" if the number is greater than 100. For that we have to use the else statement. This works when the ifstatement is not fulfilled." +msgstr "现在我们需要在上面的例子中打印\"Greater than\"如果数字大于100的话。为此我们用到了 else声明。它将奏效于当if语句不能完全的控制的时候。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"number = int(raw_input("Enter a number: "))\n" +"if number < 100:\n" +" print "The number is less than 100"\n" +"else:\n" +" print "The number is greater than 100"\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "输出" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +" \n" +"[kd@kdlappy book]$ ./number100.py\n" +"Enter a number: 345\n" +"The number is greater than 100\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Another very basic example" +msgstr "另外一个基本的实例" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> x = int(raw_input("Please enter an integer: "))\n" +">>> if x < 0:\n" +"... x = 0\n" +"... print 'Negative changed to zero'\n" +"... elif x == 0:\n" +"... print 'Zero'\n" +"... elif x == 1:\n" +"... print 'Single'\n" +"... else:\n" +"... print 'More'\n" +"\n" +msgstr "" diff --git a/zh-CN/installation.po b/zh-CN/installation.po new file mode 100644 index 0000000..fcdc945 --- /dev/null +++ b/zh-CN/installation.po @@ -0,0 +1,68 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "Installation" +msgstr "安装" + +#. Tag: para +#, no-c-format +msgid "In this chapter you will learn how to install python" +msgstr "在这一章中你将学到如何安装python" + +#. Tag: title +#, no-c-format +msgid "On Windows" +msgstr "Windows下" + +#. Tag: para +#, no-c-format +msgid "You have to download the latest Windows(TM) installer from the python site http://python.org/ftp/python/2.5.2/python-2.5.2.msi . Install it just as any other Windows software." +msgstr "到python官方站点http://python.org/ftp/python/,下载最新的版本带Windows(TM)安装程序的python版本。像安装windows其它的应用程序一样安装python。" + +#. Tag: title +#, no-c-format +msgid "On GNU/Linux" +msgstr "GNU/Linux下" + +#. Tag: para +#, fuzzy, no-c-format +msgid "Generally all GNU/Linux distributions come with Python, so no need to worry about that :) If you don't have it then you can install it by either downloading from the python website or from your distribution's repository." +msgstr "通常的GNU/Linux发行版都包含了Python,所以不用有什么担心:)如果你还没有,那么你可以直接从python的官网下载,也可以从你的发行版仓库中下载安装。" + +#. Tag: para +#, no-c-format +msgid "For Fedora" +msgstr "Fedora下" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"#yum install python\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "For Debian" +msgstr "Debian下" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"#apt-get install python\n" +msgstr "" diff --git a/zh-CN/looping.po b/zh-CN/looping.po new file mode 100644 index 0000000..135f87b --- /dev/null +++ b/zh-CN/looping.po @@ -0,0 +1,728 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "Looping" +msgstr "循环" + +#. Tag: para +#, no-c-format +msgid "In the examples we used before , sometimes it was required to do the same work couple of times. We use a counter to check how many times the code needs to be executed. This technique is known as looping. First we are going to look into while statement for looping." +msgstr "在以前我们用过的例子中,有时候会遇到作同样的事情多次这种需求。我们用计数器去检查究竟是需要多少次代码执行,这种技术就是众所周知的循环。首先我们来学习while语句实现的循环。" + +#. Tag: title +#, no-c-format +msgid "While loop" +msgstr "While循环" + +#. Tag: para +#, no-c-format +msgid "The syntax for while statement is like" +msgstr "while语句的语法规则如下" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"while condition:\n" +" statement1\n" +" statement2\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The code we want to reuse must be indented properly under the while statement. They will be executed if the condition is true. Again like in if-else statement any non zero value is true. Let us write a simple code to print numbers 0 to 10" +msgstr "如果condition条件为真,while语句之下的代码放在while语句之下,将重复执行。正如 语句if-else 不等于0为真。来看一个打印数字0到10的实例" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> n = 0\n" +">>> while n < 11:\n" +"... print n\n" +"... n += 1\n" +"...\n" +"0\n" +"1\n" +"2\n" +"3\n" +"4\n" +"5\n" +"6\n" +"7\n" +"8\n" +"9\n" +"10\n" +"\n" +msgstr "" + +#. Tag: para +#, fuzzy, no-c-format +msgid "In the first line we are setting n = 0, then in the while statement the condition is n < 11 , that means what ever line indented below that will execute until n becomes same or greater than 11. Inside the loop we are just printing the value of n and then increasing it by one." +msgstr "在第一行我们初始化 n = 0,接下来给定while的条件n 11 ,它的意思是直到n 等于或大于11时才停止执行下面的代码。在循环内部我们打印n的值并且每次增加1。" + +#. Tag: title +#, no-c-format +msgid "Fibonacci Series" +msgstr "斐波那契数列" + +#. Tag: para +#, no-c-format +msgid "Let us try to solve Fibonacci series. In this series we get the next number by adding the previous two numbers. So the series looks like 1,1,2,3,5,8,13 ......." +msgstr "让我们试着去解决Fibonacci数列的问题。这此数列中我们知道是下一个数字是其前两个数的和。所以数列看其来是这个样子的1,1,2,3,5,8,13 ......." + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"a, b = 0, 1\n" +"while b < 100:\n" +" print b\n" +" a, b = b, a + b\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "输出" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./fibonacci1.py\n" +"1\n" +"1\n" +"2\n" +"3\n" +"5\n" +"8\n" +"13\n" +"21\n" +"34\n" +"55\n" +"89\n" +"\n" +msgstr "" + +#. Tag: para +#, fuzzy, no-c-format +msgid "In the first line of the code we are initializing a and b, then looping while b's value is less than 100. Inside the loop first we are printing the value of b and then in the next line putting the value of b to a and a + b to b in the same line." +msgstr "代码的第一行我们初始化了ab,while的条件是b的值小于100.在循环内部我们先打印出b的值,然后紧接着将b 的值给 a ,并且使a + b 的值赋予b 。" + +#. Tag: para +#, no-c-format +msgid "If you put a trailing comma in the print statement , then it will print in the same line" +msgstr "如果你在print 语句后加一个逗号,输出将在同一行" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"a, b = 0, 1\n" +"while b < 100:\n" +" print b,\n" +" a, b = b, a + b\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./fibonacci2.py\n" +"1 1 2 3 5 8 13 21 34 55 89\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Power Series" +msgstr "幂级数" + +#. Tag: para +#, fuzzy, no-c-format +msgid "Let us write a program to evaluate the power series. The series looks like e**x =1+x+x**2/2! +x**3/3! +....+ x**n/n! where 0 < x < 1" +msgstr "让我们写一个程序来计算幂级数,形如e**x =1+x+x**2/2! +x**3/3! +....+ x**n/n! 当 " + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"x = float(raw_input("Enter the value of x: "))\n" +"n = term = num = 1\n" +"sum = 1.0\n" +"while n <= 100:\n" +" term *= x / n\n" +" sum += terrm\n" +" n += 1\n" +" if term < 0.0001:\n" +" break\n" +"print "No of Times= %d and Sum= %f" % (n, sum)\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"kd@kdlappy book]$ ./powerseries.py\n" +"Enter the value of x: 0\n" +"No of Times= 2 and Sum= 1.000000\n" +"[kd@kdlappy book]$ ./powerseries.py\n" +"Enter the value of x: 0.1\n" +"No of Times= 5 and Sum= 1.105171\n" +"[kd@kdlappy book]$ ./powerseries.py\n" +"Enter the value of x: 0.5\n" +"No of Times= 7 and Sum= 1.648720\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this program we introduced a new keyword called break. What break does is stop the innermost loop. In this example we are using break under the if statement" +msgstr "在此程序中我们介绍了一新的关键字叫做break。break就是终止内部循环。在此例中我们用到的break是在if 语句中" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"if term < 0.0001:\n" +" break\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "This means if the value of term is less than 0.0001 then get out of the loop." +msgstr "这句话的意思是当term 的值小于0.0001时跳出循环。" + +#. Tag: title +#, no-c-format +msgid "Multiplication Table" +msgstr "乘法表" + +#. Tag: para +#, no-c-format +msgid "In this example we are going to print the multiplication table up to 10." +msgstr "此例中我们将打印从1到10的乘法表。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"i = 1\n" +"print "-" * 50\n" +"while i < 11:\n" +" n = 1\n" +" while n <= 10:\n" +" print "%4d" % (i * n),\n" +" n += 1\n" +" print ""\n" +" i += 1\n" +"print "-" * 50\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./multiplication.py\n" +"--------------------------------------------------\n" +" 1 2 3 4 5 6 7 8 9 10\n" +" 2 4 6 8 10 12 14 16 18 20\n" +" 3 6 9 12 15 18 21 24 27 30\n" +" 4 8 12 16 20 24 28 32 36 40\n" +" 5 10 15 20 25 30 35 40 45 50\n" +" 6 12 18 24 30 36 42 48 54 60\n" +" 7 14 21 28 35 42 49 56 63 70\n" +" 8 16 24 32 40 48 56 64 72 80\n" +" 9 18 27 36 45 54 63 72 81 90\n" +" 10 20 30 40 50 60 70 80 90 100\n" +"--------------------------------------------------\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Here we used one while loop inside another loop, this is known as nested looping. You can also see one interesting statement here" +msgstr "这里是一个while循环里还有一个while循环,这就是循环的嵌套。你会看到在循环中更有意思的语句" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"print "-" * 50\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In a print statement if we multiply the string with an integer n , the string will be printed nmany times. Some examples" +msgstr "在print语句中,如果我们定义了整数n 个字符,那么这个字符将被打印n次。如下例子" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> print "*" * 10\n" +"**********\n" +">>> print "#" * 20\n" +"####################\n" +">>> print "--" * 20\n" +"----------------------------------------\n" +">>> print "-" * 40\n" +"----------------------------------------\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Some printing * examples" +msgstr "一些打印*的实例" + +#. Tag: para +#, no-c-format +msgid "Here are some examples which you can find very often in college lab reports" +msgstr "如下的几个例子,你会在大学实验室的报告里会经常看到" + +#. Tag: para +#, no-c-format +msgid "Design 1" +msgstr "设计 1" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"row = int(raw_input("Enter the number of rows: "))\n" +"n = row\n" +"while n >= 0:\n" +" x = "*" * n\n" +" print x\n" +" n -= 1\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./design1.py\n" +"Enter the number of rows: 5\n" +"*****\n" +"****\n" +"***\n" +"**\n" +"*\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Design 2" +msgstr "设计 2" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"n = int(raw_input("Enter the number of rows: "))\n" +"i = 1\n" +"while i <= n:\n" +" print "*" * i\n" +" i += 1\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./design2.py\n" +"Enter the number of rows: 5\n" +"*\n" +"**\n" +"***\n" +"****\n" +"*****\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Design 3" +msgstr "设计 3" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"row = int(raw_input("Enter the number of rows: "))\n" +"n = row\n" +"while n >= 0:\n" +" x = "*" * n\n" +" y = " " * (row - n)\n" +" print y + x\n" +" n -= 1\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./design3.py\n" +"Enter the number of rows: 5\n" +"*****\n" +" ****\n" +" ***\n" +" **\n" +" *\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Lists" +msgstr "列表" + +#. Tag: para +#, no-c-format +msgid "We are going to learn a data structure called list before we go ahead to learn more on looping. Lists an be written as a list of comma-separated values (items) between square brackets." +msgstr "在进一步学习循环之前,我们先学习一个叫做list的数据结构。Lists(列表)的写法是用中括号括起来的每个值(项)都用逗号分开。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = [ 1 , 342, 2233423, 'India', 'Fedora']\n" +">>> a\n" +"[1, 342, 2233423, 'India', 'Fedora']\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Lists can keep any other data inside it. It works as a sequence too, that means" +msgstr "列表中可以保存任何数据,它也可以用于队列,意思是" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a[0]\n" +"1\n" +">>> a[4]\n" +"'Fedora'\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can even slice it into different pieces, examples are given below" +msgstr "你可以利用切片将之分成不同的部分,如下实例" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a[4]\n" +"'Fedora'\n" +">>> a[-1]\n" +"'Fedora'\n" +">>> a[-2]\n" +"'India'\n" +">>> a[0:-1]\n" +"[1, 342, 2233423, 'India']\n" +">>> a[2:-2]\n" +"[2233423]\n" +">>> a[:-2]\n" +"[1, 342, 2233423]\n" +">>> a[0::2]\n" +"[1, 2233423, 'Fedora']\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the last example we used two :(s) , the last value inside the third brackets indicates step. s[i:j:k] means slice of s from i to j with step k." +msgstr "最后一个例子我们用到了两个:(s),在中括号里的最后一个值指定步骤。s[i:j:k]的意思是从 ij with用了k步将s切片." + +#. Tag: para +#, no-c-format +msgid "To check if any value exists within the list or not you can do" +msgstr "检查列表中是否含有给定的值" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = ['Fedora', 'is', 'cool']\n" +">>> 'cool' in a\n" +"True\n" +">>> 'Linux' in a\n" +"False\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "That means we can use the above statement as if clause expression. The built-in function len() can tell the length of a list." +msgstr "意思是我们可以使用上述的语句像if子句表达式一样。内建函数len()可以返回列表的长度。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> len(a)\n" +"3\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "For loop" +msgstr "For 循环" + +#. Tag: para +#, no-c-format +msgid "There is another to loop by using for statement. In python the for statement is different from the way it works in C. Here for statement iterates over the items of any sequence (a list or a string). Example given below" +msgstr "另外一个更常见的循环语句是for 。在Python中for 语句是和C中有着不同。这里是for语句的一个重复队列项(列表或字符)的例子。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = ['Fedora', 'is', 'powerfull']\n" +">>> for x in a:\n" +"... print x,\n" +"...\n" +"Fedora is powerfull\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We can also do things like" +msgstr "我们也可以像这样去做" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +">>> a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n" +">>> for x in a[::2]:\n" +"... print x\n" +"...\n" +"1\n" +"3\n" +"5\n" +"7\n" +"9\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "range() function" +msgstr "range()函数" + +#. Tag: para +#, no-c-format +msgid "range() is a buitin function. From the help document" +msgstr "range() 是一内建的函数,查看帮助文档会得到如下内容" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"range(...)\n" +" range([start,] stop[, step]) -> list of integers\n" +" Return a list containing an arithmetic progression of integers.\n" +" range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.\n" +" When step is given, it specifies the increment (or decrement).\n" +" For example, range(4) returns [0, 1, 2, 3]. The end point is omitted!\n" +" These are exactly the valid indices for a list of 4 elements.\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now if you want to see this help message on your system type help(range) in the python interpreter. help(s) will return help message on the object s. Examples of range function" +msgstr "这个时候如果你想在你的系统里查看帮助信息,在python解释器中敲入help(range)即可。help(s)返回对象s的帮助信息。range 函数的例子" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> range(1,5)\n" +"[1, 2, 3, 4]\n" +">>> range(1,15,3)\n" +"[1, 4, 7, 10, 13]\n" +">>> range(10)\n" +"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Continue statement" +msgstr "Continue 语句" + +#. Tag: para +#, no-c-format +msgid "Just like break we have another statement, continue, which skips the execution of the code after itself and goes back to the start of the loop. That means it will help you to skip a part of the loop. In the below example we will ask the user to input an integer, if the input is negative then we will ask again, if positive then we will square the number. To get out of the infinite loop user must input 0." +msgstr "和break 语句一样的另外一个忽略当前循环条件并返回到循环的开始的语句是continue,这意味着它可以帮助你忽略一部分循环。下面的例子中我们将对用户的输入整型进行提问,如果输入负数我们接着问,否则我们给出其平方后的值。退出循环你必须输入数字0." + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"while True:\n" +" n = int(raw_input("Please enter an Integer: "))\n" +" if n < 0:\n" +" continue #this will take the execution back to the starting of the loop\n" +" elif n == 0:\n" +" break\n" +" print "Square is ", n ** 2\n" +"print "Goodbye"\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"[kd@kdlappy book]$ ./continue.py\n" +"Please enter an Integer: 34\n" +"Square is 1156\n" +"Please enter an Integer: 4\n" +"Square is 16\n" +"Please enter an Integer: -9\n" +"Please enter an Integer: 0\n" +"Goodbye\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Else loop" +msgstr "Else循环" + +#. Tag: para +#, no-c-format +msgid "We can have an optional else statement after any loop. It will be executed after the loop unless a break statement stopped the loop." +msgstr "我们可以赋予loop循环之后的else语句内容,以便于在循环之后执行,当然在有break 语句停止循环的情况下例外。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> for i in range(0,5):\n" +"... print i\n" +"... else:\n" +"... print "Bye bye"\n" +"...\n" +"0\n" +"1\n" +"2\n" +"3\n" +"4\n" +"Bye bye\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We will see more example of break and continue later in the book." +msgstr "在本书的以后,你将会看到更多的关于breakcontinue例子。" + +#. Tag: title +#, no-c-format +msgid "Game of sticks" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "This is a very simple game of sticks. There are 21 sticks, first the user picks number of sticks between 1-4, then the computer picks sticks(1-4). Who ever will pick the last stick will loose. Can you find out the case when the user will win ?" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"\n" +"sticks = 21\n" +"\n" +"print "There are 21 sticks, you can take 1-4 number of sticks at a time."\n" +"print "Whoever will take the last stick will loose"\n" +"\n" +"while True:\n" +" print "Sticks left: " , sticks\n" +" sticks_taken = int(raw_input("Take sticks(1-4):"))\n" +" if sticks == 1:\n" +" print "You took the last stick, you loose"\n" +" break\n" +" if sticks_taken >=5 or sticks_taken <=0:\n" +" print "Wrong choice"\n" +" continue\n" +" print "Computer took: " , (5 - sticks_taken) , "\n" +"\n" +""\n" +" sticks -= 5\n" +"\n" +"\n" +msgstr "" diff --git a/zh-CN/modules.po b/zh-CN/modules.po new file mode 100644 index 0000000..6a03b69 --- /dev/null +++ b/zh-CN/modules.po @@ -0,0 +1,263 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "Modules" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this chapter we are going to learn about Python modules." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Introduction" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Still now when ever we wrote code in the python interpreter, after we came out of it, the code was lost. But in when one writes a larger program, people breaks their codes into different files and reuse then as required. In python we do this by modules. Modules are nothing files with Python definitions and statements. The module name is same as the file name without the .py extension." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can find the name of the module by accessing the __name__ variable. It is a global variable." +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now we are going to see how modules work. Create a file called greetings.py. Content of the file is given bellow." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#Bars module\n" +"\n" +"def starbar(num):\n" +" print '*' * num\n" +"\n" +"def hashbar(num):\n" +" print '#' * num\n" +"\n" +"def simplebar(num):\n" +" print '-' * num\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now we are going to start the python interpreter and import our module." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> import bars\n" +">>>\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "This will import the module bars. We have to use the module name to access functions inside the module." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> bars.hashbar(10)\n" +"##########\n" +">>> bars.simplebar(10)\n" +"----------\n" +">>> bars.starbar(10)\n" +"**********\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Importing modules" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "There are different ways to import modules. We already saw one way to do this. You can even import selected functions from modules. To do so:" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> from bars import simplebar, starbar\n" +">>> simplebar(20)\n" +"--------------------\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Or you can import all functions or variables from a module directly into the current namespace by using *" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> from bars import *\n" +">>> hashbar(20)\n" +"####################\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Default modules" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now your Python installation comes with different modules installed, you can use them as required and install new modules for any other special purposes. In the following few examples we are going to see many examples on the same." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> help()\n" +"\n" +"Welcome to Python 2.6! This is the online help utility.\n" +"\n" +"If this is your first time using Python, you should definitely check out\n" +"the tutorial on the Internet at http://docs.python.org/tutorial/.\n" +"\n" +"Enter the name of any module, keyword, or topic to get help on writing\n" +"Python programs and using Python modules. To quit this help utility and\n" +"return to the interpreter, just type "quit".\n" +"\n" +"To get a list of available modules, keywords, or topics, type "modules",\n" +""keywords", or "topics". Each module also comes with a one-line summary\n" +"of what it does; to list the modules whose summaries contain a given word\n" +"such as "spam", type "modules spam".\n" +"\n" +"help> modules\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The above example shows how to get the list of all installed modules in your system. I am not pasting them here as it is a big list in my system :)" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Module os" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "os module provides operating system dependent functionality. You can import it using the following import statement." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> import os\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "getuid() function returns the current process's effective user's id." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> os.getuid()\n" +"500\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "getpid() returns the current process's id. getppid() returns the parent process's id." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> os.getpid()\n" +"16150\n" +">>> os.getppid()\n" +"14847\n" +"\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "uname() returns different information identifying the operating system, in Linux it returns details you can get from the uname command. The returned object is a tuple, (sysname, nodename, release, version, machine)" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> os.uname()\n" +"('Linux', 'd80', '2.6.34.7-56.fc13.i686.PAE', '#1 SMP Wed Sep 15 03:27:15 UTC 2010', 'i686')\n" +"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "getcwd()returns the current working directory. chdir(path) changes the current working directory to path. In the example we first see the current directory which is my home directory and change the current directory to /tmp and then again checking the current directory." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +">>> os.getcwd()\n" +"'/home/kdas'\n" +">>> os.chdir('/tmp')\n" +">>> os.getcwd()\n" +"'/tmp'\n" +"\n" +"" +msgstr "" + diff --git a/zh-CN/operatorsexpressions.po b/zh-CN/operatorsexpressions.po new file mode 100644 index 0000000..2b4ae00 --- /dev/null +++ b/zh-CN/operatorsexpressions.po @@ -0,0 +1,550 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "Operators and expressions" +msgstr "运算符和表达式" + +#. Tag: para +#, no-c-format +msgid "In python most of the lines you will write will be expressions. Expressions are made of operators and operands. An expression is like 2 + 3 ." +msgstr "在Python代码中你将用到大量的表达式。表达式由操作符和操作数组成。像2 + 3就是一个表达式。" + +#. Tag: title +#, no-c-format +msgid "Operators" +msgstr "运算符" + +#. Tag: para +#, no-c-format +msgid "Operators are the symbols which tells the python interpreter to do some mathematical or logical operation. Few basic examples of mathematical operators are given below:" +msgstr "运算符只是一种告诉python解释器去做一些数学或逻辑操作的符号。一些基本的数学操作符如下所示:" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> 2 + 3\n" +"5\n" +">>> 23 - 3\n" +"20\n" +">>> 22.0 / 12\n" +"1.8333333333333333\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To get floating result you need to the division using any of operand as floating number. To do modulo operation use % operator" +msgstr "想要得到浮点数的结果,你必须用浮点数作操作数来实现除法运算。求余的符号是 % " + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> 14 % 3\n" +"2\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Example of integer arithmetic" +msgstr "整型计算的实例" + +#. Tag: para +#, no-c-format +msgid "The code" +msgstr "代码" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"days = int(raw_input("Enter days: "))\n" +"months = days / 30\n" +"days = days % 30\n" +"print "Months = %d Days = %d" % (months, days)\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "输出" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./integer.py\n" +"Enter days: 265\n" +"Months = 8 Days = 25\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the first line I am taking the input of days, then getting the months and days and at last printing them. You can do it in a easy way" +msgstr "在头一行中我获得用户输入的天数,然后得到月份数和具体的天数并打印出来。你可以使用更容易的方法" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"days = int(raw_input("Enter days: "))\n" +"print "Months = %d Days = %d" % (divmod(days, 30))\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The divmod(num1, num2) function returns two values , first is the division of num1 and num2 and in second the modulo of num1 and num2." +msgstr "divmod(num1, num2)函数返回两个值,第一个是num1和num2相除得到的值,第二个是num1和num2求余得到的值。" + +#. Tag: title +#, no-c-format +msgid "Relational Operators" +msgstr "关系操作符" + +#. Tag: para +#, no-c-format +msgid "You can use the following operators as relational operators" +msgstr "你可以使用下面的操作符来实现关系运算" + +#. Tag: segtitle +#, no-c-format +msgid "Operator" +msgstr "数学运算符" + +#. Tag: segtitle +#, no-c-format +msgid "Meaning" +msgstr "含义" + +#. Tag: seg +#, no-c-format +msgid "<" +msgstr "" + +#. Tag: seg +#, no-c-format +msgid "Is less than" +msgstr "小于" + +#. Tag: seg +#, no-c-format +msgid "<=" +msgstr "" + +#. Tag: seg +#, no-c-format +msgid "Is less than or equal to" +msgstr "小于等于" + +#. Tag: seg +#, no-c-format +msgid ">" +msgstr "" + +#. Tag: seg +#, no-c-format +msgid "Is greater than" +msgstr "大于" + +#. Tag: seg +#, no-c-format +msgid ">=" +msgstr "" + +#. Tag: seg +#, no-c-format +msgid "Is greater than or equal to" +msgstr "大于等于" + +#. Tag: seg +#, no-c-format +msgid "==" +msgstr "" + +#. Tag: seg +#, no-c-format +msgid "Is equal to" +msgstr "等于" + +#. Tag: seg +#, no-c-format +msgid "!=" +msgstr "" + +#. Tag: seg +#, no-c-format +msgid "Is not equal to" +msgstr "不等于" + +#. Tag: para +#, no-c-format +msgid "Some examples" +msgstr "一些实例" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> 1 < 2\n" +"True\n" +">>> 3 > 34\n" +"False\n" +">>> 23 == 45\n" +"False\n" +">>> 34 != 323\n" +"True\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "// operator gives the floor division result" +msgstr "// 操作符会给出平除运算结果" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> 4.0 // 3\n" +"1.0\n" +">>> 4.0 / 3\n" +"1.3333333333333333\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Logical Operators" +msgstr "逻辑运算符" + +#. Tag: para +#, no-c-format +msgid "To do logical AND , OR we use and , or keywords. x and y returns False if x is False else it returns evaluation of y. If x is True, it returns True." +msgstr "作逻辑运算的“与”,“或”,我们用 and , or关键字。 如果xFalse x and y 返回False否则返回y的值。如果xTure,它返回真。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> 1 and 4\n" +"4\n" +">>> 1 or 4\n" +"1\n" +">>> -1 or 4\n" +"-1\n" +">>> 0 or 4\n" +"4\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Shorthand Operator" +msgstr "简写运算符" + +#. Tag: para +#, no-c-format +msgid "x op = expression is the syntax for shorthand operators. It will be evaluated like x = x op expression , Few examples are" +msgstr "x op = expression 为简写运算的语法形式。它将计算形如x = x op expression ,例如" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = 12\n" +">>> a += 13\n" +">>> a\n" +"25\n" +">>> a /= 3\n" +">>> a\n" +"8\n" +">>> a += (26* 32)\n" +">>> a\n" +"840\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "shorthand.py example" +msgstr "shorthand.py 实例" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"N = 100\n" +"a = 2\n" +"while a < N:\n" +" print "%d" % a\n" +" a *= a\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./shorthand.py\n" +"2\n" +"4\n" +"16\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Expressions" +msgstr "表达式" + +#. Tag: para +#, no-c-format +msgid "Generally while writing expressions we put spaces before and after every operator so that the code becomes clearer to read, like" +msgstr "我们一般写表达式的时候,在远算符的前后都加一个空格,这样使代码更可读。如" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"a = 234 * (45 - 56.0 / 34)\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "One example code used to show expressions" +msgstr "一个用于演示表达式的例子" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"a = 9\n" +"b = 12\n" +"c = 3\n" +"x = a -b / 3 + c * 2 -1\n" +"y = a -b / (3 + c) * (2 -1)\n" +"z = a - (b / (3 +c) * 2) -1\n" +"print "X = ", x\n" +"print "Y = ", y\n" +"print "Z = ", z\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./evaluationexp.py\n" +"X = 10\n" +"Y = 7\n" +"Z = 4\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "At first x is being calculated. The steps are like this" +msgstr "x作为第一个被计算。步骤如下所示" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"9 - 12 / 3 + 3 * 2 -1\n" +"9 - 4 + 3 * 2 - 1\n" +"9 - 4 + 6 - 1\n" +"5 + 6 -1\n" +"11 - 1\n" +"10\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now for y and z we have parentheses, so the expressions evaluated in different way. Do the calculation yourself to check them." +msgstr "现在yz均有括号,所以表达式计算会有不同的方式。请读者自行检验。" + +#. Tag: title +#, no-c-format +msgid "Type Conversions" +msgstr "类型转换" + +#. Tag: para +#, no-c-format +msgid "We have to do the type conversions manually. Like" +msgstr "我们可以手动的去作类型转换,如" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"float(string) -> float value\n" +"int(string) -> integer value\n" +"str(integer) or str(float) -> string representation \n" +">>> a = 8.126768\n" +">>> str(a)\n" +"'8.126768'\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "evaluateequ.py" +msgstr "evaluateequ.py" + +#. Tag: para +#, no-c-format +msgid "This is a program to evaluate 1/x+1/(x+1)+1/(x+2)+ ... +1/n series upto n, in our case x = 1 and n =10" +msgstr "这个程序计算1/x+1/(x+1)+1/(x+2)+ ... +1/n 直到n.在此例中x = 1 , n =10" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"sum = 0.0\n" +"for i in range(1, 11):\n" +" sum += 1.0 / i\n" +" print "%2d %6.4f" % (i , sum)\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./evaluateequ.py\n" +" 1 1.0000\n" +" 2 1.5000\n" +" 3 1.8333\n" +" 4 2.0833\n" +" 5 2.2833\n" +" 6 2.4500\n" +" 7 2.5929\n" +" 8 2.7179\n" +" 9 2.8290\n" +"10 2.9290\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the line sum += 1.0 / i what is actually happening is sum = sum + 1.0 / i." +msgstr "sum += 1.0 / i 是和sum = sum + 1.0 / i表达的相同的意思。" + +#. Tag: title +#, no-c-format +msgid "quadraticequation.py" +msgstr "quadraticequation.py" + +#. Tag: para +#, no-c-format +msgid "This is a program to evaluate the quadratic equation" +msgstr "这是一个模拟二次方运算的程序" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"import math\n" +"a = int(raw_input("Enter value of a: "))\n" +"b = int(raw_input("Enter value of b: "))\n" +"c = int(raw_input("Enter value of c: "))\n" +"d = b * b - 4 * a * c\n" +"if d < 0:\n" +" print "ROOTS are imaginary"\n" +"else:\n" +" root1 = (-b + math.sqrt(d)) / (2.0 * a)\n" +" root2 = (-b - math.sqrt(d)) / (2.0 * a)\n" +"print "Root 1 = ", root1\n" +"print "Root 2 = ", root2\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "salesmansalary.py" +msgstr "salesmansalary.py" + +#. Tag: para +#, fuzzy, no-c-format +msgid "In this example we are going to calculate the salary of a camera salesman. His basic salary is 1500, for every camera he will sell he will get 200 and the commission on the month's sale is 2 %. The input will be number of cameras sold and total price of the cameras." +msgstr "在这个例子中我们将计算一位数码相机的销售人员的工资。他的基本工资是1500,每售出一台数码相机他可以得到200而且他的月任务是%2.输入表示的分别是售出的数码相机的台数和总的数码相机的价格。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"basic_salary = 1500\n" +"bonus_rate = 200\n" +"commision_rate = 0.02\n" +"numberofcamera = int(raw_input("Enter the number of inputs sold: "))\n" +"price = float(raw_input("Enter the total prices: "))\n" +"bonus = (bonus_rate * numberofcamera)\n" +"commision = (commision_rate * numberofcamera * price)\n" +"\n" +"print "Bonus = %6.2f" % bonus\n" +"print "Commision = %6.2f" % commision\n" +"print "Gross salary = %6.2f" % ( basic_salary + bonus + commision)\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./salesmansalary.py\n" +"Enter the number of inputs sold: 5\n" +"Enter the total prices: 20450\n" +"Bonus = 1000.00\n" +"Commision = 2045.00\n" +"Gross salary = 4545.00\n" +"\n" +msgstr "" diff --git a/zh-CN/strings.po b/zh-CN/strings.po new file mode 100644 index 0000000..4d987a5 --- /dev/null +++ b/zh-CN/strings.po @@ -0,0 +1,373 @@ +# +# AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 0\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: 2010-09-27T11:50:13\n" +"Last-Translator: Automatically generated\n" +"Language-Team: None\n" +"MIME-Version: 1.0\n" +"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#, no-c-format +msgid "Strings" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Strings are nothing but simple text. In python we declare strings in between "" or '' or ''' ''' or """ """. The examples below will help you to understand sting in a better way." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "I am Indian"\n" +">>> s\n" +"'I am Indian'\n" +">>> s = 'I am Indian'\n" +">>> s = "Here is a line \\\n" +"... splitted in two lines"\n" +">>> s\n" +"'Here is a line splitted in two lines'\n" +">>> s = "Here is a line \n" +" splitted in two lines"\n" +">>> s\n" +"'Here is a line \n" +" splitted in two lines'\n" +">>> print s\n" +"Here is a line\n" +" splitted in two lines \n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now if you want to multiline strings you have to use triple single/double quotes." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = """ This is a\n" +"... multiline string, so you can\n" +"... write many lines"""\n" +">>> print s\n" +" This is a\n" +"multiline string, so you can\n" +"write many lines\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Different methods available for Strings" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Every string object is having couple of buildin methods available, we already saw some of them like s.split(" ")." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "kushal das"\n" +">>> s.title()\n" +"'Kushal Das' \n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "title() method returns a titlecased version of the string, words start with uppercase characters, all remaining cased characters are lowercase." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> z = s.upper()\n" +">>> z\n" +"'KUSHAL DAS'\n" +">>> z.lower()\n" +"'kushal das'\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "upper() returns a total uppercase version whereas lower() returns a lower case version of the string." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "I am A pRoGraMMer"\n" +">> s.swapcase()\n" +"'i AM a PrOgRAmmER'\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "swapcase() returns the string with case swapped :)" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "jdwb 2323bjb"\n" +">>> s.isalnum()\n" +"False\n" +">>> s = "jdwb2323bjb"\n" +">>> s.isalnum()\n" +"True\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Because of the space in the first line isalnum() returned False , it checks for all charecters are alpha numeric or not." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "SankarshanSir"\n" +">>> s.isalpha()\n" +"True\n" +">>> s = "Sankarshan Sir"\n" +">>> s.isalpha()\n" +"False\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "isalpha() checkes for only alphabets." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "1234"\n" +">>> s.isdigit() #To check if all the characters are digits or not\n" +"True\n" +">>> s = "Fedora9 is coming"\n" +">>> s.islower() # To check if all chracters are lower case or not\n" +"False\n" +">>> s = "Fedora9 Is Coming" \n" +">>> s.istitle() # To check if it is a title or not\n" +"True\n" +">>> s = "INDIA"\n" +">>> s.isupper() # To check if characters are in upper case or not\n" +"True\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To split any string we have split(). It takes a string as an argument , depending on that it will split the main string and returns a list containing splitted strings." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "We all love Python"\n" +">>> s.split(" ")\n" +"['We', 'all', 'love', 'Python']\n" +">>> x = "Nishant:is:waiting"\n" +">>> x.split(':')\n" +"['Nishant', 'is', 'waiting']\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The opposite method for split() is join(). It takes a list contains strings as input and join them." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> "-".join("GNU/Linux is great".split(" "))\n" +"'GNU/Linux-is-great'\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the above example first we are splitting the string "GNU/Linux is great" based on the white space, then joining them with "-"." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "String the strings" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Strings do have few methods to do striping. The simplest one is strip(chars). If you provide the chars argument then it will strip any combination of them. By default it strips only whitespace or newline characters." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = " abc\n" +" "\n" +">>> s.strip()\n" +"'abc'\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "You can particularly strip from the left hand or right hand side also using lstrip(chars) or rstrip(chars)." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s = "www.foss.in"\n" +">>> s.lstrip("cwsd.")\n" +"'foss.in'\n" +">>> s.rstrip("cnwdi.")\n" +"'www.foss'\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Finding text" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Stings have some methods which will help you in finding text/substring in a string. Examples are given below:" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +">>> s.find("for")\n" +"7\n" +">>> s.find("fora")\n" +"-1\n" +">>> s.startswith("fa") #To check if the string startswith fa or not\n" +"True\n" +">>> s.endswith("reason") #\n" +"True\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "find() helps to find the first occurrence of the substring given, if not found it returns -1." +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Palindrome checking" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Palindrome are the kind of strings which are same from left or right whichever way you read them. Example "madam". In this example we will take the word as input from the user and say if it is palindrome or not." +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"s = raw_input("Please enter a string: ")\n" +"z = [x for x in s]\n" +"z.reverse()\n" +"if s == "".join(z):\n" +" print "The string is a palindrome"\n" +"else:\n" +" print "The string is not a palindrome"\n" +"\n" +"" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"[kd@kdlappy book]$ ./palindrome.py\n" +"Please enter a string: madam1\n" +"The string is not a palindrome\n" +"[kd@kdlappy book]$ ./palindrome.py\n" +"Please enter a string: madam\n" +"The string is a palindrome\n" +"\n" +"" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Number of words" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In this example we will count the number of words in a given line" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"#!/usr/bin/env python\n" +"s = raw_input("Enter a line: ")\n" +"print "The number of words in the line are %d" % (len(s.split(" ")))\n" +"\n" +"" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "\n" +"\n" +"[kd@kdlappy book]$ ./countwords.py\n" +"Enter a line: Sayamindu is a great programmer\n" +"The number of words in the line are 5 \n" +"\n" +"" +msgstr "" + diff --git a/zh-CN/thebeginning.po b/zh-CN/thebeginning.po new file mode 100644 index 0000000..a5a8131 --- /dev/null +++ b/zh-CN/thebeginning.po @@ -0,0 +1,182 @@ +msgid "" +msgstr "" +"Project-Id-Version: Python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "The Beginning" +msgstr "初光乍现" + +#. Tag: para +#, no-c-format +msgid "So we are going to look at our first code. As python is an interpreted language , you can directly write the code into the python interpreter or write in a file and then run the file. First we are going to do that using the interpreter, to start type python in the command prompt (shell or terminal)." +msgstr "现在我们来看下我们的第一次编码。众所周知,python是一门解释性语言,你可以在python解释器中直接写代码,也可以将之写到文件中,然后执行这个文件。首先,我们将用python的解释器来作示范,启动python:在终端或shell下键入“python\":" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"[kd@kdlappy ~]$ python\n" +"Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)\n" +"[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2\n" +"Type "help", "copyright", "credits" or "license" for more information. \n" +">>> \n" +"\n" +msgstr "" + +#. Tag: para +#, fuzzy, no-c-format +msgid "In our first code we are going to print "Hello World!" , so do it as below," +msgstr "作为第一次编码,我们将打印经典的\"Hello World!\",如下所示:" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +">>> print "Hello World!"\n" +"Hello World!\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "helloworld.py" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Now as a serious programmer you may want to write the above code into a source file. We will create a helloworld.py. Use any text editor you like to create the file. I used vi, you can even use GUI based tools like Kate, gedit too." +msgstr "作为正式的程序员,你可能要将上述代码写到一个文件。那么我们来建立一个文件名为helloworld.py的文件,用你喜欢的任何编辑器,我用的是vi,你可以使用基于GUI的工具,如kate,gedit等。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"#!/usr/bin/env python\n" +"print "Hello World!"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "To run the code first you have to make the file executable, in GNU/Linux you can do that by giving the command in a shell or terminal" +msgstr "欲运行上述写下的代码,你首先得使文件属性为可执行,在GNU/Linux环境下,你可以在shell中执行如下命令:" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"$ chmod +x helloworld.py\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Then" +msgstr "这时你可以执行此文件了。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"$ ./helloworld.py \n" +"Hello World!\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "On the first line you can #! , we call it sha-bang. Using this we are telling that use python interpreter to run this code. In the next line we are printing a text message. In python we call all the line of texts as strings." +msgstr "在代码的第一行我们以#! 开始,我们称之为sha-bang。这样做的目的是告诉shell用python解释器来执行下面代码。接下来的一行,仅仅是打印一条信息。在python中我们认为所有的文本行都是strings类型(下面会讲到python数据类型--译者注)。" + +#. Tag: title +#, no-c-format +msgid "Whitespaces and indentation" +msgstr "空格和缩进" + +#. Tag: para +#, no-c-format +msgid "In Python whitespace is an important thing. We divide different identifiers using spaces.Whitespace in the beginning of the line is known as indentation, but if you give wrong indentation it will throw an error. Examples are given below:" +msgstr "在python语言中,空格很重要。我们使用空格将标志符区分开。空格在行的开始处被称之为缩排,但是如果你写了错误的缩排,python解释器将抛出错误。例如下面情形:" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = 12\n" +">>> a = 12\n" +" File "<stdin>", line 1\n" +" a = 12\n" +" ^\n" +" IndentationError: unexpected indent\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Warning" +msgstr "警告" + +#. Tag: para +#, no-c-format +msgid "There is an extra space in the beginning of the second line which is causing the error, so always look for the proper indentation." +msgstr "在第二行的开始处出现了多余的空格,以至于引起错误。所以要经常检查合适的缩排!" + +#. Tag: para +#, fuzzy, no-c-format +msgid "You can even get into this indentation errors if you mix up tabs and spaces. Like if you use spaces and only use spaces for indentation, don't use tabs in that case. For you it may look same, but the code will give you error if you try to run it." +msgstr "如果你混合使用制表符和空格,这种缩排错误会常见。所以建议如果使用空格,就一直用空格作缩排,不要使用制表符。对于你来说他们俩是一样的,但是你试图去运行的时候,代码会给你抛出错误" + +#. Tag: title +#, no-c-format +msgid "Comments" +msgstr "注释" + +#. Tag: para +#, fuzzy, no-c-format +msgid "Comments are some piece of English text which explains what this code does, we write comments in the code so that is easier for others to understand. A comment line starts with # , everything after that is ignored as comment, that means they don't effect on the program." +msgstr "注释是一些英语文本方式提供解释此处代码是做什么的,我们写在代码中写注释是便于其他人容易理解。python的注释是以#开始的行,注释在程序中将被忽略,也就是说对程序没有任何的作用。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> #this is a comment\n" +">>> #the next line will add two numbers\n" +">>> a = 12 + 34\n" +">>> print c #this is a comment too :)\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Modules" +msgstr "模块" + +#. Tag: para +#, no-c-format +msgid "Modules are python files which contain different function definitions , variables which we can reuse, it should always end with a .py extension.. Python itself is having a vast module library with the default installation. We are going to use some of them. To use a module you have to import it first." +msgstr "模块是包含可以直接使用(重用)的函数定义、变量的python文件,它们通常是以.py为扩展名。Python本身在安装时就带有大量的模块。我们将会用到一部分。欲使用模块你首先的将之导入(import)。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> import math\n" +">>> print math.e\n" +"2.71828182846\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "We are going to learn more about modules on the Modules chapter." +msgstr "我们将会在Modules那章中学习更多的关于模块的内容。" diff --git a/zh-CN/variablesanddatatypes.po b/zh-CN/variablesanddatatypes.po new file mode 100644 index 0000000..1614e07 --- /dev/null +++ b/zh-CN/variablesanddatatypes.po @@ -0,0 +1,334 @@ +msgid "" +msgstr "" +"Project-Id-Version: python_for_you_and_me\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2010-09-27T11:50:13\n" +"PO-Revision-Date: \n" +"Last-Translator: LiJiansheng \n" +"Language-Team: lijiangsheng1@gmail.com \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-Country: CHINA\n" + +#. Tag: title +#, no-c-format +msgid "Variables and Datatypes" +msgstr "变量和数据类型" + +#. Tag: para +#, no-c-format +msgid "Every programming language is having own grammar rules just like the other languages we speak." +msgstr "每一种编程语言都有其自身的语法规则,正如我们日常所说的其它国家、民族的语言。" + +#. Tag: title +#, no-c-format +msgid "Keywords and Identifiers" +msgstr "关键字和标识符" + +#. Tag: para +#, no-c-format +msgid "Python codes can be divided into identifiers. Identifiers (also referred to as names) are described by the following lexical definitions:" +msgstr "Python代码使用标识符来分离。标识符(通常提供名称)被描述为以下定义:" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"identifier ::= (letter|"_") (letter | digit | "_")* \n" +"letter ::= lowercase | uppercase \n" +"lowercase ::= "a"..."z" \n" +"uppercase ::= "A"..."Z" \n" +"digit ::= "0"..."9"\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "This means _abcd is a valid identifier where as 1sd is not. The following identifiers are used as reserved words, or keywords of the language, and cannot be used as ordinary identifiers. They must be spelled exactly as written here:" +msgstr "这意味着_abcd是合法的而1sd不是。以下列出的是用于预留字,或者说是语言的关键字,它们是不可用于通常的标识符的。他们是必须按如下拼写:" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"and del from not while \n" +"as elif global or with \n" +"assert else if pass yield \n" +"break except import print \n" +"class exec in raise \n" +"continue finally is return \n" +"def for lambda try\n" +"\n" +msgstr "" + +#. Tag: para +#, fuzzy, no-c-format +msgid "In Python we don't specify what kind of data we are going to put in a variable. So you can directly write abc = 1 and abc will become an integer datatype. If you write abc = 1.0 abc will become of floating type. Here is a small program to add two given numbers" +msgstr "在python中我们不需要特别的为变量指定数据类型。所以你可以直接写abc = 1,这样变量abc就是整型,如果你写出 abc =1.0,那么abc就是一浮点型。以下是一个增加上述给定的数字的简单程序" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a = 13 \n" +">>> b = 23\n" +">>> a + b \n" +"36\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "From the above example you can understand that to declare a variable in python , what you need is just to type the name and the value. Python can also manipulate strings They can be enclosed in single quotes or double quotes like" +msgstr "通过上面的例子你可能已经理解了在python中如何定义变量,也就是只需要敲入名称和值就可以了。Python可以很精妙的操纵字符串,它们只需要如下用单引号和双引号括起来即可" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> 'India'\n" +"'India' \n" +">>> 'India\\'s best' \n" +""India's best" \n" +">>> "Hello World!" \n" +"'Hello World!'\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Reading input from the Keyboard" +msgstr "从键盘读取用户输入" + +#. Tag: para +#, fuzzy, no-c-format +msgid "Generally the real life python codes do not need to read input from the keyboard. In python we use raw_input function to do input. raw_input("String to show") , this will return a string as output. Let us write a program to read a number from the keyboard and check if it is less than 100 or not. Name of the program is testhundred.py" +msgstr "通常情况下,在python的代码中是不需要从键盘读取输入的。当然python还是提供了这个输入函数,那就是raw_input。raw_input(\"String to show\") ,这将返回一字符串用于输出。让我们写一个程序:实现从键盘读入一数字,然后判断其是否小于100.程序的名称是 testhundred.py" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python \n" +"number = int(raw_input("Enter an integer: "))\n" +"if number < 100: \n" +" print "Your number is smaller than 100" \n" +"else: \n" +" print "Your number is greater than 100" \n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "The output" +msgstr "输出" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./testhundred.py \n" +"Enter an integer: 13 \n" +"Your number is smaller than 100 \n" +"[kd@kdlappy book]$ ./testhundred.py \n" +"Enter an integer: 123 \n" +"Your number is greater than 100\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "In the next program we are going to calculate investments." +msgstr "在接下来的程序我们将计算投资。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python \n" +"amount = float(raw_input("Enter amount: ")) \n" +"inrate = float(raw_input("Enter Interest rate: ")) \n" +"period = int(raw_input("Enter period: ")) \n" +"value = 0 \n" +"year = 1 \n" +"while year <= period:\n" +" value = amount + (inrate * amount)\n" +" print "Year %d Rs. %.2f" %(year, value)\n" +" amount = value\n" +" year = year + 1 \n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./investment.py\n" +"Enter amount: 10000\n" +"Enter Interest rate: 0.14\n" +"Enter period: 5\n" +"Year 1 Rs. 11400.00\n" +"Year 2 Rs. 12996.00\n" +"Year 3 Rs. 14815.44\n" +"Year 4 Rs. 16889.60\n" +"Year 5 Rs. 19254.15\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Some Examples" +msgstr "一些例子" + +#. Tag: para +#, no-c-format +msgid "Some examples of variables and datatypes:" +msgstr "一些关于变量和数据类型的例子:" + +#. Tag: title +#, no-c-format +msgid "Average of N numbers" +msgstr "N个数字的平均值" + +#. Tag: para +#, no-c-format +msgid "In the next program we will do an average of N numbers." +msgstr "接下来的程序我们将实现计算N个数字的平均值。" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"N = 10\n" +"sum = 0\n" +"count = 0\n" +"while count < N:\n" +" number = float(raw_input(""))\n" +" sum = sum + number\n" +" count = count + 1\n" +"average = float(sum)/N\n" +"print "N = %d , Sum = %f" % (N, sum)\n" +"print "Average = %f" % average\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./averagen.py\n" +"1\n" +"2.3\n" +"4.67\n" +"1.42\n" +"7\n" +"3.67\n" +"4.08\n" +"2.2\n" +"4.25\n" +"8.21\n" +"N = 10 , Sum = 38.800000\n" +"Average = 3.880000\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Temperature conversion" +msgstr "温度转换" + +#. Tag: para +#, no-c-format +msgid "In this program we will convert the given temperature to Celsius from Fahrenheit by using the formula C=(F-32)/1.8" +msgstr "在此程序中我们用公式 C=(F-32)/1.8将华氏温度转换为摄氏温度" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"#!/usr/bin/env python\n" +"fahrenhite = 0.0\n" +"print "Fahrenheit Celsius"\n" +"while fahrenheit <= 250:\n" +" celsius = ( fahrenheit - 32.0 ) / 1.8 #Here we calculate the fahrenhite value\n" +" print "%5.1f %7.2f" % (fahrenheit , celsius)\n" +" fahrenheit = fahrenheit + 25\n" +"\n" +msgstr "" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +"[kd@kdlappy book]$ ./temperature.py\n" +"Fahrenheit Celsius\n" +" 0.0 -17.78\n" +" 25.0 -3.89\n" +" 50.0 10.00\n" +" 75.0 23.89\n" +"100.0 37.78\n" +"125.0 51.67\n" +"150.0 65.56\n" +"175.0 79.44\n" +"200.0 93.33\n" +"225.0 107.22\n" +"250.0 121.11\n" +"\n" +msgstr "" + +#. Tag: title +#, no-c-format +msgid "Multiple assignments in a single line" +msgstr "在单行定义多个变量或赋值" + +#. Tag: para +#, no-c-format +msgid "You can even assign values to multiple variables in a single line, like" +msgstr "你可以在单行中实现多个变量并赋值,例如" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a , b = 45, 54\n" +">>> a\n" +"45\n" +">>> b\n" +"54\n" +"\n" +msgstr "" + +#. Tag: para +#, no-c-format +msgid "Using this swapping two numbers becomes very easy" +msgstr "此用于交换两个数字变的非常容易" + +#. Tag: screen +#, no-c-format +msgid "" +"\n" +"\n" +">>> a, b = b , a\n" +">>> a\n" +"54\n" +">>> b\n" +"45\n" +"\n" +msgstr ""