Re: cmd all commands method?

2007-02-18 Thread Michele Simionato
gt; sum a 5 > > > this would return 8 or an error saying that res is not defined > > Are you sure you're talking about Python here? Yes, he is talking about the cmd module: http://docs.python.org/dev/lib/Cmd-objects.html. However that module was never intended as a real inter

Re: cmd all commands method?

2007-02-18 Thread Michele Simionato
On Feb 18, 10:49 am, "placid" <[EMAIL PROTECTED]> wrote: > On Feb 18, 7:17 pm, "Michele Simionato" <[EMAIL PROTECTED]> > > > Yes, he is talking about the cmd > > module:http://docs.python.org/dev/lib/Cmd-objects.html. > > However

Re: Getting a class name

2007-02-18 Thread Michele Simionato
#x27;t really an attribute, it is a descriptor defined on the metaclass: >>> type(type.__dict__['__name__']) See http://users.rcn.com/python/download/Descriptor.htm for a guide to descriptors, and the papers by me and David Mertz for a guide to metaclasses. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do a Decorator Here?

2007-02-20 Thread Michele Simionato
27;s last article http://www-128.ibm.com/developerworks/linux/library/l-cpdecor.html Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-27 Thread Michele Simionato
e > who's good enough. It depends on how hard the programming is. Right, so they should hire Python programmers who know Lisp too. This is not so uncommon, we have at least three people here where I work. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Curses sorely lacking an event loop?

2007-02-27 Thread Michele Simionato
() returned ERR". This is much less informative > than one might hope. > > Thanks in advance for any help. > > James Did you check Urwid? http://excess.org/urwid Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a technic to avoid this bug

2007-02-27 Thread Michele Simionato
On Feb 27, 1:49 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > However, it might be that either pychecker or pylint will give you a warning > for such statements. Yep, pychecker gives a warning "Statement appears to have no effect" Michele Simionato --

Re: design question: no new attributes

2007-03-01 Thread Michele Simionato
hanks, > Alan Isaac There is a Cookbook recipe for that: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: class declaration shortcut

2007-03-01 Thread Michele Simionato
o > give some information in stack traces or when doing introspection. Also, the name is used by pickle to find the class of pickled instances. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: AOP and pep 246

2007-11-02 Thread Michele Simionato
ake additional features appear necessary" (Clinger). Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about closures and scoping rules

2007-11-06 Thread Michele Simionato
test with) > does the same thing. Closures in Haskell's list comprehensions work as Fernando (and many others would expect). See for instance this post: http://groups.google.com/group/comp.lang.python/browse_frm/thread/d691240a5cfebcdf/63234494ebbca54e?hl=en&lnk=gst&q=simionato+haske

logging module: removing handlers

2007-11-21 Thread Michele Simionato
the problem, so I would like to know the rationale for not closing the handler in removeHandler. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: logging module: removing handlers

2007-11-21 Thread Michele Simionato
implicit closing > bar.addHandler(h) > > It does kind of make sense if you decouple the life-cycles IMHO. > > Diez But what is the use case for removing an handler without closing it? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: logging module: removing handlers

2007-11-21 Thread Michele Simionato
On Nov 21, 11:08 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Having thought more about this, it _has_ to be that way - think of one > handler attached to several loggers. Removing AND closing it from one would > render it useless for others. You can't want that to happen. You have a point.

Re: New+old-style multiple inheritance

2007-12-18 Thread Michele Simionato
On Dec 18, 9:25 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > A well-considered, timely monkey-patch can sometimes save all kinds of > workarounds and other headaches. > > Carl Banks +1 Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: How to memoize/cache property access?

2007-12-20 Thread Michele Simionato
p = Test() print p.foo print p.foo p.reset() print p.foo print p.foo p.reset() print p.foo Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: How to memoize/cache property access?

2007-12-20 Thread Michele Simionato
interface) without restarting the application. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Updated PEP 359: The make statement

2006-04-20 Thread Michele Simionato
is is not necessarly dead. Let us wait a few years ... Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing interfaces in Python...

