Talk:Python (programming language)
|This is the talk page for discussing improvements to the Python (programming language) 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.|
|Current status: Good article|
|This article is of interest to the following WikiProjects:|
|Threads older than 3 months may be archived by.|
Object-oriented vs. Object-orientation
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
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?
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. 126.96.36.199 (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 , where a discussion took place. Subsequent to this, he decided that we'd have the Java-style  @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)
- Wouldn't they be more convincing if they contained the word "Python"? Andy Dingley (talk) 21:44, 4 November 2014 (UTC)
Is Python duck typed? re 
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  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)
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__)
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.
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. 188.8.131.52 (talk) 15:45, 31 March 2015 (UTC)