Re: Class.__class__ magic trick help

2012-08-21 Thread Massimo Di Pierro
Hello Oscar, thanks for your help but your proposal of adding: def __setitem__(self,key,value): self.__dict__[key] = value dict.__setitem__(self, key, value) does not help me. What I have today is a class that works like SlowStorage. I want to replace it with NewStorage because it is 10x

Re: Class.__class__ magic trick help

2012-08-21 Thread Massimo Di Pierro
On Aug 21, 2:40 am, Oscar Benjamin wrote: > On Mon, 20 Aug 2012 21:17:15 -0700 (PDT), Massimo Di Pierro > > > > > > > > > > wrote: > > Consider this code: > > class SlowStorage(dict): > >     def __getattr__(self,key): > >  

Re: Class.__class__ magic trick help

2012-08-20 Thread Massimo Di Pierro
Consider this code: class SlowStorage(dict): def __getattr__(self,key): return self[key] def __setattr__(self,key): self[key]=value class FastStorage(dict): def __init__(self, __d__=None, **kwargs): self.update(__d__,**kwargs) def __getitem__(self,key):

Re: Class.__class__ magic trick help

2012-08-20 Thread Massimo Di Pierro
, in File "", line 3, in __init__ TypeError: __class__ assignment: only for heap types On Aug 20, 1:39 pm, Ian Kelly wrote: > On Mon, Aug 20, 2012 at 12:01 PM, Massimo Di Pierro > > wrote: > > I discovered I can do this: > > >     class A(object): pass

Class.__class__ magic trick help

2012-08-20 Thread Massimo Di Pierro
I discovered I can do this: class A(object): pass class B(object): __class__ = A # magic b = B() isinstance(b,A) # returns True (as if B derived from A) isinstance(b,B) # also returns True I have some reasons I may want to do this (I an object with same methods a

Re: __future__ and __rdiv__

2012-01-22 Thread Massimo Di Pierro
Thank you. I tried __rtruediv__ and it works. On Jan 23, 2012, at 12:14 AM, Ian Kelly wrote: > On Sun, Jan 22, 2012 at 10:22 PM, Massimo Di Pierro > wrote: > Hello everybody, > > I hope somebody could help me with this problem. If this is not the right > place to ask, pleas

__future__ and __rdiv__

2012-01-22 Thread Massimo Di Pierro
Hello everybody, I hope somebody could help me with this problem. If this is not the right place to ask, please direct me to the right place and apologies. I am using Python 2.7 and I am writing some code I want to work on 3.x as well. The problem can be reproduced with this code: # from __futu

Re: Frameworks

2009-10-20 Thread Massimo Di Pierro
On Oct 20, 2009, at 4:59 PM, Emmanuel Surleau wrote: Compared to custom tags in, say, Mako? Having to implement a mini- parser for each single tag when you can write a stupid Python function is needless complication. I like Mako a lot and in fact web2py template took some inspiration from

Re: Frameworks

2009-10-20 Thread Massimo Di Pierro
> So does web2py allow for raw sql if there is an advanced procedure or query that needs to be performed that is outside the scope of the web2pr orm Yes db.executesql("whatever you want") http://www.web2py.com/examples/static/epydoc/web2py.gluon.sql.SQLDB-class.html Massimo -- http://mail.

Re: Frameworks

2009-10-19 Thread Massimo Di Pierro
Hello, Just to clarify. I did not make any statement about "web2py is superior to SQLAlchemy" since that is somewhat subjective. SQLALchemy for example does a much better job at accessing legacy databases. web2py is more limited in that respect and we are working on removing those limitatio

Re: newbie question: if var1 == var2:

2008-11-29 Thread Massimo Di Pierro
because when you loop over open(...) is the same as looping over open (...).readlines() and readlines() reads everything including newlines. Try replace: if item == var: with if item.strip() == var: Massimo On Nov 28, 2008, at 9:47 PM, [EMAIL PROTECTED] wrote: Hi All, I dont un

Re: Framework recommendations for web service?

