Python Source Code Item: Difference between revisions

From GM-RKB
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
A [[Python Source Code Item]] is a [[source code item]] composed of [[Python statement]]s (for a [[Python programming language]]).
A [[Python Source Code Item]] is a [[source code item]] that is composed of [[Python statement]]s and [[Python expression]]s (for [[Python programming language]] [[execution]] and [[implementation]]).
* <B>Context</B>
* <B>Context:</B>
** It can be processed by a [[Python Interpreter]].
** It can typically contain [[Python syntax element]]s such as [[Python variable]]s, [[Python function]]s, [[Python class]]es, and [[Python module import]]s.
** It can range from being [[Pythonic Code]] to being [[Non-Pythonic Code]].
** It can typically follow [[Python coding convention]]s such as [[Python indentation rule]]s, [[Python naming convention]]s, and [[Python PEP 8 guideline]]s.
** It can typically be processed by a [[Python interpreter]] to produce [[Python runtime behavior]].
** It can typically utilize [[Python library]]s and [[Python framework]]s to extend its [[Python functionality]].
** It can typically implement various [[Python programming paradigm]]s including [[Python object-oriented programming]], [[Python functional programming]], and [[Python procedural programming]].
** ...
** ...
* <B>Example(s):</B>
** It can often include [[Python comment]]s and [[Python docstring]]s to document [[Python code purpose]] and [[Python usage instruction]]s.
** a [[Python Coding Example]].
** It can often implement [[Python error handling]] through [[Python exception]] mechanisms like [[Python try-except block]]s.
** a [[Python Program]].
** It can often use [[Python data structure]]s such as [[Python list]]s, [[Python dictionary]]s, [[Python set]]s, and [[Python tuple]]s.
** a [[Python Expression]].
** It can often interact with [[external system]]s through [[Python file operation]]s, [[Python network communication]], and [[Python database interface]]s.
** a [[Python Class Definition]] or a [[Python Method Definition]].
** ...
** a [[Python File Operation]].
** It can range from being a [[Simple Python Source Code Item]] to being a [[Complex Python Source Code Item]], depending on its [[Python code complexity]].
** a [[Recursive Python Function]] (within a [[recursive Python program]]).
** It can range from being a [[Pythonic Python Source Code Item]] to being a [[Non-Pythonic Python Source Code Item]], depending on its [[Python idiom adherence]].
** a [[Python Regular Expression Code Segment]].
** It can range from being a [[Procedural Python Source Code Item]] to being an [[Object-Oriented Python Source Code Item]], depending on its [[Python programming paradigm]].
** a [[Python Docstring]].
** ...
**
** It can be organized into [[Python module]]s, [[Python package]]s, and [[Python library]]s for [[Python code reuse]] and [[Python distribution]].
* <B>Counter-Example(s):</B>
** It can be executed in various [[Python environment]]s including [[Python interactive shell]]s, [[Python script execution]], and [[Python web application server]]s.
** [[R Code]].
** It can be analyzed using [[Python static analysis tool]]s, [[Python type checker]]s, and [[Python linter]]s for [[Python code quality assurance]].
** [[Scala Code]], [[Java Code]].
** ...
** [[JavaScript Code]].
* <B>Examples:</B>
* <B>See:</B> [[Python-based Process]], [[Python Variable]], [[Python Application Development Framework]], [[Python Program Template]].
** [[Python Source Code Item Type]]s, such as:
*** [[Python Executable Unit]]s, such as:
**** [[Python Program]] for complete [[Python application]] implementation.
**** [[Python Script]] for [[Python automation task]]s and [[Python utility operation]]s.
**** [[Python Module]] containing related [[Python function]]s and [[Python class]]es.
*** [[Python Code Segment]]s, such as:
**** [[Python Function Definition]] implementing a specific [[Python functionality]].
**** [[Python Class Definition]] defining [[Python object structure]] and [[Python behavior]].
**** [[Python Method Definition]] implementing [[Python object functionality]].
** [[Python Source Code Item Purpose]]s, such as:
*** [[Python Data Operation Source Code Item]]s, such as:
**** [[Python Data Processing Code]] for [[Python data transformation]] and [[Python analysis]].
**** [[Python Database Operation Code]] for [[Python data storage]] and [[Python data retrieval]].
**** [[Python File Operation Code]] for [[Python file reading]] and [[Python file writing]].
*** [[Python Web Source Code Item]]s, such as:
**** [[Python Web Framework Code]] using frameworks like [[Python Django code]] or [[Python Flask code]].
**** [[Python API Implementation Code]] for creating [[Python web service]]s.
** [[Python Language Feature Source Code Item]]s, such as:
*** [[Python Advanced Language Feature Code]]s, such as:
**** [[Python Decorator Code]] for modifying [[Python function behavior]].
**** [[Python Generator Expression Code]] for [[Python lazy evaluation]].
**** [[Python Asynchronous Code]] using [[Python async/await syntax]].
*** [[Python Special Purpose Code]]s, such as:
**** [[Python Regular Expression Code Segment]] for [[Python text pattern matching]].
**** [[Python Docstring]] for [[Python documentation]] embedded in code.
**** [[Python Oneliner Program]] for concise [[Python task implementation]].
** ...
* <B>Counter-Examples:</B>
** [[JavaScript Source Code Item]], which uses [[JavaScript syntax]] and is processed by a [[JavaScript engine]] rather than a [[Python interpreter]].
** [[Java Source Code Item]], which follows [[Java language specification]] and requires [[Java compilation]] rather than [[Python interpretation]].
** [[R Source Code Item]], which implements [[R programming language]] semantics for [[statistical computing]] rather than [[Python semantics]].
** [[Scala Source Code Item]], which combines [[object-oriented programming]] and [[functional programming]] in the [[JVM ecosystem]] rather than the [[Python ecosystem]].
* <B>See:</B> [[Python Programming Language]], [[Python-Based Process]], [[Python Interpreter]], [[Python Variable]], [[Python Application Development Framework]], [[Python Program Template]], [[Python Development Environment]].


----
----

Latest revision as of 21:15, 1 May 2025

A Python Source Code Item is a source code item that is composed of Python statements and Python expressions (for Python programming language execution and implementation).



References

2018

  • (Horton & Parnin, 2018) ⇒ Eric Horton, and Chris Parnin. (2018). “Gistable: Evaluating the Executability of Python Code Snippets on GitHub.” arXiv preprint arXiv:1808.04919
    • ABSTRACT: Software developers create and share code online to demonstrate programming language concepts and programming tasks. Code snippets can be a useful way to explain and demonstrate a programming concept, but may not always be directly executable. A code snippet can contain parse errors, or fail to execute if the environment contains unmet dependencies.

      This paper presents an empirical analysis of the executable status of Python code snippets shared through the GitHub gist system, and the ability of developers familiar with software configuration to correctly configure and run them. We find that 75.6% of gists require non-trivial configuration to overcome missing dependencies, configuration files, reliance on a specific operating system, or some other environment configuration. Our study also suggests the natural assumption developers make about resource names when resolving configuration errors is correct less than half the time.

      We also present Gistable, a database and extensible framework built on GitHub's gist system, which provides executable code snippets to enable reproducible studies in software engineering. Gistable contains 10,259 code snippets, approximately 5,000 with a Dockerfile to configure and execute them without import error. Gistable is publicly available at this https URL