less_retarded_wiki

main page, file list (598), source, all in md+txt+html+pdf, commit RSS feed, report abuse, stats, random article, consoomer version

Python

What if pseudocode was actually code?

Python (name being a reference to Monty Python) is an exceptionally bloated, extremely popular high level interpreted programming language. Its priority is readability, popularity and making it easy and fast to bash together some code for anyone with at least half a brain hemisphere, so it is eminently popular among beginners, children, women, non-programmers such as scientists and unqualified soydevs who can't handle real languages like C. Python just werks and is comfortable, but any program written in it is forever doomed to be bloated, slow, ugly, big and will unavoidably die without maintenance, for Python's updates purposefully break backwards compatibility. At this moment it is the language most frequently used for programming "neural net AIs".

Python is extremely slow, even much slower than JavaScript and PHP (according to Computer Language Benchmarks Game). If you want to make your python programs faster, use the PyPy implementation over the default CPython.

Programming in python is not real programming. Making a program in Python versus writing a real program is like making a house in Minetest vs making a real house. Python was in fact made exactly for people who CANNOT program, such as women, economists and professional programmers, it is basically a wheelchair -- those who can program don't need Python just like those who can walk don't need a wheelchair.

Python was conceived in 1991 by a Dutchman Guido van Rossum who announced it on Usenet. Version 1.0 was released in 1994 and version 2.0 in 2000. A very important version was 2.7 released in 2010 -- this was used and supported for a long time but the support was ended in 2020 in favor of Python 3. As of writing this the latest version is 3.9.

Can we use python? There are certain use cases for it, mostly writing throwaway scripts and other quick, temporary code. Python can easily help you get into programming as well, so it may well serve as an educational language, however be sure to transition to a better language later on. Remember, python mustn't ever be used for a serious program.

The reference implementation, CPython, is at the same time the one in most widespread use; it is written in C and python itself. There also exist different implementations such as MicroPython (for embedded), PyPy (alternative implementation, often faster), Jython and so on.

What follows is a summary of the python language:

Example

Here is the divisor tree program implemented in Python3, it showcases most of the basic language features:

# recursive function, prints the divisor tree of a number
def printDivisorTree(x):
  a = -1
  b = -1

  for i in range(2,int(x / 2) + 1): # find closest divisors
    if x % i == 0:
      a = i
      b = int(x / i)

      if a >= b:
        break

  print("(",end="")

  if a > 1:
    printDivisorTree(a)
    print(" " + str(x) + " ",end="")
    printDivisorTree(b)
  else:
    print(x,end="")

  print(")",end="")

while True: # main loop, read numbers
  try:
    x = int(input("enter a number: "))
  except ValueError:
    break

  printDivisorTree(x)
  print("")

Powered by nothing. All content available under CC0 1.0 (public domain). Send comments and corrections to drummyfish at disroot dot org.