Talk:Python Programming

About

 * Started: 19 October 2003‎
 * Size: 27,300 words (Oct 2013)
 * Printable version
 * Printable version
 * Printable version

Safety of user input data
Hi i didn't found anything about preventing XSS injection and SQL injections. I think its important part of doing web apps. Chris.
 * Although avoiding XSS injection and SQL injection is indeed important, I believe it is a cross-language skill that should be learned separately from the language itself (it could make a book by itself). There are however, aspects of certain language that is often an easy weak-point for malicious hackers coupled with careless programmer. In python, these weak points would be (not a complete list): input (python 2.x and below), eval, exec, popen, and subprocess, possibly open too. These weak points should be mentioned.

Non-programmers python tutorial
If anyone wants to, feel free to take any material from the tutorial that I wrote for the python programming language. Non-programmers python tutorial. I grant permission to relicense it under the GNU Free Documentation License (though I would recommend keeping the public domain exception for the programming samples). Josh Cogliati. Jrincayc 15:42, 16 Jan 2004 (UTC)

Thank you very much! I'll start to integrate it into the module ASAP Thunderbolt16 22:56, 17 Jan 2004 (UTC)
 * I started wikifiying it to simplify integrating it in. See my User:Jrincayc page for the contents. Jrincayc 02:43, 1 Jun 2004 (UTC)
 * More or less finished wikifying it. See User:Jrincayc/Contents -- Jrincayc 02:54, 2 Jun 2004 (UTC)
 * I plan on moving it from User:Jrincayc to Non-programmers Python Tutorial, if nobody objects. I am doing this because the server honors.montana.edu is being permanently shutdown, so I wish to start changing links to it to point to wikibooks rather than honors.montana.edu.   Jrincayc 02:44, 31 August 2006 (UTC)
 * Josh's work is now avaialable at http://www.andamooka.org/reader.pl?section=easytut as his link to the website at U. Montana is broken.--DavidRoss 06:23, 7 August 2006 (UTC)


 * Thank you. That looks excellent. We now have Non-Programmer's Tutorial for Python.
 * Well, that's technically merely a redirect to the specific version of Python we recommend for new people.
 * At the moment it redirects to Non-Programmer's Tutorial for Python 2.6.
 * Someday it will become a redirect to Non-Programmer's Tutorial for Python 3 (after a few more issues are resolved).
 * Even further in the future I expect Non-Programmer's Tutorial for Python to redirect to Non-Programmer's Tutorial for Python 4. :-) --DavidCary (discuss • contribs) 19:18, 29 February 2012 (UTC)

Explain what makes this book unique
People mentioned that Python is already covered in:
 * the book "How to think like a Computer Scientist: Learning with Python", which is already a comprehensive text about Python and covers a lot of topics on programming. Why not use that? --Offray
 * Dive Into Python by Mark Pilgrim, which is licenced under the GNU FDL--::Noldoaran 18:14, 6 Aug 2004 (UTC)
 * The official Python documentation --Beuc

Please add a note in the synopsys or introduction about what fostered the development of this wikibook :)

September 2004 revamp
I am about to delve into this thing, and find it's pretty much in disarray. It appears nobody is workin on it, so I'm going to go right ahead.

I have a structure in mind. The sections of the book will go something like this:


 * 1) Introduction - What is Python; Getting Python; Editing Python programs.
 * 2) Tutorial - A series of examples and exercises.
 * 3) Language concepts - Indepth and complete treatment of Python's implementation of syntax, variables, flow control, files, classes, etc.
 * 4) Standard modules - Indepth documentation of standard modules.
 * 5) Function reference - Indepth documentation of standard functions. (Not sure about this section.)
 * 6) Appendices - List of keywords and similar stuff.

See User:Yath/Python for the full chapter outline.

Yath 19:24, 24 Sep 2004 (UTC)

Web scripting
I'd like to read how to write a page containing a python script and how to configure apache to understand python. Thanks 158.193.85.212 07:28, 5 May 2005 (UTC)

Using saved programs
Could somebody elaborate on how to get a saved python program? I entered the program in a notepad file. But when I try to get it on the python command line, it says that the : in C:\ is wrong syntax. How do I get the programs? --elpenmaster

Naming policy
You might want to consider the WB:NP. Your current naming convention is deprecated and has several disadvantages - e.g. it has no navigational links. Also your worthy effort is neither considered a book nor a section inside a book. See wikistats which implements an extensive book and section detector.