2006-04-20 Thread Michele Simionato
rojects that get that far. :) +1 QOTW Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: what has python added to programming languages? (lets be esoteric, shall we ; )

2006-04-21 Thread Michele Simionato
. One of the strenght of Python is that it does not try to be particularly original, most of the times it just borrows the good features from other languages without borrowing the warts. 2. If you ask in a Lisp newsgroup, they will tell you that they invented everything that it is cool now (in a

Re: are docstrings for variables a bad idea?

2006-04-21 Thread Michele Simionato
pi is 3.14159' return 3.14159 c = C() print c.pi help(C.pi) # gives you the docstring Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Zope Guru...

2006-05-03 Thread Michele Simionato
The guys here are Zope and workflow guru's I have worked with and I have been very happy with them: http://www.reflab.com/ Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Michele Simionato
this is the end of the story. OTOH, sometimes you want read-only attributes which should not be accidentally overwritten but that are not really constants. In this case, the solution is to use properties. Just google the newsgroup for "properties" and you will find many examples of

Re: Dispatching operations to user-defined methods

2006-05-04 Thread Michele Simionato
Apparently Guido fell in love with generic functions, so (possibly) in future Python versions you will be able to solve dispatching problems in in an industrial strenght way. Sometimes however the simplest possible way is enough, and you can use something like this : class SimpleDispatcher(object

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-04 Thread Michele Simionato
Edward Elliott wrote: > Michele Simionato wrote: > > Python solution is to rely on the intelligence of programmers. If they > > see an all caps name and then they try to change it without knowing what > > they are doing, then they are stupid. If you have stupid programmers th

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-05 Thread Michele Simionato
Edward Elliott wrote: > Michele Simionato wrote: > >> >>> A = [] # let's declare a "constant" here > >> >>> b = A # and let's assign the constant here > >> >>> b.append('1') # OOPS! > > > > But

Re: Tuple assignment and generators?

2006-05-05 Thread Michele Simionato
s=11 >>> t=11 >>> id(r) 135620508 >>> id(s) 135620532 >>> id(t) 135104688 It worked with the number 0 because of an implementation accident, in general Python can use different ids for constant objects that are equals in the == sense. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a good use of __metaclass__?

2006-05-08 Thread Michele Simionato
classname, *args, **kw): try: func = getattr(self._ns, '%s_%s' % (classname, funcname)) except AttributeError: func = self._ns['%s_%s' % (classname, funcname)] return func(*args, **kw) if __name__ == "__main__": import doctest; doctest.testmod() BTW, the usual advice holds here: if you can find an workable solution not involving metaclasses and decorators, don't use them. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: A critic of Guido's blog on Python's lambda

2006-05-09 Thread michele . simionato
, lambda : set_x(2)).start() # => 2 time.sleep(3) print getx() # => 0 Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: A critic of Guido's blog on Python's lambda

2006-05-09 Thread Michele Simionato
thread that Scheme macros are simpler than Common Lisp macros; perhaps, you are not familiar with syntax-case. BTW, there is still research going on on macros, for instance look at http://srfi.schemers.org/srfi-72/srfi-72.html which is pretty nice. Just to bring some info in yet another useless

Re: Is this a good use of __metaclass__?

2006-05-09 Thread Michele Simionato
_greetings', 'do_quit' respectively. You could have done the same without a metaclass, with a function modifying the class. However every time you subclass Cmd (or a subclass of it), you would have to invoke the function again to generate the aliases corresponding to the new metho

Re: What to use for adding syntax for hierarcical trees, metaclasses, tokenize.py or PLY?

2006-05-09 Thread Michele Simionato
e.html for examples. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: A critic of Guido's blog on Python's lambda

2006-05-10 Thread Michele Simionato
t; gets rebound and (the fun part) reverts back to the original dependent > as soon as the scope of the let is exited. Python 2.5 has a "with" statement (yes, the name is Lispish on purpose) that could be used to implement this. See http://www.python.org/dev/peps/pep-0343

Re: New tail recursion decorator