2008-07-16 Thread Massimo Di Pierro
web2py (not to be confused with web.py although both of them are excellent) comes with XMLRPC, XML, JSON and RSS API. You can find an XMLRPC example here: http://mdp.cti.depaul.edu/examples/default/examples#xmlrpc_examples The web2py source (including the optional web based interface) fits

Re: python project ideas

2007-10-25 Thread Massimo Di Pierro
Hi Menkaur, I work in a university as well. I am looking for some help in developing an apache graphical log analyzer using gluon http:// mdp.cti.depaul.edu/ I am about to release a pre-configured virtual appliance with it and a graphical log analyzer would be very handy. Massimo On Oct

Re: __main__ : What is this?

2007-10-19 Thread Massimo Di Pierro
if the .py file is imported as a module that condition is false else (if the .py file is executed) that condition is true On Oct 19, 2007, at 6:29 PM, Robert Dailey wrote: > Hi, > > I've read various portions of the Python 2.5 documentation in an > attempt to figure out exactly what the following

Re: Yet another comparison of Python Web Frameworks

2007-10-16 Thread Massimo Di Pierro
Schluehr wrote: > On Oct 13, 4:23 am, Massimo Di Pierro <[EMAIL PROTECTED]> > wrote: >> Hello everybody, >> >> I just joined this mailing list. Thanks for your comments about >> gluon. >> >> I have posted a short video about it and I am planni

Re: re.sub

2007-10-16 Thread Massimo Di Pierro
Even stranger >>> re.sub('a', '\\n','bab') 'b\nb' >>> print re.sub('a', '\\n','bab') b b Massimo On Oct 16, 2007, at 1:54 AM, DiPierro, Massimo wrote: > Shouldn't this > print re.sub('a','\\n','bab') > b > b > > output > > b\nb > > instead? > > Massimo > > On Oct 16, 2007, at 1:34 AM, G

re.sub

2007-10-15 Thread Massimo Di Pierro
Shouldn't this >>> print re.sub('a','\\n','bab') b b output b\nb instead? Massimo On Oct 16, 2007, at 1:34 AM, George Sakkis wrote: > On Oct 15, 11:02 pm, 7stud <[EMAIL PROTECTED]> wrote: >> I'm applying groupby() in a very simplistic way to split up some >> data, >> but when I timeit aga

py2app help

2007-10-15 Thread Massimo Di Pierro
Hello, Two users have reported this error when used the OSX version of Gluon (http://mdp.cti.depaul.edu/examples) Traceback (most recent call last): File "/Users/jacek/src/gluon/runme.app/Contents/Resources/ __boot__.py", line 157, in rograms/gluon/runme.py')) File "/Users/jacek/

Re: Yet another comparison of Python Web Frameworks

2007-10-13 Thread Massimo Di Pierro
... I almost forgot ... another difference between Gluon and Django,TG is that in Gluon if you write controllers without view you automatically get generic view that render and BEAUTIFY() the variables returned by the controllers. That means you can develop the logic of your application with

Re: Yet another comparison of Python Web Frameworks

2007-10-13 Thread Massimo Di Pierro
Hi Daniel, in many respects Gluon is similar to Django and was greatly inspired by Django. Some differences are: Gluon is easier to install - you never need to use the shell, there are no configuration files. Gluon is a web app. You can do all development via a web interface. You can compil

Re: Yet another comparison of Python Web Frameworks

2007-10-12 Thread Massimo Di Pierro
happy to hear that. you may want take a loot at http://mdp.cti.depaul.edu/vqcd It is mostly python stuff and will post the code soon. Massimo On Oct 12, 2007, at 10:47 PM, Fernando Perez wrote: > Massimo Di Pierro wrote: > >> P.S. Michele Simionato. I have heard your name before? Is

Yet another comparison of Python Web Frameworks

2007-10-12 Thread Massimo Di Pierro
Hello everybody, I just joined this mailing list. Thanks for your comments about gluon. I have posted a short video about it and I am planning to make more over the week-end. http://www.youtube.com/watch?v=VBjja6N6IYk About some of your comments: - the most complex modules (like html and sql