--Krischik T 07:15, 11 October 2005 (UTC)


 * Adding to this, it would be a good idea in my opinion to drop the "Programming" pseudo-namespace. Books are starting to move out of that, notably Ada Programming. -Matt 23:41, 17 January 2006 (UTC)


 * Now what should be the new location, is it Python?. --Baijum81 04:40, 8 June 2006 (UTC)
 * One day the pages should be moved by a bot to fit the new scheme, but I'm not sure how to request that. Going to the bot maintainer's talk page will probably do it. -Matt 14:30, 9 June 2006 (UTC)


 * I'm adding the Development stages to each of the sections to it's easier to find stuff to work on at a glance. Help:Development_stages I'm not going to 100% beside any sections (yet) as I am not a python expert, and I am reluctant to say that a section that is complete.  Once I have done this, I will work on fleshing out some of the sections that need content.


 * I am new to contributing to wikibooks--well to any of the wikimedia projects--so any pointers or suggestions would be helpful. -DavidRoss 20:00, 6 Aug 2006 (PDT)

Unified Navigation
The navigation bars on this book are problematic: there doesn't seem to be any kind of general consensus on navigation bar template. What is/should be the convention? --Quartz25 21:19, 8 March 2007 (UTC)

For reference, the convention seems to be to use the  template for the top, and no template is used on the bottom. --Quartz25 23:54, 11 June 2007 (UTC)

Changes to the Introduction section
The introduction, as it now appears, is convoluted, incomplete, and circular. Thus I propose the following pages to be used in the following order:

1. Installing the python language itself
 * Broken down by platform

2. Interactive mode Python interpreter.
 * With demonstrative "Hello World" program (or perhaps a very simple print "What Is Your Name?", print "What is your quest?", print "What is your favorite color?") example.

3. Non-interactive mode python interpreter.
 * With the same demonstrative Hello program, instructing the user to use a simple text editor to save it as a text file.

4. Python Editors & Addons
 * (broken down by OS)
 * I'm placing this last, because this section is always going to be very much up in the air relative to a user's own tastes, but the link to the Python Editors should be maintained.
 * Furthermore, some people will be quite happy with the simple built-in text editors for quite a while, and we want to get them up to coding as quickly as possible, thus this section isn't, strictly speaking, necessary.
 * The addons come very last, because people just taking their first steps into python probably aren't looking to extend the language; again, not strictly necessary, not here anyway.
 * In fact, this last page could probably be best served as 2 separate sections of the appendix.

Once I figure out how to create subfolders and subpages in my user page, I'll start posting my reworking of the introduction there, and people can start commenting as they see fit. --MyOwnLittlWorld 19:24, 4 June 2007 (UTC)

The pages are up now at my user page, please tell me what you think and whether or not the intro should be replaced. Thanks, MyOwnLittlWorld 23:18, 4 June 2007 (UTC)

Question or Suggestion on the TOC
When you say User Interface on the TOC to you mean a topic on UI creation or is it a section to explain the UI of Python IDLE. And if its a UI section I will suggest some GUI Programming using the Tkinter Library if possible also support the Glade Library.

Few changes or Updates
--Dragonecc (talk) 01:34, 8 December 2007 (UTC)
 * 1) Help on the Python OOP page. I can use a little more help on the terms as their still too technical.
 * 2) Help with the installation of Python language (Ubuntu and Mac section)

Two links to Gaming
There seems to be two links to the module "Game Programming in Python" in the index. Should one be deleted? It is messing up the navigation on each page.

If so, which one should go? I was thinking about getting rid of the one under the section "Learning to program in Python" because the game programming is a more advanced subject.

--hypergeek14 (talk) 21:14, 26 July 2008 (UTC)

I have just noticed that there are also two links to the Files module. This time I think the link under "Rocking the Python (Modules)" section should go, as files are a basic concept.

--hypergeek14 (talk) 21:21, 26 July 2008 (UTC)


 * The deed has been done.
 * --hypergeek14 (talk) 21:44, 29 July 2008 (UTC)
 * --hypergeek14 (talk) 21:44, 29 July 2008 (UTC)

Examples?
I would like to understand the reasons for using dictionaries, tuples, lists, etc. I can't see the reasons for doing most of the things in this language. There are never an explanation of why you'd want to use certain things. Hires an editor (talk) 21:40, 18 February 2010 (UTC)

