Jump to content

Talk:Python syntax and semantics

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Peterl (talk | contribs) at 05:07, 5 August 2021 (Not fit for wikipedia: Add bolding to make it clearer differing points). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconComputing: Software C‑class Low‑importance
WikiProject iconThis 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.
CThis article has been rated as C-class on Wikipedia's content assessment scale.
LowThis article has been rated as Low-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software (assessed as Mid-importance).

Not fit for wikipedia

As much as I love python, I simply don't think this is fit for wikipedia. Speak now or forever hold your peace. This would be great rewritten in someone's blog or the python documentation perhaps, but wikipedia is not meant for software documentation, this is better left up to the project's documentation team or a specific website. — Preceding unsigned comment added by 68.227.144.76 (talk) 10:05, 9 March 2014 (UTC)[reply]

I feel better to see at least one noticed the same. This article is advertising or propaganda (as there are plenty of others on Wikipedia, by the way). --Hibou57 (talk) 14:18, 11 September 2014 (UTC)[reply]
I agree, it's (IMHO) not the highest quality either. Robertwb (talk) 00:47, 23 September 2014 (UTC)[reply]
Disagreed. Wikipedia is totally meant for software "documentation" -- and everything-else documentation -- when the documentation is notable and discriminate. This article summarizes well, and the subsections are cohesive. The article is neither advertising nor propaganda by any reasonable definition. I agree it could benefit from a more neutral tone in some places, e.g. "another strength of Python...". Bob Stein - VisiBone (talk) 15:54, 23 November 2015 (UTC)[reply]
I also disagree. If you find this article to be too propagandistic, please help improving it and make it more fact based. PAB-global (talk) 10:29, 1 June 2016 (UTC)[reply]
I 100% agree. Vast swathes of the article are unsourced, use too much opinionated language, are out of date, and large parts should just be merged with Python_(programming_language). Unless someone really wants to improve it, I'm +1 for deletion. It's not "advertising or propaganda" though. LetterC (talk) 15:36, 18 December 2020 (UTC)[reply]
Agreed. I find it extraordinary that the language definition is here on Wikipedia and not on python.org. I am not a big fan of the modern style of programming language documentation, where there's no language definition, only a big cookbook of examples that one must learn by osmosis (with no guarrantee that the cookbook has covered everything). Java and C have their flaws, but at least you can be sure that the language is definitely all in one place. 203.13.3.93 (talk) 00:32, 5 August 2021 (UTC)[reply]
My apologies. The language reference is available at https://docs.python.org . Which, again, means that there's no particular reason for it to be here. 203.13.3.93 (talk) 01:15, 5 August 2021 (UTC)[reply]

This page needs a better name

Very little of the page is syntax, it's almost entirely semantics. It needs a better name. Otherwise, it's well done. 165.189.91.148 21:15, 28 August 2006 (UTC)[reply]

Stupid examples

The example C function int foo() is missing a return statement. I assume this was supposed to be declared void foo(int x), and have corrected it. 202.89.153.166 09:35, 8 January 2007 (UTC)[reply]

List Comprehensions Out of date?

If i recall, the language was changed in a recent rev so that list comprehensions are no longer immediately expanded. --64.238.49.65 01:09, 3 March 2007 (UTC)[reply]

No, you're thinking of generator expressions. EdC 11:19, 3 March 2007 (UTC)[reply]

closure example needed

closure example needed —Preceding unsigned comment added by 150.101.166.15 (talk) 01:43, 15 February 2008 (UTC)[reply]

Added, using the example from Closure (computer science). EdC (talk) 00:23, 21 February 2008 (UTC)[reply]
Doesn't the example need to show the results of running foo(1, 2) (i.e. what gets printed) in order to make the point? Ma-Ma-Max Headroom (talk) 18:11, 28 September 2014 (UTC)[reply]

Scoping?

