Talk:Python (programming language)/Archive 11
This is an archive of past discussions about Python (programming language). Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 5 | ← | Archive 9 | Archive 10 | Archive 11 |
More Python programming examples
Hello. My fellow classmates and I are interested in making some positive contributions to the Python article. We plan on adding in a few Python programming examples and possibly explanations that aim to illustrate core Python syntax for a brief introduction without requiring the readers to go the Python syntax page directly. However, we noticed a comment in the edit page, which is to quote, "Please don’t add more examples". We would like to ask why this is discouraged. We have looked at other pages on popular languages such as JavaScript, Haskell, Java, and observed that they each have a much richer example section, thus we believe we can and should move this page in such a direction. Mtran0842 (talk) 17:51, 15 March 2022 (UTC)
- @Akeosnhaoe: I believe you added the
Please don’t add more examples
comment. Perhaps you can explain further. - @Mtran0842: My supposition is that Wikipedia articles are not "how to" documentation. I think that is more the purpose of wikibooks:Python Programming & wikiversity:Python. If you wish to add examples that are not already covered, these may be the appropriate venues. Peaceray (talk) 18:03, 15 March 2022 (UTC)
- Thank you for your response. While I do wholeheartedly agree that Wikipedia articles are not meant to behave like a manual book, it is also not our intention to be exhaustive when it comes to adding more programming examples. Again I wish to emphasize that we aim to "illustrate core Python syntax for a brief introduction without requiring the readers to go the Python syntax page directly". To be more specific, adding two to three examples, or even only one, would suffice in our vision.
- Mtran0842 (talk) 18:21, 15 March 2022 (UTC)
- The 'Hello, world!' and the factorial example we already have are the traditional two samples used in this kind of situation and are plenty for this page. Please don't add more. I've seen example lists on similar articles grow out of control over time, so this list needs to be kept lean. Also, I took a look at some of the other programming language articles you mentioned, and (except for the javascript article, which is IMO awful) the number of examples on them seems to be in line with what we have here - even if you find counterexamples, consider that the proper action might be to trim those rather than grow this article. - MrOllie (talk) 18:42, 15 March 2022 (UTC)
- Considering this perspective, could it be appropriate to provide brief direction for where an interested reader can go next? Some other pages have a link near the top of the subsection such as see other features and examples(Haskell) or Language Syntax(Java at least) to have more examples without the bloat in the main page. Would adding a link to the Python Syntax and semantics page from the Examples subsection work at accomplishing this? Calvinroth1 (talk) 01:25, 16 March 2022 (UTC)
- There's a section called 'Syntax and semantics' where such links can be found - in fact it is the neighboring section to the examples. I think the readers who want to know more about syntax already know where to go. MrOllie (talk) 12:03, 16 March 2022 (UTC)
- Considering this perspective, could it be appropriate to provide brief direction for where an interested reader can go next? Some other pages have a link near the top of the subsection such as see other features and examples(Haskell) or Language Syntax(Java at least) to have more examples without the bloat in the main page. Would adding a link to the Python Syntax and semantics page from the Examples subsection work at accomplishing this? Calvinroth1 (talk) 01:25, 16 March 2022 (UTC)
- The 'Hello, world!' and the factorial example we already have are the traditional two samples used in this kind of situation and are plenty for this page. Please don't add more. I've seen example lists on similar articles grow out of control over time, so this list needs to be kept lean. Also, I took a look at some of the other programming language articles you mentioned, and (except for the javascript article, which is IMO awful) the number of examples on them seems to be in line with what we have here - even if you find counterexamples, consider that the proper action might be to trim those rather than grow this article. - MrOllie (talk) 18:42, 15 March 2022 (UTC)
- Thanks, but sorry, that's not going to work. Experience tells us that as soon as more examples start to appear, there is no end. People edit the examples to make them more "Pythonesque" with one-line-is-all-you-need tricks that are not appropriate here. We have (IMHO) let Hello World decay recently but it will be pruned eventually. Johnuniq (talk) 22:44, 15 March 2022 (UTC)
- Yea, this was also part of my reason for adding the comment. People see 5 examples and and think "hey, there's all this code but no example for <some specific concept I just learned about, like decorators or something>, I'll just add one more" and it just never stops and few people that want to delete examples but lots of people coming by that want to add one so eventually the article is looking like a Rosetta Code page. It's already a really long article. Akeosnhaoe (talk) 06:45, 16 March 2022 (UTC)
- The comment, is meant for people that were making drive-by edits of useless code, maybe just so that they could think to themselves "hah my code is literally the textbook example of Python code". It's not meant for people making high-effort contributions. It sounds like you want to actually improve the article and give some thought to the examples on the page, so feel free to disregard it. WP:BOLD and all that.
- But I will say that to me, when I read about a programming language, just a dozen lines or so, like what we have now gets me like 80% of what I want, just to get the gist of the syntax. If I then want to go and actually learn the language, that doesn't happen on Wikipedia. I don't think it would be helpful to have readers scroll through pages and pages of code, but more examples could be good. The current examples already demonstrate
- - significant whitespace
- - functions and their invocation
- - dynamic types (the fact that in Python you don't annotate variables with their type)
- - for loops and range()
- - input/output
- - math
- one obvious thing that I would say is missing is function definition syntax. Akeosnhaoe (talk) 06:39, 16 March 2022 (UTC)
- The edit that finally made me add the comment
- https://wiki.riteme.site/w/index.php?diff=968326272&oldid=968258780&diffmode=source
- was adding a Fibonacci sequence function as an example which doesn't illustrate anything meaningful the other two example don't already. Akeosnhaoe (talk) 10:19, 16 March 2022 (UTC)
- I think I agree that Fibonacci doesn't add enough that isn't already here if factorial is already present. In my mind if one wanted to add a new example it would include using Lists or some other default data structure in a basic way. Simply rewriting the factorial example as a function is something we could do as well. Calvinroth1 (talk) 13:46, 16 March 2022 (UTC)
- An attempt was made to do that, but it needlessly made the example more confusing, so I reverted it. MrOllie (talk) 17:27, 23 March 2022 (UTC)
- I am interested in why you find the reverted edit to be confusing. Can you perhaps elaborate further on your reason? I find adding a function definition and in turn a call to such defined function is quite helpful as the practice of doing so is one of the cornerstones not just to Python but also to most programming languages. Also I am confident that the majority of beginner programmers will have little to no difficulty in understanding the edit that I made. Mtran0842 (talk) 19:47, 23 March 2022 (UTC)
- You created a function definition that accomplished nothing and was unnecessary for the functioning or structure of the program - it served no purpose and thus its presence was misleading. You seem to still be laboring under the misunderstanding that this article should help beginner programmers - that is not the purpose of an encyclopedia article (WP:NOTTEXTBOOK). Perhaps the material you and your classmates seem to want to add would fit better at Wikiversity, where the mission is to produce learning materials. MrOllie (talk) 19:48, 23 March 2022 (UTC)
- Thank you for your elaboration and your suggestion regarding where to direct our effort. I want to clarify that we aim to make this page better as a general informative resource and not as a study material, but perhaps we were bad at demonstrating our intention and so we apologize for that. After all it is our first attempt. Anyway, I get where you are coming from regarding your explanation to the revision, but I want to ask this so I can better understand: would it not be better to have the program written in such a way that is more traditionally seen in actual coding practice compared to having it be presented in a bare-bones fashion? I would argue that by presenting the program in the way of the former, it is still in spirit of bettering this encyclopedic page. Mtran0842 (talk) 20:48, 23 March 2022 (UTC)
- First, I don't agree with the premise that your version was an example of something a typical python programmer would produce. And no, I don't think it would be better to make an example of 'actual coding practice' - that these are minimalist examples is a feature, not a bug. Python in particular tends to have a lot of clever, densely written code, which practitioners say is 'pythonic'. I don't think we should reproduce that kind of thing, and I don't think more complex example programs that are trying to demo additional language features is the direction this article should move in. MrOllie (talk) 12:21, 24 March 2022 (UTC)
- Thank you for your elaboration and your suggestion regarding where to direct our effort. I want to clarify that we aim to make this page better as a general informative resource and not as a study material, but perhaps we were bad at demonstrating our intention and so we apologize for that. After all it is our first attempt. Anyway, I get where you are coming from regarding your explanation to the revision, but I want to ask this so I can better understand: would it not be better to have the program written in such a way that is more traditionally seen in actual coding practice compared to having it be presented in a bare-bones fashion? I would argue that by presenting the program in the way of the former, it is still in spirit of bettering this encyclopedic page. Mtran0842 (talk) 20:48, 23 March 2022 (UTC)
- You created a function definition that accomplished nothing and was unnecessary for the functioning or structure of the program - it served no purpose and thus its presence was misleading. You seem to still be laboring under the misunderstanding that this article should help beginner programmers - that is not the purpose of an encyclopedia article (WP:NOTTEXTBOOK). Perhaps the material you and your classmates seem to want to add would fit better at Wikiversity, where the mission is to produce learning materials. MrOllie (talk) 19:48, 23 March 2022 (UTC)
- I am interested in why you find the reverted edit to be confusing. Can you perhaps elaborate further on your reason? I find adding a function definition and in turn a call to such defined function is quite helpful as the practice of doing so is one of the cornerstones not just to Python but also to most programming languages. Also I am confident that the majority of beginner programmers will have little to no difficulty in understanding the edit that I made. Mtran0842 (talk) 19:47, 23 March 2022 (UTC)
- An attempt was made to do that, but it needlessly made the example more confusing, so I reverted it. MrOllie (talk) 17:27, 23 March 2022 (UTC)
- I think I agree that Fibonacci doesn't add enough that isn't already here if factorial is already present. In my mind if one wanted to add a new example it would include using Lists or some other default data structure in a basic way. Simply rewriting the factorial example as a function is something we could do as well. Calvinroth1 (talk) 13:46, 16 March 2022 (UTC)
neural network
how does this work? 115.247.106.78 (talk) 11:38, 24 August 2022 (UTC)
Strings as a separate heading?
The discussion of Python strings appears in the list of expressions, which seems odd (if not fully wrong). I propose that a new section be started on Python's strings, starting with the current text and maybe expanding somewhat. Paulehoffman (talk) 01:30, 21 November 2022 (UTC)
Python and BASIC
Seems that nobody have noticed that Python is very similar to a very old language: BASIC. BASIC has a lot of versions and like Python has interpreter and compiler versions. 84.111.134.34 (talk) 13:16, 17 September 2022 (UTC)
- Python is very similar to many languages that existed before it was created. Listing them, and trying to parse which was most influential, could be revisionist history. Paulehoffman (talk) 01:31, 21 November 2022 (UTC)
External links
Maybe add some guides on how to use Python in the external links? GenZenny💖 (talk) 07:33, 21 November 2022 (UTC)
- There's a billion and one guides on how to learn/use Python, which anyone with the most basic working knowledge of how to use a search engine could find. Linking to any particular guide would not only show preference towards it (could be seen as spam, unwanted promotion etc.), but also is outside the scope of this article. — Jumbo T (talk) 20:15, 21 November 2022 (UTC)
Design philosophy and features is inaccurate
Suggest rewriting the Python (programming language)#Design philosophy and features section to reflect the actual language rather than PEP20. Specifically, commentators have criticised Python's additions for violating Python's design principles with unnecessary bloat and complexity. Would this be supported? BordenC (talk) 10:02, 22 December 2022 (UTC)
I would support this, as long as there was still a discussion of PEP20 along the lines of "the stated philosophy" (talk) 15:55, 22 December 2022 (UTC)
New resource for historical info about Python
For any editors updating this page, I just noticed today that in November 2022 Professor Lambert Meertens published an article on "The Origins of Python" in the journal Inference. It may be useful in that it covers a great amount of the history of ABC and Guido van Rossum's early development of python. (I unfortunately don't have the cycles myself to do any editing of this page right now.) - Dyork (talk) 13:07, 23 January 2023 (UTC)
Good article reassessment needed?
This article has been listed as possibly requiring a WP:Good article reassessment for quite a while now. We're trying to empty this category (and possible deprecate it). Do editors here believe it still meets the criteria? My impression is that it's close, but that a few improvements are needed:
- Most importantly, I think the lead needs to be simplified to comply with WP:make technical articles understandable. The most difficult words in the lead for me are garbage-collected, structured programming, standard library, and what type of language ABC was. I think more emphasis should be put on uses of the language (simple to learn, large community and therefore loads of specific libraries, but slow).
- Occasionally, the body also misses opportunities to explain things simply "Python uses duck typing and has typed objects but untyped variable names.". Duck typing is easy to explain, but will be unfamiliar to many.
- There are occasional (potentially) uncited statements like:
- When speed is important, a Python programmer can move time-critical functions to extension modules written in languages such as C; or use PyPy, a just-in-time compiler. Cython is also available, which translates a Python script into C and makes direct C-level API calls into the Python interpreter.
- Most of the text in "Development environments"
- Some of the text may be in need of updates, such as:
- Cython compiles (a superset of) Python 2.7 to C (while the resulting code is also usable with Python 3 and also e.g. C++). I assume Cython now works with python 3?
- Should we cover the current project of making python faster? [1].
If no progress is made towards these issues, I'll list the article at GAR in a few weeks. Pinging top contributors: @Abductive, Comp.arch, Thumperward, and Akeosnhaoe:. —Femke 🐦 (talk) 10:19, 29 January 2023 (UTC)
- I don't have anything to say about whether this needs reassessment, but I would strongly oppose removing the technical language you list from the lead. It's a well-established convention in articles about programming languages (see Rust, C, Perl) to describe their features using technical terms that may not be familiar to the general reader. Programming languages are a specialized subject; it is rather difficult to talk about them in a meaningful way without technical language. From the essay you linked:
For highly specialized topics where it is difficult to give an overview in terms with which a general audience will be familiar, it may be reasonable to assume some background knowledge in the lead while linking to the prerequisites required to understand it.
- That said, this doesn't mean we can't add content to the lead about the uses, history and appeal of the language (in the articles linked above, large parts of the leads consist of this sort of content, and this article is indeed lacking). In fact, I'd strongly support this. — Jumbo T (talk) 11:47, 29 January 2023 (UTC)
- I do not believe Python is a highly specialized topic. It's probably the most common programming language out there, and is often used by those just starting to program. Information such as " cycle-detecting garbage collection, reference counting," for python 2 is not really relevant to most readers, and it is highly technical. Not saying that we should remove all jargon of course. You can't understand what python is without saying it's high-level, dynamically typed and so forth. We can take the example of Rust, where jargon is either explained or contextualised (see second sentence). —Femke 🐦 (talk) 12:02, 29 January 2023 (UTC)
- I moved that Python 2 stuff out of the lead because I agree, it was relevant when Python 2 was the latest version but it doesn't make sense to have it in the lead anymore. Akeosnhaoe (talk) 12:50, 29 January 2023 (UTC)
- I do not believe Python is a highly specialized topic. It's probably the most common programming language out there, and is often used by those just starting to program. Information such as " cycle-detecting garbage collection, reference counting," for python 2 is not really relevant to most readers, and it is highly technical. Not saying that we should remove all jargon of course. You can't understand what python is without saying it's high-level, dynamically typed and so forth. We can take the example of Rust, where jargon is either explained or contextualised (see second sentence). —Femke 🐦 (talk) 12:02, 29 January 2023 (UTC)
- Without looking at the rubric, I support marking this down/re-assessing (whatever that means) because I can't call this article "good". It's written as an introduction to the language and it's a pretty complete high-level description of Python, which is hopefully helpful to beginners, but on the other hand it's just kind of an ugly article and repeats itself often. It's grown organically, with people adding small snippets and expanding/completing sections they care about with little to no regard for the entire article. It would be great for someone to sit down and systematically edit it, pare it down/reorganize stuff. And also remove more mentions of Python 2?
- > I think the lead needs to be simplified
- It would be nice but I don't think it can be in a useful way. You could make the edit and then we can discuss reverting the specific edit. For the audience that's familiar with programming languages, the list "significant whitespace, dynamic typing and garbage collection" is the first sentence you want to read. The stuff about "programming paradigms" is kind of fluff in my opinion, all modern languages are "structured, object-oriented and functional", and I would support just removing it completely, but other people like to talk about that kind of stuff.
- > simple to learn, large community and therefore loads of specific libraries, but slow
- I agree that this kind of summary of what Python is in practice is good and writing it as a more explicit list into the article is a great idea. This article is trying to say these things in different places.
- > what type of language ABC was
- I don't think anyone is expected to know that. It's a link if you care to know how Python is connected to the past.
- > I assume Cython now works with python 3?
- No, as per the Cython article, there's a preview version that does but formally the current version still doesn't. Cython isn't that widely used. Akeosnhaoe (talk) 14:33, 29 January 2023 (UTC)
no complaints from me: the areas highlighted are things that I've tried to tackle over the years, but any technical article on here tends to backslid towards trivia and pointless nitpicking if not strictly watched. In particular, all of the bulleted syntax stuff should be relegated to the syntax sub-article if not removed entirely. Chris Cunningham (user:thumperward) (talk) 06:46, 2 February 2023 (UTC)
Semi-protected edit request on 6 August 2023
This edit request to Python (programming language) has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Update latest beta release version - Python 3.12 0rc1 has been released (2023-08-06) 86.130.253.139 (talk) 14:51, 6 August 2023 (UTC)
- Already done via Wikidata —PlanetJuice (talk • contribs) 20:19, 6 August 2023 (UTC)
What platforms can run Python applications?
It would be good to know on what platforms and version Python can run on in a table, eg Windows, macOS, linux, iOS, Android, ... The table would probably need an explanation of any specific tools needed (frameworks, compilers). Also whether packaged packaged apps can be built that can be distributed (eg app store) to users without users requiring anything else to be installed.
An explanation of how features unique to each platform can be accessed would be useful. FreeFlow99 (talk) 16:59, 6 March 2024 (UTC)
Climate change
This page should mention that programming languages like Python that are not compiled into native executable code (e.g., they are interpreted or compiled into byte code that is run in a virtual machine) require more processor cycles for the same results compared to native executables. Therefore they use more power to execute, and they contribute more to climate change. Given the ubiquity of Python, a vast amount of power is wasted on interpretation or byte-code execution. 209.145.84.194 (talk) 20:08, 28 March 2024 (UTC)
- Do you have a source which describes this? The correlation between interpreted languages and climate change is not something I have seen described before. —Panamitsu (talk) 23:59, 28 March 2024 (UTC)
- I've seen this mentioned before (don't have any immediate links) and it probably has some validity. But, I agree with Panamitsu that to actually include this we need good sources (I think more than one unless it's a really solid one) that discuss this and do a pretty complete analysis. Since this isn't unique to Python and there are other tradeoffs beyond just how the final applications are run. Skynxnex (talk) 13:21, 29 March 2024 (UTC)
- I can find a few reliable sources which suggest that Python does indeed use much more energy for the same tasks when compared with compiled languages like C.[1][2][3] However, I find no studies examining a link with climate change. This could be because demonstrating such causality would, I imagine, be very difficult. I do wonder what the impact of language choice is, though, relative to e.g. the total power draw of all electronics in a country—it might be an interesting exercise to estimate how many GW (or perhaps only MW?) could be saved in your country by rewriting all Python programs in C. — Jumbo T (talk) 13:27, 29 March 2024 (UTC)
- Even if true that interpreted or VM run Bytecode compiled languages require more processor cycles, then the proper place for that discussion would be on the pages for those execution environments rather than on specific languages pages. I would also like to see the citations for that. But creating a link to climate change is an additional leap that again would require evidence. It's quite possible that despite requiring more processor cycles to run similar code there are other features that make it more efficient in practice, or even that python is a more amenable language for the creation of control systems for products that combat or mitigate against climate change - to be clear, that is a hypothesis without evidence but it does caution against a simplistic narrative: Python -> Byte code -> more cycles -> worse for environment. Chris (talk) 09:06, 2 April 2024 (UTC)
References
- ^ Abdulsalam, Sarah; Lakomski, Donna; Gu, Qijun; Jin, Tongdan; Zong, Ziliang (November 2014). "Program energy efficiency: The impact of language, compiler and implementation choices". International Green Computing Conference: 1–6. doi:10.1109/IGCC.2014.7039169.
- ^ Pereira, Rui; Couto, Marco; Ribeiro, Francisco; Rua, Rui; Cunha, Jácome; Fernandes, João Paulo; Saraiva, João (May 2021). "Ranking programming languages by energy efficiency". Science of Computer Programming. 205: 102609. doi:10.1016/j.scico.2021.102609.
- ^ Koedijk, Lukas; Oprescu, Ana (June 2022). "Finding Significant Differences in the Energy Consumption when Comparing Programming Languages and Programs". 2022 International Conference on ICT for Sustainability (ICT4S): 1–12. doi:10.1109/ICT4S55073.2022.00012.
Naming
Python is named so, because the (long) code of the language looks like a snake/python. 49.37.96.186 (talk) 15:06, 28 June 2024 (UTC)
- Not done You have not provided verification from a reliable source for this claim. This appears to be original research. Peaceray (talk) 18:36, 28 June 2024 (UTC)