2006-05-10 Thread Michele Simionato
nc Using my decorator module 'tail_recursive' can even be turned in a signature-preserving decorator. I think I will add this great example to the documentation of the next version of decorator.py! Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: A critic of Guido's blog on Python's lambda

2006-05-10 Thread Michele Simionato
jayessay wrote: > "Michele Simionato" <[EMAIL PROTECTED]> writes: > > > Ken Tilton wrote: > > > I was not thinking about the thread issue (of which I know little). The > > > big deal for Cells is the dynamic bit: > > > > > >

Re: New tail recursion decorator

2006-05-10 Thread Michele Simionato
Michele Simionato wrote: > Using my decorator module 'tail_recursive' can even be turned in a > signature-preserving > decorator. I think I will add this great example to the documentation > of the next version > of decorator.py! > > Michele Simionato Done:

Re: A critic of Guido's blog on Python's lambda

2006-05-11 Thread Michele Simionato
*x*", 2): print getvar("*x*") # => 2 print getvar("*x*") # => 1 If you are not happy with this implementation, please clarify. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Michele Simionato
jayessay wrote: > "Michele Simionato" <[EMAIL PROTECTED]> writes: > I can't get this to work at all - syntax errors (presumably you must > have 2.5?, I only have 2.4). You can download Python 2.5 from www.python.org, but the important bit, i.e. the use of threa

Re: New tail recursion decorator

2006-05-12 Thread Michele Simionato
job (converting a long recursion in a loop) only with the first function, which is properly tail recursive. Just as Duncan said. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: New tail recursion decorator

