About Python

You might find here some details about this curious animal:

Slides of seminar april 2003-Ircam [/Volumes/os9/fichiers/WEB/ircam/python/intiation-python.htm]

Some scripts [./scripts]

For MacOSX Users / Fink, Emacs and Python:

 
Until Python2.3 is released it seems reasonable to use  it with Fink (a large project  dedicated to port Linux OpenSource softwares to the Mac).

How to install Fink (en français...)

 
X11:  
http://www.apple.com/macosx/x11/  
télécharger apple X11 et X11sdk (liens sur   la même page)
FINK:télécharger fink installer
% pico ~/.cshrc
source /sw/bin/init.csh
FINK-GUI:chercher system
installer system-xfree86 (bouton-droit + in terminal->install binary)
installer python     (idem)
installer emacs
RESTE A FAIRE:
Installer apple developper tools
installer python-mode.el pour emacs
installer ipython
installer eterm
configurer .cshrc
en cas de pépins:sudo dpkg -r --force-depends xfree86-rootless xfree86-rootless-shlibs xfree86-base xfree86-base-shlibs

Some notes about xml, regular expressions...

* arguments

if len(sys.argv)>1:
python_filename = sys.argv[0]
arg1 = sys.argv[1]
arg2 = sys.argv[2]

* pyxml

import xml.dom.minidom
import xml.dom.ext
from xml.xpath import Evaluate

** open xml file

fxml = open(xmlpath, 'r')
doc = xml.dom.minidom.parse(fxml)

** get child

if doc.hasChildNodes():
node = doc.childNodes()
for node in nodes:
  text_attribute = node.getAttribute('name')
  numeric_attr = int(text_attribute)

** get a certain child

childs_tag1 = Evaluate("descendant::tag1", doc)

** get text value

def gettxtvalue(node):
 if node.hasChildNodes():
  childs = node.childNodes
  for child in childs:
   if child.nodeName == "#text":
    return child.nodeValue

** exemple

<tag1> texte ... </tag1>

* sortie ascii

asciifile = open('ascii.txt', 'w')
value = gettxtvalue(node_n)
asciifile.write('\t'*4+value)

* regular expression re module

simInf ='[^<]<([^<]*)>[^>]'
douInf = '<<([^<]*)>>'
simBra = re.compile(string.replace(string.replace(simInf,"<", "\["),">", "\]"))
douBra = re.compile(string.replace(string.replace(douInf,"<", "\["),">", "\]"))
simCurl = re.compile(string.replace(string.replace(simInf,"<", "\{"),">", "\}"))
douCurl = re.compile(string.replace(string.replace(douInf,"<", "\{"),">", "\}"))
simInf ='<([^<]*)>'
simInf = re.compile(simInf)
douInf =re.compile(douInf)
def parsePic(line):
 result = simCurl.findall(line)
 if result != []:
  return result, [simCurl.search(line).start(), simCurl.search(line).end()]
 else:
  return ""
def parsePicPath(line):
 result = douCurl.findall(line)
 if result != []:
  return result, [douCurl.search(line).start(), douCurl.search(line).end()]
 else:
  return ""