Warning: this is an htmlized version!
The original is across this link,
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.
#
# 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-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-examples»	(to "python-examples")
# «.pyex»		(to "pyex")
# «.pydb»		(to "pydb")
# «.pdb»		(to "pdb")
# «.python-tk»		(to "python-tk")
# «.tkinter»		(to "tkinter")
# «.PYTHONSTARTUP»	(to "PYTHONSTARTUP")
# «.execfile»		(to "execfile")
# «.ee-for-python»	(to "ee-for-python")
# «.eechannel-python»	(to "eechannel-python")
# «.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")
# «.pygame»		(to "pygame")
# «.modules»		(to "modules")
# «.tostring»		(to "tostring")
# «.scipy»		(to "scipy")
# «.matplotlib»		(to "matplotlib")
# «.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")
# «.facebook-sdk»	(to "facebook-sdk")
# «.textwrap»		(to "textwrap")
# «.easyhtmlparser»	(to "easyhtmlparser")
# «.oilercode»		(to "oilercode")
# «.faceutils»		(to "faceutils")
# «.faceutils-wrap»	(to "faceutils-wrap")
# «.pip»		(to "pip")
# «.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")
# «.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")
# «.comprehension»	(to "comprehension")

# (defun u () (interactive) (find-escript-upload-links "python" "u8_to_l1"))
# (to "u8_to_l1")





#####
#
# 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.2")
# (find-vldifile "python3.2.list")
# (find-udfile   "python3.2/")
# (find-status   "python3.2-doc")
# (find-vldifile "python3.2-doc.list")
# (find-udfile   "python3.2-doc/")
# (find-status   "python3.2-examples")
# (find-vldifile "python3.2-examples.list")
# (find-udfile   "python3.2-examples/")
# file:///usr/share/doc/python3.2/html/index.html




#####
#
# 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-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-status "python2.1-tk")
# (find-vldifile "python2.1-tk.list")
# (find-fline "/usr/doc/python2.1-tk/")

#*
# (find-pyexdfile "tkinter/guido/hanoi.py")
cd /usr/share/doc/python2.1/examples/Demo/tkinter/guido/
python hanoi.py

#*




#####
#
# TkInter
# 2013jan10
#
#####

# «tkinter» (to ".tkinter")
# (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)








# (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 python" " PYTHONSTARTUP")
# (find-man "1 python" " PYTHONPATH")
# (find-eevrc ".pythonrc.py")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
PYTHONSTARTUP=$HOME/.pythonrc.py
python
# (find-angg ".pythonrc.py")




#####
#
# execfile
# 2016jul31
#
#####

# «execfile» (to ".execfile")
# (find-angg ".pythonrc.py")
# https://docs.python.org/2/tutorial/
# https://docs.python.org/2/library/functions.html#execfile

* (eepitch-isympy)
* (eepitch-kill)
* (eepitch-isympy)
os.getenv("HOME") + "/.foo"



#####
#
# 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()
%%%)

#*



#####
#
# 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

#*



#####
#
# 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






#####
#
# 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")
* (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/")




#####
#
# PyGame
# 2011nov25
#
#####

# «pygame»  (to ".pygame")
# (find-es "vnc" "vnc2swf-2011")
# (find-status   "python-pygame")
# (find-vldifile "python-pygame.list")
# (find-udfile   "python-pygame/")
# (find-udfile "python-pygame/ref/")
# (find-udfile "python-pygame/tut/")



#####
#
# Modules
# 2012may02
#
#####

# «modules»  (to ".modules")
# (find-pytutnode "Modules")
# (find-pytutnode "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))



#####
#
# __tostring for Python
# 2012may08
#
#####

# «tostring»  (to ".tostring")
# http://rgruet.free.fr/PQR2.3.html#SpecialMethods

# (find-pyrefnode "Special method names")
#  (find-pyrefnode "Basic customization")
#  (find-pyrefnode "Basic customization" "`__repr__(self)'")
#  (find-pyrefnode "Basic customization" "`__str__(self)'")
#  (find-pyrefnode "Emulating container types")
#  (find-pyrefnode "Emulating numeric types")




#####
#
# SciPy
# 2012nov24
#
#####

# «scipy» (to ".scipy")
# http://www.scipy.org/SciPy



#####
#
# matplotlib
# 2012nov24
#
#####

# «matplotlib» (to ".matplotlib")
# 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




#####
#
# 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")
# http://docs.python.org/2/library/os.html#os.putenv

* (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")
# 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")
# (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, requests, virtualenv (for facebook-sdk)
# 2014aug18
#
#####

# «pip» (to ".pip")
# «requests» (to ".requests")
# «virtualenv» (to ".virtualenv")
# (find-zsh "availabledebs | sort | grep pip")
# (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-status   "python-requests")
# (find-vldifile "python-requests.list")
# (find-udfile   "python-requests/")
# (find-status   "python-virtualenv")
# (find-vldifile "python-virtualenv.list")
# (find-udfile   "python-virtualenv/")

* (eepitch-shell2)
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")





#####
#
# 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



# 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/library/re.html
# file:///usr/share/doc/python2.7/html/library/re.html#re.MatchObject.groups
# file:///usr/share/doc/python2.7/html/library/stdtypes.html#str.count
# file:///usr/share/doc/python2.7/html/reference/executionmodel.html#naming
# file:///usr/share/doc/python2.7/html/reference/expressions.html#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")
# file:///usr/share/doc/python2.7/html/reference/executionmodel.html#index-1
# file:///usr/share/doc/python2.7/html/tutorial/classes.html
# file:///usr/share/doc/python2.7/html/tutorial/classes.html#python-scopes-and-namespaces



#####
#
# import
# 2014oct01
#
#####

# «import» (to ".import")
# file:///usr/share/doc/python2.7/html/reference/simple_stmts.html#the-import-statement




#####
#
# 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")
# file:///usr/share/doc/python2.7/html/library/stdtypes.html#index-31
# file:///usr/share/doc/python2.7/html/library/stdtypes.html#dict.items
# https://docs.python.org/2.7/tutorial/datastructures.html#dictionaries

* (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





#####
#
# Tuples
# 2016jul23
#
#####

# «tuples» (to ".tuples")
# «tut-tuples» (to ".tut-tuples")
# https://docs.python.org/3/tutorial/datastructures.html
# https://docs.python.org/3/tutorial/datastructures.html#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")
# 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")
# https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
# https://docs.python.org/3/tutorial/datastructures.html#nested-list-comprehensions
# http://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/
# Also: dict comprehensions, set comprehensions





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/




#

#  Local Variables:
#  coding:               raw-text-unix
#  ee-delimiter-hash:    "\n#*\n"
#  ee-delimiter-percent: "\n%*\n"
#  ee-anchor-format:     "«%s»"
#  End: