Re: Is the behavior expected?

2008-11-27 Thread Michele Simionato
On Nov 27, 10:11 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > Michele Simionato wrote: > > Guido and the Common Lisp implementors are happy with mutating the loop > > index. I myself prefer the functional way. > > I'd agree wi

Re: Getting in to metaprogramming

2008-11-27 Thread Michele Simionato
On Nov 27, 5:41 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Given that, can anybody think of an example that you could not do with > a class?  (excepting the "stored procedure" aspect) The namedtuple recipe by Raymond Hettinger (http:// code.activestate.com/recipes/500261) is an interest

What about a decorator module version 3.0?

2008-12-01 Thread Michele Simionato
I am thinking about releasing a new version of the decorator module, completely rewritten from scratch. The new implementation takes half the lines of the original one and it is much more general, so I like it more. However, there is an issue of compatibility with the past and I am asking here for

Re: What about a decorator module version 3.0?

2008-12-01 Thread Michele Simionato
On Dec 1, 9:18 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > Release a final 2.x version with whatever internal changes but with > external api unchanged or at least backward compatible.  Mark items to > be deleted as deprecated.  Keep that available indefinately. > > Then release a 3.0 version wi

porting modules to Python 3.0

2008-12-02 Thread Michele Simionato
she is using. Is there something like that already in place? What are the recommendations for library authors willing to support both Python 2.X and 3.X in parallel? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic design patterns

2008-12-04 Thread Michele Simionato
On Dec 4, 10:09 am, Slaunger <[EMAIL PROTECTED]> wrote: > Hi comp.lang.python > > I am this novice Python programmer, who is not educated as a computer > scientist (I am a physicist), and who (regrettably) has never read the > GOF on design patterns. > > I find myself spending a lot of time in Pyth

Re: Pythonic design patterns

2008-12-04 Thread Michele Simionato
On Dec 4, 11:00 am, James Stroud <[EMAIL PROTECTED]> wrote: > > The cookbook has a lot of complex examples and may not provide you with > the insight you are looking for. Only a small fraction of the recipes do > this. Whereas I agree that the online cookbook has too many complex recipes, as far I

Re: Maintaining signature in help(decorated function)

2008-12-10 Thread Michele Simionato
On Dec 10, 5:07 pm, jelsas <[EMAIL PROTECTED]> wrote: > Hi -- I can't seem to maintain the function signature when applying a > decorator.  I'm using functools.wraps.  Example: > > >>> def mydecorator(fn): > > ...     from functools import wraps > ...     # simple decorator > ...     @wraps(fn) > .

Re: ethical questions about global variables

2008-12-15 Thread Michele Simionato
On Dec 16, 3:45 am, "Giampaolo Rodola'" wrote: > Hi, > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > variable named "use_gmt_times" to decide whether the server has to > return times in GMT or localtime but I'm not sure if it is a good idea > because of the "ethical" doub

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread Michele Simionato
On Jan 2, 4:45 pm, ming_cuhk wrote: > Hi all, I'm new to here and python. > When I tried the code below to test python's speed... > I found that python use more than 1.5G memory to run this and cost > several minutes And this happened only under my linux os. Both > jython and python...  Is the

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread Michele Simionato
On Jan 2, 4:50 pm, ming_cuhk wrote: > On Jan 2, 11:49 pm, Michele Simionato > wrote: > > > > > On Jan 2, 4:45 pm, ming_cuhk wrote: > > > > Hi all, I'm new to here and python. > > > When I tried the code below to test python's speed... > &

Re: newbie: decorator

2008-10-05 Thread Michele Simionato
On Oct 5, 4:27 pm, TK <[EMAIL PROTECTED]> wrote: > Hi, > > I need an understandable Decorator-Example? Who can help? Thanks. > > o-o > > Thomas You may want to look at my decorator module, which has plenty of examples, some simple, some less simple: http://www.phyast.pitt.edu/~micheles/python/docu

Re: managing releases of web applications: is svn checkout the best way?

2008-10-07 Thread Michele Simionato
On Oct 7, 9:55 am, Ksenia <[EMAIL PROTECTED]> wrote: > Hi, > > For website development, I am using SVN repository to commit the code > from my development computer, and on the production server use svn > checkout to update the code to the latest version. > Is this the most common approach people us

Re: execute a function before and after any method of a parent class

2008-10-07 Thread Michele Simionato
classes will not have any visual clue that something magic is going on; moreover, you will lower the risk of decorating methods that should not be decorated (I mean, in case of accidents). Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: MRO inconsistency: why?

2008-10-08 Thread Michele Simionato
On Oct 8, 9:09 pm, Ravi <[EMAIL PROTECTED]> wrote: > Why the following code gives inconsistent method resolution order > error: > If you want to know all the nitty-gritty details about the MRO (including the reason for the error you get) you should read this: http://www.python.org/download/releas

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-15 Thread Michele Simionato
On Oct 14, 7:37 pm, [EMAIL PROTECTED] wrote: > If you're an Emacs user who has used both python-mode.el (the python mode > code distributed with Python and XEmacs) and python.el (the python mode code > distributed with GNU Emacs), I'd like to get your impressions on how they > compare and where you

Re: Finding the instance reference of an object

2008-10-16 Thread Michele Simionato
On Oct 16, 4:01 pm, Astley Le Jasper <[EMAIL PROTECTED]> wrote: > Sorry for the numpty question ... > > How do you find the reference name of an object? > > So if i have this > > bob = modulename.objectname() > > how do i find that the name is 'bob' This is a FAQ: http://www.python.org/doc/faq/p

Re: Installing multiple python versions - CentOs Linux

2008-10-17 Thread Michele Simionato
On Oct 17, 2:51 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Brendan schrieb: > > > The current CentOs Linux distro includes python 2.4.3. I need to > > install a more recent version but I am worried about breaking CentOs > > python dependencies. Is it safe to install python 2.6 using pup? >

Re: dumping in destructor

2008-10-20 Thread Michele Simionato
On Oct 20, 10:12 am, Митя <[EMAIL PROTECTED]> wrote: > But when g_register is being destroyed, dump seems to be already dead, > so I get: > > Exception exceptions.TypeError: "'NoneType' object is not callable" in > at 0x835a74c>> ignored > > can I somehow save my data from destructor? The best th

Re: no module named _tkinter

2008-10-21 Thread Michele Simionato
On Oct 22, 2:10 am, Ben ZX <[EMAIL PROTECTED]> wrote: > When I type > > import Tkinter > > I get > > no module named _tkinter. > > I compiled my own python 2.5.2, and I didn't do anything special: just > configure; make; make install. > > I checked there is a tk library in /usr/lib64. You need the

Re: using modules in destructors

2008-10-24 Thread Michele Simionato
/recipes/523007/ If you Google in this newsgroup for __del__ you will find a lot of discussion. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Unyeilding a permutation generator

2008-11-03 Thread Michele Simionato
On Nov 2, 10:34 pm, [EMAIL PROTECTED] wrote: > Anyway what I want to do is experiment with code similar to this (i.e. > same algorithm and keep the recursion) in other languages, > particularly vbscript and wondered what it would look like if it was > rewritten to NOT use the yield statement - or a

Re: Structures

2008-11-03 Thread Michele Simionato
On Nov 4, 2:57 am, Glenn Linderman <[EMAIL PROTECTED]> wrote: > Note that classes, by default, are based on a contained dict!  There are > games to be played with slots that can apparently improve that.  I am > not yet experienced enough with Python to know if a slot is as fast as a > C struct, but

Re: Structures

2008-11-04 Thread Michele Simionato
On Nov 4, 11:20 am, [EMAIL PROTECTED] wrote: > Michele Simionato: > > > No, slots have nothing to do with speed, they are a memory optimization. > > In many languages, often in Python too, the less memory you use/ > allocate the faster you go. > > In fact slots allow a

Re: Does Python have Multiple Inheritance ?

2008-11-07 Thread Michele Simionato
On Nov 7, 3:50 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > Aaron Gray wrote: > > Wikipedia says Python has Multiple Inheritance, is this true ? > > >    http://en.wikipedia.org/wiki/Multiple_inheritance > > > Thanks, > > > Aaron > > Good grief. You can use Wikipedia but you can't use Google? > > ht

Re: Does Python have Multiple Inheritance ?

2008-11-07 Thread Michele Simionato
On Nov 7, 4:38 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > Seriously, though, although Python does indeed support multiple inheritance, > I have the impression from comments over the years that it's used a lot less > than in other languages where it is more of a common idiom. Certainly in my > own

Re: Programming exercises/challenges

2008-11-22 Thread Michele Simionato
On Nov 20, 1:28 pm, [EMAIL PROTECTED] wrote: >     >> a diary manager compatible with my Emacs diary file (sometimes I >     >> don't want to open Emacs for a quick note) > >     Arnaud> You mean that you sometimes don't have emacs open? > > I am constantly amazed at work that people open a separat

Re: Proposed implementation for an Ordered Dictionary

2009-02-28 Thread Michele Simionato
On Mar 1, 1:43 am, Paul Rubin wrote: > "Colin J. Williams" writes: > > >      # print [mydict[x] for x in sorted(mydict.keys)] Instance object > > is not iterable > > It was a typo.  Use: > >     print [mydict[x] for x in sorted(mydict.keys())] Even better print [m

Re: What's so wrong about execfile?

2009-02-28 Thread Michele Simionato
I would have expected >>> exec(open('myfile.py')) to work too. Any idea why it does not? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorators

2009-03-06 Thread Michele Simionato
On Mar 6, 2:59 pm, Johny wrote: > Hi, > Can anyone explain to me what are decorators for? What are advantages > of using them? > Thanks > L. See http://pypi.python.org/pypi/decorator for many examples of useful decorators, or the references in the Wikipedia page: http://en.wikipedia.org/wiki/Pyt

Re: Is python worth learning as a second language?

2009-03-09 Thread Michele Simionato
On Mar 9, 12:47 pm, Tim Wintle wrote: > My slight issue with this list that I think things are in too many > places. E.g. although you can do functional programming in Python (and > many do), I think it's worth trying to learn a language like lisp just > for the sake of forcing yourself to fully

Re: What happened to NASA at Python? :(

2009-03-12 Thread Michele Simionato
On Mar 12, 4:26 am, r wrote: > On Mar 11, 10:09 pm, s...@pobox.com wrote: > > > In fact, graphics were added for several organizations.  I believe they will > > be chosen randomly.  NASA is still there. > > > --http://mail.python.org/mailman/listinfo/python-list > > Whew! Thats good news, i though

Re: how to repeat function definitions less

2009-03-14 Thread Michele Simionato
On Mar 15, 12:09 am, s...@pobox.com wrote: >     I'm doing this in my code, how to make it define all this functions for me >     with lambda, I've been up for a while and cant seem to figure it out, > whats >     the most efficient way to do it? with lambda? how? thx > >     def red(self,value,co

Re: how to repeat function definitions less

2009-03-15 Thread Michele Simionato
ass (for instance, think of a "debug" class decorator replacing methods with a debug-friendly version of them). Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: A request (was: how to repeat function definitions less

2009-03-16 Thread Michele Simionato
On Mar 16, 8:08 am, Dennis Lee Bieber wrote: > On Sun, 15 Mar 2009 23:18:54 -0500, alex goretoy >         Many of your posts are actually exceeding the 500-line limit I've > set in my client for down-load -- yet have nothing worthy of 500 lines! Could this be the reason why I cannot see his messa

Re: Mangle function name with decorator?

2009-03-17 Thread Michele Simionato
urn noclashdict() class C(metaclass=Meta): def foo(self): return 1 def foo(self): return 2 print(sorted(n for n in vars(C) if not n.startswith('__'))) # prints ['foo', 'foo_new'] if __name__ == '__main__': import doctest; doctest.testmod() It seems Guido's time machine is ticking again ;) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Mangle function name with decorator?

2009-03-17 Thread Michele Simionato
I forgot; people interested in metaclasses in Python 3.0 will want to read this paper: http://www.artima.com/weblogs/viewpost.jsp?thread=236234 -- http://mail.python.org/mailman/listinfo/python-list

Re: Mangle function name with decorator?

2009-03-18 Thread Michele Simionato
On Mar 18, 4:18 pm, Adam wrote: > Hey, Cliff.  Thanks for sharing this idea.  Unfortunately, providing a > way to actually call the method with the mangled name is relatively > easy, and there are options there.  The real issue, to me, seems to be > finding a way to prevent Python from eating all

Re: Object System

2009-03-19 Thread Michele Simionato
lasses. The second Google hit for "python object system": http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html This is actually a very good book indeed. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda forms and scoping

2009-03-20 Thread Michele Simionato
On Mar 19, 10:52 pm, Márcio Faustino wrote: > Hi, > > Executing the example below doesn't produce the expected behavior, but > using the commented code does. Is this normal, or is it a problem with > Python? It is a common gotcha. Notice that it has nothing to do with lambda functions, you would

Re: Preparing teaching materials

2009-03-20 Thread Michele Simionato
On Mar 20, 12:58 pm, grkunt...@gmail.com wrote: > I am considering teaching a beginning programming course using Python. > I would like to prepare my class handouts in such a way that I can > import the Python code from real ".py" files directly into the > documents. This way I can run real unit te

Re: Preparing teaching materials

2009-03-20 Thread Michele Simionato
On Mar 20, 1:44 pm, Tim Golden wrote: > Michele Simionato wrote: > > One word: Sphinx. > > And the second word(s): > > ..  literalinclude:: example.py > > TJG The interesting thing is that Sphinx uses pygments and can highlight any code fragment, not only Python code

Re: Preparing teaching materials

2009-03-20 Thread Michele Simionato
On Mar 20, 3:05 pm, Tim Golden wrote: > Michele Simionato wrote: > > >http://www.phyast.pitt.edu/~micheles/scheme/TheAdventuresofaPythonist... > > > (I think the OP may be interested in how the PDF output of > > Sphinx-generated documents may look like). > > That

Re: c.l.py dead, news at 11 (was Re: Mangle function name with decorator?)

2009-03-30 Thread Michele Simionato
On Mar 30, 3:31 pm, srepmub wrote: > for the record, the input for Shedskin is pure Python, so there is no > added syntax or optional type declaration system. that said, I can > understand it not being on some list for not being production-ready. > > thanks, > mark dufour. But does ShedSkin accep

Re: An inheritance question: getting the name of the "one up" class

2009-03-31 Thread Michele Simionato
On Mar 31, 5:13 am, "Nick" wrote: > Oh, and while the gurus are at it, what would be the advantage (if any) of > changing, say >    Primate.__init__(self) > to >     super(Human, self).__init__() What others said. In Python 3.0 you would have a bigger advantage, since you can just write super()

Re: Beazley on Generators

2009-03-31 Thread Michele Simionato
On Apr 1, 7:03 am, Terry Reedy wrote: > At PyCon2008, David Beazley presented an excellent talk on generators. > Generator Tricks for Systems > Programmershttp://www.dabeaz.com/generators/index.html > > At PyCon2009, he followed up with another talk on more advanced > generator usage, which Guido

Re: Beazley on Generators

2009-04-01 Thread Michele Simionato
On Apr 1, 7:57 am, Lawrence D'Oliveiro wrote: > In message > , Michele > > Simionato wrote: > > Excellent reading for everybody wanting to understand cooperative > > concurrency! > > Hey, some of us were doing "cooperative concurrency" progra

Re: A design problem I met again and again.

2009-04-02 Thread Michele Simionato
On Apr 3, 7:18 am, Emile van Sebille wrote: >  So, I think the question becomes, when does code need > refactoring? I would say that 99.9% of the times a single class with 15,000 lines of code is a signal that something is wrong, and refactoring is needed. M. Simionato -- http://mail.

Re: User or UserManager ? Problems of Observer Pattern

2009-04-03 Thread Michele Simionato
;Programming Python" by Ludz which has many examples of how to write OO applications in Python (I mean no offense, but indeed from you examples is seems to me that you are missing the point of OOP, as you are the first to recognize). HTH, Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Books about refactoring in Python (Was: A design problem I met again and again.)

2009-04-03 Thread Michele Simionato
On Apr 4, 6:10 am, Carl Banks wrote: > A piece of user code that looked like this (where sc is an instance of > your enormous class): > > sc.startX() > sc.send_data_via_X() > sc.receive_data_via_X() > sc.stopX() > > might look like this after you factor it out: > > session = sc.startX()  # creates

Re: Python Goes Mercurial

2009-04-04 Thread Michele Simionato
which is well above the average programmer - says that he would need help with Git, I take this as meaning that most people would get lost with Git. Heck, I am getting lost even with SVN! Michele Simionato P.S. the thing I do not understand if why we are moving away from Subv

Re: Python Goes Mercurial

2009-04-05 Thread Michele Simionato
On Apr 5, 8:50 am, Lawrence D'Oliveiro wrote: > Michele wrote: > > the thing I do not understand if why we are moving > > away from Subversion. > > Because it's still centralized. That means different developers cannot pursue > parallel branches on their own, those branches must be represented on

Re: replacement for new.instancemethod in Python3?

2009-04-05 Thread Michele Simionato
On Apr 5, 2:02 pm, s...@pobox.com wrote: > Is there a replacement in Python3 for new.instancemethod?  That is, given an > arbitrary instance (not its class) how can I add a new appropriately defined > function as a method to it? There is no need for new.instancemethod for new style classes: >>> c

Re: replacement for new.instancemethod in Python3?

2009-04-05 Thread Michele Simionato
On Apr 5, 3:58 pm, s...@pobox.com wrote: >     Michele> There is no need for new.instancemethod for new style classes: > >     >>> class C: pass >     ... >     >>> c=C() >     >>> def f(self): pass >     ... >     >>> c.f = f.__get__(c, C) >     >>> c.f >     > > > Like a chimpanzee I can mimic yo

Re: decorator module in stdlib?

2009-04-06 Thread Michele Simionato
tus. Perhaps people wanting this should make some noise on python-dev. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: decorators don't play nice with nose?

2009-04-06 Thread Michele Simionato
On Apr 6, 11:11 pm, "Diez B. Roggisch" wrote: > Nose works via the func_name parameter of a method/function. > > So when you decorate it, you need to make sure that is set properly. One > option is to do something like this: > > from functools import wraps > > def my_decorator(f): >     @wraps(f)

Re: decorator module in stdlib?

2009-04-06 Thread Michele Simionato
On Apr 7, 7:57 am, Daniel Fetchinson wrote: > > have always seen the decorator module > > as a temporary hack waiting for a proper solution > > at the language level. I wanted the possibility to modify the > > signature of a function. Everybody more or less agreed > > that this was a good idea on

Re: Adding method to class at run-time: bad style?

2009-04-07 Thread Michele Simionato
On Apr 7, 4:37 pm, Grant Edwards wrote: > I realize that technically all methods are added to classes at > "run-time", but what I'm talking about is this: Raymond Hettinger solves this problem nicely with a class decorator: http://code.activestate.com/recipes/576685/ -- http://mail.python.org/ma

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-18 Thread Michele Simionato
On Apr 18, 3:03 pm, a...@pythoncraft.com (Aahz) wrote: > In article , > Peter Otten  <__pete...@web.de> wrote: > > > > >If it were up to me I'd rip out send() immediatly. At first I thought I > >would see a compelling use case and be enlightened, but it never happened. > > Too late -- it's likely t

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-18 Thread Michele Simionato
es instead could have been implemented as a library, without requiring any language change. But the point is moot, anyway, and certainly I did not think of it at the time yield expressions were introduced. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-19 Thread Michele Simionato
On Apr 19, 8:09 am, Michele Simionato wrote: > Coroutines instead could have been implemented as > a library, without requiring any syntax change. Here is a proof of principle, just to make clearer what I have in mind. Suppose you have the following library: $ cat coroutine.py from abc

Re: unpythonic use of property()?

2009-04-20 Thread Michele Simionato
On Apr 17, 7:21 pm, J Kenneth King wrote: > Consider: > > code: > > > class MyInterface(object): > >     def __get_id(self): >         return self.__id > >     id = property(fget=__get_id) > >     def __init__(self, id, foo):

Re: python list handling and Lisp list handling

2009-04-25 Thread Michele Simionato
ere is a weak form of pattern matching built-in: >>> head, *tail = [1,2,3] # Python 3.0 only! >>> head 1 >>> tail [2, 3] Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: python list handling and Lisp list handling

2009-04-25 Thread Michele Simionato
On Apr 25, 10:01 am, Paul Rubin wrote: > Mark Tarver writes: > > "Assuming the following Python encodings, and ignoring questions > > of performance, would Python and Lisp lists then be observationally > > indistinguishable? i.e. would these then be fair encodings?"

Re: Lisp mentality vs. Python mentality

2009-04-25 Thread Michele Simionato
On Apr 25, 10:26 pm, Carl Banks wrote: > I totally disagree.  Scheme might be a pure language with no > compromises and impurities, but Common Lisp is certainly not. I can assure you that even Scheme is a language full of compromises and inconsistencies :-/ Michele, who is now writing a book a

Re: python docs for beginner programmer?

2009-05-06 Thread Michele Simionato
On May 5, 10:37 pm, Deep_Feelings wrote: > that is good ,thank you > > anyone did that ? learning from python docs straight away ? A lot of people did. I did, but I usually prefer reading user manuals over books, and YMMV. -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorating methods - where do my arguments go?

2009-05-11 Thread Michele Simionato
On May 8, 5:33 pm, Mikael Olofsson wrote: >  >>> class test_decorator(object): > ...     def __init__(self,func): > ...         self._func = func > ...     def __call__(self, *args): > ...         print 'Decorator:', args > ...         self._func(*args) Or you could use the decorator module (htt

Re: Decorating methods - where do my arguments go?

2009-05-12 Thread Michele Simionato
On May 12, 8:54 am, Mikael Olofsson wrote: > Peter Otten wrote: > > I usually use decorator functions, but I think the following should work, > > too: > > > class deco(object): > >     def __init__(self, func): > >         self._func = func > >     def __call__(self, *args): > >         print "Dec

Re: Swapping superclass from a module

2009-05-17 Thread Michele Simionato
Try this: class Base(object): pass class C(Base): pass class NewBase(object): pass C.__bases__ = (NewBase,) help(C) -- http://mail.python.org/mailman/listinfo/python-list

Re: Metaclass mystery

2009-06-01 Thread Michele Simionato
On May 31, 2:32 am, LittleGrasshopper wrote: > Seriously, metaclasses are making my brain hurt. How do people like > Michele Simionato and David Mertz figure these things out? Does it all > come to looking at the C source code for the CPython interpreter? Actually I never looked at the

Re: Metaclass mystery

2009-06-01 Thread Michele Simionato
On Jun 1, 7:18 pm, LittleGrasshopper wrote: > I have to thank you for all the invaluable materials you have provided > to the python community. The process that you followed must have been > incredibly arduous. *Incredibly ardous* is an exaggeration, but in the case of the MRO I needed to do som

Re: Odd closure issue for generators

2009-06-04 Thread Michele Simionato
On Jun 5, 1:18 am, Carl Banks wrote: > It's really the only sane way to handle it, odd though it may seem in > this narrow case.  In Python nested functions have to be able to > reference the current value of a variable because of use cases like > this: > > def func(): >     def printx(): >      

Re: Odd closure issue for generators

2009-06-05 Thread Michele Simionato
On Jun 5, 6:49 am, a...@pythoncraft.com (Aahz) wrote: > In article > <05937a34-5490-4b31-9f07-a319b44dd...@r33g2000yqn.googlegroups.com>, > Michele Simionato   wrote: > > > > >Actually, in Scheme one would have to fight to define > >a list comprehension (mor

Re: Odd closure issue for generators

2009-06-05 Thread Michele Simionato
On Jun 5, 6:49 am, a...@pythoncraft.com (Aahz) wrote: > In article > <05937a34-5490-4b31-9f07-a319b44dd...@r33g2000yqn.googlegroups.com>, > Michele Simionato   wrote: > > > > >Actually, in Scheme one would have to fight to define > >a list comprehension (mor

a problem with concurrency

2009-06-05 Thread Michele Simionato
kedby field of the database table respectively. It took me more time to write this email than to write the prototype, so I do not feel confident with it. Will it really work for multiple threads and multiple processes? I have always managed to stay away from concurrency in my career ;-)

Re: Odd closure issue for generators

2009-06-05 Thread Michele Simionato
On Jun 5, 11:26 am, "Gabriel Genellina" wrote: > Mmm, the URL ends with: thread, an equals sign, and the number 251156 > If you see =3D -- that's the "=" encoded as quoted-printable... Actually this is the right URL: http://www.artima.com/weblogs/viewpost.jsp?thread=251156 -- http://mail.pytho

Re: anonymous assignment

2008-05-12 Thread Michele Simionato
On May 12, 4:28 am, Yves Dorfsman <[EMAIL PROTECTED]> wrote: >there's got to be a better way than: > > d = time.local() > y = d[0] > d = d[1] Uses Python 2.6! ;) Python 2.6a3 (r26a3:62861, May 12 2008, 11:41:56) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or

Re: Literate programs in Python

2008-05-13 Thread Michele Simionato
On May 13, 5:28 pm, Paul Miller <[EMAIL PROTECTED]> wrote: > Does anyone know of any (preferably largish) examples of literate > programs written using Python? Alternatively, does anyone know of any > literate programming tools which support Python well? (I am aware of > Leo and I've been to lite

pickle error: can't pickle instancemethod objects

2008-05-23 Thread Michele Simionato
r/lib/python2.5/pickle.py", line 306, in save rv = reduce(self.proto) File "/usr/lib/python2.5/copy_reg.py", line 69, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle instancemethod objects I know that inst

Re: pickle error: can't pickle instancemethod objects

2008-05-23 Thread Michele Simionato
On May 23, 10:12 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Michele Simionato wrote: > > Can somebody explain what's happening with the following script? > >     def __gestate__(self): # should skip the bound methods attributes > > Must be __getstate__ ;) > >

Re: class-oriented rather than object-oriented?

2008-05-24 Thread Michele Simionato
mean the sense of Smalltalk) so it should have a different name, but the mistake has been made twenty years ago and there is nothing we can do now. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: cmd.Cmd bug or at least docu-bug

2008-05-29 Thread Michele Simionato
ng a custom subclass of Cmd, but I agree that the cmd module could be improved. I even wrote a cmd2 module that I should publish one day or another. +1 to submit a bug report. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

undocumented functions in pkgutil

2008-05-29 Thread Michele Simionato
sure before relying on it. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Webpy vs Django?

2008-06-03 Thread Michele Simionato
webpy, consider a bigger framework (there are many of them, Django is not your only choice). I would expect the performance of all Python framework to be roughly the same, the difference is in the learning curve and in the features, not in the performance. Michele Simionato -- http://mail.pyth

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Michele Simionato
> Pardon, but I think you mean "experienced". > > Of course, GvR may qualify as "experimented" if one considers > designing a language from scratch to be an experiment It looks like in French (as in Italian) *experimented* has the meaning of &q

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread Michele Simionato
periences gained from working with > similar implementations that exist in various real-world applications > and other programming languages. +1, I have been waiting for an odict in the library for at least 5 years. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Find class attributes creation order

2008-06-23 Thread Michele Simionato
ttributes creation order. > Using __metaclass__ is not of help because special method __new__ > receive attrs as a dictionary and so the order isn't preserved. Any > other idea? You need to wait for Python 3.0 metaclasses: http://stacktrace.it/articoli/2008/01/metaclassi-python-3000/

Re: Python 3000 vs Perl 6

2008-06-24 Thread Michele Simionato
On Jun 24, 11:16 am, [EMAIL PROTECTED] wrote: > Towards it being more advanced than Python 3k, time will tell. It is worth reminding that, in more than one sense, the most advanced language is the one with less features ... Michele Simionato -- http://mail.python.org/mailman/listinfo/pyt

Re: Python 3000 vs Perl 6

2008-06-24 Thread Michele Simionato
On Jun 24, 1:19 pm, [EMAIL PROTECTED] wrote: > Michele Simionato: > > > It is worth reminding that, in more than one sense, the most advanced > > language is the one with less features ... > > I don't agree, Scheme or Brainfuck may have less features, but this > doe

Re: Python 3000 vs Perl 6

2008-06-24 Thread Michele Simionato
than in Scheme for many reasons, but not because I think that Clinger's maxin is wrong. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Wrapping a method twice

2008-06-25 Thread Michele Simionato
On Jun 25, 1:52 pm, [EMAIL PROTECTED] wrote: >Try: > > def append(method,bottom): >     def wrapped(*args, **kwargs): >         res = method(*args, **kwargs) >         return bottom(res,*args, **kwargs) >     wrapped.__name__ = method.__name__ >     setattr(method.im_class,method.__name__,wrapped)

Re: Dynamically Changing the Base Class

2008-07-07 Thread Michele Simionato
On Jul 7, 8:08 pm, "Adam C." <[EMAIL PROTECTED]> wrote: > Thanks. I think we would want new-style classes, and 6-year-old > patches strike me as maybe a little out of the desired path... so this > really just doesn't work in modern Python? Can you use (multiple) inheritance instead of changing the

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Michele Simionato
On Jul 9, 4:38 pm, Phillip B Oldham <[EMAIL PROTECTED]> wrote: > I'm wondering whether anyone can offer suggestions on FOSS projects/ > apps which exhibit solid OO principles, clean code, good inline > documentation, and sound design principles? > > I'm devoting some time to reviewing other people'

Re: python scalability

2008-07-10 Thread Michele Simionato
On Jul 10, 6:32 am, Tim Mitchell <[EMAIL PROTECTED]> wrote: > Hi All, > > I work on a desktop application that has been developed using python and > GTK (seewww.leapfrog3d.com).  We have around 150k lines of python code > (and 200k+ lines of C). We have bigger numbers than yours here (although not

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Michele Simionato
frozen classes is not Pythonic at all, and I wrote the recipe as a proof of concept, not to use it. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Michele Simionato
On Jul 11, 6:38 pm, Robert Bossy > I don't get it. Why use a metaclass? Wouldn't the following be the same, > but easier to grasp: > > class Frozen(object): >     def __setattr__(self, name, value): >        if not hasattr(self, name): >           raise AttributeError, "cannot add attributes to %s"

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Michele Simionato
On Jul 11, 9:24 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > Robert Bossy wrote: > > class Foo(Freezeable): > > def __init__(self): > > self.bar = 42 > > self.freeze() # ok, we set all variables, no more from here > > > x = Foo() > > print x.bar > > x.bar = -42 > > print x.bar > > x.baz = "OMG! A t

Re: parameterized classes

2008-07-24 Thread Michele Simionato
John Tantalo wrote: > I really wish I could create a class whose instances were classes that > subclassed BaseRequestHandler. Is this possible, or is there a better > way than my approach here? Or am I crazy? You may use type: type('MuSubclass', (Base, ), dict(a1=1, a2=2, ...)) -- http://mail.pyt

Re: Attack a sacred Python Cow

2008-07-26 Thread Michele Simionato
s. So, it is not a big point. Still I think that it would make sense to automatically define __neq__ as the negation of __eq__. I suppose the developers did not want to make a special case in the implementation and this is also a legitimate concern. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: How to close all python-opened file identifiers?

2008-07-26 Thread Michele Simionato
y the same in Python 2.4) you could also track 'open' in the same way. If you are using Python 2.4 you can use the same trick, but in a less clean way, using a try ..finally instead of the context manager. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

<    2   3   4   5   6   7   8   9   >