2006-05-15 Thread Michele Simionato
Duncan Booth wrote: > My other problem with this is that the decorator is very fragile although > this may be fixable This version should be more robust against exceptions: class tail_recursive(object): """ tail_recursive decorator based on Kay Schluehr's recipe http://aspn.activestat

Re: Decorator

2006-05-15 Thread Michele Simionato
I will shamelessly plug in my own decorator module: http://www.phyast.pitt.edu/~micheles/python/decorator.zip and http://www.phyast.pitt.edu/~micheles/python/documentation.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple inheritance : waht does this error mean ?

2006-05-16 Thread Michele Simionato
eError: Error when calling the metaclass bases > Cannot create a consistent method resolution > order (MRO) for bases object, list It is explained here: http://www.python.org/download/releases/2.3/mro/ Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Name conflict in class hierarchy

2006-05-23 Thread Michele Simionato
return super(check_if_we_are_overriding_names, mcl).__new__( mcl, name, bases, dic) class MyClass(Base): __metaclass__ = check_if_we_are_overriding_names func = 2 # you will get a warning at this point Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: A critic of Guido's blog on Python's lambda

2006-05-24 Thread Michele Simionato
Kay Schluehr wrote: > http://www.fiber-space.de/EasyExtend/doc/EE.html Well, I have not read that page yet, but the name "fiber space" reminds me of old memories, when I was doing less prosaic things than now. Old times .. ;) Michele Simionato > It fits quite nice

Re: How does a generator object refer to itself?

2006-05-25 Thread Michele Simionato
is restartable) but it may work for you anyway. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: genexp surprise (wart?)

2006-05-26 Thread Michele Simionato
luding myself; there is a long thread involving me and Jacek Generowitz debating this at death, you may find it if you google the newsgroup). I would be curious to know if your code would work the way you expect in Haskell (I know it would for 'for' loop, dunno about 'while'

Re: Cheat sheet

2007-12-28 Thread Michele Simionato
Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> file is open False Nowadays file is no more an alias for open. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-29 Thread Michele Simionato
in practice and should be deprecated. But I will wait for other respondents. It may just be that I never needed them. I presume you did scans of large code bases and you did not find occurrences of takewhile and dropwhile, right? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected __metaclass__ method behavior

2007-12-30 Thread Michele Simionato
The regular method is checked for *before* the metaclass method. You must use type(Test).Foo(Test) to call the method. It is clear that it must be that way: when you do (for instance) SomeClass.__init__ you do not expect to have type.__init__(SomeClass) called. Notice that *all* classes have

Re: using super

2008-01-01 Thread Michele Simionato
t; class C(B): def get_name(self): print "This is C.get_name" C().get_name() Now every subclass of B defining a get_name method will automagically call its parent method. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: python interfaces

2008-01-04 Thread Michele Simionato
On Jan 4, 3:59 pm, hyperboreean <[EMAIL PROTECTED]> wrote: > Hi, > Probably it has been asked before, but I'll still ask. > Why doesn't python provide interfaces trough its standard library? Or it > was ever proposed to be included in the language? > Zope's implementation seems pretty flexible and

Re: MRO Error on Multiple Inheritance?

2008-01-04 Thread Michele Simionato
On Jan 4, 9:03 pm, Ming <[EMAIL PROTECTED]> wrote: > I'm working through Wesley Chun's CPP2e and got this error on 13.11.1, > pp 548 where his interpreter snippet shows no problems: > > ActivePython 2.5.1.1 (ActiveState Software Inc.) b > Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) [ > win32 >

Re: super, decorators and gettattribute

2008-01-14 Thread Michele Simionato
On Jan 14, 1:41 pm, Richard Szopa <[EMAIL PROTECTED]> wrote: > However, there's one piece that doesn't completely fit to the puzzle: > why does getattr work? The help says: > > getattr(...) > getattr(object, name[, default]) -> value > > Get a named attribute from an object; getattr(x, 'y')

Re: super, decorators and gettattribute

2008-01-14 Thread Michele Simionato
t to see a hackish way involving bytecode tricks see http://groups.google.com/group/comp.lang.python/browse_frm/thread/a6010c7494871bb1/62a2da68961caeb6?hl=en&lnk=gst&q=currentClass#62a2da68961caeb6 (and notice that this is really not recommended). Michele Simionato -- http://mail.p

Re: Why must implementing Python be hard unlike Scheme?

2008-02-19 Thread Michele Simionato
On Feb 19, 7:15 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm learning Scheme and I am amazed how easy it is to start building a > half baked Scheme implementation that somewhat works. This was true for R5RS Scheme, not anymore. Michele Simionato -- htt

Re: Beautiful Code in Python?

2008-03-02 Thread Michele Simionato
On Mar 2, 5:23 pm, js <[EMAIL PROTECTED]> wrote: > Hi, > > Have you ever seen Beautiful Python code? > Zope? Django? Python standard lib? or else? > > Please tell me what code you think it's stunning. The doctest module in the standard library. M.S. -- http://mail.python.org/mailman/listinfo/py

debugging ignored exceptions at cleanup

2009-01-12 Thread Michele Simionato
In some conditions (typically with threads, __del__ methods, etc) the cleanup mechanism of Python gets in trouble and some exceptions are not raised but just printed on stderr. I have an application using Paste and when I run the tests I get some annoying ignored exceptions during cleanup. Running

Re: executing multiple functions in background simultaneously

2009-01-13 Thread Michele Simionato
On Jan 14, 2:02 am, Catherine Moroney wrote: > Hello everybody, > > I know how to spawn a sub-process and then wait until it > completes.  I'm wondering if I can do the same thing with > a Python function. > > I would like to spawn off multiple instances of a function > and run them simultaneously

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Michele Simionato
On Jan 14, 8:16 pm, Paul Rubin wrote: > I have a situation which I face almost every day, where I have some > gigabytes of data that I want to slice and dice somehow and get some > numbers out of.  I spend 15 minutes writing a one-off Python program > and then several

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Michele Simionato
On Jan 12, 10:58 pm, Paul Rubin wrote: > We are in an era for programming languages sort of like the Windows 95 > era was for operating systems, where everything is broken but some of > the fixes are beginning to come into view.  So there is no language > that current

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Michele Simionato
On Jan 13, 2:48 am, "Russ P." wrote: > I started looking at Scala a while back. It is has many nice features. > It seamlessly combines object orientation with advanced functional > programming. I don't like that. Scala was designed with the idea of putting together the two worlds, by I think the

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Michele Simionato
On Jan 13, 6:47 pm, Bruno Desthuilliers wrote: > I really wonder why peoples that seems to dislike one of the central > features of Python - it's dynamism - still use it (assuming of course > they are free to choose another language). And FWIW, I at least had a > partial answer on this. It could

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Michele Simionato
retically. It is easier to write a new Python-like language from scratch than to add type checking to Python (I think you were not proposing adding type checking in this post, right?). Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Michele Simionato
e Python definition is good as any other. Don't get pissed off on words. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Michele Simionato
On Jan 15, 7:38 am, "James Mills" wrote: > > If one is a clumsy programmer, then perhaps > one ought to be using a language that holds one's hand. Yes, and I use Python because it is a language that holds my hand, otherwise I would use C and enjoy segmentation faults all the time. -- http://mail.

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-15 Thread Michele Simionato
On Jan 15, 8:02 am, Paul Rubin wrote: > I'd say there was a time Lisp worked the right way, and a time C > worked the right way, and maybe a time Python worked the right way, > and for a while, Algol 60 was perfection embodied.  But times have > changed more than thos

Re: *Advanced* Python book?

2009-01-16 Thread Michele Simionato
here is plenty of info about Advanced Python on the net, much more than in book form. Come to think of it, there are my Oxford lectures (the title was exactly "Advanced Python Programming") and I could republish it on my blog, since I cannot find them on the net anymore. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-27 Thread Michele Simionato
On Jan 21, 2:11 am, Mark Wooding wrote: > CLOS is much more complex and dynamic than Python's object system; > but it > can be compiled very aggressively. I agree that CLOS is complex and that it can be compiled very aggressively, but I do not think that it is more dynamic than Python. What fea

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-27 Thread Michele Simionato
odule of mine: http://pypi.python.org/pypi/strait The module changes the standard object system from a multiple inheritance one to a single inheritance one plus traits. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: dicts,instances,containers, slotted instances, et cetera.

2009-01-28 Thread Michele Simionato
, which may give the desired speedup or not. Good luck! Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Where to host a (Python) project?

2009-01-31 Thread Michele Simionato
On Jan 31, 12:46 pm, andrew cooke wrote: > Any recommendations? Google Code seems fine. -- http://mail.python.org/mailman/listinfo/python-list

Re: Flattening lists

2009-02-05 Thread Michele Simionato
On Feb 5, 2:17 pm, mk wrote: > Hello everybody, > > Any better solution than this? > > def flatten(x): >      res = [] >      for el in x: >          if isinstance(el,list): >              res.extend(flatten(el)) >          else: >              res.append(el) >      return res > > a = [1, 2, 3, [4

Re: Flattening lists

2009-02-05 Thread Michele Simionato
On Feb 5, 7:24 pm, a...@pythoncraft.com (Aahz) wrote: > In article > , > Michele Simionato   wrote: > > > > >Looks fine to me. In some situations you may also use hasattr(el, > >'__iter__') instead of isinstance(el, list) (it depends if you want to &g

Re: Flattening lists

2009-02-06 Thread Michele Simionato
On Feb 6, 10:23 pm, Rhamphoryncus wrote: > On Feb 5, 1:16 pm, Michele Simionato > wrote: > > > On Feb 5, 7:24 pm, a...@pythoncraft.com (Aahz) wrote: > > > > In article > > > , > > > Michele Simionato   wrote: > > > > >Look

Re: "Super()" confusion

2009-02-09 Thread Michele Simionato
ad on python-dev about the issue of super documentation: http://www.gossamer-threads.com/lists/python/dev/673833 Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: "Super()" confusion

2009-02-10 Thread Michele Simionato
On Feb 10, 10:42 am, Marc 'BlackJack' Rintsch wrote: > On Tue, 10 Feb 2009 02:02:43 +, Benjamin Peterson wrote: > > Jean-Paul Calderone divmod.com> writes: > >> Consider whether you really need to use super(). > > >>http://fuhm.net/super-harmful/ > > > This article chiefly deals with super()'

Re: "Super()" confusion

2009-02-10 Thread Michele Simionato
a full time job ;) But if you and others keep bugging me something may happen ... Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Functional schmunctional...

2009-02-11 Thread Michele Simionato
On Feb 10, 9:28 pm, r0g wrote: > def ip2inet(a): >   li = a.split('.') >   assert len(li) == 4 or len(li) == 6 >   return reduce(add,[int(li[e])*(256**((len(li)-1)-e)) for e in > xrange(0,len(li))]) Aagh! Notice that functional programming is not about filter, map, reduce and other unreadable con

Re: Embarrasing questio

2009-02-12 Thread Michele Simionato
On Feb 12, 5:07 pm, TechieInsights wrote: > On Feb 12, 9:03 am, Catherine Heathcote > > wrote: > > But I just cant find it. How do I do an or, as in c/c++'s ||? Just > > trying to do something simple, the python equivilent of: > > > if(i % 3 == 0 || i % 5 == 0) > > > Thanks. > > in 2.5 and above

Re: Embarrasing questio

2009-02-12 Thread Michele Simionato
On Feb 12, 6:22 pm, MRAB wrote: > Michele Simionato wrote: > > On Feb 12, 5:07 pm, TechieInsights wrote: > >> On Feb 12, 9:03 am, Catherine Heathcote > > >> wrote: > >>> But I just cant find it. How do I do an or, as in c/c++'s ||? Just > >&g

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-13 Thread Michele Simionato
On Feb 14, 12:56 am, Gustavo Narea wrote: > Hello, everybody. > > I have this signature-changing decorator > > which I > want to turn into a signature-preserving one. Here's my try >

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-14 Thread Michele Simionato
On Feb 14, 1:30 pm, Gustavo Narea wrote: > This is what I get: > """ > (Pdb) func.__name__ > 'greetings' > (Pdb) func.__dict__ > {} > (Pdb) func.__module__ > 'pylonsproject.controllers.root' > """ > > Which seems correct to me. > > By the way, I forgot to mention that what is decorated is an insta

Re: doctest fails to see tests in decorated functions

2009-02-14 Thread Michele Simionato
On Feb 15, 6:31 am, Steven D'Aprano wrote: > Never mind, it was a PEBCAK error. I failed to notice that applying a > decorator to a function shadows the functions docstring. > > Normally I would use functools.wraps, but I am currently limping along on a > Python 2.4 installation here, which doesn'

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-15 Thread Michele Simionato
On Feb 14, 3:27 pm, Michele Simionato wrote: > I should probably raise a clearer error message. Ok, I have uploaded version 3.0.1 of the decorator module, which raises a more meaningful message in case you try to decorate a method incorrectly. I have also added a discussion of that case in

Re: Will multithreading make python less popular?

2009-02-16 Thread Michele Simionato
. So (assuming you are not a troll) you are just mistaken in thinking that the only way to use multicores is via multithreading. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Michele Simionato
On Feb 16, 3:50 pm, Gustavo Narea wrote: > On Feb 14, 3:27 pm, Michele Simionato > wrote: > > > I lack the context to see how this could be fixed in your case, but > > this a not a show stopper, you can just keep the original decorator > > and forget about making itsi

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Michele Simionato
On Feb 16, 4:07 pm, Gustavo Narea wrote: > But the problem is that it is broken. > > That decorator is for controller actions in Pylons-powered web > applications (which are instance methods). Pylons inspects the > action's signature to find what parameters it's going to pass to its > instance met

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Michele Simionato
On Feb 16, 4:29 pm, Gustavo Narea wrote: > On Feb 16, 4:18 pm, Michele Simionato > wrote: > > > Yes, I am saying don't mess with the internal mechanism of Pylons and > > leave it as > > it was. Or was it broken from the beginning? The only reason I see for > &g

Re: Turning a signature-changing decorator into a signature-preserving one

2009-02-16 Thread Michele Simionato
On Feb 16, 4:59 pm, Gustavo Narea wrote: > I've not seen anything special in Pylons or TurboGears 2 decorators, > except that they are all functions that use the decorator package -- > while my decorator is a class that doesn't use the decorator package > yet. > > My attempt to turn that decorator

Re: Will multithreading make python less popular?

2009-02-16 Thread Michele Simionato
On Feb 16, 10:20 pm, rushen...@gmail.com wrote: > Hi again > > OpenERP and ERP5 was written in python as i know. I really wonder how > they do this without threads. I want to see a real time graph at the > same time while i am working on the same screen. What is the secret? > > Thanks > Rushen Her

Re: Is there something easier than ORM?

2009-02-17 Thread Michele Simionato
On Feb 17, 1:27 pm, 一首诗 wrote: > Hi all, > > Recently I am studying some python ORM libraries, such as sqlalchemy. > > These are very powerful technologies to handle database. But I think > my project are not complicated to enough to benefit from a complete > ORM system. > > What I really want, i

Re: Will multithreading make python less popular?

2009-02-17 Thread Michele Simionato
nown Python (+C extension) library - such as mod_wsgi - is already well equipped to manage multithreading on multiple cores without any further effort from the user. This is a good point. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there something easier than ORM?

2009-02-18 Thread Michele Simionato
On Feb 17, 5:35 pm, Philip Semanchuk wrote: > > I don't intend this as a criticism of SqlAlchemy. On the contrary I am   > impressed by what it does. But I often see people promoting ORM as the   > solution to all database access problems, and I certainly don't feel   > like it is. I am also not

Re: Porting to new Python version

2009-02-19 Thread Michele Simionato
ind Python releases. I have currently a Zope application running in Python 2.4 that I cannot upgrade. It all depends from your external dependencies. If you do not have any, and you do not anticipate the need for any, you can probably upgrade to Python 2.6 with no effort. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: "metaclass conflict" error: where is noconflict ?

2009-02-19 Thread Michele Simionato
On Feb 19, 9:58 pm, Chris Rebert wrote: > On Thu, Feb 19, 2009 at 5:01 AM, Barak, Ron wrote: > > Hi, > > > I have a class derived from two parents (in blue below), which gives me the > > following error: > > > $ python -u ./failover_pickle_demo09.py > > Traceback (most recent call last): > >   Fi

Re: How to inherit from two classes without metaclass clashing ?

2009-02-22 Thread Michele Simionato
On Sun, Feb 22, 2009 at 2:29 PM, Barak, Ron wrote: > Hi Michele, > > I tried understanding how to avoid the metaclasses clashing, and I did read > the link you referred to below, > as well as the relevant O'Reilly cookbook chapter (Recipe 20.17. Solving > Metaclass Conflicts), but seems I do not u

Re: Getting in to metaprogramming

2008-11-25 Thread Michele Simionato
On Nov 25, 11:08 am, Rafe <[EMAIL PROTECTED]> wrote: > Hi, > > In the name of self-education can anyone share some pointers, links, > modules, etc that I might use to begin learning how to do some > "metaprogramming". That is, using code to write code (right?) > > Cheers, > > - Rafe The word "meta

Re: Getting in to metaprogramming

2008-11-25 Thread Michele Simionato
On Nov 25, 12:12 pm, Rafe <[EMAIL PROTECTED]> wrote: > is it really as simple as gathering strings of code? Yes. > Sort of like generating HTML or XML directly? Is there any other framework or > pattern set that is worth looking in to? Yes, the compiler module and the ast module in the standard

Re: Getting in to metaprogramming

2008-11-26 Thread Michele Simionato
On Nov 26, 11:55 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Then another thing - it strikes me that any problem that can be solved > by metaprogramming, can be solved by putting similar code into a class > and instanciating an instance. > > Does anybody know if this is true? > > If it is

Re: Is the behavior expected?

2008-11-26 Thread Michele Simionato
on Lisp implementors are happy with mutating the loop index. I myself prefer the functional way. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   >