diff options
author | michele.simionato <devnull@localhost> | 2007-12-11 05:05:51 +0000 |
---|---|---|
committer | michele.simionato <devnull@localhost> | 2007-12-11 05:05:51 +0000 |
commit | 942c5d69ab765feead8c49d2ca724419bcf281c4 (patch) | |
tree | 705429e5644a07425e3bc9004b6eacae239f0dc7 /pypers | |
parent | 9b1b7aa5a6b762b1110391c79241a1b8dccbfa83 (diff) | |
download | micheles-942c5d69ab765feead8c49d2ca724419bcf281c4.tar.gz |
Removed some cruft
Diffstat (limited to 'pypers')
-rwxr-xr-x | pypers/pro.txt | 106 | ||||
-rwxr-xr-x | pypers/pro1.py | 28 | ||||
-rwxr-xr-x | pypers/pro2.py | 13 | ||||
-rwxr-xr-x | pypers/pro3.py | 0 | ||||
-rwxr-xr-x | pypers/pro4.py | 0 | ||||
-rwxr-xr-x | pypers/pro5.py | 10 | ||||
-rwxr-xr-x | pypers/pro6.py | 18 | ||||
-rwxr-xr-x | pypers/prog_inter.py | 13 | ||||
-rwxr-xr-x | pypers/prova.txt | 4 | ||||
-rw-r--r-- | pypers/pycon07/abstract-en.txt (renamed from pypers/simionato_talk/abstract-en.txt) | 0 | ||||
-rw-r--r-- | pypers/pycon07/abstract-scipy.txt (renamed from pypers/simionato_talk/abstract-scipy.txt) | 0 | ||||
-rw-r--r-- | pypers/pycon07/abstract.txt (renamed from pypers/simionato_talk/abstract.txt) | 0 | ||||
-rw-r--r-- | pypers/pycon07/badpricehistory.png (renamed from pypers/simionato_talk/badpricehistory.png) | bin | 4224 -> 4224 bytes | |||
-rw-r--r-- | pypers/pycon07/badpricehistory2.png (renamed from pypers/simionato_talk/badpricehistory2.png) | bin | 5693 -> 5693 bytes | |||
-rw-r--r-- | pypers/pycon07/bio.txt (renamed from pypers/simionato_talk/bio.txt) | 0 | ||||
-rw-r--r-- | pypers/pycon07/cdf-dist.png (renamed from pypers/simionato_talk/cdf-dist.png) | bin | 20911 -> 20911 bytes | |||
-rw-r--r-- | pypers/pycon07/delta-cdf.png (renamed from pypers/simionato_talk/delta-cdf.png) | bin | 193776 -> 193776 bytes | |||
-rw-r--r-- | pypers/pycon07/delta-dist.png (renamed from pypers/simionato_talk/delta-dist.png) | bin | 12316 -> 12316 bytes | |||
-rw-r--r-- | pypers/pycon07/delta_dist.py (renamed from pypers/simionato_talk/delta_dist.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/error_trapper.py (renamed from pypers/simionato_talk/error_trapper.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/evalexception_ex.py (renamed from pypers/simionato_talk/evalexception_ex.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/formulas.tex (renamed from pypers/simionato_talk/formulas.tex) | 0 | ||||
-rw-r--r-- | pypers/pycon07/formulas.txt (renamed from pypers/simionato_talk/formulas.txt) | 0 | ||||
-rw-r--r-- | pypers/pycon07/hello.py (renamed from pypers/simionato_talk/hello.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/nonblocking.py (renamed from pypers/simionato_talk/nonblocking.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/nongaussian.png (renamed from pypers/simionato_talk/nongaussian.png) | bin | 21380 -> 21380 bytes | |||
-rw-r--r-- | pypers/pycon07/objectpublisher.py (renamed from pypers/simionato_talk/objectpublisher.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/simpleplotter.py (renamed from pypers/simionato_talk/simpleplotter.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/talk.txt (renamed from pypers/simionato_talk/talk.txt) | 0 | ||||
-rw-r--r-- | pypers/pycon07/test_cdf.py (renamed from pypers/simionato_talk/test_cdf.py) | 0 | ||||
-rw-r--r-- | pypers/pycon07/ui/default/slides.js (renamed from pypers/simionato_talk/ui/default/slides.js) | 0 | ||||
-rw-r--r-- | pypers/pycon07/webplotter.py (renamed from pypers/simionato_talk/webplotter.py) | 0 |
32 files changed, 0 insertions, 192 deletions
diff --git a/pypers/pro.txt b/pypers/pro.txt deleted file mode 100755 index b71158f..0000000 --- a/pypers/pro.txt +++ /dev/null @@ -1,106 +0,0 @@ -Operator overloading is best done with metaclasses: - - :: - - #<autowrap.py> - - import inspect - - class wrappedmethod(Customizable): - """Customizable method factory intended for derivation. - The wrapper method is overridden in the children.""" - - logfile=sys.stdout # default - namespace='' # default - - def __new__(cls,meth): # meth is a descriptor - if isinstance(meth,FunctionType): - kind=0 # regular method - func=meth - elif isinstance(meth,staticmethod): - kind=1 # static method - func=meth.__get__('whatever') - elif isinstance(meth,classmethod): - kind=2 # class method - func=meth.__get__('whatever','whatever').im_func - elif isinstance(meth,wrappedmethod): # already wrapped - return meth # do nothing - elif inspect.ismethoddescriptor(meth): - kind=0; func=meth # for many builtin methods - else: - return meth # do nothing - self=super(wrappedmethod,cls).__new__(cls) - self.kind=kind; self.func=func # pre-initialize - return self - - def __init__(self,meth): # meth not used - self.logfile=self.logfile # default values - self.namespace=self.namespace # copy the current - - def __get__(self,obj,cls): # closure - def _(*args,**kw): - if obj is None: o=() # unbound method call - else: o=(obj,) # bound method call - allargs=[o,(),(cls,)][self.kind]+args - return self.wrapper()(*allargs,**kw) - return _ # the wrapped function - # allargs is the only nontrivial line in _; it adds - # 0 - obj if meth is a regular method - # 1 - nothing if meth is a static method - # 2 - cls if meth is a class method - - def wrapper(self): return self.func # do nothing, to be overridden - - class autowrappedmethod(wrappedmethod): - """Makes the method returning cls instances, by wrapping its - output with cls""" - klass=None # has to be fixed dynamically from outside - def __init__(self,meth): - super(autowrappedmethod,self).__init__(meth) # cooperative - self.klass=self.klass # class variable -> instance variable - def wrapper(self): # closure - return lambda *args,**kw: self.klass(self.func(*args,**kw)) - - class AutoWrapped(type): - """Metaclass that looks at the methods declared in the attributes - builtinlist and wraplist of its instances and wraps them with - autowrappedmethod.""" - def __init__(cls,name,bases,dic): - super(AutoWrapped,cls).__init__(name,bases,dic) # cooperative - cls.builtinlist=getattr(cls,'builtinlist',[]) - if not hasattr(cls,'diclist') : # true only at the first call - cls.diclist=[(a,vars(bases[0])[a]) for a in cls.builtinlist] - if dic.has_key('wraplist'): # can be true at any call - cls.diclist+=[(a,dic[a]) for a in cls.wraplist] - wrapper=autowrappedmethod.With(klass=cls) - d=dict([(a,wrapper(v)) for a,v in cls.diclist]) - customize(cls,**d) - - class Str(str): - __metaclass__=AutoWrapped - builtinlist="""__add__ __mod__ __mul__ __rmod__ __rmul__ capitalize - center expandtabs join ljust lower lstrip replace rjust rstrip strip - swapcase title translate upper zfill""".split() - - #</autowrap.py> - -Here I show various tests. - - .. doctest - - >>> from autowrap import Str - >>> sum=Str('a')+Str('b') # check the sum - >>> print sum, type(sum) - ab <class 'autowrap.Str'> - >>> rprod=Str('a')*2 # check the right product - >>> print rprod,type(rprod) - aa <class 'autowrap.Str'> - >>> lprod=2*Str('a') # check the left product - >>> print lprod,type(lprod) - aa <class 'autowrap.Str'> - >>> r=Str('a').replace('a','b') # check replace - >>> print r,type(r) - b <class 'autowrap.Str'> - >>> r=Str('a').capitalize() # check capitalize - >>> print r,type(r) - A <class 'autowrap.Str'> diff --git a/pypers/pro1.py b/pypers/pro1.py deleted file mode 100755 index 2d9e9bc..0000000 --- a/pypers/pro1.py +++ /dev/null @@ -1,28 +0,0 @@ -"Incredible behaviour of metafunctions" - -from oopp import * - -def magicallyTransform(name,bases,dic): - print "called!" - dic['formatstring']="Very beautiful, since I am %s" - return type(name,bases,dic) - #return TransformedUglyDuckling(name,bases,dic) - -class MagicallyTransformed(Class): - "Metaclass changing the formatstring of its instances" - def __init__(cls,name,bases,dic): - print "called!" - cls.formatstring="Very beautiful, since I am %s" - -class TransformedUglyDuckling(PrettyPrint): - "A class metamagically modified" - __metaclass__ = MagicallyTransformed - __metaclass__ = magicallyTransform - formatstring="Not beautiful, I am %s" # will be changed - -class Swan(TransformedUglyDuckling): - formatstring="Very beautiful, I am %s" - -print Swan() - -print Swan.__class__,Swan.__metaclass__ diff --git a/pypers/pro2.py b/pypers/pro2.py deleted file mode 100755 index bbe1074..0000000 --- a/pypers/pro2.py +++ /dev/null @@ -1,13 +0,0 @@ - -from oopp import * - -wrongcode=''' -r"""Code processing example: replaces 'Print' with 'print' except in -comments and literal strings""" -Print "Prints \"Hello World!\"" # look at this line -''' - -fixPrint=lambda s: s.replace('Print','print') -print codeprocess(wrongcode,fixPrint) - -print quotencode(wrongcode) diff --git a/pypers/pro3.py b/pypers/pro3.py deleted file mode 100755 index e69de29..0000000 --- a/pypers/pro3.py +++ /dev/null diff --git a/pypers/pro4.py b/pypers/pro4.py deleted file mode 100755 index e69de29..0000000 --- a/pypers/pro4.py +++ /dev/null diff --git a/pypers/pro5.py b/pypers/pro5.py deleted file mode 100755 index d99fb75..0000000 --- a/pypers/pro5.py +++ /dev/null @@ -1,10 +0,0 @@ -class M(type): - def __init__(cls,name,bases,dic): - print 'called!' - -class C(object): - pass - -C.__class__=M - -class D(C): pass diff --git a/pypers/pro6.py b/pypers/pro6.py deleted file mode 100755 index 5039ca7..0000000 --- a/pypers/pro6.py +++ /dev/null @@ -1,18 +0,0 @@ -"""This script looks at its own source code and extracts dotted names, -i.e. names containing at least one dot, such as object.attribute or -more general one, such as obj.attr.subattr.""" - -# Notice that dotted.names in comments and literal strings are ignored - -from oopp import * -import __main__ - -text=inspect.getsource(__main__) - -dotname=Regexp.CODESEP| Regexp.DOTNAME.named() - -print 'Using the regular expression',dotname - -print "I have found the following dotted names:\n%s" % [ - MO.group() for MO in dotname.finditer(text)] - diff --git a/pypers/prog_inter.py b/pypers/prog_inter.py deleted file mode 100755 index 00a2c9d..0000000 --- a/pypers/prog_inter.py +++ /dev/null @@ -1,13 +0,0 @@ -from oopp import Final -class C: - __metaclass__=Final -from oopp import singletonClass -C=singletonClass() -class D(C): - pass -id(C),id(D) -C is D -type(C) -type(C).__bases__ -c=C(); d=D() -id(c),id(d) diff --git a/pypers/prova.txt b/pypers/prova.txt deleted file mode 100755 index e35912a..0000000 --- a/pypers/prova.txt +++ /dev/null @@ -1,4 +0,0 @@ -.. image:: fig1.png - - - diff --git a/pypers/simionato_talk/abstract-en.txt b/pypers/pycon07/abstract-en.txt index 844956c..844956c 100644 --- a/pypers/simionato_talk/abstract-en.txt +++ b/pypers/pycon07/abstract-en.txt diff --git a/pypers/simionato_talk/abstract-scipy.txt b/pypers/pycon07/abstract-scipy.txt index 22fe89f..22fe89f 100644 --- a/pypers/simionato_talk/abstract-scipy.txt +++ b/pypers/pycon07/abstract-scipy.txt diff --git a/pypers/simionato_talk/abstract.txt b/pypers/pycon07/abstract.txt index 6e88e8a..6e88e8a 100644 --- a/pypers/simionato_talk/abstract.txt +++ b/pypers/pycon07/abstract.txt diff --git a/pypers/simionato_talk/badpricehistory.png b/pypers/pycon07/badpricehistory.png Binary files differindex 33767cf..33767cf 100644 --- a/pypers/simionato_talk/badpricehistory.png +++ b/pypers/pycon07/badpricehistory.png diff --git a/pypers/simionato_talk/badpricehistory2.png b/pypers/pycon07/badpricehistory2.png Binary files differindex c557af7..c557af7 100644 --- a/pypers/simionato_talk/badpricehistory2.png +++ b/pypers/pycon07/badpricehistory2.png diff --git a/pypers/simionato_talk/bio.txt b/pypers/pycon07/bio.txt index 3adf82e..3adf82e 100644 --- a/pypers/simionato_talk/bio.txt +++ b/pypers/pycon07/bio.txt diff --git a/pypers/simionato_talk/cdf-dist.png b/pypers/pycon07/cdf-dist.png Binary files differindex dcb4b27..dcb4b27 100644 --- a/pypers/simionato_talk/cdf-dist.png +++ b/pypers/pycon07/cdf-dist.png diff --git a/pypers/simionato_talk/delta-cdf.png b/pypers/pycon07/delta-cdf.png Binary files differindex e1d582d..e1d582d 100644 --- a/pypers/simionato_talk/delta-cdf.png +++ b/pypers/pycon07/delta-cdf.png diff --git a/pypers/simionato_talk/delta-dist.png b/pypers/pycon07/delta-dist.png Binary files differindex 445e4b6..445e4b6 100644 --- a/pypers/simionato_talk/delta-dist.png +++ b/pypers/pycon07/delta-dist.png diff --git a/pypers/simionato_talk/delta_dist.py b/pypers/pycon07/delta_dist.py index deb0024..deb0024 100644 --- a/pypers/simionato_talk/delta_dist.py +++ b/pypers/pycon07/delta_dist.py diff --git a/pypers/simionato_talk/error_trapper.py b/pypers/pycon07/error_trapper.py index 172b679..172b679 100644 --- a/pypers/simionato_talk/error_trapper.py +++ b/pypers/pycon07/error_trapper.py diff --git a/pypers/simionato_talk/evalexception_ex.py b/pypers/pycon07/evalexception_ex.py index 51b70a8..51b70a8 100644 --- a/pypers/simionato_talk/evalexception_ex.py +++ b/pypers/pycon07/evalexception_ex.py diff --git a/pypers/simionato_talk/formulas.tex b/pypers/pycon07/formulas.tex index 052405c..052405c 100644 --- a/pypers/simionato_talk/formulas.tex +++ b/pypers/pycon07/formulas.tex diff --git a/pypers/simionato_talk/formulas.txt b/pypers/pycon07/formulas.txt index ea4a232..ea4a232 100644 --- a/pypers/simionato_talk/formulas.txt +++ b/pypers/pycon07/formulas.txt diff --git a/pypers/simionato_talk/hello.py b/pypers/pycon07/hello.py index caa7f62..caa7f62 100644 --- a/pypers/simionato_talk/hello.py +++ b/pypers/pycon07/hello.py diff --git a/pypers/simionato_talk/nonblocking.py b/pypers/pycon07/nonblocking.py index c91d494..c91d494 100644 --- a/pypers/simionato_talk/nonblocking.py +++ b/pypers/pycon07/nonblocking.py diff --git a/pypers/simionato_talk/nongaussian.png b/pypers/pycon07/nongaussian.png Binary files differindex e779e89..e779e89 100644 --- a/pypers/simionato_talk/nongaussian.png +++ b/pypers/pycon07/nongaussian.png diff --git a/pypers/simionato_talk/objectpublisher.py b/pypers/pycon07/objectpublisher.py index 88201f9..88201f9 100644 --- a/pypers/simionato_talk/objectpublisher.py +++ b/pypers/pycon07/objectpublisher.py diff --git a/pypers/simionato_talk/simpleplotter.py b/pypers/pycon07/simpleplotter.py index dcdb5ef..dcdb5ef 100644 --- a/pypers/simionato_talk/simpleplotter.py +++ b/pypers/pycon07/simpleplotter.py diff --git a/pypers/simionato_talk/talk.txt b/pypers/pycon07/talk.txt index f3c0a3a..f3c0a3a 100644 --- a/pypers/simionato_talk/talk.txt +++ b/pypers/pycon07/talk.txt diff --git a/pypers/simionato_talk/test_cdf.py b/pypers/pycon07/test_cdf.py index 110f870..110f870 100644 --- a/pypers/simionato_talk/test_cdf.py +++ b/pypers/pycon07/test_cdf.py diff --git a/pypers/simionato_talk/ui/default/slides.js b/pypers/pycon07/ui/default/slides.js index 81e04e5..81e04e5 100644 --- a/pypers/simionato_talk/ui/default/slides.js +++ b/pypers/pycon07/ui/default/slides.js diff --git a/pypers/simionato_talk/webplotter.py b/pypers/pycon07/webplotter.py index f2b9a55..f2b9a55 100644 --- a/pypers/simionato_talk/webplotter.py +++ b/pypers/pycon07/webplotter.py |