redundancy
Is there a reason why most of the content is there twice? Once under "Learning to program in Python" and once under "Python concepts". I believe we should merge those sections. Especially the following are very similar:


 * Errors and Exceptions
 * Flow control and Decision control
 * Scoping and Namespaces

Also I dont see a reason why modules need to be treated separately but still appear many times before in the text. I would also like to fix that. Any other suggestions? Greetings --Hannes Röst (talk) 07:56, 20 August 2010 (UTC)
 * Yes, I believe the sections were written by separate people with differing visions of the final book. I was trying to rewrite the whole thing coherently, but moved on to other projects.  You can see my single plan here.  Your goals seem similar to what I was thinking.  I might return as I would like to teach Python to a friend from this. --Jesdisciple (talk) 12:12, 23 August 2010 (UTC)

Which version of Python to use
Python 2.x or 3.x? The book in its current form contains many examples and explanation of language structures, internal functions, statements and all of that. However, there seems to be great inconsistency in the implementation of it. The most glaring is the use of print as a function (3.x style) or as a bare statement (2.x style). Whichever choice is made, it needs to be clearly represented somewhere, that or all examples need a note as to the language major version they're written in, or even written in both major versions as examples should be copy/past-able.

Drivers for a decision 2 vs 3:
 * How long is this book expected to be useful (3.x is going to be more useful in the longer run)
 * Is third-party package support critical for people still learning the language (as most exist purely for 2.x and 2to3 is not a tool for those new to the language)
 * What version is mastered by the editors here (going with 3, only to discover a wholesome three people know it, is a disappointment about to happen)


 * Greetings while you may have a valid point on newer Python release, there are some problems. Python 2.6 is highly use release across major Linux :releases and corporate development.  For this environment Python module are a great impact and migration to Python 3 make have costly deployment.  :Until modules are translated to Python 3 or native supported development for Python 2.6 will continue. This has being experimented with other :programming language like Cobol, Fortran and Pascal.  Also this book samples could be easily ported to Python 3 with minor changes.  Went the :development community embrace Python 3 then the book could either be ported or a new book could be written.
 * Hope this help.
 * Hope this help.


 * --Dragonecc (talk) 16 January 2011(UTC)


 * Question remains. Is this book based on Python 2 or 3 or is it mix of both? In any case it should be clearly stated. --Usp (discuss • contribs) 18:29, 22 March 2013 (UTC)

Python 2 Vs Python 3
As there are substantial differences between Python2 and Python3, it would be better if this book clearly stated which version it does cover to avoid leading newbies onto a steep learning curve. --Mecanismo (discuss • contribs) 17:05, 26 July 2013 (UTC)
 * The book mainly covers Python 2; in each location in which it covers Python 3 in addition, it should state so explicitly. An example of indicating which Python is being described is at Python Programming/Input and Output. --Dan Polansky (discuss • contribs) 20:03, 13 October 2013 (UTC)

Archive Old Discussions
Let's archive the old discussions. It is pointless and confusing having them around if they are no longer relevant. Hackbinary (discuss • contribs) 21:50, 13 October 2013 (UTC)
 * This is for you Dan-the-man, so could you revert the Talk page back to where I had it last night, and copy in the additions that we both have put on it? Thanks in advance. Hackbinary (discuss • contribs) 21:51, 13 October 2013 (UTC)


 * I oppose archiving the old discussions. I only support their archiving after the page becomes long, which it has not. --Dan Polansky (discuss • contribs) 22:08, 13 October 2013 (UTC)

