Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
####### # # E-scripts on Python. # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # An introduction to eev can be found here: # # (find-eev-quick-intro) # http://angg.twu.net/eev-intros/find-eev-quick-intro.html # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at <http://angg.twu.net/e/python.e> # or at <http://angg.twu.net/e/python.e.html>. # See also <http://angg.twu.net/emacs.html>, # <http://angg.twu.net/.emacs[.html]>, # <http://angg.twu.net/.zshrc[.html]>, # <http://angg.twu.net/escripts.html>, # and <http://angg.twu.net/>. # ####### # «.python-bullseye» (to "python-bullseye") # «.tut-numbers» (to "tut-numbers") # «.tut-strings» (to "tut-strings") # «.tut-lists» (to "tut-lists") # «.tut-firststeps» (to "tut-firststeps") # «.tut-controlflow» (to "tut-controlflow") # «.tut-break» (to "tut-break") # «.tut-datastructures» (to "tut-datastructures") # «.tut-modules» (to "tut-modules") # «.tut-inputoutput» (to "tut-inputoutput") # «.tut-errors» (to "tut-errors") # «.tut-classes» (to "tut-classes") # «.type» (to "type") # «.luatree» (to "luatree") # «.list» (to "list") # «.tuple» (to "tuple") # «.python-wheezy» (to "python-wheezy") # «.python3-wheezy» (to "python3-wheezy") # «.python-on-squeeze» (to "python-on-squeeze") # «.python-on-lenny» (to "python-on-lenny") # «.python-base» (to "python-base") # «.python-3.9.9» (to "python-3.9.9") # «.python-examples» (to "python-examples") # «.pyex» (to "pyex") # «.pydb» (to "pydb") # «.pdb» (to "pdb") # «.python-tk» (to "python-tk") # «.tk» (to "tk") # «.tkinter» (to "tkinter") # «.PYTHONSTARTUP» (to "PYTHONSTARTUP") # «.open» (to "open") # «.exec» (to "exec") # «.read» (to "read") # «.execfile» (to "execfile") # «.str.split» (to "str.split") # «.os.path.split» (to "os.path.split") # «.ee-for-python» (to "ee-for-python") # «.2to3» (to "2to3") # «.str.format» (to "str.format") # «.eechannel-python» (to "eechannel-python") # «.sigusr1» (to "sigusr1") # «.python-docutils» (to "python-docutils") # «.rst» (to "rst") # «.diveintopython» (to "diveintopython") # «.closures» (to "closures") # «.python-apt» (to "python-apt") # «.python-apt-deb-src» (to "python-apt-deb-src") # «.python-opengl» (to "python-opengl") # «.pymacs» (to "pymacs") # «.python-sphinx» (to "python-sphinx") # «.sphinx-build» (to "sphinx-build") # «.sphinx-git» (to "sphinx-git") # «.pygame» (to "pygame") # «.modules» (to "modules") # «.module.__file__» (to "module.__file__") # «.tostring» (to "tostring") # «.MyVector» (to "MyVector") # «.scipy» (to "scipy") # «.matplotlib» (to "matplotlib") # «.matplotlib-examples» (to "matplotlib-examples") # «.matplotlib-rougier» (to "matplotlib-rougier") # «.numpy» (to "numpy") # «.scipy-lectures» (to "scipy-lectures") # «.ipython» (to "ipython") # «.ameliabot» (to "ameliabot") # «.rends-tutorial» (to "rends-tutorial") # «.environment» (to "environment") # «.scikits» (to "scikits") # «.pyobjects» (to "pyobjects") # «.emacs-ipython-notebook» (to "emacs-ipython-notebook") # «.audio» (to "audio") # «.pprint» (to "pprint") # «.sympy» (to "sympy") # «.spyder» (to "spyder") # «.idle» (to "idle") # «.felipe-pinheiro» (to "felipe-pinheiro") # «.scipy-wav» (to "scipy-wav") # «.pip» (to "pip") # «.pip3-upgrade» (to "pip3-upgrade") # «.pip-as-root» (to "pip-as-root") # «.pip-from-git» (to "pip-from-git") # «.tox» (to "tox") # «.facebook-sdk» (to "facebook-sdk") # «.textwrap» (to "textwrap") # «.easyhtmlparser» (to "easyhtmlparser") # «.oilercode» (to "oilercode") # «.faceutils» (to "faceutils") # «.faceutils-wrap» (to "faceutils-wrap") # «.poetry» (to "poetry") # «.pypi» (to "pypi") # «.requests» (to "requests") # «.virtualenv» (to "virtualenv") # «.string.gsub.old» (to "string.gsub.old") # «.string.gsub» (to "string.gsub") # «.encoding» (to "encoding") # «.scope» (to "scope") # «.import» (to "import") # «.importlib» (to "importlib") # «.inspect» (to "inspect") # «.re» (to "re") # «.re.sub» (to "re.sub") # «.u8_to_l1» (to "u8_to_l1") # «.dict» (to "dict") # «.print» (to "print") # «.tuples» (to "tuples") # «.tut-tuples» (to "tut-tuples") # «.tut-def» (to "tut-def") # «.def» (to "def") # «.comprehension» (to "comprehension") # «.multiline-comments» (to "multiline-comments") # «.lambda» (to "lambda") # «.after» (to "after") # «.graphics.py» (to "graphics.py") # «.python-for-cs1» (to "python-for-cs1") # «.turtle» (to "turtle") # «.help» (to "help") # «.books» (to "books") # «.popen» (to "popen") # «.bytes» (to "bytes") # «.split» (to "split") # «.vararg-functions» (to "vararg-functions") # «.pandas» (to "pandas") # «.elpy» (to "elpy") # «.naufuto» (to "naufuto") # «.hy» (to "hy") # «.codespell» (to "codespell") # «.pygments» (to "pygments") # «.pygments-pip3» (to "pygments-pip3") # «.plot3D» (to "plot3D") # «.dictionaries» (to "dictionaries") # «.fsmunoz-k8s-diagrams» (to "fsmunoz-k8s-diagrams") # «.all-the-builtins» (to "all-the-builtins") # «.doctest» (to "doctest") # «.breakpoint» (to "breakpoint") # «.python-repl-in-eshell» (to "python-repl-in-eshell") # «.conda» (to "conda") # «.pep-503» (to "pep-503") # «.pexpect» (to "pexpect") # «.xonsh» (to "xonsh") # «.iterable» (to "iterable") # «.pillow» (to "pillow") # «.midi-synth» (to "midi-synth") # «.pip3-repl» (to "pip3-repl") # «.venv-2024may13» (to "venv-2024may13") # «.python-lsp-server» (to "python-lsp-server") # «.shiv» (to "shiv") # «.buscador-de-meteoritos» (to "buscador-de-meteoritos") # «.timestr» (to "timestr") # «.emacs_291_as_ide» (to "emacs_291_as_ide") # «.habamax» (to "habamax") # «.skybert» (to "skybert") # (defun u () (interactive) (find-escript-upload-links "python" "u8_to_l1")) # (to "u8_to_l1") # (find-zsh "installeddebs | sort | grep python") # (find-zsh "installeddebs | sort | grep python | awk -F _ '{print $1}'") ipython3 ipython libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libpython2.7 libpython3-stdlib libpython3.5-minimal libpython3.5-stdlib libpython3.5 python-central python-doc python-matplotlib-data python-matplotlib-doc python-matplotlib python-minimal python-sympy-doc python-sympy python-tk python2.7-doc python2.7-minimal python2.7 python3-apt python3-debian python3-doc python3-examples python3-matplotlib python3-minimal python3-tk python3.5-doc python3.5-examples python3.5-minimal python3.5 python3 python * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) apti python-matplotlib python-matplotlib-doc python3-matplotlib apti python-doc python3-doc apti python-examples python3-examples apti python-pip python3-pip pip install --upgrade pip pip3 install --upgrade pip ;; (find-fline "/usr/share/doc/python2.7/html/_sources/") (code-c-d "python27docsrc" "/usr/share/doc/python2.7/html/_sources/") ;; (find-python27docsrcfile "") ##### # # python-bullseye # 2021aug31 # ##### # «python-bullseye» (to ".python-bullseye") # (find-status "python3.9-doc") # (find-vldifile "python3.9-doc.list") # (find-udfile "python3.9-doc/") # (find-status "python3.9-examples") # (find-vldifile "python3.9-examples.list") # (find-udfile "python3.9-examples/") # (find-status "python3-tk") # (find-vldifile "python3-tk:amd64.list") # (find-udfile "python3-tk/") # file:///usr/share/doc/python3.9/html/index.html # file:///usr/share/doc/python3.9/html/library/index.html # file:///usr/share/doc/python3.9/html/library/inspect.html # file:///usr/share/doc/python3.9/html/tutorial/index.html # file:///usr/share/doc/python3.9/html/tutorial/modules.html # file:///usr/share/doc/python3.9/html/tutorial/classes.html * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rv /tmp/pyexamples/ mkdir /tmp/pyexamples/ cd /tmp/pyexamples/ cp -Rv /usr/share/doc/python3.9/examples/* /tmp/pyexamples/ # (find-fline "/tmp/pyexamples/") # (find-fline "/usr/share/doc/python3.9/examples/pynche/") # (find-sh "apt-file search python | grep tkinter") # (find-sh "apt-file search python | grep turtle") cd /usr/share/doc/python3.9/examples/pynche/ ./pynche # (find-fline "/usr/lib/python3.9/turtledemo/") # (find-fline "/usr/lib/python3.9/turtledemo/fractalcurves.py") cd /usr/lib/python3.9/turtledemo/ ./fractalcurves.py python3 -m tkinter # (find-pydoc "index") # (find-pydoc "tutorial/index") # (find-pydoc "tutorial/index") # (find-pydoc "tutorial/interpreter#interactive-mode") # (find-pydocr "tutorial/interpreter#interactive-mode") ##### # # tutorial/introduction: comments, calculator, numbers # 2022aug17 # ##### # «tut-numbers» (to ".tut-numbers") # (find-pydoc "tutorial/introduction") # (find-pydoc "tutorial/introduction#an-informal-introduction-to-python") # (find-pydocr "tutorial/introduction#an-informal-introduction-to-python") * (eepitch-python) * (eepitch-kill) * (eepitch-python) # this is the first comment spam = 1 # and this is the second comment # ... and now a third! text = "# This is not a comment because it's inside quotes." # (find-pydoc "tutorial/introduction#numbers") # (find-pydocr "tutorial/introduction#numbers") # (find-pydocw "tutorial/introduction#numbers") 2 + 2 50 - 5*6 (50 - 5*6) / 4 8 / 5 # division always returns a floating point number 17 / 3 # classic division returns a float 17 // 3 # floor division discards the fractional part 17 % 3 # the % operator returns the remainder of the division 5 * 3 + 2 # result * divisor + remainder 5 ** 2 # 5 squared 2 ** 7 # 2 to the power of 7 width = 20 height = 5 * 9 width * height n # try to access an undefined variable 4 * 3.75 - 1 tax = 12.5 / 100 price = 100.50 price * tax price + _ round(_, 2) ##### # # tut-strings # 2022aug17 # ##### # «tut-strings» (to ".tut-strings") # (find-pydoc "tutorial/introduction#strings") # (find-pydocr "tutorial/introduction#strings") * (eepitch-python) * (eepitch-kill) * (eepitch-python) 'spam eggs' # single quotes 'doesn\'t' # use \' to escape the single quote... "doesn't" # ...or use double quotes instead '"Yes," they said.' "\"Yes,\" they said." '"Isn\'t," they said.' '"Isn\'t," they said.' print('"Isn\'t," they said.') s = 'First line.\nSecond line.' # \n means newline s # without print(), \n is included in the output print(s) # with print(), \n produces a new line print('C:\some\name') # here \n means newline! print(r'C:\some\name') # note the r before the quote print("""\ Usage: thingy [OPTIONS] -h Display this usage message -H hostname Hostname to connect to """) 3 * 'un' + 'ium' # 3 times 'un', followed by 'ium' 'Py' 'thon' text = ('Put several strings within parentheses ' 'to have them joined together.') text prefix = 'Py' prefix 'thon' # can't concatenate a variable and a string literal ('un' * 3) 'ium' prefix + 'thon' word = 'Python' word[0] # character in position 0 word[5] # character in position 5 word[-1] # last character word[-2] # second-last character word[-6] word[0:2] # characters from position 0 (included) to 2 (excluded) word[2:5] # characters from position 2 (included) to 5 (excluded) word[:2] + word[2:] word[:4] + word[4:] word[:2] # character from the beginning to position 2 (excluded) word[4:] # characters from position 4 (included) to the end word[-2:] # characters from the second-last (included) to the end # +---+---+---+---+---+---+ # | P | y | t | h | o | n | # +---+---+---+---+---+---+ # 0 1 2 3 4 5 6 # -6 -5 -4 -3 -2 -1 word[42] # the word only has 6 characters word[4:42] word[42:] word[0] = 'J' # error: Python strings cannot be changed word[2:] = 'py' # same 'J' + word[1:] word[:2] + 'py' s = 'supercalifragilisticexpialidocious' len(s) ##### # # tut-lists # 2022aug17 # ##### # «tut-lists» (to ".tut-lists") # (to "list") # (find-pydoc "tutorial/introduction#lists") # (find-pydocr "tutorial/introduction#lists") # (find-pydocr "tutorial/introduction#lists" "_tut-lists:") * (eepitch-python) * (eepitch-kill) * (eepitch-python) squares = [1, 4, 9, 16, 25] squares squares[0] # indexing returns the item squares[-1] squares[-3:] # slicing returns a new list squares[:] squares + [36, 49, 64, 81, 100] cubes = [1, 8, 27, 65, 125] # something's wrong here 4 ** 3 # the cube of 4 is 64, not 65! cubes[3] = 64 # replace the wrong value cubes cubes.append(216) # add the cube of 6 cubes.append(7 ** 3) # and the cube of 7 cubes letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] letters letters[2:5] = ['C', 'D', 'E'] # replace some values letters letters[2:5] = [] # now remove them letters # clear the list by replacing all the elements with an empty list letters[:] = [] letters letters = ['a', 'b', 'c', 'd'] len(letters) a = ['a', 'b', 'c'] n = [1, 2, 3] x = [a, n] x x[0] x[0][1] ##### # # Tutorial: First Steps Towards Programming # 2022aug17 # ##### # «tut-firststeps» (to ".tut-firststeps") # (find-pydoc "tutorial/introduction#first-steps-towards-programming") # (find-pydocr "tutorial/introduction#first-steps-towards-programming") # (find-pydocr "tutorial/introduction" "_tut-firststeps:") # (find-pydocr "tutorial/introduction" "_tut-firststeps:" "space is inserted") # (find-pydocr "tutorial/introduction" "_tut-firststeps:" "keyword argument") * (eepitch-python) * (eepitch-kill) * (eepitch-python) # Fibonacci series: # the sum of two elements defines the next a, b = 0, 1 while a < 10: print(a) a, b = b, a+b i = 256*256 print('The value of i is', i) a, b = 0, 1 while a < 1000: print(a, end=',') a, b = b, a+b # (find-pydoc "library/functions#print") # (find-pydoc "tutorial/controlflow#defining-functions") # (find-pydoc "tutorial/controlflow#default-argument-values") # (find-pydoc "tutorial/controlflow#keyword-arguments") # (find-pydoc "reference/compound_stmts#function-definitions") # (find-pydoc "reference/compound_stmts#def") ##### # # Tutorial: 4. More Control Flow Tools # 2022aug17 # ##### # «tut-controlflow» (to ".tut-controlflow") # (find-pydoc "tutorial/controlflow") # (find-pydocr "tutorial/controlflow") # (find-pydocw "tutorial/controlflow") * (eepitch-python) * (eepitch-kill) * (eepitch-python) x = int(input("Please enter an integer: ")) 42 -3 if x < 0: x = 0 print('Negative changed to zero') elif x == 0: print('Zero') elif x == 1: print('Single') else: print('More') # Measure some strings: words = ['cat', 'window', 'defenestrate'] for w in words: print(w, len(w)) # Create a sample collection users = {'Hans': 'active', 'Éléonore': 'inactive', 'Other': 'active'} # Strategy: Iterate over a copy for user, status in users.copy().items(): if status == 'inactive': del users[user] # Strategy: Create a new collection active_users = {} for user, status in users.items(): if status == 'active': active_users[user] = status for i in range(5): print(i) range(5, 10) range(0, 10, 3) range(-10, -100, -30) a = ['Mary', 'had', 'a', 'little', 'lamb'] for i in range(len(a)): print(i, a[i]) print(range(10)) sum(range(4)) # 0 + 1 + 2 + 3 list(range(4)) ##### # # Tutorial: 4. More Control Flow Tools - break, etc # 2022aug17 # ##### # «tut-break» (to ".tut-break") # (find-pydoc "tutorial/controlflow#break-and-continue-statements-and-else-clauses-on-loops") # (find-pydocr "tutorial/controlflow" "_tut-break:") * (eepitch-python) * (eepitch-kill) * (eepitch-python) for n in range(2, 10): for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) break else: # loop fell through without finding a factor print(n, 'is a prime number') for num in range(2, 10): if num % 2 == 0: print("Found an even number", num) continue print("Found an odd number", num) # while True: # pass # Busy-wait for keyboard interrupt (Ctrl+C) class MyEmptyClass: pass def initlog(*args): pass # Remember to implement this! def fib(n): # write Fibonacci series up to n """Print a Fibonacci series up to n.""" a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print() # Now call the function we just defined: fib(2000) fib f = fib f(100) fib(0) print(fib(0)) def fib2(n): # return Fibonacci series up to n """Return a list containing the Fibonacci series up to n.""" result = [] a, b = 0, 1 while a < n: result.append(a) # see below a, b = b, a+b return result f100 = fib2(100) # call it f100 # write the result def ask_ok(prompt, retries=4, reminder='Please try again!'): while True: ok = input(prompt) if ok in ('y', 'ye', 'yes'): return True if ok in ('n', 'no', 'nop', 'nope'): return False retries = retries - 1 if retries < 0: raise ValueError('invalid user response') print(reminder) ask_ok('Do you really want to quit?') y ask_ok('OK to overwrite the file?', 2) foo bar plic ask_ok('OK to overwrite the file?', 2, 'Come on, only yes or no!') foo y i = 5 def f(arg=i): print(arg) i = 6 f() def f(a, L=[]): L.append(a) return L print(f(1)) print(f(2)) print(f(3)) # If you don't want the default to be shared between subsequent calls... def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'): print("-- This parrot wouldn't", action, end=' ') print("if you put", voltage, "volts through it.") print("-- Lovely plumage, the", type) print("-- It's", state, "!") parrot(1000) # 1 positional argument parrot(voltage=1000) # 1 keyword argument parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments parrot('a million', 'bereft of life', 'jump') # 3 positional arguments parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 keyword parrot() # required argument missing parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword argument parrot(110, voltage=220) # duplicate value for the same argument parrot(actor='John Cleese') # unknown keyword argument def function(a): pass function(0, a=0) # error: multiple values for keyword argument 'a' def cheeseshop(kind, *arguments, **keywords): print("-- Do you have any", kind, "?") print("-- I'm sorry, we're all out of", kind) for arg in arguments: print(arg) print("-" * 40) for kw in keywords: print(kw, ":", keywords[kw]) cheeseshop("Limburger", "It's very runny, sir.", "It's really very, VERY runny, sir.", shopkeeper="Michael Palin", client="John Cleese", sketch="Cheese Shop Sketch") ##### # # Tutorial: 5. Data Structures # 2022aug17 # ##### # «tut-datastructures» (to ".tut-datastructures") # (find-pydoc "tutorial/datastructures") # (find-pydocr "tutorial/datastructures") * (eepitch-python) * (eepitch-kill) * (eepitch-python) fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana'] fruits.count('apple') fruits.count('tangerine') fruits.index('banana') fruits.index('banana', 4) # Find next banana starting a position 4 fruits.reverse() fruits fruits.append('grape') fruits fruits.sort() fruits fruits.pop() stack = [3, 4, 5] stack.append(6) stack.append(7) stack stack.pop() stack stack.pop() stack.pop() stack from collections import deque queue = deque(["Eric", "John", "Michael"]) queue.append("Terry") # Terry arrives queue.append("Graham") # Graham arrives queue.popleft() # The first to arrive now leaves queue.popleft() # The second to arrive now leaves queue # Remaining queue in order of arrival squares = [] for x in range(10): squares.append(x**2) squares [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] combs = [] for x in [1,2,3]: for y in [3,1,4]: if x != y: combs.append((x, y)) combs vec = [-4, -2, 0, 2, 4] # create a new list with the values doubled [x*2 for x in vec] # filter the list to exclude negative numbers [x for x in vec if x >= 0] # apply a function to all the elements [abs(x) for x in vec] # call a method on each element freshfruit = [' banana', ' loganberry ', 'passion fruit '] [weapon.strip() for weapon in freshfruit] # create a list of 2-tuples like (number, square) [(x, x**2) for x in range(6)] [ x, x**2 for x in range(6)] # error: the tuple must be parenthesized # flatten a list using a listcomp with two 'for' vec = [[1,2,3], [4,5,6], [7,8,9]] [num for elem in vec for num in elem] from math import pi [str(round(pi, i)) for i in range(1, 6)] matrix = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], ] [[row[i] for row in matrix] for i in range(4)] transposed = [] for i in range(4): transposed.append([row[i] for row in matrix]) transposed transposed = [] for i in range(4): # the following 3 lines implement the nested listcomp transposed_row = [] for row in matrix: transposed_row.append(row[i]) transposed.append(transposed_row) transposed list(zip(*matrix)) a = [-1, 1, 66.25, 333, 333, 1234.5] del a[0] a del a[2:4] a del a[:] a del a a t = 12345, 54321, 'hello!' t[0] t # Tuples may be nested: u = t, (1, 2, 3, 4, 5) u # Tuples are immutable: t[0] = 88888 # but they can contain mutable objects: v = ([1, 2, 3], [3, 2, 1]) v empty = () singleton = 'hello', # <-- note trailing comma len(empty) len(singleton) singleton x, y, z = t ##### # # Tutorial: 6. Modules # 2022aug17 # ##### # «tut-modules» (to ".tut-modules") # (find-pydoc "tutorial/modules") # (find-pydocr "tutorial/modules") # (find-pydoc "tutorial/modules#the-module-search-path") # (find-downeytppage (+ 22 32) "import statement:") # (find-downeytptext (+ 22 32) "import statement:") # (find-downeytppage (+ 22 32) "module object:") # (find-downeytptext (+ 22 32) "module object:") # (find-pydoc "library/sys#sys.path") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import sys sys.path type(sys.path) # Untested. def fib(n): # write Fibonacci series up to n a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print() def fib2(n): # return Fibonacci series up to n result = [] a, b = 0, 1 while a < n: result.append(a) a, b = b, a+b return result import fibo fibo.fib(1000) fibo.fib2(100) fibo.__name__ fib = fibo.fib fib(500) from fibo import fib, fib2 fib(500) from fibo import * fib(500) import fibo as fib fib.fib(500) from fibo import fib as fibonacci fibonacci(500) if __name__ == "__main__": import sys fib(int(sys.argv[1])) import sys sys.ps1 sys.ps2 sys.ps1 = 'C> ' import sys sys.path.append('/ufs/guido/lib/python') import fibo, sys dir(fibo) dir(sys) # doctest: +NORMALIZE_WHITESPACE a = [1, 2, 3, 4, 5] import fibo fib = fibo.fib dir() import builtins dir(builtins) # doctest: +NORMALIZE_WHITESPACE __all__ = ["echo", "surround", "reverse"] import sound.effects.echo import sound.effects.surround from sound.effects import * from . import echo from .. import formats from ..filters import equalizer ##### # # Tutorial: 7. Input and Output # 2022aug17 # ##### # «tut-inputoutput» (to ".tut-inputoutput") # (find-pydoc "tutorial/inputoutput") # (find-pydocr "tutorial/inputoutput") ##### # # Tutorial: 8. Errors and Exceptions # 2022aug17 # ##### # «tut-errors» (to ".tut-errors") # (find-pydoc "tutorial/errors") # (find-pydocr "tutorial/errors") ##### # # Tutorial: 9. Classes # 2022aug17 # ##### # «tut-classes» (to ".tut-classes") # (to "MyVector") # (find-pydoc "tutorial/classes") # (find-pydocr "tutorial/classes") # (find-pydoc "reference/simple_stmts#global") * (eepitch-python) * (eepitch-kill) * (eepitch-python) def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spam = "nonlocal spam" def do_global(): global spam spam = "global spam" spam = "test spam" do_local() print("After local assignment:", spam) do_nonlocal() print("After nonlocal assignment:", spam) do_global() print("After global assignment:", spam) scope_test() print("In global scope:", spam) class MyClass: """A simple example class""" i = 12345 def f(self): return 'hello world' x = MyClass() def __init__(self): self.data = [] x = MyClass() class Complex: def __init__(self, realpart, imagpart): self.r = realpart self.i = imagpart x = Complex(3.0, -4.5) x.r, x.i x.counter = 1 while x.counter < 10: x.counter = x.counter * 2 print(x.counter) del x.counter class Dog: kind = 'canine' # class variable shared by all instances def __init__(self, name): self.name = name # instance variable unique to each instance d = Dog('Fido') e = Dog('Buddy') d.kind # shared by all dogs e.kind # shared by all dogs d.name # unique to d e.name # unique to e class Dog: tricks = [] # mistaken use of a class variable def __init__(self, name): self.name = name def add_trick(self, trick): self.tricks.append(trick) d = Dog('Fido') e = Dog('Buddy') d.add_trick('roll over') e.add_trick('play dead') d.tricks # unexpectedly shared by all dogs class Dog: def __init__(self, name): self.name = name self.tricks = [] # creates a new empty list for each dog def add_trick(self, trick): self.tricks.append(trick) d = Dog('Fido') e = Dog('Buddy') d.add_trick('roll over') e.add_trick('play dead') d.tricks e.tricks class Warehouse: purpose = 'storage' region = 'west' w1 = Warehouse() print(w1.purpose, w1.region) w2 = Warehouse() w2.region = 'east' print(w2.purpose, w2.region) # Function defined outside the class def f1(self, x, y): return min(x, x+y) class C: f = f1 def g(self): return 'hello world' h = g class Bag: def __init__(self): self.data = [] def add(self, x): self.data.append(x) def addtwice(self, x): self.add(x) self.add(x) class Mapping: def __init__(self, iterable): self.items_list = [] self.__update(iterable) def update(self, iterable): for item in iterable: self.items_list.append(item) __update = update # private copy of original update() method class MappingSubclass(Mapping): def update(self, keys, values): # provides new signature for update() # but does not break __init__() for item in zip(keys, values): self.items_list.append(item) class Employee: pass john = Employee() # Create an empty employee record # Fill the fields of the record john.name = 'John Doe' john.dept = 'computer lab' john.salary = 1000 for element in [1, 2, 3]: print(element) for element in (1, 2, 3): print(element) for key in {'one':1, 'two':2}: print(key) for char in "123": print(char) for line in open("myfile.txt"): print(line, end='') s = 'abc' it = iter(s) it next(it) next(it) next(it) next(it) class Reverse: """Iterator for looping over a sequence backwards.""" def __init__(self, data): self.data = data self.index = len(data) def __iter__(self): return self def __next__(self): if self.index == 0: raise StopIteration self.index = self.index - 1 return self.data[self.index] rev = Reverse('spam') iter(rev) for char in rev: print(char) def reverse(data): for index in range(len(data)-1, -1, -1): yield data[index] for char in reverse('golf'): print(char) sum(i*i for i in range(10)) # sum of squares xvec = [10, 20, 30] yvec = [7, 5, 3] sum(x*y for x,y in zip(xvec, yvec)) # dot product unique_words = set(word for line in page for word in line.split()) valedictorian = max((student.gpa, student.name) for student in graduates) data = 'golf' list(data[i] for i in range(len(data)-1, -1, -1)) ##### # # type # 2022aug22 # ##### # «type» (to ".type") # (find-es "sympy" "func-and-args") # (find-pydoc "library/types") # (find-pydocr "library/types") # (find-pydoc "library/functions#type") # (find-pydoc "library/functions#isinstance") # (find-pydoc "library/stdtypes#bltin-type-objects") # (find-pydoc "reference/datamodel#types") # (find-pydocrgrep "grep --color=auto -nRH --null -e __name__ *") * (eepitch-python) * (eepitch-kill) * (eepitch-python) 55 type(55) type(type(55)) print(55, type(55), type(type(55))) type(55).__name__ isinstance(55, int) isinstance("55", int) isinstance("55", str) type("55") ##### # # luatree # 2022aug22 # ##### # «luatree» (to ".luatree") # (find-anggfile "luatree/luatree.py") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import sys sys.path[1:1] = ["/home/edrx/luatree"] from luatree import * s = '{[0]="[", {[0]="/", "x", "y"}, "33"}' s print(luatree_lua(s)) s = '{[0]="[", {[0]="/", "x", "y"}, "33"}' s print(luatree_lua(s)) print(luatree_dir) sys.path ##### # # list # 2022aug22 # ##### # «list» (to ".list") # (to "tut-lists") # (find-pydoc "tutorial/introduction#lists") # (find-pydoc "library/stdtypes#list") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import sys sys.path type(sys.path) luatree_dir = "~/luatree" luatree_dir = "/home/edrx/luatree" sys.path[1:1] = [luatree_dir] sys.path import luatree luatree ##### # # tuple # 2022aug23 # ##### # «tuple» (to ".tuple") # (find-pydoc "library/stdtypes#tuple") ##### # # python on wheezy # 2014sep08 # ##### # «python-wheezy» (to ".python-wheezy") # (find-zsh "availabledebs | sort | grep python") # (find-zsh "availabledebs | sort | grep python | egrep 'dev|doc'") # (find-zsh "installeddebs | sort | grep python") # (find-status "python-dev") # (find-vldifile "python-dev.list") # (find-udfile "python-dev/") # (find-status "python-doc") # (find-vldifile "python-doc.list") # (find-udfile "python-doc/") # (find-status "python-examples") # (find-vldifile "python-examples.list") # (find-udfile "python-examples/") # (find-status "python2.7-dev") # (find-vldifile "python2.7-dev.list") # (find-udfile "python2.7-dev/") # (find-status "python2.7-doc") # (find-vldifile "python2.7-doc.list") # (find-vldifile "python2.7-doc.list" "/usr/share/info/") # (find-udfile "python2.7-doc/") # file:///usr/share/doc/python2.7/html/c-api/tuple.html # file:///usr/share/doc/python2.7/html/library/ # file:///usr/share/doc/python2.7/html/library/stdtypes.html#bltin-file-objects # file:///usr/share/doc/python2.7/html/library/functions.html#open # «python3-wheezy» (to ".python3-wheezy") # (find-status "python3") # (find-vldifile "python3.list") # (find-udfile "python3/") # (find-status "python3.5") # (find-vldifile "python3.5.list") # (find-udfile "python3.5/") # (find-status "python3.7-doc") # (find-vldifile "python3.7-doc.list") # (find-udfile "python3.7-doc/") # (find-status "python3.7-examples") # (find-vldifile "python3.7-examples.list") # (find-udfile "python3.7-examples/") # file:///usr/share/doc/python3.5/html/index.html # (find-status "python3-examples") # (find-vldifile "python3-examples.list") # (find-udfile "python3-examples/") # (find-status "python3.5-examples") # (find-vldifile "python3.5-examples.list") # (find-udfile "python3.5-examples/") ##### # # python on squeeze # 2012mar30 # ##### # «python-on-squeeze» (to ".python-on-squeeze") # (find-zsh "availabledebs | sort | grep python") # (find-zsh "availabledebs | sort | grep python | egrep 'dev|doc'") # (find-zsh "dmissing python | grep -e .info") ##### # # python on lenny # 2010mar09 # ##### # «python-on-lenny» (to ".python-on-lenny") # (find-angg ".emacs" "python") # (find-zsh "availabledebs | sort | grep python") # (find-zsh "availabledebs | sort | grep python | egrep 'dev|doc'") # (find-zsh "dmissing python | grep -e .info") apti python python-doc python-examples python-mode python-dev apti python python-doc python-examples python-dev apti python2.5-doc # (find-status "python-dev") # (find-vldifile "python-dev.list") # (find-udfile "python-dev/") # (find-status "python-doc") # (find-vldifile "python-doc.list") # (find-udfile "python-doc/") # (find-status "python-examples") # (find-vldifile "python-examples.list") # (find-udfile "python-examples/") # (find-status "python2.6-dev") # (find-vldifile "python2.6-dev.list") # (find-udfile "python2.6-dev/") # (find-status "python2.6-doc") # (find-vldifile "python2.6-doc.list") # (find-vldifile "python2.6-doc.list" "/usr/share/info/") # (find-udfile "python2.6-doc/") # (find-vldifile "python2.5-doc.list") # (find-vldifile "python2.5-doc.list" "/usr/share/info/") # (find-udfile "python2.5-doc/") # (find-udfile "python2.6/html/_sources/faq/") # (find-udfile "python2.6/html/_sources/faq/design.txt") # (find-udfile "python2.6/html/_sources/tutorial/") # (find-status "python2.6-examples") # (find-vldifile "python2.6-examples.list") # (find-udfile "python2.6-examples/") ##### # # Installing and finding the basic docs # 2000may09 # ##### Pgrepp m/python/i |& tee ~/o # (find-fline "~/o") apti python-base python-doc python-examples python-elisp python-dev \ pydb python-pygresql # (find-vldifile "python-base.list") # (find-vldifile "python-dev.list") # (find-vldifile "python-doc.list") # (find-vldifile "python-elisp.list") # (find-vldifile "python-examples.list") # (find-fline "/usr/doc/python-base/") # (find-fline "/usr/doc/python-dev/") # (find-fline "/usr/doc/python-doc/") # (find-fline "/usr/doc/python-elisp/") # (find-fline "/usr/doc/python-examples/") # (find-node "(python-tut)Top") # (find-node "(python-tut)Numbers") # (find-node "(python-lib)Top") # (find-node "(python-ref)Top") # (find-pytutnode "Top") # (find-pytutnode "Defining Clean-up Actions") # (find-pytutnode "A Word About Terminology" "if a function modifies") # (find-pytutnode "Python Scopes and Name Spaces" "three nested") # (find-pytutnode "Method Objects") # (find-pytutnode "Defining Functions") # (find-angg "EXPECT/eeg") * (eepitch-python) * (eepitch-kill) * (eepitch-python) class foo: x = 2 def f(_, x): return x*20 foo a = foo() a a.x a.f a.f(a.x) ##### # # python-base # 2000may25 # ##### # «python-base» (to ".python-base") # (find-status "python-base") # (find-vldifile "python-base.list") # (find-eeman "1 python") # (find-fline "/usr/doc/python-base/") # (find-fline "/usr/doc/python/") # (find-fline "/usr/doc/python/NEWS.gz") # (find-fline "/usr/doc/python/HISTORY.gz") # (find-fline "/usr/doc/python/BLURB") # (find-fline "/usr/doc/python/sample.postinst") # (find-fline "/usr/doc/python/sample.prerm") # (find-fline "/usr/doc/python/README.maintainers") # (find-fline "/usr/doc/python/README.dbm") # (find-fline "/usr/doc/python/TODO.Debian.gz") # (find-fline "/usr/doc/python/copyright") # (find-fline "/usr/doc/python/README.gz") # (find-fline "/usr/doc/python/ACKS.gz") # (find-fline "/usr/doc/python/README.Debian.gz") laf /usr/bin/python laf /usr/bin/python1.5 # (find-pylibfile "lib-dynload/") laf /usr/lib/libpython1.5.so.0.0 # (find-fline "/usr/lib/menu/python-base") # (find-fline "/usr/lib/python1.4/") ##### # # python and postgresql # 2000may12 # ##### # (find-status "python-pygresql") # (find-vldifile "python-pygresql.list") # (find-fline "/usr/doc/python-pygresql/") # (find-fline "/usr/doc/python-pygresql/README.gz" "connect -") # (find-fline "/usr/doc/python-pygresql/tutorial/") # (find-pylibfile "site-packages/pg.py") # (find-pylibfile "site-packages/pgsqldb.py") # (find-vldifile "postgresql.list") # (find-fline "/usr/doc/postgresql/") # (find-vldifile "postgresql-client.list") # (find-fline "/usr/doc/postgresql-client/") # (find-fline "/var/lib/postgres/") (w3-open-local "/snarf/http/www.idi.ntnu.no/~mlh/python/instant.html") (find-fline "$S/http/www.python.org/doc/essays/metaclasses/meta-vladimir.txt") (find-file "/snarf/http/www.idi.ntnu.no/~mlh/python/quicksort.py") (find-fline "$S/http/www.strout.net/python/pattern.py") (find-fline "$S/http/www.strout.net/python/tabfix.py") # (find-w3 "/usr/doc/python/examples/Demo/metaclasses/index.html") # (find-fline "/usr/lib/python1.5/cgi.py") # (find-node "(python-ref)import statement") # (find-pyrefnode "import statement") # (find-pyrefnode "Module Index") # (find-pyrefnode "standard type hierarchy") # (find-pyrefnode "Objects") # (find-pytutnode "A First Look at Classes") # (find-pytutnode "Python Scopes and Name Spaces") # (find-pyrefnode "Keywords") # (find-pyrefnode "standard type hierarchy" "`Classes'") #* cat > $EEG <<'---' * (eepitch-python) * (eepitch-kill) * (eepitch-python) class A: attr1 = "Hello" # an attribute of A def method1(self, *args): pass # method1 of A def method2(self, *args): pass # method2 of A A # What is A? a = A() # 'a' is the 1st instance of A a # What is 'a'? b = A() # 'b' is another instance of A b # What is 'b'? a == b # Is 'a' the same object as 'b'? a.__class__ # What is the class of 'a'? b.__class__ # What is the class of 'b'? a.__class__ == b.__class__ # Is it really the same class A? class B(A): # B inherits A's properties attr2 = "World" # additional attr2 def method2(self, arg1): pass # method2 is redefined def method3(self, *args): pass # additional method3 B # What is B? B == A # Is B the same class as A? A.__bases__ # Does A have any superclasses? B.__bases__ # Does B have any superclasses? B.__bases__[0] == A # Is it really the class A? * (eepitch-python) * (eepitch-kill) * (eepitch-python) import sys sys.__dict__ type(sys.__dict__) type(sys) type(type) `sys.__dict__` type(`sys.__dict__`) s = lambda n: n + 1 s(2) s type(s) `s` # (find-pyrefnode "Basic customization") # (find-pyrefnode "Code blocks") # (find-pyrefnode "Dictionary displays") # (find-pyrefnode "String conversions") # (find-pyrefnode "Boolean operations" "lambda x") # (find-pyrefnode "Summary") # (find-pyrefnode "Assignment statements" "target list") # (find-pyrefnode "exec statement") # (find-pyrefnode "Function definitions") # (find-pyrefnode "Class definitions") # (find-pylibnode "More String Operations") #* cat > $EEG <<'---' vars() import sys vars() "foo %d %d" % (2, 3) "foo %s %d" % (2, 3) "foo %s %d" % ("2", "3") "foo %(a)d %(b)d" % {"b":2, "a":3} --- eeg python #* ##### # # python-3.9.9 # 2022mar22 # ##### # «python-3.9.9» (to ".python-3.9.9") # https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # (find-fline "~/bigsrc/Python-3.9.9/") rm -Rv ~/bigsrc/Python-3.9.9/ mkdir ~/bigsrc/Python-3.9.9/ tar -C ~/bigsrc/ -xvzf $S/https/www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz cd ~/bigsrc/Python-3.9.9/ # (code-c-d "python399" "~/bigsrc/Python-3.9.9/") # (find-python399file "") # (find-python399sh "find * | sort") # (find-python399file "Doc/library/inspect.rst") # (find-python399file "Doc/library/inspect.rst" "function:: isawaitable") # (find-python399file "Doc/library/inspect.rst" "def gen():") # file:///usr/share/doc/python3.9/html/library/inspect.html # file:///usr/share/doc/python3.9/html/library/inspect.html#inspect.isawaitable ##### # # python-examples # 2000may25 # ##### # «python-examples» (to ".python-examples") # «pyex» (to ".pyex") # (find-status "python-examples") # (find-vldifile "python-examples.list") # (find-pylibnode "regex") # (find-pylibnode "re") # (find-pylibnode "Matching vs. Searching") # (find-pyrefnode "Miscellaneous Index") #* cat > $EEG <<'---' import re d = re.__dict__ d.keys d.keys() d.__methods__ re.__name__ re.__file__ re.__builtins__.keys() [].__methods__ --- eeg python #* cat > $EEG <<'---' [].__methods__ import re,string string.join(["a", "b"]) string.join(["a", "b", "c"], "--") --- eeg python #* cat > $EEG <<'---' [].__methods__ import re, string string.join(["a", "b"]) string.join(["a", "b", "c"], "--") string.__dict__.keys() dir(string) join string.__dict__.keys().sort.__doc__ --- eeg python #* #* cat > $EEG <<'---' a = [2, 4, 1, 3] a.sort() a d = {1:2, 5:6, 3:4} d --- eeg python #* a.join # (find-pytutnode "for Statements") # (find-pytutnode "dir Function") # (find-pylibnode "Mutable Sequence Types") cd /usr/share/info/ zcat python-ref.info{,-?}.gz > /tmp/python-ref zcat python-lib.info{,-?,-??}.gz > /tmp/python-lib zcat python-tut.info{,-?}.gz > /tmp/python-tut # (find-status "htmlgen") # (find-vldifile "htmlgen.list") # (find-fline "/usr/doc/htmlgen/") # (find-status "idle") # (find-vldifile "idle.list") # (find-fline "/usr/doc/idle/") # (find-status "python-bobo") # (find-vldifile "python-bobo.list") # (find-fline "/usr/doc/python-bobo/") # (find-status "python-bobodtml") # (find-vldifile "python-bobodtml.list") # (find-fline "/usr/doc/python-bobodtml/") python-bobo apti python-bobodtml ##### # # dpkg-python # 2000aug02 # ##### pdsc $SDEBIAN/dists/woody/main/source/devel/dpkg-scriptlib_0.1-3.1.dsc cd /usr/src/dpkg-scriptlib-0.1/ # (find-status "dpkg-python") # (find-vldifile "dpkg-python.list") # (find-fline "/usr/doc/dpkg-python/") # (code-c-d "dsl" "/usr/src/dpkg-scriptlib-0.1/") # (find-dslfile "") # (find-dslfile "perl5/Dpkg/Archive/") # (find-dslfile "perl5/Dpkg/Package/") # (find-dslfile "python/dpkg/") # (find-fline "/usr/lib/site-python/dpkg/") #* cat > $EEG <<'---' import sys; sys.path.append("/usr/lib/site-python/dpkg") from dpkg_packages import * parse_package_name("kernel-image-2.2.15_angg.00jun13.deb") --- eeg python #* echo 'import foo' \ | strace-to ~/s python # (find-pytutnode "Invoking the Interpreter") python -c ' import sys; sys.path.append("/usr/lib/site-python/dpkg") from dpkg_packages import * print parse_package_name("kernel-image-2.2.15_angg.00jun13.deb") ' ##### # # classes # 2000aug02 # ##### # (find-pytutnode "Class Definition Syntax") # (find-pytutnode "Class Objects") # (find-pytutnode "Instance Objects") # (find-pyrefnode "del statement") # (find-pytutnode "Method Objects") # (find-pytutnode "Random Remarks") # (find-pytutnode "Inheritance") # (find-pytutnode "Multiple Inheritance") # (find-pytutnode "Dictionaries") # (find-pyrefnode "Special method names") # (find-pyrefnode "Emulating sequence and mapping types") # (find-pyrefnode "Code blocks" "\"namespace\"") # (find-shttpw3 "www.idi.ntnu.no/~mlh/python/instant.html" "__init__") #* cat > $EEG <<'---' import sys class DictFirst: # dict = {} # Wrong: makes every instance share the same dict! def __init__(self): # This is the corrected version. self.dict = {} def feed(self, k, v): # print self; print self.dict; print k; print v if self.dict.has_key(k): print "Repeated key %s, old val %s" % (k, self.dict[k]) else: self.dict[k] = v d = DictFirst() d.feed(2,3) d.dict d.feed(4,5) d.dict d.feed(2,10) d.dict d2 = DictFirst() d2.feed("a", "b") d2.dict d.dict # d and d2 are sharing the same dict! d.a = 20 # However new "fields" like a here are not shared: d.a # this is ok d2.a # but this gives an error. d d2 d.__dict__ d2.__dict__ d.__class__ d2.__class__ pr1 = lambda x: print "pr1 %s" % x # error: print is a statement (?) d.f = pr1 d.pr1(12) d2.pr1(12) --- eeg python #* ##### # # regexps in Python (module re) # 2000aug06 # ##### # (find-pylibnode "re") # (find-pylibnode "Contents of Module re") # (find-pylibnode "Regular Expression Objects") # (find-pylibnode "Match Objects") # (find-pylibnode "Regular Expression Syntax" "?P<id>") # (find-pyrefnode "String literals") # (find-angg ".zshrc" "debbasename") # (find-pyrefnode "Exceptions") # (find-pyrefnode "try statement") # (find-fline "~/PYTHON/debs.py") #* lynx http://www.python.org/doc/howto/ #* cd ~/PYTHON/ echo 'from debs import *' > $EEG eeg python #* ##### # # python source # 2000aug08 # ##### pdsc $SDEBIAN/dists/potato/main/source/interpreters/python_1.5.2-10.dsc cd /usr/src/python-1.5.2/ # find * | grep '\.[ch]$' find Include Modules Objects Parser Python | grep '\.[ch]$' > .files.ch etags $(<.files.ch) glimpseindex -H . -y $(<.files.ch) # (code-c-d "pysrc" "/usr/src/python-1.5.2/") # (find-pysrcfile "") # (find-pysrcfile "Python/") # (find-pysrcfile "Python/bltinmodule.c") # (find-pysrctag "execfile_doc") # (find-pysrctag "eval_doc") # (find-pysrctag "intern_doc") ##### # # compiling # 2000aug21 # ##### # «compiling» # (find-pylibfile "compileall.py") # (find-pylibfile "py_compile.py") # (find-vldifile "" " python") ##### # # running interactively # 2004aug07 # ##### #* # (find-pytutnode "Interactive Startup File") # (find-pyrefnode "global statement" "execfile()") # (find-man "1 python") # (find-man "1 python" " PYTHONSTARTUP") cd /usr/share/doc/python/examples/Demo/tkinter/guido/ cat > $EEG <<'---' import os execfile("hanoi.py") --- eeg python #* cat > /tmp/test.py <<'---' print "Hello from tmp!\n" --- python /tmp/test.py cd /tmp cat > $EEG <<'---' import test import test --- eeg python #* ##### # # pdb # 2004aug06 # ##### # «pdb» (to ".pdb") # http://page.sourceforge.net/tricks.html # (find-efile "progmodes/python.el" "M-x pdb") #* # (eev-bounded) # This block works - both "python /tmp/fib.py" and ".../pdb.py /tmp/fib.py". cat > /tmp/fib.py <<'%%%' def fib(n): # write Fibonacci series up to n "Print a Fibonacci series up to n" a, b = 0, 1 while b < n: print b, a, b = b, a+b # Now call the function we just defined: fib(2000) %%% python /tmp/fib.py /usr/lib/python2.1/pdb.py /tmp/fib.py #* # But the pdb invocation does NOT work: # (require 'gud) # (setq gud-pdb-command-name "/usr/lib/python2.1/pdb.py") # (pdb "/usr/lib/python2.1/pdb.py /tmp/fib.py") #* # «pydb» (to ".pydb") # # (find-status "pydb") # (find-vldifile "pydb.list") # (find-fline "/usr/doc/pydb/") /usr/bin/pydb /tmp/fib.py #* # Running pdb with pydb still doesn't show the source lines, but at # least it shows the prompt and accepts the "h" command". # (require 'gud) # (setq gud-pdb-command-name "/usr/bin/pydb") # (pdb "/usr/bin/pydb /tmp/fib.py") ##### # # python-tk # 2004aug07 # ##### # «python-tk» (to ".python-tk") # (find-es "tcl" "blt") # (find-status "python-tk") # (find-status "python-tk" "Also known as Tkinter") # (find-vldifile "python-tk.list") # (find-udfile "python-tk/") # The following additional packages will be installed: # blt tk8.6-blt2.5 # Suggested packages: # blt-demo tix python-tk-dbg #* # (find-pyexdfile "tkinter/guido/hanoi.py") cd /usr/share/doc/python2.1/examples/Demo/tkinter/guido/ python hanoi.py #* ##### # # tk # 2019jul17 # ##### # «tk» (to ".tk") # file:///usr/share/doc/python2.7/html/library/tk.html # file:///usr/share/doc/python3.5/html/library/tk.html # file:///usr/share/doc/python2.7/html/library/index.html # file:///usr/share/doc/python3.5/html/library/index.html ##### # # TkInter # 2013jan10 # ##### # «tkinter» (to ".tkinter") # file:///usr/share/doc/python2.7/html/library/tkinter.html # file:///usr/share/doc/python3.5/html/library/tkinter.html # https://www.manning.com/books/python-and-tkinter-programming # (find-zsh "apt-file search tkinter") # (find-fline "/usr/share/doc/python2.7/examples/Demo/tkinter/guido/") # (find-zsh "dmissing -i tkinter") # (find-fline "/usr/share/doc/python2.6/examples/Demo/tkinter/") # (code-c-d "tkinterex" "/usr/share/doc/python2.6/examples/Demo/tkinter/") # (code-c-d "tkinterexg" "/usr/share/doc/python2.6/examples/Demo/tkinter/guido/") # (find-tkinterexfile "") # (find-tkinterexgfile "") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd /usr/share/doc/python2.6/examples/Demo/tkinter/guido/ python hanoi.py python ShellWindow.py python brownian.py python brownian2.py python canvasevents.py python dialog.py python electrons.py python hanoi.py python hello.py python imagedraw.py python imageview.py python kill.py python listtree.py python mbox.py python newmenubardemo.py python optionmenu.py python paint.py python rmt.py python solitaire.py python sortvisu.py python ss1.py python svkill.py python switch.py python tkman.py python wish.py <Tau> edrx and pack this one with button2.pack(side='left') <Tau> edrx then after that <Tau> edrx call button1.destroy() <Tau> then button2.destroy() <Tau> edrx and see what happens when you pack button1 with side='top' <Tau> and button2 with side='top' too <Tau> edrx tell me when you have done * (eepitch-python) * (eepitch-kill) * (eepitch-python) import os os.environ["PAGER"] = "cat" from Tkinter import * root = Tk() button1 = Button(master=root) button1.pack() help(button1.pack) # http://effbot.org/tkinterbook/tkinter-hello-tkinter.htm * (eepitch-python) * (eepitch-kill) * (eepitch-python) import os os.environ["PAGER"] = "cat" from Tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() root.mainloop() # (find-status "python") # (find-vldifile "python.list") # (find-fline "/usr/doc/python/") # (find-status "python2.1") # (find-vldifile "python2.1.list") # (find-fline "/usr/doc/python2.1/") # (find-fline "/usr/lib/python2.1/") # (find-fline "/usr/lib/python2.1/pdb.py") # (find-fline "/usr/lib/python2.1/pdb.doc") apti python2.1-doc # (find-status "python2.1-doc") # (find-vldifile "python2.1-doc.list") # (find-fline "/usr/doc/python2.1-doc/") # (find-progoutput "dpkg --get-selections") # (find-status "python2.1") # (find-vldifile "python2.1.list") # (find-fline "/usr/doc/python2.1/") (find-pytutnode "") (find-pylibnode "") (find-pyrefnode "") (find-pyapinode "") (find-pydistnode "") (find-pyextnode "") (find-pytutnode "break and continue Statements") # (find-status "python2.1-examples") # (find-vldifile "python2.1-examples.list") # (find-fline "/usr/doc/python2.1-examples/") # (find-pyexdfile "") # (find-pyexdfile "scripts/") # (find-status "python2.1-elisp") # (find-vldifile "python2.1-elisp.list") # (find-fline "/usr/doc/python2.1-elisp/") #* python =(<<'%%%' print 2+3 %%%) #* #* # By kov function pyrename () { python =(<<'%%%' import os l = os.listdir ('.') for arquivo in l: os.rename (arquivo, arquivo.replace (' ', '_')) %%%) $* } rm -Rv /tmp/pyr mkdir /tmp/pyr cd /tmp/pyr echo 1 > 'um um um' echo 2 > 'dois dois dois' pyrename 'um um um' 'dois dois dois' #* ##### # # PYTHONSTARTUP # 2013jun26 # ##### # «PYTHONSTARTUP» (to ".PYTHONSTARTUP") # (find-angg ".zshrc" "python") # (find-man "1 python") # (find-man "1 python3") # (find-man "1 python3" " PYTHONSTARTUP") # (find-man "1 python" "~/.pythonrc.py") # (find-man "1 python" " PYTHONSTARTUP") # (find-man "1 python" " PYTHONPATH") # (find-eevrc ".pythonrc.py") # (find-angg ".pythonrc.py") # (find-sh "locate python | grep user") # (find-fline "/usr/lib/python2.7/user.py") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) PYTHONSTARTUP=$HOME/.pythonrc.py python # (find-angg ".pythonrc.py") ##### # # open # 2019aug03 # ##### # «open» (to ".open") # file:///usr/share/doc/python2.7/html/library/functions.html#open # file:///usr/share/doc/python3.5/html/library/functions.html#open # file:///usr/share/doc/python2.7/html/library/os.html#os.write # file:///usr/share/doc/python3.5/html/library/os.html#os.write # (find-downeytppage (+ 22 165) "14. Files.") # (find-downeytptext (+ 22 165) "Files") # (find-downeytppage (+ 22 166) "To write a file") # (find-downeytptext (+ 22 166) "To write a file") # (find-multiwindow-intro "5. Restarting eepitch targets") # (find-multiwindow-intro "5. Restarting eepitch targets" "open") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) date | tee /tmp/o * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) readfile("/tmp/o") writefile("/tmp/o", "HELLO\n") readfile("/tmp/o") ##### # # exec # 2022aug18 # ##### # «exec» (to ".exec") # (find-pydoc "library/functions#exec") # (find-pydoc "library/functions#open") # (find-pydoc "library/functions#globals") # (find-efunction 'ee-insert-test-python-mode) ##### # # read # 2022aug18 # ##### # «read» (to ".read") # (to "tut-inputoutput") # (find-pydoc "tutorial/inputoutput#reading-and-writing-files") # (find-pydocr "tutorial/inputoutput#reading-and-writing-files") # (find-pydocr "tutorial/inputoutput" "read_data = f.read()") # (find-pydoc "library/io#io.BufferedIOBase.read") # (find-pydoc "library/io#io.BufferedReader.read") # (find-pydoc "library/io#io.RawIOBase.read") # (find-pydoc "library/io#io.TextIOBase.read") ##### # # execfile and replacements for it (it was removed in Python3) # 2016jul31 # ##### # «execfile» (to ".execfile") # (find-prepared-intro "An `ee' for Python") # (find-prepared-intro "An `ee' for Python" "def ee():") # (find-prepared-intro "An `ee' for Python" "def ee():" "execfile") # (find-angg ".emacs" "pytest") # (find-angg ".pythonrc.py") # (find-angg ".pythonrc.py" "ee_dofile") # https://docs.python.org/2/tutorial/ # https://docs.python.org/2/library/functions.html#execfile # file:///usr/share/doc/python2.7/html/library/functions.html#execfile # file:///usr/share/doc/python3.5/html/library/functions.html#execfile # file:///usr/share/doc/python3.5/html/library/functions.html#exec # file:///usr/share/doc/python3.7/html/library/functions.html#exec # file:///usr/share/doc/python2.7/html/howto/doanddont.html#unadorned-exec-execfile-and-friends # (find-fline "/usr/lib/python3.5/lib2to3/fixes/fix_execfile.py") # (find-fline "/usr/lib/python2.7/lib2to3/fixes/fix_execfile.py") # (to "2to3") # -execfile("bar.py", globals()) # +exec(compile(open("bar.py").read(), "bar.py", 'exec'), globals()) * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cat > /tmp/foo.py <<'%%%' print(2+3) %%% * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) c = compile(ee_readfile("/tmp/foo.py"), "foo.py", "exec") c exec(c, globals()) ee_dofile("/tmp/foo.py") https://stackoverflow.com/questions/6357361/alternative-to-execfile-in-python-3 https://stackoverflow.com/questions/436198/what-is-an-alternative-to-execfile-in-python-3 ##### # # str.split # 2022aug18 # ##### # «str.split» (to ".str.split") # (find-pydoc "library/stdtypes#str.split") ##### # # os.path.split # 2019aug04 # ##### # «os.path.split» (to ".os.path.split") # (find-pydoc "library/os.path#os.path.split") # (find-anggfile "LUA/lua50init.lua" "fnamenondirectory") * (eepitch-python) * (eepitch-kill) * (eepitch-python) os.path.split("/tmp/foo.py") os.path.split("/tmp/foo.py")[1] ##### # # an ee() function for python # 2004nov03 # ##### # «ee-for-python» (to ".ee-for-python") #* # The wrong way: # (find-pyrefnode "exec statement") python <(<<'%%%' def ee(): exec "print 999" exec "print 777\ndef foo():\n print 888\nfoo()" ee() print "We lost the definition of foo:" foo() %%%) #* # The right way: execfile("fname", globals()) # (find-pyrefnode "import statement") # (find-pylibnode "os") # (find-pylibnode "Process Parameters" "`getenv(varname[, value])'") # (find-pylibnode "Built-in Functions" "`execfile(filename") # (find-pyrefnode "exec statement" "`globals()'") cat > $EEVTMPDIR/ee.py <<'%%%' print 11 def foo(): print 22 print 33 %%% python =(<<'%%%' import os def ee(): execfile(os.getenv("EEVTMPDIR")+"/ee.py", globals()) print 0 ee() foo() %%%) #* ##### # # 2to3 # 2019aug03 # ##### # «2to3» (to ".2to3") # (find-man "1 2to3") # (find-man "1 2to3-2.7") # (find-man "1 2to3-3.5") # (find-zsh "apt-file search bin/2to3") # (find-fline "/usr/bin/" "2to3") # (find-fline "/usr/bin/2to3-2.7") # (find-fline "/usr/bin/2to3-3.5") # (find-sh "locate lib2to3") # (find-fline "/usr/lib/python2.7/lib2to3/") # (find-fline "/usr/lib/python3.5/lib2to3/") # (find-fline "/usr/lib/python3.5/lib2to3/fixes/fix_execfile.py") # (find-fline "/usr/lib/python2.7/lib2to3/fixes/fix_execfile.py") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd /tmp/ cat > foo.py <<'%%%' execfile("bar.py", globals()) %%% 2to3 -v foo.py 2to3 foo.py laf cat foo.py ##### # # dumping the arguments # 2004nov04 # ##### # (find-pylibnode "File Descriptor Operations") #* rm -v /tmp/o python =(<<'%%%' import os def foo(*args): fd = open("/tmp/o", "w") fd.write(str(args)+"\n") fd.close foo((1, 2), "3") %%%) cat /tmp/o #* ##### # # str.format # 2019aug04 # ##### # «str.format» (to ".str.format") # file:///usr/share/doc/python2.7/html/library/stdtypes.html#str.format # file:///usr/share/doc/python3.5/html/library/stdtypes.html#str.format # file:///usr/share/doc/python2.7/html/library/stdtypes.html#string-formatting # file:///usr/share/doc/python3.5/html/library/stdtypes.html#string-formatting (nao) # file:///usr/share/doc/python2.7/html/library/string.html#formatstrings # file:///usr/share/doc/python3.5/html/library/string.html#formatstrings # file:///usr/share/doc/python2.7/html/library/string.html#formatspec # file:///usr/share/doc/python3.5/html/library/string.html#formatspec # file:///usr/share/doc/python2.7/html/library/string.html#format-string-syntax # file:///usr/share/doc/python3.5/html/library/string.html#format-string-syntax # file:///usr/share/doc/python2.7/html/library/functions.html#str # file:///usr/share/doc/python3.5/html/library/functions.html#str * (eepitch-python) * (eepitch-kill) * (eepitch-python) "{0}\n".format("foo") "" + 1234 "" + str(1234) str(1234) + "\n" ##### # # talking to python through eechannel # 2005jan01 # ##### # «eechannel-python» (to ".eechannel-python") # http://people.debian.org/~kov/stuff/edrx.tar.gz # (find-pylibnode "signal") # (find-pyrefnode "Comments") # (find-pyrefnode "String literals") # (my-modes :scroll-bar :pager :erc-track :fringe :width80) # (my-modes :no-scroll-bar :no-pager :no-erc-track :no-fringe :width80) * (eebg-channel-xterm "pysh") * (eechannel "pysh") cd /tmp/ python import signal, time, os channel = 'python' pidfile = os.getenv('EEVTMPDIR') + '/eeg.' + channel + '.pid' strfile = os.getenv('EEVTMPDIR') + '/eeg.' + channel + '.str' fhandle = open (pidfile, 'w') fhandle.write (str(os.getpid()) + '\n') fhandle.close () def signal_handler (num, frame): execfile(strfile, globals()) signal.signal (signal.SIGUSR1, signal_handler) a = 0 while (1): print a time.sleep (1) a = a + 1 * (eechannel "python") print '(hi)' print '(hi again)' * (find-sh0 "~/bin/Xscreenshot") * ;; http://angg.twu.net/tmp/shot-pychannel0.png # (write-region "print '(oi)'\n" nil "/tmp/coisa.py") # (find-zsh0 "kill -SIGUSR1 $(cat /tmp/eeg.python.pid)") (find-pytutnode "") (find-pylibnode "") (find-pyrefnode "") (find-pyapinode "") (find-pydistnode "") (find-pyextnode "") import coisa del coisa ##### # # Listening to SIGUSR1s # 2019aug03 # ##### # «sigusr1» (to ".sigusr1") # (find-channels-intro "SIGUSR1") # (find-multiwindow-intro "5. Restarting eepitch targets") # (find-multiwindow-intro "5. Restarting eepitch targets" "* (find-3EE") # https://www.programcreek.com/python/example/5524/signal.SIGUSR2 # https://kite.com/python/docs/signal.SIGUSR2 # https://pymotw.com/2/signal/ # https://stackabuse.com/handling-unix-signals-in-python/ # https://docs.python.org/3.7/library/signal.html#module-signal # file:///usr/share/doc/python2.7/html/library/signal.html # file:///usr/share/doc/python3.5/html/library/signal.html # file:///usr/share/doc/python2.7/html/library/signal.html#signal.signal # file:///usr/share/doc/python3.5/html/library/signal.html#signal.signal # file:///usr/share/doc/python2.7/html/library/os.html#os.chdir # file:///usr/share/doc/python3.5/html/library/os.html#os.chdir # file:///usr/share/doc/python2.7/html/library/os.html#os.getpid # file:///usr/share/doc/python3.5/html/library/os.html#os.getpid # Standard syntax: # def signal_handler (num, frame): # ee_dofile(strfname) # # signal.signal (signal.SIGUSR1, signal_handler) # (setenv "EEVTMPDIR" (ee-expand "~/.eev")) # (find-fline "$EEVTMPDIR/") # (find-angg ".pythonrc.py") * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) import signal channel = "py" pidfname = os.getenv("EEVTMPDIR") + "/eeg." + channel + ".pid" strfname = os.getenv("EEVTMPDIR") + "/eeg." + channel + ".str" ee_writefile(pidfname, str(os.getpid()) + "\n") signal.signal (signal.SIGUSR1, lambda num,frame: ee_dofile(strfname)) os.getenv("EEVTMPDIR") pidfname strfname os.getpid() * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) * (find-3ee '(eepitch-shell) '(eepitch-python3)) * (eepitch-shell) cd $EEVTMPDIR laf echo 'print(2+3)' > $EEVTMPDIR/eeg.py.str kill -USR1 $(cat $EEVTMPDIR/eeg.py.pid) echo 'exit()' > $EEVTMPDIR/eeg.py.str kill -USR1 $(cat $EEVTMPDIR/eeg.py.pid) ##### # # python-docutils / ReStructuredText # 2007mar25 # ##### # «python-docutils» (to ".python-docutils") # «rst» (to ".rst") # (find-es "rst") # http://docutils.sourceforge.net/rst.html # http://docutils.sourceforge.net/docs/user/rst/quickstart.txt # http://docutils.sourceforge.net/docs/user/emacs.html # (find-efile "textmodes/rst.el") # (find-status "python-docutils") # (find-vldifile "python-docutils.list") # (find-udfile "python-docutils/") # (code-c-d "pydocudoc" "/usr/share/doc/python-docutils/") # (find-pydocudocfile "ref/rst/introduction.txt.gz") # (find-pydocudocfile "user/rst/quickstart.txt.gz") # (find-pydocudocfile "user/rst/") # (find-pydocudocfile "") # (find-fline "/tmp/rst/") #* rm -Rv /tmp/rst/ mkdir /tmp/rst/ cd /usr/share/doc/python-docutils/user/rst/ cp -v * /tmp/rst/ cd /tmp/rst/ gunzip -v *.gz for i in *.txt; do echo $i rst2html $i > $(basename $i .txt).html done |& tee o #* # Source: # (code-c-d "pydocusp" "/usr/lib/site-python/docutils/") # (find-pydocuspfile "") ##### # # dive into python # 2007mar25 # ##### # «diveintopython» (to ".diveintopython") # (find-status "diveintopython") # (find-vldifile "diveintopython.list") # (find-udfile "diveintopython/") # (code-c-d "pydip" "/usr/share/doc/diveintopython/") # (find-pydipfile "") # (find-pydipw3m "html/toc/index.html") # Very bad book, incredibly bad examples. # http://oppugn.us/posts/1272050135.html Criticism of Dive into Python ##### # # closures # 2008jun28 # ##### # «closures» (to ".closures") # (find-pydoc "index") * (eepitch-python) * (eepitch-kill) * (eepitch-python) def adder(x): def foo(y): return y + x return foo plus2 = adder(2) plus2(3) plus3 = adder(3) plus3(5) ##### # # python-apt (from the debian sources) # 2009jul27 # ##### # «python-apt-deb-src» (to ".python-apt-deb-src") # http://ftp.de.debian.org/debian/pool/main/p/python-apt/ # http://ftp.de.debian.org/debian/pool/main/p/python-apt/python-apt_0.7.7.1+nmu1.dsc # http://ftp.de.debian.org/debian/pool/main/p/python-apt/python-apt_0.7.7.1+nmu1.tar.gz #* rm -Rv ~/usrc/python-apt/ mkdir ~/usrc/python-apt/ cd $S/http/ftp.de.debian.org/debian/pool/main/p/python-apt/ cp -v python-apt_0.7.7.1+nmu1* ~/usrc/python-apt/ cd ~/usrc/python-apt/ dpkg-source -sn -x python-apt_0.7.7.1+nmu1.dsc cd ~/usrc/python-apt/python-apt-0.7.7.1+nmu1/ dpkg-buildpackage -us -uc -b -rfakeroot |& tee odb #* # (find-fline "~/usrc/python-apt/") * (eepitch-shell) cd ~/usrc/python-apt/ sudo dpkg -i *.deb #* # (code-c-d "pythonapt" "~/usrc/python-apt/python-apt-0.7.7.1+nmu1/") # (find-pythonaptfile "") # (find-pythonaptfile "doc/examples/") ##### # # python-apt # 2009jul27 # ##### # «python-apt» (to ".python-apt") # (find-es "apt" "libapt") # (find-status "python-apt") # (find-vldifile "python-apt.list") # (find-udfile "python-apt/") # (find-status "python-apt-doc") # (find-vldifile "python-apt-doc.list") # (find-udfile "python-apt-doc/") # (find-udfile "python-apt/html/_sources/") # (find-udgrep "grep -nH -e VersionCompare python-apt-doc/examples/*") # (find-angg "LUA/apt-move.lua" "debversions") # (find-fline "/usr/share/doc/python-apt/examples/") # (find-fline "/usr/lib/python2.6/dist-packages/apt/") # (find-fline "/usr/share/pyshared/apt/") # (find-fline "/usr/share/doc/python-apt/") # (code-c-d "pythonapt" "/usr/lib/python2.6/dist-packages/apt/") # (code-c-d "pythonaptex" "/usr/share/doc/python-apt/examples/") # (find-pythonaptfile "") # (find-pythonaptexfile "") # (find-pythonaptexfile "build-deps.py") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import apt_pkg import sys import sets def get_source_pkg(pkg, records, depcache): """ get the source package name of a given package """ version = depcache.GetCandidateVer(pkg) if not version: return None file, index = version.FileList.pop(0) records.Lookup((file, index)) if records.SourcePkg != "": srcpkg = records.SourcePkg else: srcpkg = pkg.Name return srcpkg # main apt_pkg.init() cache = apt_pkg.GetCache() depcache = apt_pkg.GetDepCache(cache) depcache.Init() records = apt_pkg.GetPkgRecords(cache) srcrecords = apt_pkg.GetPkgSrcRecords() base = cache["emacs22-el"] # For example all_build_depends = sets.Set() # get the build depdends for the package itself srcpkg_name = get_source_pkg(base, records, depcache) print "srcpkg_name: %s " % srcpkg_name if not srcpkg_name: print "Can't find source package for '%s'" % pkg.Name srcrec = srcrecords.Lookup(srcpkg_name) if srcrec: print "Files:" print srcrecords.Files bd = srcrecords.BuildDepends print "build-depends of the package: %s " % bd for b in bd: all_build_depends.add(b[0]) # calculate the build depends for all dependencies depends = depcache.GetCandidateVer(base).DependsList for dep in depends["Depends"]: # FIXME: do we need to consider PreDepends? pkg = dep[0].TargetPkg srcpkg_name = get_source_pkg(pkg, records, depcache) if not srcpkg_name: print "Can't find source package for '%s'" % pkg.Name continue srcrec = srcrecords.Lookup(srcpkg_name) if srcrec: #print srcrecords.Package #print srcrecords.Binaries bd = srcrecords.BuildDepends #print "%s: %s " % (srcpkg_name, bd) for b in bd: all_build_depends.add(b[0]) print "\n".join(all_build_depends) ##### # # python-opengl # 2009jul27 # ##### # «python-opengl» (to ".python-opengl") apti python-opengl python-opengl-doc # (find-status "python-opengl") # (find-vldifile "python-opengl.list") # (find-udfile "python-opengl/") # (find-status "python-opengl-doc") # (find-vldifile "python-opengl-doc.list") # (find-udfile "python-opengl-doc/") # (find-fline "/usr/share/doc/python-opengl-doc/documentation/pydoc/") # http://code.activestate.com/recipes/325391/ * (eepitch-python) * (eepitch-kill) * (eepitch-python) from OpenGL.GLUT import * from OpenGL.GLU import * from OpenGL.GL import * import sys name = 'ball_glut' def main(): glutInit(sys.argv) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) glutInitWindowSize(400,400) glutCreateWindow(name) # glClearColor(0.,0.,0.,1.) glShadeModel(GL_SMOOTH) glEnable(GL_CULL_FACE) glEnable(GL_DEPTH_TEST) glEnable(GL_LIGHTING) lightZeroPosition = [10.,4.,10.,1.] lightZeroColor = [0.8,1.0,0.8,1.0] #green tinged glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition) glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor) glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1) glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05) glEnable(GL_LIGHT0) glutDisplayFunc(display) glMatrixMode(GL_PROJECTION) gluPerspective(40.,1.,1.,40.) glMatrixMode(GL_MODELVIEW) gluLookAt(0,0,10, 0,0,0, 0,1,0) glPushMatrix() glutMainLoop() return def display(): glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) glPushMatrix() color = [1.0,0.,0.,1.] glMaterialfv(GL_FRONT,GL_DIFFUSE,color) glutSolidSphere(2,20,20) glPopMatrix() glutSwapBuffers() return if __name__ == '__main__': main() ##### # # Pymacs # 2011oct25 # ##### # «pymacs» (to ".pymacs") # (find-status "pymacs") # (find-vldifile "pymacs.list") # (find-udfile "pymacs/") # http://pymacs.progiciels-bpi.ca/index.html ##### # # Python-sphinx # 2011nov14 # ##### # «python-sphinx» (to ".python-sphinx") # (find-es "lua5" "gsl-shell") # (find-status "python-sphinx") # (find-vldifile "python-sphinx.list") # (find-udfile "python-sphinx/") ##### # # sphinx-build (used by the Agda docs) # 2019may20 # ##### # «sphinx-build» (to ".sphinx-build") # (find-es "sphinx" "python3-sphinx") # (find-es "agda" "agda-git") # https://www.sphinx-doc.org/en/1.6/man/sphinx-build.html # (find-sh "apt-file search sphinx-build") # (find-sh "apt-file search sphinx.ext.imgmath") # python-sphinx: /usr/share/sphinx/scripts/python2/sphinx-build # python3-sphinx: /usr/share/sphinx/scripts/python3/sphinx-build # (find-status "python3-sphinx") # (find-vldifile "python3-sphinx.list") # (find-udfile "python3-sphinx/") # (find-status "sphinx-common") # (find-vldifile "sphinx-common.list") # (find-udfile "sphinx-common/") # (find-status "sphinx-doc") # (find-vldifile "sphinx-doc.list") # (find-udfile "sphinx-doc/") # (find-man "sphinx-build") # sphinx.ext.imgmath not found: # https://github.com/rtfd/readthedocs.org/issues/2418 sphinx.ext.imgmath not found # https://github.com/sphinx-doc/sphinx/issues/2436 Running Sphinx v1.3.6 /conf.py needs_sphinx = '1.4.3' /requirements.txt Sphinx>=1.4.3 aptrm python3-sphinx ##### # # sphinx-git # 2019may21 # ##### # «sphinx-git» (to ".sphinx-git") # https://github.com/sphinx-doc/sphinx * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rfv ~/usrc/sphinx/ cd ~/usrc/ git clone https://github.com/sphinx-doc/sphinx cd ~/usrc/sphinx/ make |& tee om # (code-c-d "sphinx" "~/usrc/sphinx/") # (find-sphinxfile "") # (find-gitk "~/usrc/sphinx/") # (find-sphinxfile "setup.py" "flake8>=3.5.0") ##### # # PyGame # 2011nov25 / 2024oct11 # ##### # «pygame» (to ".pygame") # (find-angg ".emacs" "ee-rstdoc-:pygame") # (find-zsh "installeddebs | sort | grep pygame") # (find-zsh "availabledebs | sort | grep pygame") # (find-status "python-pygame-doc") # (find-vldifile "python-pygame-doc.list") # (find-udfile "python-pygame-doc/") # (find-status "python3-pygame-sdl2") # (find-vldifile "python3-pygame-sdl2.list") # (find-udfile "python3-pygame-sdl2/") # (find-status "python3-pygame") # (find-vldifile "python3-pygame.list") # (find-udfile "python3-pygame/") # (find-udfile "python-pygame/ref/") # (find-udfile "python-pygame/tut/") # (find-pygamedoc) # (find-pygamedoc "genindex") # (find-pygamedoc "ref/display#pygame.display.set_mode") # https://dataswamp.org/~incal/pix/pixel.py * (eepitch-python) * (eepitch-kill) * (eepitch-python) import pygame_sdl2 screen = pygame_sdl2.display.set_mode((100,60)) screen.set_at((x, y), (r, g, b)) pygame_sdl2.display.flip() # http://programarcadegames.com/index.php?chapter=introduction_to_graphics ##### # # Modules # 2012may02 # ##### # «modules» (to ".modules") # (find-pydoc "index") # (find-pydoc "tutorial/modules") # (find-pydoc "tutorial/modules#executing-modules-as-scripts") # (find-fline "/tmp/fibo.py") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd /tmp/ rm -v fibo.py cat > fibo.py <<'%%%' print "Hello" def square (x): return x*x if __name__ == "__main__": import sys print(square(int(sys.argv[1]))) else: print("Loading as a module") print "Bye" %%% python fibo.py 6 python import fibo print(fibo.square(6)) ##### # # module.__file__ # 2019sep25 # ##### # «module.__file__» (to ".module.__file__") # (find-pydoc "library/os.path") # (find-pydoc "library/os.path#os.path.abspath") # (find-pydoc "library/pathlib#module-pathlib") # (find-pydoc "library/pathlib#operators" "slash operator") # (find-pydoc "library/pathlib#pathlib.Path") # (find-pydoc "reference/import#import-related-module-attributes" "__import__") * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) import IPython IPython IPython.__file__ os.path.abspath(IPython.__file__) I tried to run these lines in the REPL: "import IPython", "IPython", "IPython.__file__", "os.abspath(IPython.__file__)"... the first three ones work, but the last one gives this error: "AttributeError: module 'os' has no attribute 'abspath'"... ##### # # __tostring for Python # 2012may08 # ##### # «tostring» (to ".tostring") # (find-pydoc "index") # (find-pydoc "library/functions#func-str") # (find-pydoc "reference/datamodel#basic-customization") # (find-pydoc "reference/datamodel#object.__repr__") # (find-pydoc "reference/datamodel#object.__str__") # (find-pydoc "reference/datamodel#special-method-names") # (find-pydocr "reference/datamodel#object.__repr__") # (find-books "__comp/__comp.el" "python-downey" "__str__") # (find-pyrefnode "Special method names") # (find-pyrefnode "Emulating container types") # (find-pyrefnode "Emulating numeric types") # http://rgruet.free.fr/PQR2.3.html#SpecialMethods (let ((default-directory "/usr/share/doc/python3.9/html/_sources/")) (grep "grep --color=auto -nriH --null -e 'Container' *") ) * (eepitch-python) * (eepitch-kill) * (eepitch-python) foo = 5 foo.__str__ foo.__str__() foo.__str__(foo) str(foo) "5" ##### # # MyVector # 2022sep17 # ##### # «MyVector» (to ".MyVector") # (to "tut-classes") # (find-books "__comp/__comp.el" "python-downey" "__str__") # (find-downeytppage (+ 22 199) "__init__") # (find-downeytptext (+ 22 199) "__init__") # (find-downeytppage (+ 22 200) "The __str__ Method") # (find-downeytptext (+ 22 200) "The __str__ Method") # (find-pydoc "reference/datamodel#object.__init__") # (find-pydoc "reference/datamodel#object.__str__") # (find-pydoc "reference/datamodel#object.__add__") * (eepitch-python) * (eepitch-kill) * (eepitch-python) class MyVector: def __init__(v, x, y): v.x = x v.y = y def __str__(v): return '(%d,%d)' % (v.x, v.y) def __add__(v, w): return MyVector(v.x+w.x, v.y+w.y) print(MyVector(20,30)) print(MyVector(20,30)+MyVector(4,5)) ##### # # SciPy # 2012nov24 # ##### # «scipy» (to ".scipy") # http://www.scipy.org/SciPy ##### # # matplotlib # 2012nov24 / 2019aug03 # ##### # «matplotlib» (to ".matplotlib") # https://matplotlib.org/gallery.html # (find-zsh "installeddebs | sort | grep matplotlib") # (find-zsh "availabledebs | sort | grep matplotlib") # (find-mpldoc "index") # (find-mpldoc "tutorials/index") # (find-mpldoc "tutorials/introductory/usage") # (find-mpldoc "tutorials/introductory/pyplot") # (find-mpldoc "tutorials/introductory/sample_plots") # (find-mpldoc "tutorials/introductory/images") # (find-mpldoc "tutorials/introductory/lifecycle") # (find-mpldoc "tutorials/introductory/customizing") # (find-status "python-matplotlib-doc") # (find-vldifile "python-matplotlib-doc.list") # (find-udfile "python-matplotlib-doc/") # (find-status "python3-matplotlib") # (find-vldifile "python3-matplotlib.list") # (find-udfile "python3-matplotlib/") # (find-udfile "python-matplotlib-doc/examples/") # (find-udfile "python-matplotlib-doc/examples/README.txt") # file:///usr/share/doc/python-matplotlib-doc/html/index.html # file:///usr/share/doc/python-matplotlib-doc/html/gallery.html # file:///usr/share/doc/python-matplotlib-doc/html/ # file:///usr/share/doc/python-matplotlib-doc/html/tutorials/index.html # file:///usr/share/doc/python-matplotlib-doc/html/tutorials/introductory/usage.html # (find-fline "/usr/share/doc/python-matplotlib-doc/html/_sources/") # (find-fline "/usr/share/doc/python-matplotlib-doc/html/_sources/tutorials/introductory/pyplot.rst.txt") # (find-fline "/usr/share/doc/python-matplotlib-doc/html/_sources/tutorials/introductory/usage.rst.txt") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) apti python-matplotlib-doc python3-matplotlib # Old: # http://stackoverflow.com/questions/tagged/matplotlib # http://matplotlib.org/ # http://matplotlib.org/api/figure_api.html # http://www.scipy.org/Additional_Documentation?action=show&redirect=Documentation ##### # # matplotlib-examples # 2019aug29 # ##### # «matplotlib-examples» (to ".matplotlib-examples") # (find-angg ".emacs.templates" "find-matplotlib-links") # (find-angg ".emacs.templates" "find-matplotlib-links" "M-x brmpd") # (find-angg ".emacs" "matplotlib-examples") # (find-matplotlibexfile "") # (find-matplotlibexfile "pyplots/") # (find-matplotlibexfile "pyplots/align_ylabels.py") # (find-fline "~/MATPLOTLIB/") # (find-fline "~/MATPLOTLIB/rotate_axes3d_demo.py") ##### # # matplotlib-rougier # 2021sep07 # ##### # «matplotlib-rougier» (to ".matplotlib-rougier") # https://github.com/rougier # https://github.com/rougier/matplotlib-tutorial # https://github.com/rougier/scientific-visualization-book # https://github.com/rougier/figure-anatomy # https://github.com/matplotlib/cheatsheets https://news.ycombinator.com/item?id=29229103 An open access book on scientific visualization using Python and Matplotlib (github.com/rougier) ##### # # NumPy # 2013may13 # ##### # «numpy» (to ".numpy") # http://www.scipy.org/Tentative_NumPy_Tutorial # http://scipy-lectures.github.com/ # (find-angg ".emacs" "ipython") # «scipy-lectures» (to ".scipy-lectures") # (find-git-links "https://github.com/scipy-lectures/scipy-lecture-notes.git" "scipylectures") # (find-es "rst") # https://github.com/scipy-lectures/scipy-lecture-notes # https://github.com/scipy-lectures/scipy-lecture-notes.git (code-c-d "scipylectures" "~/usrc/scipy-lecture-notes/") (code-c-d "scipylectureshtml" "~/usrc/scipy-lecture-notes/build/html/") ;; (find-scipylecturesfile "") ;; (find-scipylecturesfile "intro/") ;; (find-scipylecturesfile "intro/intro.rst") ;; (find-scipylecturessh "find * | sort") ;; (find-scipylecturessh "find * | sort | grep rst") ;; (find-scipylectureshtmlfile "") ;; (find-scipylectureshtmlfile "_sources/packages/traits/index.txt") ;; (find-scipylectureshtmlfile "_sources/packages/scikit-learn/index.txt") ;; (find-scipylectureshtmlfile "_sources/packages/3d_plotting/") ;; file:///home/edrx/usrc/scipy-lecture-notes/build/html/index.html * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd ~/usrc/scipy-lecture-notes/ make html |& tee om ##### # # ipython # 2012sep27 # ##### # «ipython» (to ".ipython") # https://en.wikipedia.org/wiki/IPython # (find-angg ".emacs" "ipython") # (find-angg ".emacs" "pylab") # (find-status "ipython") # (find-vldifile "ipython.list") # (find-udfile "ipython/") # (find-status "python-matplotlib") # (find-vldifile "python-matplotlib.list") # (find-udfile "python-matplotlib/") # (find-sitelispfile "ipython.el") (code-c-d "ipython" "/usr/share/pyshared/IPython/") (code-c-d "ipythonex" "/usr/share/doc/ipython/examples/") ;; (find-ipythonfile "") ;; (find-ipythonexfile "") # http://www.thetechrepo.com/main-articles/465-how-to-create-a-graph-in-python # http://coreygoldberg.blogspot.com.br/2012/01/python-matplotlib-and-numpy-on.html # http://stackoverflow.com/questions/1596684/python-library-to-plot-graph # http://www.youtube.com/watch?v=26wgEsg9Mcc IPython: Python at your fingertips # http://www.youtube.com/watch?v=2G5YTlheCbw IPython in-depth: high-productivity interactive and parallel python # http://stackoverflow.com/questions/13575703/ipython-ide-for-windows # http://nbviewer.ipython.org/urls/raw.github.com/jrjohansson/scientific-python-lectures/master/Lecture-5-Sympy.ipynb # (find-youtubedl-links "/sda5/videos/" "IPython_-_Python_at_your_fingertips" "26wgEsg9Mcc" ".mp4" "ipythonayf") # (code-video "ipythonayfvideo" "/sda5/videos/IPython_-_Python_at_your_fingertips-26wgEsg9Mcc.mp4") # (code-video "ipythonayfvideo" "/sda5/videos/IPython_-_Python_at_your_fingertips-26wgEsg9Mcc.mp4.part") # (find-ipythonayfvideo) # (find-ipythonayfvideo "0:00") # (find-sh "ipython --help") # (find-sh "ipython --help" "pylab") # (find-sh "ipython --help-all") apti python-matplotlib # (find-man "1 ipcluster") # (find-man "1 ipcontroller") # (find-man "1 ipengine") # (find-man "1 ipython") # (find-man "1 ipython" "-pylab") # (find-man "1 ipython-wx") # (find-man "1 ipythonx") # (find-man "1 irunner") # (find-man "1 pycolor") * (eepitch-pylab) * (eepitch-kill) * (eepitch-pylab) ? x = randn(10000) hist(x, 100) ?hist print(x) ?randn ##### # # Ameliabot # 2012oct27 # ##### # «ameliabot» (to ".ameliabot") # (find-es "git" "git-shallow-clone") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # (find-es "cvs" "git-shallow-clone") rm -Rfv /tmp/ameliabot/ mkdir /tmp/ameliabot/ cd /tmp/ameliabot/ git clone --depth 1 git://git.code.sf.net/p/ameliabot/code ameliabot-code git clone --depth 1 git://git.code.sf.net/p/untwisted/code untwisted-code git clone --depth 1 git://git.code.sf.net/p/uxirc/code uxirc-code # (find-fline "/tmp/ameliabot/") <Tau> daí voce instala o untwisted depois o uxric lib com python setup.py install, se voce quiser instalar em uma conta do linux comum voce usa python setup.py install --prefix=$HOME <Tau> aí pra rodar o ameliabot voce só edita o amelia.py configurando lá os canais/plugins etc <Tau> e roda com python amelia.py """ Author:Iury O. G. Figueiredo Name:codenv Description: This plugin uses codepage.org to run code. Usage: <Tau>.proc python .done <Tau>def snard(value): <Tau> for ind in range(value): <Tau> print 'snardbafulator is a molester' <Tau>snard(6) <Tau>.done <yu> snardbafulator is a molester snardbafulator is a molester snardbafulator is a molester snardbafulator is a molester snardbafulator is a molester snardbafulator is a molester """ from utils import codepad from uxirc.misc import * from untwisted.network import hold, xmap class Codenv(object): def __init__(self, server, max_width=512 * 3): self.max_width = max_width xmap(server, ('PRIVCHAN', '.$'), self.proc) def proc(self, server, (nick, user, host, target, msg), lang, tag): code = '' flag = hold(server, 'PRIVCHAN') while True: event, args = yield flag if args[4] == target and args[3] == host: if args[5] == tag: break code = code + args[5] + '\n' url, output = codepad.sandbox(code, lang) if len(output) <= self.max_width: send_msg(server, target, output) else: send_msg(server, target, url) ##### # # Rend's tutorial # 2013jan01 # ##### # «rends-tutorial» (to ".rends-tutorial") # (find-fline "~/LOGS/2013jan01.eev") (defun u () (interactive) (find-escript-upload-links "python" "rends-tutorial")) (defun eejump-666 () (find-wset "13_o_2o_o" ;; ' (find-angg "TODO") ' (find-es "python") ' (ee-here '(eepitch-python)) ' (find-ebuffer "#eev@irc.freenode.net") )) * (eepitch-python) * (eepitch-kill) * (eepitch-python) # class Car(): class Car(object): def __init__(self, name, model=None): self.name = name self.model = model def start(self): return 'running ...' def accelerate(self, number=10): print 'accelerating ... [%s]' % number self.speed = number def accelerate2(foo, number=10): print 'accelerating ... [%s]' % number foo.speed = number def speed(self): return 22 def stop(self): return 'stopped.' ferrari = Car("Ferrari", "M") ferrari ferrari.name ferrari.model ferrari.start ferrari.start() ferrari.accelerate(20) ferrari.speed ferrari.accelerate2(30) ferrari.speed # ferrari = {'start':start_func, # 'accelerate':accelerate_func, # 'stop':stop_func, # name:'Ferrari', # model:'whatever_model'} class miniCar(Car): def jump(foo, height): foo.height = height print foo.height minicar = miniCar('cooper') minicar.jump(100) minicar ferrari = Car('Ferrari') dir(ferrari) ferrari.__dict__ dir(minicar) minicar.__dict__ minicar.__sizeof__ ferrari.__sizeof__ ferrari.__sizeof__() * (eepitch-python) * (eepitch-kill) * (eepitch-python) # A port of: (find-dn5 "eoo.lua" "test-eoo") # See: (to "environment") # (to "tostring") # (find-pyrefnode "Basic customization" "`__repr__(self)'") # (find-pyrefnode "Basic customization" "`__str__(self)'") # import os os.environ["PAGER"] = "cat" import math dir(math) help(math.sqrt) class V2(object): def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return str((self.x,self.y)) # return "(%d, %d)" % (self.x, self.y) def __add__(self, other): return V2(self.x + other.x, self.y + other.y) def norm(self): return math.sqrt(self.x ** 2 + self.y ** 2) v = V2(3, 4) v.norm() v V2(3, 4) + V2(20, 30) ##### # # Environment variables # 2013jan02 # ##### # «environment» (to ".environment") # file:///usr/share/doc/python2.7/html/library/os.html # file:///usr/share/doc/python3.5/html/library/os.html # file:///usr/share/doc/python2.7/html/library/os.html#os.environ # file:///usr/share/doc/python3.5/html/library/os.html#os.environ * (eepitch-python) * (eepitch-kill) * (eepitch-python) import os os.getenv("PAGER") os.putenv("PAGER", "cat") os.getenv("PAGER") os.environ["PAGER"] os.environ["PAGER"] = "cat" os.getenv("PAGER") help(os) help(os.environ) help(os.getenv) help(os.putenv) ##### # # scikits and scikits.audiolab # 2012nov18 # ##### # «scikits» (to ".scikits") # (find-status "python-scikits-learn") # (find-vldifile "python-scikits-learn.list") # (find-udfile "python-scikits-learn/") # (find-status "python-scikits-learn-doc") # (find-vldifile "python-scikits-learn-doc.list") # (find-udfile "python-scikits-learn-doc/") apti python-scikits-learn python-scikits-learn-doc * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rfv /tmp/hybrid/ mkdir /tmp/hybrid/ cd /tmp/hybrid/ git clone git://labmacambira.git.sourceforge.net/gitroot/labmacambira/dissertacao cd dissertacao git pull origin msc git checkout msc cd scripts/ cd /tmp/hybrid/dissertacao/scripts/ # (code-c-d "hybridscripts" "/tmp/hybrid/dissertacao/scripts/") # (find-hybridscriptsfile "") # (find-hybridscriptsfile "pecas2.3/microTom.py") cd /tmp/hybrid/dissertacao/scripts/pecas2.3/ python microTom.py # (find-zsh "dmissing scikits") <automata> em scripts vc vai encontrar pecas2.1 pecas2.2 e pecas2.3 <automata> basta entrar em cada um desses diretórios e executar os códigos em python ##### # # PyObjects (by Sergey Sergeev) # 2013jan02 # ##### # «pyobjects» (to ".pyobjects") # https://github.com/sharedmemory/pyobjects # https://github.com/jfearn/HTML-Tree/blob/master/lib/HTML/Tree/AboutObjects.pod # (find-fline "/usr/share/perl5/HTML/Tree/AboutObjects.pod") # http://lua-users.org/lists/lua-l/2009-09/msg00565.html ##### # # emacs-ipython-notebook # 2012dec08 # ##### # «emacs-ipython-notebook» (to ".emacs-ipython-notebook") # (find-es "jupyter" "emacs-ipython-notebook") # https://github.com/tkf/emacs-ipython-notebook ##### # # audio # 2013mar06 # ##### # «audio» (to ".audio") # http://stackoverflow.com/questions/307305/play-a-sound-with-python # http://wiki.python.org/moin/Audio # http://wiki.python.org/moin/PythonInMusic ##### # # pprint # 2014sep06 # ##### # «pprint» (to ".pprint") # file:///usr/share/doc/python2.7/html/library/pprint.html # https://docs.python.org/2/library/pprint.html # http://pymotw.com/2/pprint/ # http://stackoverflow.com/questions/9135485/how-to-use-pprint-to-print-an-object-using-the-built-in-str-self-method ##### # # SymPy # 2013mar23 # ##### # «sympy» (to ".sympy") #******** #******** Tutorial: #******** (find-es "sympy" "tutorial") #******** # (find-status "python-sympy") # (find-vldifile "python-sympy.list") # (find-udfile "python-sympy/") from __future__ import division from sympy import * x, y, z, t = symbols('x y z t') k, m, n = symbols('k m n', integer=True) f, g, h = symbols('f g h', cls=Function) Stephanie, vou te passar as anotacoes por aqui pra mais gente (Hugo, por exemplo =) ) ter noção do que a gente está começando a fazer... Você instalou o Python(x,y) baixando isso aqui, né? http://www.mirrorservice.org/sites/pythonxy.com/Python(x,y)-2.7.5.0.exe E a gente tá tentando aprender a fazer computação simbólica nele... quando eu rodo "isympy" no Linux as mensagens são estas: IPython console for SymPy 0.7.1.rc1 (Python 2.7.3-32-bit) (ground types: python) These commands were executed: >>> from __future__ import division >>> from sympy import * >>> x, y, z, t = symbols('x y z t') >>> k, m, n = symbols('k m n', integer=True) >>> f, g, h = symbols('f g h', cls=Function) Documentation can be found at http://www.sympy.org In [1]: e aí a gente pode dar expressões como (1 - x) * 2 e o interpretador responde: -2*x + 2 porque ele trata isto como uma expressão (um polinômio)... Estamos dando uma olhada neste tutorial e nestas páginas de referência, http://docs.sympy.org/0.7.2/tutorial.html http://docs.sympy.org/0.7.2/modules/core.html http://docs.sympy.org/0.7.2/modules/polys/reference.html mas ainda não descobrimos um modo do Python pra Windows já começar rodando os comandos que carregam o sympy e definem x, y, z, t, etc como "expressões"... # http://docs.sympy.org/0.7.2/tutorial.html # http://docs.sympy.org/0.7.2/modules/core.html # http://docs.sympy.org/0.7.2/modules/polys/reference.html ##### # # Spyder # 2013jun25 # ##### # «spyder» (to ".spyder") # (find-status "spyder") # (find-vldifile "spyder.list") # (find-udfile "spyder/") # (find-status "python-spyderlib") # (find-vldifile "python-spyderlib.list") # (find-udfile "python-spyderlib/") # (find-man "1 spyder") * (eepitch-shell2) * (eepitch-kill) * (eepitch-shell2) spyder # (find-fline "~/.spyder2/") # (find-fline "~/.spyder2/.temp.py") # http://www.mirrorservice.org/sites/pythonxy.com/ # file:///usr/share/doc/python-spyderlib/html/index.html ##### # # Idle # 2013jun26 # ##### # «idle» (to ".idle") # file:///usr/share/doc/python2.7/html/library/idle.html # file:///usr/share/doc/python3.5/html/library/idle.html # (find-zsh "apt-file search idle") # (find-zsh "installeddebs | sort | grep idle") # (find-zsh "availabledebs | sort | grep idle") idle-python2.7 idle-python3.5 idle3-tools idle3-tools idle3 idle idlestat idlestat telepathy-idle telepathy-idle # (find-angg "PYTHON/a.py") # (find-sh "locate idle | grep -i python") # (find-fline "/usr/lib/python2.5/idlelib/") # (find-zsh "dmissing idlelib") # (find-zsh "installeddebs | sort | grep python") # (find-status "python2.7") # (find-vldifile "python2.7.list") # (find-udfile "python2.7/") # (find-status "idle") # (find-vldifile "idle.list") # (find-udfile "idle/") # (find-status "idle-python2.7") # (find-vldifile "idle-python2.7.list") # (find-udfile "idle-python2.7/") # (find-man "1 idle") * (eepitch-python) * (eepitch-kill) * (eepitch-python) * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) PAGER=cat python help("import") # sys.meta_path ##### # # Links do Felipe Pinheiro # 2013jun14 # ##### # «felipe-pinheiro» (to ".felipe-pinheiro") Comece por aqui: http://ericstk.wordpress.com/2013/01/22/o-que-e-preciso-para-comecar-a-programar-em-python/ PDF, Python for Zombies(português): https://docs.google.com/file/d/0B2FCVdJY8NOqeUIwUV9SaU1jYlU/edit http://www.slideshare.net/renatopp/introduo-ao-python http://www.python.org.br/wiki/AprendaProgramar ---------------------------------------------- Exercícios: http://www.python.org.br/wiki/ListaDeExercicios ---------------------------------------------- Vídeos Lógica de Programação Usando Python - Curso Completo(comece aqui) http://www.youtube.com/playlist?list=PL51430F6C54953B73 Exemplo Programa(médio) http://www.youtube.com/watch?v=eTKB6of96GQ Curso de desenvolvimento Web com Python e Django : http://migre.me/cWcDU Palestras e vídeos: http://aprenda-python.blogspot.com.br/2013/03/palestras-gratuitas-e-atualizadas-2013.html Python e QT4 http://www.youtube.com/playlist?list=PLF4575388795F2531 Python e GTK http://www.youtube.com/playlist?list=PL7604BFACE2442F9A Curso em Video Aulas Python http://www.baixebr.org/cursos-e-apostilas/cursos/curso-video-aulas-python/ http://www.youtube.com/course?list=EC36E7A2B75028A3D6 Computer Science - Khan Academy http://www.youtube.com/playlist?list=PLE549A038CF82905F Tutoriales de Programación ---------------------------------------------- Orientação a Objetos: http://www.fem.unicamp.br/~labaki/Python/ModuloB.pdf Aprendendo Django: http://www.aprendendodjango.com/ Banco de dados: http://www.python.org.br/wiki/BancosDeDadosSql Exemplos de programas prontos http://www.python.org.br/wiki/CookBook Learn Python in 10 minutes(inglês): http://www.korokithakis.net/tutorials/python/ Learn Python The Hard Way(inglês): http://learnpythonthehardway.org/book/ Alguns tutoriais: http://linuxresort.blogspot.com.br/p/e-uma-linguagem-de-alto-nivel-de-mexer.html Listas: http://www.lcg.ufrj.br/Cursos/algprog/Programando%20em%20Python%20-%20Listas.pdf Introdução ao QT4(inglês): http://www.rkblog.rk.edu.pl/w/p/introduction-pyqt4/ PyQT(inglês): http://www.commandprompt.com/community/pyqt/?page=pyqtbook http://www.async.com.br/projects/python/pnp/ http://aprenda-python.blogspot.com.br http://aprenda-python.blogspot.com.br/2010/09/curso-gratuito-de-python-em-portugues.html http://zetcode.com/ ---------------------------------------------- -Livros Python para desenvolvedores: http://ark4n.files.wordpress.com/2010/01/python_para_desenvolvedores_2ed.pdf Download de vários livros(inglês): http://it-ebooks.info/search/?q=Python&type=title 57 livros/apostilas sobre Python(torrent): http://kat.ph/python-book-collection-t6830161.html ##### # # Playing wavs with scipy # 2013aug12 # ##### # «scipy-wav» (to ".scipy-wav") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cp -v ~/TH/L/html5-audio.mp3 /tmp/in.mp3 avconv -y -i /tmp/in.mp3 /tmp/in.wav # (find-sh "file /tmp/in.wav") file /tmp/in.wav * (eepitch-python) * (eepitch-kill) * (eepitch-python) import scipy wavfile = "/tmp/in.wav" from scipy.io import wavfile as w amostras = w.read(wavfile)[1] .. usa o scipy.io para abrir o wav from scipy.io import wavfile as w amostras = w.read('foo.wav')[1] se quiser uma lib mais porreta, tem a pysndobj e pyo <edrx> can anyone recommend me an audio library for python in which I can play sounds and use the repl at the same time? for example, one in which I can read the value of nowplaying1.currentTime, and in which changing that value would make the player skip to another position... <edrx> alguem pode me recomendar alguma biblioteca pra python na qual eu consiga tocar arquivos de audio e rodar a repl ao mesmo tempo? <edrx> o que eu queria fazer era o seguinte: deem uma olhada em http://angg.twu.net/html5-audio.html - os links do final tocam um arquivo mp3 a partir de um certo ponto... e o player de audio roda em paralelo com o javascript console e com a parte do browser que interpreta cliques e outros eventos na pagina html renderizada... <edrx> isto talvez seja uma pergunta boba, mas la vai... <edrx> meu arquivo /tmp/in.wav parece ser um arquivo WAV todo certinho... acabei de cria-lo com ffmpeg a partir de um mp3, e "file /tmp/in.wav" diz isto: <edrx> /tmp/in.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz <edrx> mas ai' eu rodo isto... <edrx> import scipy <edrx> wavfile = "/tmp/in.wav" <edrx> from scipy.io import wavfile as w <edrx> amostras = w.read(wavfile)[1] <edrx> e ganho: <edrx> /usr/lib/python2.7/dist-packages/scipy/io/wavfile.py:31: WavFileWarning: Unfamiliar format bytes <edrx> warnings.warn("Unfamiliar format bytes", WavFileWarning) <edrx> e quando eu tento examinar o "amostras" ganho isto: <edrx> NameError: name 'amostras' is not defined <edrx> (obs: se eu desconectar do canal e' so' porque o meu cliente de irc ta' mal configurado, nao porque eu desisti...) http://freenet.mcnabhosting.com/python/pyPortAudio/ http://inventwithpython.com/blog/2010/09/01/the-top-10-pygame-tutorials/ http://pygametutorials.wikidot.com/ http://pymedia.org/tut/index.html http://pymedia.org/tut/src/play_wav.py.html http://rope.sourceforge.net/ropemacs.html http://www.youtube.com/watch?v=EHvQG7dbk_8 RT 2011 - Screencast 08 - Python part 2 - Running Python Code http://www.youtube.com/watch?v=JhAF6puNTxI Audio in Python - introduction (Software Carpentry) (LOW-RES) http://www.youtube.com/watch?v=OMi-uN-6O1Q Emacs as a Python IDE http://www.youtube.com/watch?v=nnuEqzAAkHw pygame - tutorial part 1 https://pypi.python.org/pypi/PyAudio/ pygame # (find-status "python-pyaudio") # (find-vldifile "python-pyaudio.list") # (find-udfile "python-pyaudio/") # (find-status "python-rope") # (find-vldifile "python-rope.list") # (find-udfile "python-rope/") # (find-status "python-ropemacs") # (find-vldifile "python-ropemacs.list") # (find-udfile "python-ropemacs/") # (find-status "pymacs") # (find-vldifile "pymacs.list") # (find-udfile "pymacs/") ##### # # pip # 2019aug03 # ##### # «pip» (to ".pip") # https://linuxize.com/post/how-to-install-pip-on-debian-9/ # https://pip.pypa.io/en/stable/user_guide/ # https://www.tecmint.com/install-pip-in-linux/ # (find-zsh "apt-file search bin/pip") # (find-zsh "installeddebs | sort | grep pip") # (find-zsh "availabledebs | sort | grep pip") # (find-zsh "availabledebs | sort | grep python | grep pip") # (find-angg ".zshrc" "pip-path") # (find-status "python3-pip") # (find-vldifile "python3-pip.list") # (find-udfile "python3-pip/") # (find-fline "/usr/lib/python3/dist-packages/pip/") python-pip: /usr/bin/pip python-pip: /usr/bin/pip2 python3-pip: /usr/bin/pip3 * (eepitch-shell2) apti python-pip apti python3-pip * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) pip3 pip3 install ipython pip3 install youtube-dl ##### # # pip3-upgrade # 2022may01 # ##### # «pip3-upgrade» (to ".pip3-upgrade") # (find-sh "pip3 --help") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) pip3 --upgrade pip3 list pip3 list | awk 'NR > 2 {print $1}' | tee /tmp/o pip3 install $(cat /tmp/o) pip3 install --upgrade $(cat /tmp/o) Requirement already satisfied: dblatex in /usr/lib/python3/dist-packages (0.3.12) Collecting dblatex Downloading dblatex-0.3.10.tar.bz2 (1.7 MB) |████████████████████████████████| 1.7 MB 12.5 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_0e48fa1858794329b03ea0964192e516/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_0e48fa1858794329b03ea0964192e516/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-_10_4xy3 cwd: /tmp/pip-install-xljt60ni/dblatex_0e48fa1858794329b03ea0964192e516/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_0e48fa1858794329b03ea0964192e516/setup.py", line 86 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/a8/1c/a07b54389399ac0c014c175936eb142f562468c607150a2df3e94d365611/dblatex-0.3.10.tar.bz2#sha256=56fee45ef3c242c4800bad20c5aeb934b31ba0894bdf86275b60b2e7b2f4cb8e (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.9.tar.bz2 (1.7 MB) |████████████████████████████████| 1.7 MB 9.7 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_05d15e3c8c7b486294be3e83d8466af9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_05d15e3c8c7b486294be3e83d8466af9/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-85z5503m cwd: /tmp/pip-install-xljt60ni/dblatex_05d15e3c8c7b486294be3e83d8466af9/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_05d15e3c8c7b486294be3e83d8466af9/setup.py", line 86 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/51/1b/688fcc3766dda4b3c1b90ba5f77584bf716fd63b160653983635baf1d324/dblatex-0.3.9.tar.bz2#sha256=493f7f8f6234794379e47560ec24c9abcb4bd5bdc9c4bd659175046a33211223 (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.8.1.tar.bz2 (1.6 MB) |████████████████████████████████| 1.6 MB 9.8 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_63aa375a01c1405c982bb4989a50333c/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_63aa375a01c1405c982bb4989a50333c/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-vlneou_m cwd: /tmp/pip-install-xljt60ni/dblatex_63aa375a01c1405c982bb4989a50333c/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_63aa375a01c1405c982bb4989a50333c/setup.py", line 86 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/d1/05/c9f5d1ead06d29d4dfa23fd4d406fd742ee7556670798edc97e28bedd23a/dblatex-0.3.8.1.tar.bz2#sha256=f2716eb47d50d8c8d5588592c50e414ecda4480e92cd82086cdc47e2d3df3947 (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.7.tar.bz2 (1.5 MB) |████████████████████████████████| 1.5 MB 11.1 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_9a202530b6b740e68154c2e8807b78d0/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_9a202530b6b740e68154c2e8807b78d0/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-q1vjpfn9 cwd: /tmp/pip-install-xljt60ni/dblatex_9a202530b6b740e68154c2e8807b78d0/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_9a202530b6b740e68154c2e8807b78d0/setup.py", line 86 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/01/ae/cce6b462aa6b25e5e80dfb42cb7d2888f5b3a82efbf6f0dd54996e3d681e/dblatex-0.3.7.tar.bz2#sha256=4e868fe5c481467ab33e1e0e7f2db7477d9e979084aea4256f63eb4942b438fe (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.6.tar.bz2 (1.5 MB) |████████████████████████████████| 1.5 MB 11.2 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_879b203a2ad943b0bcdd47368d2f3061/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_879b203a2ad943b0bcdd47368d2f3061/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-o04bfzlk cwd: /tmp/pip-install-xljt60ni/dblatex_879b203a2ad943b0bcdd47368d2f3061/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_879b203a2ad943b0bcdd47368d2f3061/setup.py", line 86 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/22/dd/3574e172fead961907274bd6f3a7e59d603f8916488db4f9fc0a4ac1fa4f/dblatex-0.3.6.tar.bz2#sha256=31b3105180ed79fad0ac81c7d32dafd941d040b99ae359f0149171241f2447ce (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.5.tar.bz2 (1.4 MB) |████████████████████████████████| 1.4 MB 10.9 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_d8b1b62ceb974563bd5c4f91a7012116/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_d8b1b62ceb974563bd5c4f91a7012116/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-bxo1ci5c cwd: /tmp/pip-install-xljt60ni/dblatex_d8b1b62ceb974563bd5c4f91a7012116/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_d8b1b62ceb974563bd5c4f91a7012116/setup.py", line 86 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/c1/14/cc893aa9124725960934129f924eca3c46a6f868d80ea9ea2cdf5f083a0b/dblatex-0.3.5.tar.bz2#sha256=faf8373231f4cf94c20194c8282cb7b2bad9b507d3ef678d105906922682299d (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.4.tar.bz2 (1.5 MB) |████████████████████████████████| 1.5 MB 11.2 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_624499ccbd66436d982db296b52e9558/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_624499ccbd66436d982db296b52e9558/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-aozqepgp cwd: /tmp/pip-install-xljt60ni/dblatex_624499ccbd66436d982db296b52e9558/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_624499ccbd66436d982db296b52e9558/setup.py", line 86 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/84/b4/062816b3592a13e0955175d6880c6edd89f387f11d590c15232296ef1603/dblatex-0.3.4.tar.bz2#sha256=5ca67bf5e51bd6ad94426524c599f41b9f00c5589e7fba7ebfb6bcac6d8ba3cf (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.3.tar.bz2 (1.4 MB) |████████████████████████████████| 1.4 MB 9.3 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_6dcb9ae4601e49a3871a07b2fb101e27/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_6dcb9ae4601e49a3871a07b2fb101e27/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-kgf47wcx cwd: /tmp/pip-install-xljt60ni/dblatex_6dcb9ae4601e49a3871a07b2fb101e27/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_6dcb9ae4601e49a3871a07b2fb101e27/setup.py", line 85 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/80/0d/a5e5eada0a9443939a3b44366aa7c671525f7a22d5b2debc6f49e971f481/dblatex-0.3.3.tar.bz2#sha256=5903255da7ac15f0f090a16b577f129c0beabdc074b4b2a40bc43fc932ae7031 (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.2.tar.bz2 (1.2 MB) |████████████████████████████████| 1.2 MB 11.2 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_187e182fb3d945dbb2595180567d2dd7/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_187e182fb3d945dbb2595180567d2dd7/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-kyg9hnjz cwd: /tmp/pip-install-xljt60ni/dblatex_187e182fb3d945dbb2595180567d2dd7/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_187e182fb3d945dbb2595180567d2dd7/setup.py", line 85 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/bb/1b/92a287d4ca36c378d1fa7bc76c5922e525d1b0b4a495bd4d7b90e81f2114/dblatex-0.3.2.tar.bz2#sha256=7a25bc0bbb990100b365e9dbbd118d4986e0a1eec595b3c2086da534436cdd9b (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Downloading dblatex-0.3.1.1.tar.bz2 (1.2 MB) |████████████████████████████████| 1.2 MB 9.7 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xljt60ni/dblatex_be89b4d5fb214d2f892d643248cd699b/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xljt60ni/dblatex_be89b4d5fb214d2f892d643248cd699b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-jxgn5162 cwd: /tmp/pip-install-xljt60ni/dblatex_be89b4d5fb214d2f892d643248cd699b/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-xljt60ni/dblatex_be89b4d5fb214d2f892d643248cd699b/setup.py", line 82 print self._package_base ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(self._package_base)? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/e6/bd/887d042a621631938432678e92c2314b89c682fd39acefbffe6ac27dc3d0/dblatex-0.3.1.1.tar.bz2#sha256=7b323f27c75e717536dd1f80605c40a2da187d0a50b814af2013a0f5a64c6d64 (from https://pypi.org/simple/dblatex/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ##### # # Pip as root (don't!) # 2019sep25 # ##### # «pip-as-root» (to ".pip-as-root") # (find-fline "~/LOGS/2019sep25.python" "when you run sudo pip") # (find-fline "/usr/local/lib/") # (find-fline "/usr/local/lib/python2.7/dist-packages/") # (find-fline "/usr/local/lib/python3.5/dist-packages/") # (find-asrootfile "/usr/local/lib/python3.5/dist-packages/") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # (find-man "pip3") strace -o /tmp/s2 pip strace -o /tmp/s3 pip3 # (find-fline "/tmp/s2") # (find-sh "sort /tmp/s2") # (find-sh "sort /tmp/s2 | grep -v ENOENT") # (find-sh "sort /tmp/s2 | grep -v ENOENT | grep open") # (find-sh "sort /tmp/s3 | grep -v ENOENT | grep open") # (find-sh "cat /tmp/s3 | grep -v ENOENT | grep open") # (find-fline "~/.local/lib/python2.7/site-packages/") # (find-fline "~/.local/lib/python3.5/site-packages/") # (find-fline "~/.local/lib/") # (find-asrootfile "/usr/local/lib/python3.5/" "dist-packages/") # (find-asrootfile "/home/edrx/.local/lib/python3.5/") # (find-asrootfile "/home/edrx/.local/lib/python3.5/" "site-packages/") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) pip3 pip3 install ipython # (find-sh "pip3") # (find-sh "pip3 list") # (find-sh "pip3 show pycurl") ##### # # pip-from-git # 2019sep25 # ##### # «pip-from-git» (to ".pip-from-git") # https://packages.debian.org/sid/python-pip # https://packages.debian.org/sid/python3-pip # https://en.wikipedia.org/wiki/Pip_(package_manager) # https://pip.pypa.io/en/stable/ # https://pip.pypa.io/en/stable/user_guide/ # https://pip.pypa.io/en/stable/reference/ # https://pip.pypa.io/en/stable/quickstart/ # https://github.com/pypa/pip # (find-git-links "https://github.com/pypa/pip" "pipgit") # (find-fline "~/LOGS/2019sep25.pypa") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # rm -Rfv ~/usrc/pip/ cd ~/usrc/ git clone https://github.com/pypa/pip cd ~/usrc/pip/ git branch --list -a git for-each-ref PAGER=cat git log --oneline --graph --all -20 # (find-fline "~/usrc/") # (find-fline "~/usrc/pip/") # (find-gitk "~/usrc/pip/") # (code-c-d "pipgit" "~/usrc/pip/") # (find-pipgitfile "") # (find-pipgitfile "tox.ini") # (find-pipgitfile "tox.ini" "[testenv:docs]") <edrx> hi, I just downloaded the pip source from <https://github.com/pypa/pip> because I wanted to have a local copy of the docs, but I can't figure out how to compile it... I was expecting to be able to do something like "make docs", but it seems that it uses other tools... any hints? <altendky> edrx: https://github.com/pypa/pip/blob/master/tox.ini#L36-L41 # (find-man "sphinx-build") # (find-pipgitfile "docs/html/") # cd ~/usrc/pip/ sphinx-build -W -d _envtmpdir_/doctrees/html -b html docs/html docs/build/html sphinx-build -W -d _envtmpdir_/doctrees/man -b man docs/man docs/build/man -c docs/html # # Extension error: # Could not import extension pip_sphinxext (exception: No module named 'pip._internal') ##### # # tox # 2019sep25 # ##### # «tox» (to ".tox") # https://en.wikipedia.org/wiki/Tox_(Python_testing_wrapper) # (find-status "tox") # (find-vldifile "tox.list") # (find-udfile "tox/") # (find-fline "/usr/share/doc/tox/html/") # file:///usr/share/doc/tox/html/index.html # (find-man "1 tox") tox -h apt-cache show tox apt-cache search tox apt-cache depends tox apt-cache rdepends tox ##### # # virtualenv (2019) # 2019sep25 # ##### # «virtualenv» (to ".virtualenv") # (find-fline "~/LOGS/2019sep25.python2" "virtualenv -p") # (find-status "virtualenv") # (find-vldifile "virtualenv.list") # (find-udfile "virtualenv/") # (find-status "python3-virtualenv") # (find-vldifile "python3-virtualenv.list") # (find-udfile "python3-virtualenv/") # (find-man "1 virtualenv") # (find-man "1 virtualenv" "-p PYTHON_EXE") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) sudo apt install virtualenv * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rv /tmp/myenv/ cd /tmp/ virtualenv -p python3 myenv |& tee ov myenv/bin/pip install tox |& tee opi # # (find-fline "/tmp/myenv/") # (find-fline "/tmp/myenv/bin/") # myenv/bin/python myfile.py ##### # # poetry # 2019sep25 / 2023aug01 # ##### # «poetry» (to ".poetry") # https://python-poetry.org/docs/master/#installing-with-the-official-installer * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rfv ~/.poetry/ cd /tmp/ # curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python # curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3 curl -sSL https://install.python-poetry.org | python3 - # (find-fline "~/.poetry/") # (find-fline "~/.poetry/env") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) source ~/.poetry/env cd /tmp/ poetry new --src myproject # Old: # (find-fline "~/LOGS/2019sep25.python2" "poetry instead of setup.py") # (find-fline "~/LOGS/2019sep25.python2" "poetry new --src") # http://blog.habnab.it/blog/2013/07/21/python-packages-and-you/ ##### # # pip, requests, virtualenv (for facebook-sdk) # 2014aug18 # ##### # «requests» (to ".requests") # (find-zsh "availabledebs | sort | grep requ") # (find-status "python-pip") # (find-vldifile "python-pip.list") # (find-udfile "python-pip/") # (find-udfile "python-pip/usage.txt.gz") # (find-udfile "python-pip/usage.rst") # (find-status "python3-requests") # (find-vldifile "python3-requests.list") # (find-udfile "python3-requests/") # (find-status "python-virtualenv") # (find-vldifile "python-virtualenv.list") # (find-udfile "python-virtualenv/") # (find-pip3-links "requests") pip3 install requests # Requirement already satisfied: requests in /usr/lib/python3/dist-packages (2.25.1) # (code-c-d "requests" "/usr/lib/python3/dist-packages/requests/") # (find-requestsfile "") # (find-fline "/usr/lib/python3/dist-packages/") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import importlib.metadata, requests, pprint r = requests.get("https://pypi.org/pypi/requests/json") d = r.json() pprint.pprint(d["info"]) pprint.pprint(d["info"]["home_page"]) importlib.metadata.distribution('requests').read_text('top_level.txt').splitlines() * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) PAGER=cat python3 import requests help(requests) help(help) r = requests.get("https://pypi.org/pypi/requests/json") # print(r.json()) pprint.pprint(r.json()) * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) PAGER=cat python3 -c ' import requests, pprint r = requests.get("https://pypi.org/pypi/requests/json") d = r.json() d["info"] data= resp.json(); data["info"]["homepage"] pprint.pprint(r.json()) pprint.pprint(r.json().info) pprint.pprint(r.json()["info"]) # (find-sh "curl -s https://pypi.org/pypi/requests/json | jq") # (find-man "jq") this: lua5.1 -e 'import requests; r = requests.get("https://pypi.org/pypi/requests/json"); pprint.pprint(r.json())' r = requests.get('https://www.python.org') <grym> ok, then `resp = requests.get("https://pypi.org/pypi/requests/json"); print(resp.json())` * (eepitch-shell2) apti python-pip sudo apt-get install python-pip python-requests python-virtualenv sudo pip install facebook-sdk # sudo apt-get install python-dev-all # https://pypi.python.org/pypi/requests # http://www.pip-installer.org/ # http://www.virtualenv.org/ # https://virtualenv.pypa.io/en/latest/ # (find-fline "/usr/local/lib/python2.7/dist-packages/") # (find-fline "/usr/local/lib/python2.7/dist-packages/facebook.py") ##### # # PyPi # 2019may21 # ##### # «pypi» (to ".pypi") # https://pypi.org/ # https://packaging.python.org/tutorials/installing-packages/ # (find-zsh "installeddebs | sort | grep pip") # (find-zsh "availabledebs | sort | grep pip") # https://packaging.python.org/guides/installing-using-linux-tools/ <BrenBarn> there's some info about pypi api here: https://warehouse.pypa.io/api-reference/json.html aptrm python-pygments python3-pygments * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd /tmp/ wget https://bootstrap.pypa.io/get-pip.py sudo python3 get-pip.py --prefix=/usr/local/ sudo pip install -U sphinx sudo pip install -U pygments ##### # # facebook-sdk # 2014aug18 # ##### # «facebook-sdk» (to ".facebook-sdk") # (find-angg ".emacs" "pyfb") # https://developers.facebook.com/docs/other-sdks # https://github.com/pythonforfacebook/facebook-sdk # http://pythonforfacebook.com/ # (find-git-links "https://github.com/pythonforfacebook/facebook-sdk" "pyfb") # (find-pyfbfile "") # (find-pyfbfile "docs/") # (find-pyfbfile ".travis.yml" "FACEBOOK_APP_ID=") # (find-pyfbfile "examples/") # (find-pyfbfile "examples/get_posts.py") # (find-pyfbfile "docs/install.rst") # (find-pyfbfile "docs/install.rst" "requests") # (find-pyfbfile "docs/install.rst" "pip") # (find-pyfbfile "docs/install.rst" "virtualenv") # (find-fline "/usr/local/lib/python2.7/dist-packages/") # (find-fline "/usr/local/lib/python2.7/dist-packages/facebook.py") ##### # # textwrap # 2014aug30 # ##### # «textwrap» (to ".textwrap") # http://pymotw.com/2/textwrap/ # http://pymotw.com/2/articles/text_processing.html#article-text-processing # http://docs.python.org/lib/module-textwrap.html ##### # # easyhtmlparser # 2014aug28 # ##### # «easyhtmlparser» (to ".easyhtmlparser") # http://easyhtmlparser.sourceforge.net/ http://sourceforge.net/projects/easyhtmlparser/files/ * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # (find-fline "~/usrc/ehp-1.3/") rm -Rv ~/usrc/ehp-1.3/ tar -C ~/usrc/ -xvzf ~/tmp/ehp-1.3.tar.gz cd ~/usrc/ehp-1.3/ ;; (code-c-d "ehp" "~/usrc/ehp-1.3/") ;; (find-ehpfile "") # python setup.py install python setup.py install --user # Writing /home/edrx/.local/lib/python2.7/site-packages/ehp-1.3.egg-info # (find-fline "~/.local/lib/python2.7/site-packages/") # (find-fline "~/.local/lib/python2.7/site-packages/ehp-1.3.egg-info") git clone ssh://olliveira@git.code.sf.net/p/easyhtmlparser/code easyhtmlparser-code ##### # # oilercode # 2014aug28 # ##### # «oilercode» (to ".oilercode") # (find-git-links "git://git.code.sf.net/p/oiler/code" "oilercode") # (code-c-d "oilercode" "~/usrc/code/") # (find-oilercodefile "") # (find-oilercodefile "python/edu/") # (code-c-d "oilercode" "~/usrc/code/") # (find-oilercodefile "") # (find-oilercodefile "python/edu/") # (find-oilercodefile "python/edu/run") # (find-oilercodefile "python/edu/fbtxt.py") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd ~/usrc/code/python/edu/ git pull --depth 1 cd ~/usrc/code/python/edu/ ls python fbtxt.py fb2 python fbtxt.py fb2ah >> fb3-txt vy fb3-txt url = "https://www.facebook.com/sergio.martins.984991/posts/10152616093738086" fname = "posts_sergio.martins.984991_10152616093738086" if not file_exists(fname..".raw") then end data = curl(url) ##### # # faceutils (by Tau) # 2014aug30 # ##### # «faceutils» (to ".faceutils") # (find-angg ".emacs" "faceutils") # (find-fline "~/usrc/faceutils-code/") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # (find-fline "~/.local/lib/python2.7/site-packages/" "faceutils") rm -Rv ~/.local/lib/python2.7/site-packages/faceutils* rm -Rfv ~/usrc/faceutils-code/ cd ~/usrc/ git clone git://git.code.sf.net/p/faceutils/code faceutils-code cd ~/usrc/faceutils-code/ python setup.py install --user |& tee osi cd ~/usrc/faceutils-code/ git pull python setup.py install --user |& tee osi # (find-gitk "~/usrc/faceutils-code/") # (find-faceutilsfile "") # «faceutils-wrap» (to ".faceutils-wrap") * (eepitch-python) * (eepitch-kill) * (eepitch-python) from faceutils import * from textwrap import wrap MAX = 69 dir = "/home/edrx/usrc/faceutils-code/wget/" fname = dir + "posts_ortelladopablo_759874930744749.wget" data0 = open(fname, 'r').read() data = normalize(data0) dom = Html().feed(data) post = str(extract_text(dom)) post = '\n'.join(wrap(post, MAX)) post = post.decode('string-escape') print post xs, ns = extract_comment(data) ns = map(lambda it: '\n'.join(wrap(it, MAX)), ns) co = '%s\n%s\n%s\n%s' % ("People who commented.", xs, 'Commentaries.', ns) co = co.decode('string-escape') print co # (find-fline "~/usrc/faceutils-code/") cd ~/usrc/faceutils-code/ data = normalize(data0) dom = Html().feed(data) print extract_text(dom) print extract_comment(data) fname = dir + "photofs_10204370918135974_np.104536042.1523735650.wget" (code-c-d "faceutils" "~/usrc/faceutils-code/") ;; (find-faceutilsfile "") ;; (find-faceutilsfile "faceutils.py") ;; (find-faceutilsfile "fbtxt") ;; (find-faceutilsfile "wget/") # (find-fline "/tmp/faceutils-code/") Cloning into 'faceutils-code'... warning: You appear to have cloned an empty repository. ##### # # Translating string.gsub to Python # 2014sep06 # ##### # «string.gsub.old» (to ".string.gsub") # (find-angg "fbcache/p.py" "regexps") * (eepitch-python) * (eepitch-kill) * (eepitch-python) from re import sub from re import search REG = '[WR]' DATA ='/W/photos/W/WR' def replace(match): REP = { 'W':'([^/]+)', 'R':'(.*)'} return REP[match.group(0)] print sub(REG, replace, DATA) REG = "/([^/]+)/photos/([^/]+)/([^/]+)(.*)" DATA = "/398254483624546/photos/a.398287033621291.1073741830.398254483624546/480321305417863/?type=1" item = search(REG, DATA) print item.groups() "photos_%s_%s_%s" % item.groups()[:3] "photos_%s_%s_%s".count("%") # «string.gsub» (to ".string.gsub") * (eepitch-python) * (eepitch-kill) * (eepitch-python) # (find-faceutilsfile "url.py") # (find-angg "fbcache/p.py") import re def string_format (fmt, tuple): return fmt % (tuple[:fmt.count("%s")]) def string_match (str, r): return re.search(r, str).groups() r = "/([^/]+)/photos/([^/]+)/([^/]+)(.*)" r = "^/([^/]+)/photos/([^/]+)/([^/]+)(.*)$" str = "/398254483624546/photos/a.3.30.39824546/480863/?type=1" str = "/398254483624546/photos/a.3.30.39824546/480863/?type=1" m = re.search(r, str) print m print m.groups() print re.search(r, str).groups() re.escape(r) # Test: string_format("<%s_%s>", ("aa", "bb", "cc")) # string_format(fmt, string_match(str, r)) lambda (m): return tbl[m.group(0)] item = re.search(indi, str) try: xs = item.groups() except AttributeError: pass else: return indj % xs[:indz] import re search(re, str).groups() tbl = {"a":"AA", "b":"BB"} re.search def string_gsub_s (str, re, repl_str): return def string_gsub_f (str, re, repl_f): return def string_gsub_t (str, re, repl_str): return f = lambda def string_match (str, re): return # (find-pydoc "howto/regex") # (find-pydoc "howto/regex#search-and-replace") # (find-pydoc "library/re") # (find-pydoc "library/stdtypes#str.count") # (find-pydoc "reference/executionmodel#naming") # (find-pydoc "reference/expressions#lambda") ##### # # encoding # 2014sep11 # ##### # «encoding» (to ".encoding") # SyntaxError: Non-ASCII character '\xc2' in file foo.py on line 3, # but no encoding declared; see # http://www.python.org/peps/pep-0263.html # for details # (find-anggfile "fbcache/p.py" "vim: set fileencoding=latin-1") ##### # # Scope (of variables) # 2014sep21 # ##### # «scope» (to ".scope") # (find-pydoc "reference/executionmodel") # (find-pydoc "tutorial/classes") # (find-pydoc "tutorial/classes#python-scopes-and-namespaces") ##### # # import # 2014oct01 # ##### # «import» (to ".import") # (find-pydoc "tutorial/index") # (find-pydoc "reference/import") # (find-pydoc "reference/simple_stmts#the-import-statement") # (find-pydoc "tutorial/modules") # (find-pydoc "tutorial/modules#more-on-modules") # (find-pydocr "tutorial/modules#more-on-modules" "from fibo import *") # (find-pydoc "library/importlib") # (find-pydoc "library/importlib#module-importlib") # (find-pydoc "library/importlib#importlib.import_module") # https://github.com/drathier/stack-overflow-import # https://stackoverflow.com/questions/67631/how-do-i-import-a-module-given-the-full-path * (eepitch-python) * (eepitch-kill) * (eepitch-python) import sys sys.path.append("/home/edrx/luatree/") import luatree ##### # # importlib # 2022aug23 # ##### # «importlib» (to ".importlib") # (find-pydoc "library/importlib") # (find-pydoc "library/importlib.metadata") # (find-pydoc "library/importlib.metadata#distributions") # (find-pydocw "library/importlib.metadata#distributions") # (find-pydoc "library/importlib.metadata#package-distributions") # (find-pydocw "library/importlib.metadata#package-distributions") # (find-fline "~/LOGS/2022oct19.python" "importlib.metadata") # (find-fline "~/LOGS/2024mar04.python") # (find-fline "~/LOGS/2024mar04.python2") # (find-importlib-links "PIL") # (find-pip3-links "sphinx") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import importlib.metadata, pprint dist = importlib.metadata.distribution("sphinx") dist.read_text('top_level.txt').splitlines() pprint.pprint(dist.files) md = dist.metadata md.keys() md["Name"] md["Version"] md["Summary"] md["Home-Page"] # (find-fline "~/LOGS/2022aug22.emacs" "it's actually importlib") # https://cyber.com.au/~twb/tmp/secrets.pyz # (find-fline "$S/https/cyber.com.au/~twb/tmp/" "secrets.pyz") # (find-fline "$S/https/cyber.com.au/~twb/tmp/secrets.pyz") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # (find-fline "~/usrc/secrets/") rm -Rv ~/usrc/secrets/ mkdir ~/usrc/secrets/ cd ~/usrc/secrets/ unzip $S/https/cyber.com.au/~twb/tmp/secrets.pyz * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) import importlib.metadata from pprint import pprint d = importlib.metadata.distribution('sphinx') pprint(d.files) d.read_text('top_level.txt').splitlines() dist.files[:3] ##### # # inspect # 2020oct15 # ##### # «inspect» (to ".inspect") # https://pymotw.com/2/inspect/ # https://www.tutorialspoint.com/inspect-live-objects-in-python # https://gist.github.com/amitsaha/3486802 # (find-sh "locate python | grep inspect") # (find-pydoc "library/inspect") # (find-pydoc "library/inspect#module-inspect") # (find-pydoc "library/inspect#classes-and-functions") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import re import inspect # import pprint from pprint import pprint re type(re) pprint(inspect.getmembers(re)) # (find-fline "~/LOGS/2022jun02.emacs") # https://bpa.st/E2HQ * (eepitch-python) * (eepitch-kill) * (eepitch-python) import inspect class Foo: def __init__(self, x): self.x = x my_foo = Foo(x=1) inspect.getmembers(my_foo) dir(my_foo) repr(my_foo) ##### # # re # 2020oct15 # ##### # «re» (to ".re") # (find-books "__comp/__comp.el" "python-downey") * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) import re re type(re) ##### # # re.sub # 2019aug04 # ##### # «re.sub» (to ".re.sub") # (find-pydoc "library/re#re.sub") # (find-man "python3") # (find-angg ".pythonrc.py") * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) import re re type(re) ee_dofile("/tmp/foo.py") ##### # # u8_to_l1 # 2014oct13 # ##### # «u8_to_l1» (to ".u8_to_l1") # (find-angg "LUA/lua50init.lua" "u8_to_l1") # (find-fline "~/LOGS/2014oct12.eev") # (find-fline "~/LOGS/2014oct12.python") # http://nedbatchelder.com/text/unipain.html # https://www.youtube.com/watch?v=sgHbC6udIqc # (find-youtubedl-links "/sda5/videos/" "Pragmatic_Unicode_or_How_do_I_stop_the_pain" "sgHbC6udIqc" ".mp4" "pragmaticunicode") # (code-video "pragmaticunicodevideo" "/sda5/videos/Pragmatic_Unicode_or_How_do_I_stop_the_pain-sgHbC6udIqc.mp4") # (find-pragmaticunicodevideo) # (find-pragmaticunicodevideo "0:00") # (find-pragmaticunicodevideo "9:16" "Python 2") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import re str1 = u'\xc3\x80' str2 = u'abc \xc3\x80 def' '\xc3\x80' u'\xc3\x80' chr(192) def u8_to_l1(str): f = lambda (m): chr(ord(m.group(0)[1]) + 64) return re.sub("\xc3[\x80-\xbf]", f, str) u8_to_l1('\xc3\x80') u8_to_l1(u'\xc3\x80') * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) str1 = '\xc3\x80' str2 = 'abc \xc3\x80 def' '\xc3\x80' '\xc3\x80' chr(192) # file:///usr/share/doc/python3.2/html/reference/expressions.html#lambda def u8_to_l1(str): f = lambda m: chr(ord(m.group(0)[1]) + 64) return re.sub("\xc3[\x80-\xbf]", f, str) u8_to_l1('\xc3\x80') u8_to_l1(u'\xc3\x80') ##### # # dict methods # 2014oct25 # ##### # «dict» (to ".dict") # (find-pydoc "tutorial/datastructures#dictionaries") # (find-pydoc "library/stdtypes#mapping-types-dict") # (find-pydoc "library/stdtypes#dict.items") # (find-pydoc "c-api/dict") * (eepitch-python) * (eepitch-kill) * (eepitch-python) tel = {'jack': 4098, 'sape': 4139} tel['guido'] = 4127 tel tel['jack'] del tel['sape'] tel['irv'] = 4127 tel tel.keys() 'guido' in tel dict([('sape', 4139), ('guido', 4127), ('jack', 4098)]) {x: x**2 for x in (2, 4, 6)} dict(sape=4139, guido=4127, jack=4098) ##### # # print # 2016jul23 # ##### # «print» (to ".print") # https://docs.python.org/2.7/library/functions.html#print # https://docs.python.org/2.7/reference/simple_stmts.html # https://docs.python.org/2.7/reference/simple_stmts.html#the-print-statement # (find-pydoc "library/functions#print") # (find-pydoc "whatsnew/3.0#print-is-a-function") # (find-pydoc "reference/simple_stmts#the-print-statement") # Old: print "The answer is", 2*2 # New: print("The answer is", 2*2) ##### # # Tuples # 2016jul23 # ##### # «tuples» (to ".tuples") # «tut-tuples» (to ".tut-tuples") # (find-pydoc "tutorial/datastructures") # (find-pydoc "tutorial/datastructures#tuples-and-sequences") # (to "print") * (eepitch-python) * (eepitch-kill) * (eepitch-python) t = 12345, 54321, 'hello!' t[0] t # Tuples may be nested: u = t, (1, 2, 3, 4, 5) u # Tuples are immutable: t[0] = 88888 # but they can contain mutable objects: v = ([1, 2, 3], [3, 2, 1]) v ##### # # Tutorial: def (and local variables) # 2016jul23 # ##### # «tut-def» (to ".tut-def") # «def» (to ".def") # (find-pydoc "tutorial/controlflow#defining-functions") # (find-pydocr "tutorial/controlflow#defining-functions") # (find-pydoc "reference/compound_stmts#def") # (find-pydoc "reference/executionmodel#naming") # (find-downeytppage (+ 22 61) "6. Fruitful Functions.") # https://docs.python.org/3/tutorial/controlflow.html#defining-functions # https://docs.python.org/2.7/tutorial/controlflow.html#defining-functions * (eepitch-python) * (eepitch-kill) * (eepitch-python) def fib(n): # write Fibonacci series up to n """Print a Fibonacci series up to n.""" a, b = 0, 1 while a < n: print a, # print(a, end=' ') a, b = b, a+b # print() # Now call the function we just defined: fib(2000) fib f = fib f(100) fib(0) print(fib(0)) def fib2(n): # return Fibonacci series up to n """Return a list containing the Fibonacci series up to n.""" result = [] a, b = 0, 1 while a < n: result.append(a) # see below a, b = b, a+b return result f100 = fib2(100) # call it f100 # write the result ##### # # Comprehension # 2016aug23 # ##### # «comprehension» (to ".comprehension") # (find-pydoc "tutorial/datastructures#list-comprehensions") # (find-pydoc "tutorial/datastructures#nested-list-comprehensions") # http://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/ # Also: dict comprehensions, set comprehensions ##### # # Multiline comments # 2019jun15 # ##### # «multiline-comments» (to ".multiline-comments") # https://stackoverflow.com/questions/7696924/way-to-create-multiline-comments-in-python ##### # # lambda # 2019jun15 # ##### # «lambda» (to ".lambda") # (find-pydoc "reference/expressions#lambda") # (find-pydoc "reference/expressions#expression-lists") * (eepitch-python) * (eepitch-kill) * (eepitch-python) lambda: 2+3 * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) lambda: 2+3 # (find-angg ".pythonrc.py") ##### # # after # 2019jul02 # ##### # «after» (to ".after") # https://gitlab.com/juanmeleiro/after * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rfv ~/usrc/after/ cd ~/usrc/ git clone https://gitlab.com/juanmeleiro/after cd ~/usrc/after/ # (find-fline "~/usrc/") # (find-fline "~/usrc/after/") # (code-c-d "after" "~/usrc/after/") # (find-afterfile "") # (find-afterfile "after") # (find-gitk "~/usrc/after/") ##### # # graphics.py # 2019jul17 # ##### # «graphics.py» (to ".graphics.py") # https://www.youtube.com/watch?v=R39vTAj1u_8 # (find-anggfile "PYTHON/gra.py") # https://mcsp.wartburg.edu/zelle/python/ # https://mcsp.wartburg.edu/zelle/python/graphics.py # https://mcsp.wartburg.edu/zelle/python/graphics/graphics/index.html # https://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf # (find-sh "cp -v $S/https/mcsp.wartburg.edu/zelle/python/graphics.py ~/PYTHON/") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) ##### # # python-for-cs1 # 2019jul17 # ##### # «python-for-cs1» (to ".python-for-cs1") # https://mcsp.wartburg.edu/zelle/python/ # Picking a Language for Introductory CS - Why I don't like Python () # https://medium.com/@drmarkclewis/picking-a-languages-for-introductory-cs-the-argument-againstpython-4331cca26cfa # https://dynamicsofprogramming.blogspot.com/2019/02/problems-with-python-for-introductory-cs.html ##### # # turtle # 2019jul17 # ##### # «turtle» (to ".turtle") # https://docs.python.org/3/library/turtle.html # (find-pydoc "library/turtle") * (eepitch-python) * (eepitch-kill) * (eepitch-python) from turtle import * color('red', 'yellow') begin_fill() while True: forward(200) left(170) if abs(pos()) < 1: break end_fill() done() ##### # # help # 2019jul17 # ##### # «help» (to ".help") # (find-pydoc "library/functions#help") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import os os.environ["PAGER"] = "cat" help(os) help(help) ##### # # Books about Python # 2019aug03 # ##### # «books» (to ".books") # (find-books "__comp/__comp.el" "python") # https://realpython.com/best-python-books/ # https://realpython.com/best-python-books/#fluent-python-clear-concise-and-effective-programming # https://realpython.com/best-python-books/#think-python # https://realpython.com/best-python-books/#fluent-python # https://stackabuse.com/the-best-python-books-for-all-skill-levels/ # https://hackr.io/blog/best-python-books-for-beginners-and-advanced-programmers ##### # # popen (is obsolete; use subprocess) # 2019aug03 # ##### # «popen» (to ".popen") # (find-books "__comp/__comp.el" "python") # (find-downeytppage (+ 22 171) "Pipes") # (find-pydoc "library/os#os.popen") # (find-pydoc "library/subprocess") # (find-pydoc "library/subprocess#popen-constructor") # (find-pydoc "library/subprocess#replacing-shell-pipeline") # (find-pydocr "library/subprocess#replacing-shell-pipeline") # (find-pydocr "library/subprocess#replacing-shell-pipeline" "stdin=p1.stdout") # (find-pydocw "library/subprocess#replacing-shell-pipeline" "stdin=p1.stdout") # (find-pydoc "library/subprocess#subprocess.PIPE") # (find-pydoc "library/subprocess#subprocess.Popen.communicate") # (find-pydoc "library/subprocess#subprocess.Popen.stdin") # (find-pydoc "library/subprocess#subprocess.run") # (find-pydoc "library/io#io.StringIO") # (find-angg "LUA/lua50init.lua" "getoutput") # (find-fline "~/LOGS/2022aug22.emacs" "text=True, check=True") * (eepitch-python) * (eepitch-kill) * (eepitch-python) import subprocess o = subprocess.run(["ls", "-l"]) o = subprocess.run(["ls", "-l", "/dev/null"], stdout=subprocess.PIPE) o = subprocess.run("ls -l /dev/null".split(), stdout=subprocess.PIPE) o o.stdout def getoutput(cmd): return subprocess.run(cmd.split(), stdout=subprocess.PIPE).stdout getoutput("ls -l /dev/null") subprocess.PIPE * (eepitch-python) * (eepitch-kill) * (eepitch-python) import subprocess import io p = subprocess.run("tac", input="a\nbb\nccc\n", stdout=subprocess.PIPE, text=True) p.stdout totac = io.StringIO() totac.write('a\nbb\nccc\n') p = subprocess.run("tac", stdin=subprocess.PIPE, stdout=subprocess.PIPE) p.stdin p.stdin.write('a\nbb\nccc\n') import subprocess p CompletedProcess(args='tac', returncode=0, stdout='abc') p = subprocess.run("tac", input=totac, stdout=subprocess.PIPE) p = subprocess.run("tac", stdin=totac, stdout=subprocess.PIPE) p = subprocess.run("tac", stdin=b'foo', stdout=subprocess.PIPE) p.stdin https://docs.python.org/3/library/subprocess.html#replacing-shell-pipeline # Traceback (most recent call last): # File "<stdin>", line 1, in <module> # File "/usr/lib/python3.9/subprocess.py", line 505, in run # with Popen(*popenargs, **kwargs) as process: # File "/usr/lib/python3.9/subprocess.py", line 829, in __init__ # errread, errwrite) = self._get_handles(stdin, stdout, stderr) # File "/usr/lib/python3.9/subprocess.py", line 1588, in _get_handles # p2cread = stdin.fileno() # io.UnsupportedOperation: fileno # https://0x0.st/oLSF.txt ##### # # bytes # 2019aug03 # ##### # «bytes» (to ".bytes") # (find-pydoc "library/functions#func-bytes") # (find-pydoc "library/functions#func-bytearray") # (find-pydoc "library/stdtypes#bytes") # (find-pydoc "library/stdtypes#binaryseq") # (find-pydoc "reference/lexical_analysis#strings") # (find-downeytppage (+ 22 170) "The result is a bytes object") # (find-downeytptext (+ 22 170) "The result is a bytes object") ##### # # split # 2019aug03 # ##### # «split» (to ".split") # file:///usr/share/doc/python3.5/html/library/stdtypes.html#str.split # file:///usr/share/doc/python2.7/html/glossary.html#term-universal-newlines # file:///usr/share/doc/python3.5/html/glossary.html#term-universal-newlines * (eepitch-python) * (eepitch-kill) * (eepitch-python) "Hello world ".split() ##### # # vararg-functions # 2019aug04 # ##### # «vararg-functions» (to ".vararg-functions") # https://www.python.org/dev/peps/pep-3102/ # file:///usr/share/doc/python3.5/html/reference/compound_stmts.html#function-definitions # If the form "*identifier" is present, it is initialized to a tuple # receiving any excess positional parameters, defaulting to the empty # tuple. ##### # # pandas # 2019sep18 # ##### # «pandas» (to ".pandas") # https://www.learndatasci.com/tutorials/python-pandas-tutorial-complete-introduction-for-beginners/ # https://www.pythonforengineers.com/introduction-to-pandas/ Introduction to Pandas with Practical Examples ##### # # Elpy, the Emacs Python IDE # 2019sep20 # ##### # «elpy» (to ".elpy") # <dale> VG234: I like https://github.com/jorgenschaefer/elpy. # (find-git-links "https://github.com/jorgenschaefer/elpy" "elpy") # https://github.com/jorgenschaefer/elpy # https://elpy.readthedocs.io/en/latest/index.html # https://medium.com/analytics-vidhya/managing-a-python-development-environment-in-emacs-43897fd48c6a # https://realpython.com/emacs-the-best-python-editor/ # https://news.ycombinator.com/item?id=35507001 REBL (datomic.com) # (find-epackage-links 'elpy "elpy" t) # (find-epackage 'elpy) * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rfv ~/usrc/elpy/ cd ~/usrc/ git clone https://github.com/jorgenschaefer/elpy cd ~/usrc/elpy/ git branch --list -a git for-each-ref PAGER=cat git log --oneline --graph --all -20 # (find-fline "~/usrc/") # (find-fline "~/usrc/elpy/") # (find-gitk "~/usrc/elpy/") # (code-c-d "elpy" "~/usrc/elpy/") # (find-elpyfile "") # (find-elpyfile "README.rst") # (find-elpyfile "README.rst" "Elpy, the Emacs Python IDE") ##### # # naufuto (a telegram bot by Lucas Cavalcante) # 2019sep25 # ##### # «naufuto» (to ".naufuto") # (find-git-links "https://github.com/LcavalcanteR/naufuto" "naufuto") # https://github.com/LcavalcanteR/naufuto * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rfv ~/usrc/naufuto/ cd ~/usrc/ git clone https://github.com/LcavalcanteR/naufuto cd ~/usrc/naufuto/ git branch --list -a git for-each-ref PAGER=cat git log --oneline --graph --all -20 # (find-fline "~/usrc/") # (find-fline "~/usrc/naufuto/") # (find-gitk "~/usrc/naufuto/") # (code-c-d "naufuto" "~/usrc/naufuto/") # (find-naufutofile "") # (find-naufutofile "naufuto.py") ##### # # Hy is a Lisp dialect that is embedded in Python # 2019nov14 # ##### # «hy» (to ".hy") # http://docs.hylang.org/en/stable/quickstart.html # https://docs.hylang.org/en/alpha/ ##### # # codespell # 2020feb07 # ##### # «codespell» (to ".codespell") # (find-fline "~/.local/lib/python3.7/site-packages/" "codespell") # (find-fline "~/.local/lib/python3.7/site-packages/codespell_lib/_codespell.py") # (setq last-kbd-macro (kbd "M-h M-2 (find-fline SPC \" 2*<delete> M-z : C-y <left> \" <delete> SPC\n M-z : C-y DEL SPC \" <delete> M-z = C-y 3*<left> C-k \") C-a <down> RET")) cd /tmp/eev/ codespell codespell --help # (find-sh "codespell --help") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) pip3 install codespell pip3 show codespell pip3 help pip3 list ##### # # pygments # 2020dec24 # ##### # «pygments» (to ".pygments") # (find-es "pygments" "pygments") ##### # # pygments-pip3 # 2024apr28 # ##### # «pygments-pip3» (to ".pygments-pip3") # (find-es "pygments" "pygments-pip3") ##### # # plot3D # 2021apr19 # ##### # «plot3D» (to ".plot3D") * (eepitch-python) * (eepitch-kill) * (eepitch-python) from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection import matplotlib.pyplot as plt fig = plt.figure() ax = plt.axes(projection="3d") x = [0, 0, 0, 0, 1, 1, 1, 1] y = [0, 0, 1, 1, 0, 0, 1, 1] z = [0, 1, 0, 1, 0, 1, 0, 1] verts = [list(zip(x, y, z))] print(verts) ax.plot3D(x, y, z, 'gray') plt.show() import numpy as np ar = np.array([[1,2,3], [3,4,6]]) print(np.moveaxis(ar, 0, 1)) ##### # # dictionaries # 2021jul09 # ##### # «dictionaries» (to ".dictionaries") # file:///usr/share/doc/python3.7/html/tutorial/datastructures.html#dictionaries # file:///usr/share/doc/python3.7/html/library/stdtypes.html#dict # file:///usr/share/doc/python3.7/html/glossary.html#term-iterable ##### # # fsmunoz-k8s-diagrams # 2021oct09 # ##### # «fsmunoz-k8s-diagrams» (to ".fsmunoz-k8s-diagrams") # https://github.com/fsmunoz/k8s-diagrams/blob/main/k8s-diagrams.ipynb # https://github.com/fsmunoz/k8s-diagrams # (find-git-links "https://github.com/fsmunoz/k8s-diagrams" "k8sdiagrams") # (code-c-d "k8sdiagrams" "~/usrc/k8s-diagrams/") # (find-k8sdiagramsfile "") # (find-k8sdiagramsfile "k8s-diagrams.ipynb") http://finisterra.motd.org/?p=302 Interactive embedded development with uLisp, Arduino and Emacs ##### # # Understanding Python through its builtins # 2021oct11 # ##### # «all-the-builtins» (to ".all-the-builtins") https://news.ycombinator.com/item?id=28819030 Understanding Python through its builtins (sadh.life) https://sadh.life/post/builtins/ ##### # # doctest # 2021nov28 # ##### # «doctest» (to ".doctest") # https://docs.python.org/3/library/doctest.html ##### # # breakpoint # 2022mar01 # ##### # «breakpoint» (to ".breakpoint") # file:///usr/share/doc/python3.9/html/library/functions.html#breakpoint # file:///usr/share/doc/python3.9/html/library/bdb.html#bdb.Breakpoint ##### # # Python REPL in Eshell in M$ Windows # 2022jun04 # ##### # «python-repl-in-eshell» (to ".python-repl-in-eshell") # https://lists.gnu.org/archive/html/help-gnu-emacs/2022-06/msg00019.html ##### # # conda # 2022aug14 # ##### # «conda» (to ".conda") # (find-fline "~/LOGS/2022aug13.emacs" "conda-myths-and-misconceptions") # https://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/ # https://peps.python.org/pep-0020/#the-zen-of-python ##### # # pep-503 # 2022oct19 # ##### # «pep-503» (to ".pep-503") # https://peps.python.org/pep-0503/ # (find-sh "locate -i python | grep 503") ##### # # pexpect # 2022nov10 # ##### # «pexpect» (to ".pexpect") # (find-angg ".emacs" "ee-rstdoc-:pexpect") # (find-pip3-links "pexpect") # (find-importlib-links "pexpect") # (find-pypi-links "pexpect") # https://pexpect.readthedocs.io/ # https://pexpect.readthedocs.io/en/stable/ # https://github.com/pexpect/pexpect # (find-git-links "https://github.com/pexpect/pexpect" "pexpect") # (code-c-d "pexpect" "~/usrc/pexpect/") # (find-pexpectfile "") # (find-pexpectfile "examples/") # (find-pexpectfile "doc/") # (find-pexpectfile "doc/Makefile") # (find-pexpectfile "doc/requirements.txt") # (find-fline "~/LOGS/2022nov10.python" "pip install -r doc/requirements.txt") # (find-pexpectdoc "index") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) rm -Rfv ~/usrc/pexpect/ cd ~/usrc/ git clone https://github.com/pexpect/pexpect cd ~/usrc/pexpect/ cd ~/usrc/pexpect/doc/ make html cd ~/usrc/pexpect/ python3 -m pip install -r doc/requirements.txt # sphinx-build -b html -d _build/doctrees . _build/html # Running Sphinx v4.1.2 # # Extension error: # Could not import extension sphinxcontrib_github_alt (exception: No module named 'sphinxcontrib_github_alt') # make: *** [Makefile:45: html] Error 2 # (find-sh "locate pexpect") ##### # # xonsh # 2022nov11 # ##### # «xonsh» (to ".xonsh") # https://itsfoss.com/xonsh-shell/ # https://itsfoss.com/basic-terminal-tips-ubuntu/ # https://github.com/anki-code/xonsh-cheatsheet#basics # https://xon.sh/ # https://xon.sh/contents.html ##### # # iterable # 2024feb24 # ##### # «iterable» (to ".iterable") # (find-pydoc "c-api/iterator") # (find-pydoc "library/inspect") # (find-pydoc "library/stdtypes") # (find-pydoc "tutorial/classes") # (find-pydoc "tutorial/classes#iterators") ##### # # pillow # 2024mar04 # ##### # «pillow» (to ".pillow") # (find-angg ".emacs" "ee-rstdoc-:pillow") # (find-es "drawtree" "pymag-trees") # (find-status "python3-pil") # (find-vldifile "python3-pil:amd64.list") # (find-udfile "python3-pil/") # (find-status "python-pil-doc") # (find-vldifile "python-pil-doc.list") # (find-udfile "python-pil-doc/") # (find-importlib-links "PIL" "pillow") https://pypi.org/project/pillow/ https://python-pillow.org/ https://en.wikipedia.org/wiki/Python_Imaging_Library https://pillow.readthedocs.io/en/stable/ https://gethowstuff.com/python-pillow-pil-tutorial-examples/ ##### # # midi-synth # 2024mar06 # ##### # «midi-synth» (to ".midi-synth") # https://massimo-nazaria.github.io/midi-synth.html # https://github.com/massimo-nazaria/midi-synth # (find-git-links "https://github.com/massimo-nazaria/midi-synth" "midisynth") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) sudo apt-get install -y python3 sudo apt-get install -y python3-numpy sudo apt-get install -y python3-mido sudo apt-get install -y python3-pip sudo apt-get install -y portaudio19-dev python3 -m pip install pyaudio sudo apt-get install python3-scipy # (code-c-d "midisynth" "~/usrc/midi-synth/") # (find-midisynthfile "") # (find-midisynthfile "README.md") cd ~/usrc/midi-synth/ python3 synth.py elise.mid ##### # # pip3-repl # 2024may05 # ##### # «pip3-repl» (to ".pip3-repl") # (find-fline "/home/edrx/.local/bin/pip3") # (find-fline "~/.cache/pip/") * (eepitch-python3) * (eepitch-kill) * (eepitch-python3) import re import sys from pip._internal.cli.main import main ##### # # venv-2024may13 # 2024may13 # ##### # «venv-2024may13» (to ".venv-2024may13") # (find-pythonvenv-links "/tmp/test-venv/" "helloworld") # (find-efunction 'find-pythonvenv-links) # (find-pydoc "distributing/index#installing-the-tools") # (find-pydoc "library/venv#module-venv") * (eepitch-bash) * (eepitch-kill) * (eepitch-bash) * (code-c-d "thisvenv" "/tmp/test-venv/") ** (find-thisvenvfile "") rm -Rv /tmp/test-venv/ mkdir /tmp/test-venv/ cd /tmp/test-venv/ python3 -m venv .venv/ source .venv/bin/activate ** (find-thisvenvsh "find | sort") ** (find-thisvenvsh "find * | sort") ** (find-thisvenvfile "") ** (find-thisvenvfile ".venv/bin/") ** (find-thisvenvfile ".venv/bin/activate") pip3 install setuptools wheel twine pip3 freeze pip3 freeze | tee requirements.txt cat requirements.txt deactivate rm -Rv /tmp/test-venv/.venv/ python3 -m venv /tmp/test-venv/.venv pip3 install -r requirements.txt # requests has four dependencies cd /tmp/test-venv/ source bin/activate find * | sort | grep pkgs pip3 freeze pip3 freeze | pkgs.txt find * | sort | grep pkgs ##### # # python-lsp-server # 2024may18 # ##### # «python-lsp-server» (to ".python-lsp-server") # (find-fline "~/LOGS/2024may18.emacs" "python-lsp-server") ##### # # shiv # 2024jun05 # ##### # «shiv» (to ".shiv") # https://shiv.readthedocs.io/en/latest/ # (find-fline "~/LOGS/2024jun05.emacs" "<grym> shiv.rtfd.org") ##### # # Buscador de meteoritos (Gabriel e Wesley) # 2024aug13 # ##### # «buscador-de-meteoritos» (to ".buscador-de-meteoritos") # https://colab.research.google.com/drive/1y0KkAOfw8KwAYWfFhGrC_GhWJR4LQWI2?usp=sharing ##### # # timestr # 2024sep13 # ##### # «timestr» (to ".timestr") # (find-pydoc "reference/expressions#conditional-expressions") # (find-pydoc "library/stdtypes#printf-style-string-formatting") # https://en.wikipedia.org/wiki/Ternary_conditional_operator#Python * (eepitch-python) * (eepitch-kill) * (eepitch-python) m = lambda n: n % 60 d = lambda n: n // 60 mmss = lambda n: "%d:%02d" % (d(n), m(n)) hhmmss = lambda n: "%d:%02d:%02d" % (d(d(n)),m(d(n)),m(n)) timestr = lambda n: mmss(n) if n < 3600 else hhmmss(n) timestr(9) timestr(369) timestr(3609) from math import floor f = "find-acmetourvideo" sexp = lambda n,text: '(%s "%s" "%s")' % (f, timestr(floor(n)), text) sexp(200, "foo") q = lambda s: '"' + s + '"' from youtube_transcript_api import YouTubeTranscriptApi from math import floor vid = "dP1xVpMPn8M" f = "find-acmetourvideo" tr = YouTubeTranscriptApi.get_transcript(vid) ##### # # Reddit: emacs_291_as_ide_for_python # 2024oct04 # ##### # «emacs_291_as_ide» (to ".emacs_291_as_ide") # https://www.reddit.com/r/emacs/comments/15wr8xu/emacs_291_as_ide_for_python/ ##### # # Emacs, Python, Treesitter and Eglot (gist by habamax) # 2024oct04 # ##### # «habamax» (to ".habamax") # https://gist.github.com/habamax/290cda0e0cdc6118eb9a06121b9bc0d7 (setq major-mode-remap-alist '((python-mode . python-ts-mode))) ##### # # From vanilla Emacs to Python IDE - video by Skybert hacks # 2024oct04 # ##### # «skybert» (to ".skybert") # https://www.youtube.com/watch?v=JmmTUIahB1U # (find-yttranscript-links "skybert" "JmmTUIahB1U") # (find-skybertvideo "0:47" "pyrite was the one that worked") https://slinkp.com/python-emacs-lsp-20231229.html https://github.com/norvig/pytudes/blob/main/ipynb/SplitStates.ipynb file:///usr/share/doc/python3.5/html/library/frameworks.html file:///usr/share/doc/python3.5/html/library/cmd.html https://docs.python.org/3/library/turtle.html https://www.facebook.com/jornalanovademocracia/photos/a.288492381220437.66632.187051701364506/679809862088685/ https://www.facebook.com/permalink.php?story_fbid=921476867869306&id=347772661906399 https://www.facebook.com/photo.php?fbid=10201336092313990&set=a.1569106477271.73917.1523735650 Something that would output what it got from FB in a raw-ish form - JSON? - would be ideal. Any hints welcome, as I am trying to write a set of scripts for caching texts posted to FB that I may want to access quickly later... the code that converts URLs to local file names is ready - the URLs above are associated to files with these names, posts_sergio.martins.984991_10152616093738086 photos_jornalanovademocracia_a.288492381220437.66632.187051701364506_679809862088685 pesfi_921476867869306_347772661906399 photofs_10201336092313990_a.1569106477271.73917.1523735650 http://sourceforge.net/p/oiler/code/ci/master/tree/python/edu/fb4-txt http://sourceforge.net/p/oiler/code/ci/master/tree/python/edu/ cd ~/code/edu-code ls python fbtxt.py fb2 >> fb3-txt vy fb3-txt # (find-efunction 'find-gitclone-links) # (find-man "isympy") http://python.mirocommunity.org/ http://blip.tv/episode/5594214 About Python Namespaces (and Code Objects) # http://rgruet.free.fr/PQR2.3.html # http://rgruet.free.fr/bin/modern.css # http://rgruet.free.fr/bin/classic.css # http://rgruet.free.fr/bin/highcontrast.css # http://rgruet.free.fr/bin/printing.css # http://rgruet.free.fr/bin/styleswitcher.js # http://stackoverflow.com/questions/17988/how-to-learn-python # http://stackoverflow.com/questions/457757/what-is-the-best-python-book-for-experienced-programmers # http://stackoverflow.com/questions/623763/what-are-some-recommended-high-quality-non-basic-python-books # http://stackoverflow.com/questions/947942/advanced-python-programming-book-like-effective-c # http://stackoverflow.com/questions/tagged/python+books http://www.swaroopch.org/notes/Python http://docs.python.org/tutorial/classes.html http://rgruet.free.fr/ http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html http://www.effbot.org/zone/python-objects.htm http://www.dabeaz.com/writing.html http://www.dabeaz.com/ply/index.html http://en.wikipedia.org/wiki/PyPy # http://www.dabeaz.com/ply/ # (find-status "python-ply") # (find-vldifile "python-ply.list") # (find-udfile "python-ply/") Cairo: # http://arstechnica.com/articles/columns/linux/linux-20050822.ars # (find-zsh "availabledebs | sort | grep cairo") apti python-cairo-dev http://code.google.com/p/soc/wiki/PythonStyleGuide#Naming I would recommend that you chuck the obsolete os.popen() permanently and learn the subprocess module: you will be much happier. Setting bufsize=0 (which is the default) should give you unbuffered output from the process. -- Nick Dokos, org-mode-list, 2012feb08 http://codecondo.com/10-ways-to-learn-python/ https://www.facebook.com/sergio.martins.984991/posts/10152810706878086 https://blog.udemy.com/python-tutorial/ # file:///usr/share/doc/python2.7/html/library/re.html # file:///usr/share/doc/python2.7/html/howto/regex.html # file:///usr/share/doc/python2.7/html/howto/regex.html#search-and-replace # file:///usr/share/doc/python2.7/html/reference/expressions.html#lambda # file:///usr/share/doc/python2.7/html/reference/executionmodel.html#naming https://www.python.org/~guido/ https://www.stavros.io/tutorials/python/ http://www.leancrew.com/all-this/2012/04/where-modules-go-to-die/ ;; (find-fline "/usr/share/doc/python2.7/html/_sources/") ;; (find-fline "/usr/share/doc/python3.5/html/_sources/") # (find-py2docsrcfile "whatsnew/2.7.txt" "PEP 372: Adding an Ordered Dictionary to collections") # (find-py3docsrcfile "whatsnew/") file:///usr/share/doc/python2.7/html/library/os.html#os.getenv https://nostarch.com https://nostarch.com/automatestuff2 https://nostarch.com/pythoncrashcourse2e https://codeburst.io/building-beautiful-command-line-interfaces-with-python-26c7e1bb54df https://wiki.debian.org/Python NOTE: Debian testing (bullseye) has removed the "python" package and the '/usr/bin/python' symlink due to the deprecation of Python 2. No packaged scripts should depend on the existence of '/usr/bin/python': if they do, that is a bug that should be reported to Debian. You can use the 'python-is-python3' or 'python-is-python2' packages to restore an appropriate '/usr/bin/python' symlink for third-party or legacy scripts. https://www.cs.usfca.edu/~galles/visualization/Algorithms.html https://realpython.com/python-walrus-operator/ https://towardsdatascience.com/creating-fractals-with-python-d2b663786da6 https://news.ycombinator.com/item?id=30744698 Pointers and Memory Management in Python (github.com/zerointensity) https://news.ycombinator.com/item?id=30727189 No is a complete sentence (networkingnerd.net) https://www.youtube.com/watch?v=xWQUkRKqp2E https://morganya.org/charisma.html The Charisma Machine: the life, death, and legacy of One Laptop per Child - OLPC https://inventwithpython.com/blog/2021/07/10/book-review-the-charisma-machine-by-morgan-g-ames/ https://docs.python.org/3/whatsnew/index.html https://snarky.ca/a-reverse-chronology-of-some-python-features/ https://news.ycombinator.com/item?id=31566031 WTFPython: Exploring and understanding Python through surprising snippets (github.com/satwikkansal) https://news.ycombinator.com/item?id=31566025 Python-patterns – A collection of design patterns/idioms in Python (github.com/faif) https://gist.github.com/RobertAKARobin/a1cba47d62c009a378121398cc5477ea Python is not a great programming language. http://donkirkby.github.io/live-py-plugin/ # (find-epackage-links 'pyinspect "pyinspect" t) # (find-epackage 'pyinspect) # (find-pydoc "library/weakref") https://news.ycombinator.com/item?id=32757511 True * 2 and False * 2 https://news.ycombinator.com/item?id=33892017 A crash course in Python “comprehensions” and “generators” (medium.com/petefison) https://tafc.space/qna/the-topologists-world-map/ https://news.ycombinator.com/item?id=34227760 Python 2 removed from Debian (debian.org) http://blog.sigfpe.com/2008/09/on-writing-python-one-liners.html https://stackoverflow.com/questions/25819513/how-to-indent-code-in-emacs-with-python-mode https://stackoverflow.com/questions/2585091/emacs-bulk-indent-for-python https://news.ycombinator.com/item?id=34289581 Show HN: Futurecoder – A free interactive Python course for coding beginners (futurecoder.io) https://chriswarrick.com/blog/2023/01/15/how-to-improve-python-packaging/ https://thonny.org/ https://news.ycombinator.com/item?id=34527206 Pip and cargo are not the same (williammanley.net) https://news.ycombinator.com/item?id=34689848 PocketPy: Lightweight(~5000 LOC) Python interpreter for game engines (github.com/blueloveth) https://realpython.com/emacs-the-best-python-editor/ https://til.simonwillison.net/python/stdlib-cli-tools https://pulsar17.me/2024/02/ongettinghelp https://www.norvig.com/lispy.html https://news.ycombinator.com/item?id=39665939 (How to Write a (Lisp) Interpreter (In Python)) (2010) (norvig.com) https://www.thepythoncodingstack.com/p/python-diffusion-simulation-demo-turtle https://github.com/chapmanjacobd/library library (media toolkit) https://news.ycombinator.com/item?id=41008888 CLI tools to build, browse, and blend your media library (github.com/chapmanjacobd) https://pydong.org/posts/PythonsPreprocessor/ https://news.ycombinator.com/item?id=41322758 Python's Preprocessor (pydong.org) https://stackoverflow.com/questions/517923/what-is-the-best-way-to-remove-accents-normalize-in-a-python-unicode-string # (find-fline "~/LOGS/2024jul20.emacs" "via pytest and pudb") # (find-status "python-pip3") # (find-vldifile "python-pip3.list") # (find-udfile "python-pip3/") w pip3 # (find-es "vnc" "vnc2swf-2011") # Local Variables: # coding: utf-8-unix # End: