Talk:Python (programming language)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Good article Python (programming language) has been listed as one of the Engineering and technology good articles under the good article criteria. If you can improve it further, please do so. If it no longer meets these criteria, you can reassess it.
Article milestones
Date Process Result
March 7, 2007 Good article nominee Listed
February 17, 2009 Peer review Reviewed
March 3, 2009 Good article reassessment Kept
Current status: Good article
          This article is of interest to the following WikiProjects:
WikiProject Computing (Rated GA-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 GA  This article has been rated as GA-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
 
WikiProject Free Software / Software / Computing  (Rated GA-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Free Software, a collaborative effort to improve the coverage of free software on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 GA  This article has been rated as GA-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software.
Taskforce icon
This article is supported by WikiProject Computing.
 
WikiProject Computer science (Rated GA-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 GA  This article has been rated as GA-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
 
WikiProject Software / Computing  (Rated GA-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Software, a collaborative effort to improve the coverage of software on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 GA  This article has been rated as GA-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Computing.
 
WikiProject Netherlands (Rated GA-class)
WikiProject icon This article falls within the scope of WikiProject Netherlands, an attempt to create, expand, and improve articles related to the Netherlands on Wikipedia. If you would like to participate, visit the project page where you can join the project or contribute to the discussion.
 GA  This article has been rated as GA-Class on the project's quality scale.
 

Object-oriented vs. Object-orientation[edit]

Is this correct?

Python supports multiple programming paradigms, including object-oriented, imperative and functional programming styles. (emphasis mine)

I think it should say "object-orientation", not "object-oriented". I have made this adjustment before and it was changed back. Am I in the wrong here?

EDIT: Boy I feel stupid. I did not read the full sentence. I'm sorry for wasting your time.

Python 2 types[edit]

The table of types only describes Python 3 types, and it describes 'str' as 'A character string: an immutable sequence of Unicode codepoints.' which is of course very true for python 3, but very wrong in python 2. Python 2 is still quite commonly used, and in python 2 str is ASCII rather than unicode, and there is a base type 'basestring' and a subclass 'unicode'.

There are likely other differences between the two versions, and I think it is worth having them side by side in the table, rather than only describe Python 3. The other main difference I can see is that py3 int is essentially the py2 long, and py3 'bytes' is probably buffer() in py2, but I am not sure about that one.

If we didnt include python 2 in the table, I would like to add a note under the table that explains that the Python 3 'str' and 'int' are the Python 2 'unicode' and 'long', and the Python 2 types 'str' and 'int', which existed due to hardware/architecture/performance issues rather than ideal-world language "beauty", have been dropped in Python 3. John Vandenberg (chat) 06:00, 12 July 2014 (UTC)

Influenced by Java?[edit]

The article lists Java as an influence and the citation just mentions decorators as being influenced by Java. That seems like a pretty small influence. Seems like there either needs to be a better citation or maybe Java (which evidently didn't appear until 4 years after Python) shouldn't be on the lengthy list of influences. 50.46.176.46 (talk) 05:14, 24 October 2014 (UTC)

It seems to me pretty clear influence. Although Java didn't influence a lot in Python, it clearly influenced decorators. From the ref:
"Guido took a list of proposals to EuroPython 2004 [7], where a discussion took place. Subsequent to this, he decided that we'd have the Java-style [10] @decorator syntax, and this appeared for the first time in 2.4a2"
The ref is in a PEP, so it's pretty high-grade ref IMO.
peterl (talk) 09:56, 5 November 2014 (UTC)
The trouble is that this is a very minor influence, yet the hive-mind at WP will probably now categorize Python as a "Java-based language".
Decorators didn't come from Java - they were long pre-existing before Java, and before most WP editors were born. What Python took from Java was a convenient syntactic style for representing decorators in source, no more. Andy Dingley (talk) 10:20, 5 November 2014 (UTC)

Influenced Javascript[edit]

It appears that someone has added "[Citation Needed]" next to Javascript in the Influenced property of the Infobox.

Here are two citations regarding how Python influenced ECMAScript (and, thus, Javascript):

Wes Turner (talk) 21:19, 4 November 2014 (UTC)

Wouldn't they be more convincing if they contained the word "Python"? Andy Dingley (talk) 21:44, 4 November 2014 (UTC)

Duck typing?[edit]

Is Python duck typed? re [1]

IMHO, we should take this term out and burn it. The term "duck typing" is badly skunked: it so abused and misused that no-one knows what it means. Firstly few can define it and secondly (and most importantly) it's used to mean two contradictory things so frequently that no-one can ever communicate anything by its use.

"Duck typing" first became popular because Martelli in 2000 [2] used it in reference to Python. However (as almost no-one remembers today) he used it in contrast to Python.

I can define "duck typing". I can even define "duck typing in Python". And if you tell me first whether you think Python is, or is not duck typed, then I can explain what it means and how Python is (or is not, whichever you favour) following it. The term just has no consistent definition, or a definition that can be in any way illuminating in an article on Python.

w:Duck typing is beyond hope, but also beyond AfD. However we should not spread the confusion or nonsense further than it has already gone. The term should never be used around Python coders. Andy Dingley (talk) 21:36, 13 March 2015 (UTC)

Disagree. peterl (talk) 01:32, 15 March 2015 (UTC)
With what part? Andy Dingley (talk) 01:43, 15 March 2015 (UTC)

────────────────────────────────────────────────────────────────────────────────────────────────────

Hi. I'd like to interrupt and show this example.

class duck:
    def quack(self):
        print("Quaaaaaack!")
 
class human:
    def quack(self):
        print("Fine...quack...happy?")
 
class dog:
    def bark(self):
        print("BARK!BARK!")
 
class cat:
    def meow(self):
        print("Meeeeeeeow.")
 
for i in (duck(), cat(), human(), dog()):
    try:
        i.quack()
    except:
        print("A %s cannot quack." % i.__class__.__name__)

output:

Quaaaaaack!
A cat cannot quack.
Fine...quack...happy?
A dog cannot quack.

The above shows that i will act like a duck and quack() regardless of its class type and it will throw a graceful error if it cannot quack(). This leads me to believe that Python is pretty duck typed. I also disagree. --I8086 (talk) 21:11, 15 March 2015 (UTC)

Your example doesn't really illustrate the problem. We all know that this is how Python behaves. The question is, is this duck typing? Per Martelli's original association of the term to a Python context, this isn't duck typing. Duck typing, following the spirit of the original expression "If it walks like a duck and quacks like a duck, then it's a duck" is based on judging a set of behaviours in order to assign an identity. This is not what Python does - Python avoids the need to deal with such identities, because behaviours (i.e. supported methods) are independent. In Python we just don't care about whether things are ducks or not, or even if they "can be treated as ducks", we simply work at the level of "Make it quack if it can", "Make it walk if it can" and then we leave it at that.
The question here for this article is even simpler. If we recognise that "duck typing" is a useless term in software because there is no agreed meaning for it (can you cite a more authoritative source than Martelli?) and that the two meanings differ so far as to simply contradict each other, then does it help or hinder this article to include the term? Andy Dingley (talk) 22:54, 15 March 2015 (UTC)
Here's a definition straight from the Python Documentation:
A programming style which does not look at an object’s type to determine if it has the right interface; instead, the method or attribute is simply called or used (“If it looks like a duck and quacks like a duck, it must be a duck.”) By emphasizing interfaces rather than specific types, well-designed code improves its flexibility by allowing polymorphic substitution. Duck-typing avoids tests using type() or isinstance(). (Note, however, that duck-typing can be complemented with abstract base classes.) Instead, it typically employs hasattr() tests or EAFP programming.
This means you can call a method of any object while having EAFP (like the above example) in case you can't call that said method. So, along with that, I don't see why it should be removed; I find duck typing important. --I8086 (talk) 01:11, 16 March 2015 (UTC)

Hello world?[edit]

As you probably know, most programming languages on Wikipedia have a Hello World section. Any chance of adding it? The syntax is pretty simple: `print "Hello, world"` for Python 2.x and `print("Hello, World")` for python 3.x. I would love to add it myself, but I'm no Wikipedia editor. 84.85.246.226 (talk) 15:45, 31 March 2015 (UTC)

No. What new facet would this explain about Python? Hello World is, by its nature, trivial. Trivial examples rarely demonstrate much. Andy Dingley (talk) 17:40, 31 March 2015 (UTC)
Ok, sorry about that :) 84.85.246.226 (talk) 06:35, 1 April 2015 (UTC)