Can someone dedicate a section to scoping? Does Python use static or dynamic scoping, or some other kind? indil (talk) 05:40, 4 August 2008 (UTC)[reply]

EAFP

I'm getting really tired of people regurgitating the so-called EAFP style of programming. As far as I can tell, Alex Martelli came up with this one for Python in a Nutshell, and it has been widely quoted disseminated in spite of the fact that AFAIK there isn't a shred of evidence that EAFP actually increases readability. It probably does increase performance, but I don't think EAFP would be as widely cited if this were the only claimed benefit, and there isn't any evidence cited that it actually does increase performance. Given that readability is highly subjective anyway, I don't think the statement "EAFP increases readability" is verifiable. The tone of the section needs to be less POV for EAFP too. Mistercupcake (talk) 01:23, 10 August 2008 (UTC)[reply]

The perceived readability advantage of EAFP (i.e. using try/except rather than if/else) was certainly widely discussed on the Python newsgroup/mailing list long before Alex wrote his book. I do not know of any specific quantitative studies that provide any evidence (and doubt any exist), but the belief is pretty old and pretty widespread.
Actually, the advantage usually presented isn't really readability per se. It's more like the belief that programs structured with try/except promote better programming practice or a better way of conceptualizing the problem. That may lead to readability, but it comes from a bit different direction. LotLE×talk 01:32, 10 August 2008 (UTC)[reply]
EAFP does help when later Duck Typing as it promotes the use of less type/is-a checks and focuses on what can be done. --Paddy (talk) 10:30, 10 August 2008 (UTC)[reply]

"the whitespace thing"

QUOTE
The term "the whitespace thing" is commonly used in online discussion of the merits of block delimiter styles, e.g. "Python - Indentation/whitespace".; ""The Whitespace Thing" for OCaml".; "Proposal: Official whitespace response".
END OF QUOTE

None of the sources seems to be reliable. I would remove them from the article as well as statements they support unless reliable sources can be cited.
-- 17c (talk) 02:14, 7 February 2009 (UTC)[reply]

What sort of citation would you prefer to see for "common use in online discussions" than those very discussions where it is so used?! The sources presented aren't there mostly to discuss the third-party usage, but are direct examples of the usage (I could easily add hundreds of others, but picked a few as "typical").
I do, of course, know that (and why) secondary sources are preferred to primary ones (which one could argue those footnotes constitute). Unfortunately, for technical topics like this, primary sources are what we largely rely on, since there's not the sort secondary discussion there more often is for, e.g. political, artistic, literary, historical, etc. topics. For example, this very article has multiple citations to the actual Python.org website for various facts, even though that is also a primary source rather than secondary. LotLE×talk 02:33, 7 February 2009 (UTC)[reply]

I removed a {dubious} tag that looks WP:POINTy at best, disruptive at worst. It seems pretty much nonsensical to claim it is dubious that either "Python uses the off-side rule" or "this rule is sometimes called 'the whitespace thing'"... I honestly cannot discern any sensible meaning to the tag.

The most I can make sense of would be the claim that the phrase "whitespace thing" is insufficiently notable for the article. Or maybe the claim that mentioning it isn't an encyclopedic tone, but that seems like reaching. I confess that I used to see the phrase more often 5 years ago of so, in Python discussions, than I do nowadays. I'd like someone else to chime in on notability though. LotLE×talk 02:42, 7 February 2009 (UTC)[reply]

It seems to be jargon and not notable. Good sources are also missing. 17c (talk) 18:34, 9 February 2009 (UTC)[reply]

syntactic constructions

From the introduction:

[Python] has notably fewer syntactic constructions than other popular structured languages [...]

What does syntactic construction mean? Thanks, --Abdull (talk) 14:02, 18 September 2009 (UTC)[reply]