Contents / Landing Page re-org
Last night I reorganised the Contents page. Danielle Polansky was not happy with some of words that I chose for section headings. I propose reverting back my changes, and use the following headings: Intro --> Getting Started Basics --> Fundamentals I introduced a new section called 'Code Reuse' that moves out everything from Functions, to Classes, and namespaces. Modules is redundant Standard Library Modules Third-party modules Writing extension modules --> Extending Python Appendices What are your thoughts? Hackbinary (discuss • contribs) 21:50, 13 October 2013 (UTC)
 * I oppose your changes, now as before.
 * Your "Dan-the-man", "Danielle Polansky", and "Danny boy" are not in good faith. Go away and find another playground. --Dan Polansky (discuss • contribs) 22:10, 13 October 2013 (UTC)
 * And you calling me a moron is in not in good faith. You talking down to me is not good faith.  If you would like to be treated with respect and dignity Dan, then I suggest you treat others with respect and dignity.  Your treatment of me has been rather undignified, and I am glad that I illustrated that to you.Hackbinary (discuss • contribs) 22:27, 13 October 2013 (UTC)
 * You conceded that chapters did not follow logically. Here is my revision of the page for you to review again:   Hackbinary (discuss • contribs) 22:27, 13 October 2013 (UTC)
 * It is you that I wish could find another playground. All I want to do is add some content, and already expressed, improve the readability, and ease of use of the book. You seem to have some idea in your head on how it should be, but you will not share it and you are unwilling to have others contribute how they think the book should work.  And you have taken a very abrasive, demeaning tone with me.  Hackbinary (discuss • contribs) 22:27, 13 October 2013 (UTC)
 * I am pressing ahead with reorganising, refactoring, and rationalising the chapters and chapter order as there is a fair bit of duplicated content which needs to be sorted through. I have organised the chapters into what I think are a coherent order.   There is currently duplication across numerous chapters, and as much as as possible, I have grouped chapters with similar content together, but their names may not be representative of their content at this time, eg text is really about strings.  Hackbinary (discuss • contribs) 16:28, 15 October 2013 (UTC)
 * If you think you have a better order, or vision on how it should be, let's discuss, and get it documented Hackbinary (discuss • contribs) 16:30, 15 October 2013 (UTC)
 * I disagree with such parts of your edits as is renaming "Basics" to "Fundamentals" or even "The very Language Basics". I disagree with edits that are not constituting an objectively unquestionable improvements but rather are pushing a personal preference when these edits come from someone who is not interested in contributing actual content to the book. You are not prevented from adding content; you are prevented from an arbitrary reorganization. No, you should not be "pressing ahead with reorganising, refactoring, and rationalising" as long as your content contribution to Wikibook is nearly nonexistent and there is an opposition to that reorganizing. --Dan Polansky (discuss • contribs) 08:03, 19 October 2013 (UTC)
 * Sorry, you're inactivity lead the status quo being changed. While you have contributed some good content, you are not the dictator of Programming Python. The content must be rationalised in a progressive manner, and if you are unwilling to be cooperative, I will seek assistance from others.  You have a track record of being obstinate, and forcing your views on others.   To begin with Basics is not a good section title.  The word is overly generic and does nothing to articulate that the section is about core building blocks of the language, Fundamentals on the other hand says this is core material to what will be discussed further on.  Furthermore, it makes immeasurable sense to organise related chapters that duplicate content together, before the content is merged into one chapter.  Do you not concur that the chapters Sequences, Data types, Numbers, Strings, Text, Lists, Tuples, Dictionaries, and Sets duplicates a fair amount of material?  Do not agree that this needs to merged together in a managed, organised and controlled way? If you are going to be so argumentative, and obstructive to the work that I am doing, then fine, that is your decision, but I am going to press ahead.  If you wish to discuss it, and compromise, then I am happy to do the same.  I am not willing to be in a situation where you feel that you can call the shots and that you feel that you can make arbitrary decisions yourself.  Over the past week I have been reading through chapters with greater detail, and reading through the change logs, and for example I do not approve of your revert 6 Oct, Input and Output  as it seems to me that using with is the better way to open a file context and read the file because 1.) you do not have to explicitly close the file once the execution path falls out of scope, and 2.) the handling of exceptions is better with the with block.  My point is that you make arbitrary changes yourself that have dubious merit.Hackbinary (discuss • contribs) 12:50, 20 October 2013 (UTC)

pdf problems
In the pdf version page 94 (numbered 90) has the page number superimposed over text. The first 2 pages aren't numbered, the next 2 are numbered III & IV, & the rest are numbered starting with 1. The Contents are on pages III, IV, & 1 with the text starting on 3 which doesn't make sense. At least on my system, pages 157-159 print out cropped. In the case of 157 and 159, cropping some of the blank space at the top and bottom respectively solved the problem. To fix 158 I suggest putting the entire section 36.3 on page 159. 69.72.92.242 (discuss) 00:31, 26 December 2013 (UTC)

Printed version very differ from main article, October 2015
First I notice missed "Extending with ..." chapters in existing PDF. I generated PDF myself (mediawiki2latex 7.21) from current article, but then I found that "Extending with ctypes" and some another chapters no included in printer version too. So maybe they need to be synchronized? Yasondinalt (discuss • contribs) 18:48, 25 October 2015 (UTC)