Fewer types of statements/expressions, I believe. For instance, it only has 7 keyword statements: if, for, while, try, class, def, with. No C-style for-loop, no do-while loop, etc. --Cybercobra (talk) 03:52, 19 September 2009 (UTC)[reply]
Not really true. There are also pass, yield, return, exec, print (granted, the last two have become functions in Python 3). Benwing (talk) 09:24, 5 July 2010 (UTC)[reply]
I think it refers to comparing something like the EBNF for Python and say Ruby or Java and finding that the graph for Python would have fewer nodes and edges. --Paddy (talk) 05:27, 6 July 2010 (UTC)[reply]
Or try this for pictures of the grammar of several languages including Python. —Preceding unsigned comment added by Paddy3118 (talkcontribs) 10:07, 6 July 2010 (UTC)[reply]

Dubious edit range in "‎Data structures"

http://en.wikipedia.org/w/index.php?title=Python_syntax_and_semantics&diff=581045060&oldid=577309604
To me this addition seems dubious, poor quality, and it considerably lengthened what originally was a short introduction.
Note that this range of 11 revisions contains no less than 9 successive revisions by IP 123.123.254.234 within a very short time (followed by two external typo fixes since then (the latest one is from me)), see the article history.
I think those modifications should be reverted or at least "heavily reworked" (and maybe moved elsewhere). — Preceding unsigned comment added by 88.136.17.130 (talk) 15:09, 10 November 2013 (UTC)[reply]

Multi-line comments

Multi-line string literals can be used for comments, but I've never seen it outside of a formal docstring (i.e. as the first statement in a definition) or a hack (to block out code in an editor that doesn't support inserting #'s on multiple lines). The code example doesn't even compile. Robertwb (talk) 00:45, 23 September 2014 (UTC)[reply]

Indentation errors in C

I feel that this particular paragraph: "The following is an example of misleading indentation in C: [...] For example, the -gnatyx option perform style checks for Ada code in GNAT. Since the version 6, GCC supports a -Wmisaligned-indentation option which checks for consistency between grouping and indentation." is off-topic for a page named "Python syntax and semantics". Going into details of languages other than Python is not important here. Are you all fine to remove this text block to make this section more readable? Thanks and best greetings, PAB-global (talk) 10:34, 1 June 2016 (UTC)[reply]

Since I am not seeing any objections within 5 months, I will remove the above mentioned part of the text. PAB-global (talk) 16:28, 14 November 2016 (UTC)[reply]

This article has neither syntax nor semantics, is just useless Blah Blah Blah!

I was looking for the BNF syntax or an extended BNF if, as seems, Python has bi-dimensional syntax. I also expected a formal or at least a precise description of Python semantics.

This article is just verbose. Typical of enthusiast aficionados.

agreed. The "design and philosophy" section is sheer fluff. 203.13.3.90 (talk) 00:37, 5 August 2021 (UTC)[reply]

I know that a formal article intimidate those who learned to write programs in Python with no formal education in computing, have no idea of how the syntax of a language is, and how, according to its semantics, is used to build a compiler. So the new article should be aficionado-friendly, but precise, please.

If everybody agree, lets mark this article to be complete rewritten. At least as a first stage with a formal syntax, and later with a precise semantics.

I don't know Python, otherwise I would help.

We'd love to assist, but apparently we're all too stupid to be worthy of you.
BNF? What is this, the 1970s? I know Python is old, but even Python's not that old. Also (and because I am old), I've never seen a useful language where either BNF was able to describe it, or the extended BNF which was being used was at all consistent with anyone else's extended BNF.
If you really want to know, the place to start looking is here, as already referenced in the article. But BNF is not that place. Andy Dingley (talk) 02:54, 13 August 2018 (UTC)[reply]
I believe you're looking for https://github.com/python/cpython/blob/master/Grammar/python.gram . This was recently overhauled. On Python 3.8 the grammar was specified in https://github.com/python/cpython/blob/3.8/Grammar/Grammar Akeosnhaoe (talk) 08:34, 17 March 2021 (UTC)[reply]