Yes I think you need to modify the printable version to include these chapters respectively. It should be rather obvious for you how to do that. Thanks for using mediawiki2latex. Yours --Dirk Hünniger (discuss • contribs) 19:14, 25 October 2015 (UTC)

Ok, I will compare articles in few days. Thank you for very useful tool! Yasondinalt (discuss • contribs) 19:21, 25 October 2015 (UTC)

Chapter 4, 5 and 6 are Missing
Noticed a very annoying issue with the PDF after printing the entire thing out and binding...

Chapter 4,5 and 6 are missing and contain only the text like:

I think it may have to do with that navigation (Redirected from) which I have removed and it waiting for moderation Surfer190 (discuss • contribs) 12:25, 27 December 2015 (UTC)

Hey, I resolved the issue just now. Clear you Bowser Cache and redownload the PDF. Thanks for reporting the issue. --Dirk Hünniger (discuss • contribs) 13:49, 27 December 2015 (UTC)

This book for sale on Amazon
This book seems to be available for sale on Amazon. That's kinda cool. Good to see wikibooks content being made available in that form. Good to see an example of commercial use of the content too I guess, but...

It's rather expensive though. I mean it's kind of a normal technology book price £19.89 on the UK store. I would expect it to be cheaper, given that it's available to download from here for free, and authored here by volunteers. Either that or I would expect the profits to be donated to wikibooks (which may be the case, but I don't see any label about that). Otherwise it feels a little bit like purchasers are being misled, and the community here is not being adequately rewarded.

How do others feel about it? It's not really my place to be outraged, since I've not authored any of this book myself. It could be that the book was actually authored elsewhere and copied in here, or authored by a few people here who are now profiting from publishing the book on amazon. What's the situation?

-- Harry Wood (discuss • contribs) 21:28, 29 January 2016 (UTC)

Shouldn't this be updated to Python 3?
Since Python 2 is now officially deprecated, I think this should really be updated to Python 3. This is the most complete Wikibooks reference body on Python, and it would really be a shame if it just got supplanted by the Non-Programmer's Tutorial for Python 3. Milanand (discuss • contribs) 11:55, 12 December 2020 (UTC)
 * I'm currently working on this here. Milanand (discuss • contribs) 12:37, 12 December 2020 (UTC)
 * I've lost access to my old account, but I'm still working on this here. Milanandreew (discuss • contribs) 07:13, 18 December 2020 (UTC)

Migrate to Python 3
This book is currently very disorganized; the Python 2 and Python 3 seem to be mixed together. I think that the book should be completely migrated to Python 3 because it is more useful in the long run. At the very least, the book should either be about Python 2 or 3, so there isn't confusion. Calgary341 (discuss • contribs) 20:24, 18 February 2022 (UTC)

If people still want the Python 2 stuff, we can simply make a new book called Python 2 Programming or something like that. Calgary341 (discuss • contribs) 20:26, 18 February 2022 (UTC)


 * Seems a reasonable proposition. Additionally, it would be nice if it explained how Python 2 differed in syntax, if at all. -- Jules (Mrjulesd) 22:20, 18 February 2022 (UTC)
 * There could be a page called something like "Python 2 vs. Python 3" somewhere. Calgary341 (discuss • contribs) 17:32, 19 February 2022 (UTC)
 * Whoops, just realized that page already exists! Calgary341 (discuss • contribs) 21:45, 19 February 2022 (UTC)
 * Indeed: Python Programming/Python 2 vs. Python 3. --Dan Polansky (discuss • contribs) 14:58, 4 June 2022 (UTC)
 * Now that Python 2 is no longer supported (support ended in 2020), I agree with migrating the book to Python 3. The first obvious impact is on all the print statements that should now become print functions (invocation uses brackets), then there is the true division (3/2==1.5), then there is the new unicode treatment, and then there are other differences. Changing the print statements is a straightforward if laborious task, but making sure everything else is correctly covered will be more of a challenge. --Dan Polansky (discuss • contribs) 14:58, 4 June 2022 (UTC)
 * I migrated print statements and performed some other changes to migrate the book to Python 3. One thing that remains is converting the external links to point to Python 3 documentation. An independent review searching for remaining things to do and mistakes would be helpful. --Dan Polansky (discuss • contribs) 11:01, 5 June 2022 (UTC)