Re: Attack a sacred Python Cow

2008-08-03 Thread Michele Simionato
py with self, because sometimes it can be named cls, mcl, obj or anything else, and I take advantage of this fact in my code. self is more readable than a dot and there is no point in making a special case for it. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Attack a sacred Python Cow

2008-08-03 Thread Michele Simionato
On Aug 3, 9:29 am, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Jul 28, 8:46 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > > Letting "self" (or whatever the first argument was) be implied in > > ".cat" does absolutely *NOTHING* t

Re: Class definition attribute order

2008-08-04 Thread Michele Simionato
On Aug 5, 4:38 am, "Gabriel Genellina": > > So the namespace that the metaclass receives when the class is created,   > will be some kind of ordered dictionary? > Metaclasses are available for a long time ago, but the definition order is   > lost right at the start, when the class body is executed.

ANN: decorator 2.3

2008-08-04 Thread Michele Simionato
sing it are signature-preserving, which is not the case for naive decorators. The full documentation is here: http://www.phyast.pitt.edu/~micheles/python/documentation.html You can download the archive http://www.phyast.pitt.edu/~micheles/python/decorator-2.3.1.zip or just run easy_insta

Re: Class definition attribute order

2008-08-04 Thread Michele Simionato
On Aug 5, 7:47 am, Terry Reedy <[EMAIL PROTECTED]> wrote: > > Bfiefly, as I understood the discussion some months ago: In 2.x, the > class body is executed in a local namespace implemented as a normal dict > and *then* passed to the metaclass.  In 3.0, the metaclass gets brief > control *before* ex

Re: Hobbyist - Python vs. other languages

2008-08-05 Thread Michele Simionato
better for my needs than any commercial application could. The biggest feature is the absence of features: less is more. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

python-mode is missing the class browser

2008-08-07 Thread Michele Simionato
least how do I get back the class browser? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: python-mode is missing the class browser

2008-08-08 Thread Michele Simionato
On Aug 7, 5:55 pm, Alexander Schmolck <[EMAIL PROTECTED]> wrote: > There are two different and independently developedpython-modes. The > politically correct one that comes with emacs (IIRC python.el) that had pretty > limited functionality last time I looked, and the original but not FSF blessed >

Re: Class definition attribute order

2008-08-09 Thread Michele Simionato
On Aug 5, 5:05 am, Michele Simionato > Yep. Seehttp://stacktrace.it/articoli/2008/01/metaclassi-python-3000 > (I am working on an English translation these days, > but for the moment you can use Google Translator). > >  M. Simionato FWIW, I have just finished translating the fi

Re: Class definition attribute order

2008-08-09 Thread Michele Simionato
; however since the ordered dict implementation I show does not support __delitem__ (on purpose, to make it simple enough to fit in a short paper) I thought it was more correct to derive from Mapping, not from dict. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: some kind of trace facility ?

2008-08-10 Thread Michele Simionato
On Aug 10, 1:14 am, Stef Mientki <[EMAIL PROTECTED]> wrote: > hello, > > I want to investigate on a regular base the flow of my Python (most of > them using wxPython) programs. > So I want to have some log facilty, that logs things like > - every time a function / method is called > - the time spen

Re: __getattr__, __setattr__ and pickle

2008-08-13 Thread Michele Simionato
On Aug 12, 7:28 pm, mwojc <[EMAIL PROTECTED]> wrote: > Hi! > My class with implemented __getattr__ and __setattr__ methods cannot be > pickled because of the Error: Another option is to define __getstate__ on your class: def __getstate__(self): return vars(self) M.S. -- http://mail.python.or

Re: Factory for Struct-like classes

2008-08-13 Thread Michele Simionato
On Aug 13, 6:43 pm, eliben <[EMAIL PROTECTED]> wrote: > Hello, > > I want to be able to do something like this: > > Employee = Struct(name, salary) > > And then: > > john = Employee('john doe', 34000) > print john.salary > > Basically, Employee = Struct(name, salary) should be equivalent to: > > cl

Re: class super method

2008-04-01 Thread Michele Simionato
ool idea, but now I think it is a pretty bad idea. If I were to design a language, I would not implement multiple inheritance. In Python I never use multiple inheritance and actually I try very hard to avoid even single inheritance, preferring composition whenever it is viable. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: pry unit testing framework

2008-04-05 Thread Michele Simionato
> less than half the size of nose, and should therefore be simpler to > extend and understand. You forgot to mention the important point that nose is compatible with unittest and many developer (including myself) would consider that a major selling point. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: pry unit testing framework

2008-04-05 Thread Michele Simionato
y much sure you are making a gender mistake with Kay Schluehr here ;) For the rest, I do fully agree with your remarks. Kay +1, Aldo -1! Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning curve for new database program with Python?

2008-04-05 Thread Michele Simionato
ou use Windows or Unix, if you want graphical administration tools or not, what your final goal is, and so on. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Python generators (coroutines)

2008-04-23 Thread Michele Simionato
way to get 1) and 2). Anyway, if you have a blocking operation, the only solution is to use a thread or a separate process. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Python generators (coroutines)

2008-04-23 Thread Michele Simionato
On Apr 23, 8:26 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Wed, 23 Apr 2008 10:53:03 -0700 (PDT), Michele Simionato: > You could have #2. It's a trivial variation of sending a value. For > example, > > http://twistedmatrix.com/trac/browser/trunk/twisted/int

Re: ]ANN[ Vellum 0.16: Lots Of Documentation and Watching

2008-04-30 Thread Michele Simionato
et another lightweight markup language or to go back to TeX. Is the Vellum book written in reST? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically defined functions via exec in imported module

2008-08-15 Thread Michele Simionato
e, has a strong functional bias so it may be of interest to people coming from Scheme. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically defined functions via exec in imported module

2008-08-16 Thread Michele Simionato
On Aug 16, 3:25 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Aug 16, 12:50 am, Michele Simionato <[EMAIL PROTECTED]> > wrote: > > The namedtuple recipe by Raymond Hetting does > > exactly that and, guess what, it uses exec! > > I might be wrong, bu

Re: Dynamically defined functions via exec in imported module

2008-08-16 Thread Michele Simionato
am not sure if in Python 3.0 the signature object is powerful enough to do the job, I never had to time to check how it works. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: List of modules available for import inside Python?

2008-08-27 Thread Michele Simionato
On Aug 28, 6:21 am, ssecorp <[EMAIL PROTECTED]> wrote: > Is there a way to view all the modules I have available for import > from within Python? > Like writing in the interpreter: Try: >>> help() help> modules Please wait a moment while I gather a list of all available modules... -- http://mail

Re: Python in a Nutshell -- Book vs Web

2008-08-29 Thread Michele Simionato
On Aug 29, 1:44 pm, [EMAIL PROTECTED] (Cameron Laird) wrote: > Insightful.  Well, I find it insightful; perhaps it's > a personal blindness on my part.  I expect programmers > to understand, for example, that two lines of code can > be a good day's production, in some circumstances My best days ar

Re: Some problems with classes

2008-08-31 Thread Michele Simionato
On Sep 1, 3:39 am, ssecorp <[EMAIL PROTECTED]> wrote: > > Traceback (most recent call last): >   File "C:/Python25/Progs//Movie.py", line 42, in >     class ActionComedy(Movie, ActionMovie): > TypeError: Error when calling the metaclass bases >     Cannot create a consistent method resolution

Re: Late initialization using __getattribute__

2008-09-03 Thread Michele Simionato
On Sep 4, 12:26 am, bukzor <[EMAIL PROTECTED]> wrote: > I'm trying to optimize my number of connections by not fully > initializing (read: not connecting) my connection until it's used in > some way. I had the same use case and I solved with a simple property. Here is the code I have for pymssql:

Re: derived classes and __getattr__

2008-09-05 Thread Michele Simionato
On Sep 5, 11:46 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > I have another small problem. now, > d.third('blah') doesn't work because instance d doesn't have 'third' > attribute. I was expecting derived class to inherit the metaclass as > well, but it didn't. Yep, it is explained here: http

Re: atomic section in code

2008-09-05 Thread Michele Simionato
nts over the standard docs which are lacking in various areas. I have always wondered why they are kept separated. Wouldn't be nice to have the standard docs integrated with the effbot docs? Are there plans in this sense and if not, why not? Michele Simionato -- http://mail.python.org

Re: use str as variable name

2008-09-05 Thread Michele Simionato
On Sep 6, 8:02 am, "Marco Bizzarri" <[EMAIL PROTECTED]> wrote: > On Fri, Sep 5, 2008 at 9:16 PM, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > > Marco Bizzarri a écrit : > > >> Just a question: "generic functions" are not meant in the sense of > >> "generic functions" of CLOS, am I right? >

Re: List of modules available for import inside Python?

2008-09-10 Thread Michele Simionato
type `GtkSourceBuffer' __import__(m) /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: g_type_get_qdata: assertion `node != NULL' failed __import__(m) Segmentation fault Interesting, isn't it? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching subprocess stdout stream

2008-09-10 Thread Michele Simionato
enough. For instance on Unix you could call os.system on something like that: xterm -e "the-fortran-executable|less" Make sure the Fortran executable output is unbuffered. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Injecting new names into the above frame

2008-09-13 Thread Michele Simionato
On Sep 13, 1:35 pm, Peter Waller <[EMAIL PROTECTED]> wrote: > This makes me want to ask: is it difficult to modify a function's > code? No, it is not difficult. Look at the byteplay module: it makes possible all kinds of dirty hacks. -- http://mail.python.org/mailman/listinfo/python-list

Re: closures and dynamic binding

2008-09-29 Thread Michele Simionato
On Sep 28, 6:43 am, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > Hello all, > > To me, this is a somewhat unintuitive behavior.  I want to discuss the > parts of it I don't understand. > > >>> f= [ None ]* 10 > >>> for n in range( 10 ): > > ...     f[ n ]= lambda: n > ...>>> f[0]() > 9

Re: Are there any python micro-frameworks (like ruby's Camping)?

2008-10-01 Thread Michele Simionato
On Oct 1, 10:58 am, Phillip B Oldham <[EMAIL PROTECTED]> wrote: > On Oct 1, 9:53 am, Sam <[EMAIL PROTECTED]> wrote: > > > Did you try WebPy?http://webpy.org/Hum, the website seems to be down today > > Not yet - I'm hoping the python community can suggest some examples of > micro/small frameworks (w

Re: RELEASED Python 2.6 final

2008-10-01 Thread Michele Simionato
On Oct 2, 5:46 am, Barry Warsaw <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On behalf of the Python development team and the Python community, I   > am happy to announce the release of Python 2.6 final. Cool! I have just downloaded the Mac installer and did the

Re: questions from a lost sheep

2008-10-02 Thread Michele Simionato
On Oct 2, 11:08 pm, johannes raggam <[EMAIL PROTECTED]> wrote: > statically typed language: A language in which types are fixed at > compile time. Most statically typed languages enforce this by requiring > you to declare all variables with their datatypes before using them. > Java and C are static

Re: closures and dynamic binding

2008-10-03 Thread Michele Simionato
On Oct 3, 10:44 am, greg <[EMAIL PROTECTED]> wrote: > So if anything were to be done to the language to > fix this, it really should be focused on fixing the > semantics of the for-loop. Unfortunately, the > fact that the loop variable leaks out of the scope > of the loop is regarded as a feature,

Re: Inheritance but only partly?

2008-10-03 Thread Michele Simionato
On Oct 2, 10:16 pm, process <[EMAIL PROTECTED]> wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? Don't use inheritance, use delegation or just copy the

Re: Strange metaclass behaviour

2006-03-23 Thread Michele Simionato
ation and it should go somewhere in the standard docs. I remember I spent a significant amount of time and effort to reach the same conclusion a while ago, and now I have already started to forget eveything a again :-( Anyway, I will bookmark this post for future reference ;) Michele Simionat

Re: Strange metaclass behaviour

2006-03-23 Thread Michele Simionato
meta = get_noconflict_metaclass(b, (mcl,), right_metas=()) if meta is mcl: # meta is trivial, dispatch to the default __new__ return super(safetype, mcl).__new__(mcl, n, b, d) else: # non-trivial metaclass, dispatch to the right __new__ # (it will take a second round) return super(mcl, meta).__new__(meta, n, b, d) else: raise TypeError('%s() takes 1 or 3 arguments' % mcl.__name__) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange metaclass behaviour

2006-03-24 Thread Michele Simionato
, *args, **kw) return cls frame.f_locals["__metaclass__"] = makecls Figured you would like this one ;) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange metaclass behaviour

2006-03-24 Thread Michele Simionato
Well, I would not call it a bug, I would call it to cheat ;) The assert is there I just wanted to prevent accidents, not to *really* ensure that 'thisclass' is called inside a class statement. Do you know of any reliable method to enforce that restriction? Michele Simionato

Re: Strange metaclass behaviour

2006-03-24 Thread Michele Simionato
Ziga Seilnacht wrote: > >>> def in_class_statement2(): > ... frame = sys._getframe(1) > ... return '__module__' in frame.f_locals and not \ > ...'__module__' in frame.f_code.co_varnames On second thought, to break this check is less easy than I expected, so maybe it is reliable

Re: Why are so many built-in types inheritable?

2006-03-30 Thread Michele Simionato
I cannot find the reference now, but I remember Tim Peters saying some time ago that the only reason why FunctionType is not subclassable is that nobody bothered to write a patch for it. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: "definitive" source on advanced python?

2006-04-03 Thread Michele Simionato
I gave a course on advanced Python last year at the ACCU conference. See http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference in Python and Ruby interactive shells

2006-04-04 Thread Michele Simionato
You want this recipe from Michael Hudson: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164 "automatically upgrade class instances on reload()" -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 2.5 (alpha 1)

2006-04-05 Thread Michele Simionato
Michael Ekstrand wrote: > After reading AMK's survey of what's new in Python 2.5, I am suitably > impressed. As usual, I can't wait to start using the cool new > features... extended generators? (mind is currently swimming with the > question of "can I implement Scheme's call-with-current-continua

Re: pre-PEP: The create statement

2006-04-06 Thread Michele Simionato
Steven Bethard wrote: > The PEP is based on a suggestion [1]_ from Michele Simionato on the > python-dev list. True, but I would also mention that the idea of the 'create' keyword come from Nick Coghlan: http://mail.python.org/pipermail/python-dev/2005-October/057531.html M

Re: pre-PEP: The create statement

2006-04-06 Thread Michele Simionato
proposal, but I suggested him to propose the PEP with the 'create' keyword, just to have a nicer title ;) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 2.5 (alpha 1)

2006-04-06 Thread Michele Simionato
Michael Ekstrand wrote: > Michele Simionato wrote: > > Michael Ekstrand wrote: > >> After reading AMK's survey of what's new in Python 2.5, I am suitably > >> impressed. As usual, I can't wait to start using the cool new > >> features... extend

Re: pre-PEP: The create statement

2006-04-06 Thread Michele Simionato
Kay Schluehr wrote: > Steven Bethard wrote: > > > Python-Version: 2.6 > > Have you a rough estimation how many modules will be broken when > "create" is introduced as a keyword? This is a very relevant question. I would expect the new keyword would break lots of modules. However measuring is bette

Re: pre-PEP: The create statement

2006-04-06 Thread Michele Simionato
cept I also found an occurrence of 'create' in Tkinter). BTW, I would be curious to see the script you are using for the scanning. Are you using tokenize too? In am quite fond of the tokenize module ;) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting all permutations of a substring

2006-04-06 Thread Michele Simionato
Azolex wrote: > Python 2.5a1 (r25a1:43589, Apr 5 2006, 10:36:43) [MSC v.1310 32 bit > (Intel)] on win32 > ... > >>> cnt_ss = lambda s,ss,p=-1,n=-1 : n if n>p else > >>> cnt_ss(s,ss,s.find(ss,p+1),n+1) Ah, the pleasure of having a ternary operator in the

Re: pre-PEP: The create statement

2006-04-06 Thread Michele Simionato
Sion Arrowsmith wrote: > Michele Simionato <[EMAIL PROTECTED]> wrote: > >Sion Arrowsmith wrote: > >> A quick scan of the standard library suggests that it will have > >> a grand total of 3 modules requiring a fix (it's a method name > >> in imapli

Re: pre-PEP: The create statement

2006-04-06 Thread Michele Simionato
he name. What I had in mind was a namespace or, if you wish, a named dictionary. An simple-minded implementation could be class Namespace(object): def __init__(self, name, args, dic): self.__name__ = name self.__dict__.update(dic) create Namespace keymap: A = 1

Re: updated pre-PEP: The create statement

2006-04-06 Thread Michele Simionato
= ("", , ) > > The former allows the create statement to be applied to a wider variety > of callables; the latter keeps a better parallel with the class statement. Maybe I am thick this evening, but how that would work? It would break for classes if we do not follow the

Re: pre-PEP: The create statement

2006-04-07 Thread Michele Simionato
'make' sounds too Lispy, this is why it is never used in Pythonland. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

OT: job offering in Milan

2006-04-07 Thread Michele Simionato
My current employer is looking for a senior system administrator/programmer with good Python expertise. Notice that the job is in Milan, Italy and that we do not consider remote work. You can mail your CV and/or ask questions to [EMAIL PROTECTED] I can say this is a nice place to work ;) Here is t

Re: OT: job offering in Milan

2006-04-07 Thread Michele Simionato
Robin Becker wrote: > Michele Simionato wrote: > .. > > The Company > > StatPro, a leader Company in the field of portfolio analytics for the > > global asset management market, is looking for a Senior Systems/Network > > Engineering Specialist, wh

Re: About classes and OOP in Python

2006-04-11 Thread Michele Simionato
too. Wrong, _foo is a *private* name (in the sense "don't touch me!"), __foo on the contrary is a *protected* name ("touch me, touch me, don't worry I am protected against inheritance!"). This is a common misconception, I made the error myself in the past. Mic

Re: updated pre-PEP: The create statement

2006-04-11 Thread Michele Simionato
ial repetition/ of tags and the results of the > > statement suites are passed as unordered namespaces/dicts. > > Good point. The code above would only work if you didn't care about the > order of elements. I'm half inclined to pull the example, but the > original was due to

Re: updated pre-PEP: The create statement

2006-04-11 Thread Michele Simionato
tition/ of tags and the results of the > > statement suites are passed as unordered namespaces/dicts. > > Good point. The code above would only work if you didn't care about the > order of elements. I'm half inclined to pull the example, but the > original was due to

Re: updated pre-PEP: The create statement

2006-04-11 Thread Michele Simionato
tition/ of tags and the results of the > > statement suites are passed as unordered namespaces/dicts. > > Good point. The code above would only work if you didn't care about the > order of elements. I'm half inclined to pull the example, but the > original was due to

Re: updated pre-PEP: The create statement

2006-04-11 Thread Michele Simionato
tition/ of tags and the results of the > > statement suites are passed as unordered namespaces/dicts. > > Good point. The code above would only work if you didn't care about the > order of elements. I'm half inclined to pull the example, but the > original was due to

Re: updated pre-PEP: The create statement

2006-04-11 Thread Michele Simionato
tition/ of tags and the results of the > > statement suites are passed as unordered namespaces/dicts. > > Good point. The code above would only work if you didn't care about the > order of elements. I'm half inclined to pull the example, but the > original was due to

Re: updated pre-PEP: The create statement

2006-04-11 Thread Michele Simionato
Peter Hansen wrote: > Michele Simionato wrote: > > You can pull out the example in the official > > PEP, if you like. > > Please do. If this is supposed to have anything to do with namespaces, > it has nothing to do with the type of data structures XML is capable of &g

Re: Creating an event loop

2006-04-11 Thread Michele Simionato
ntage is that you can every easily schedule recurring and non-recurring events. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 359: The "make" Statement

2006-04-15 Thread Michele Simionato
ethods behind the scenes it's > losing that virture. And for what? Supporting some use cases that have > reasonable solutions already? FWIW, this is my feeling too. Let's keep it simple, please! Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on Python as career

2009-12-04 Thread Michele Simionato
Python user group, to go to conferences and to make yourself known in a way or another. It takes time. Good luck! Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: "file" does not work with the "with" statement!

2009-12-10 Thread Michele Simionato
On Dec 10, 11:04 am, "Diez B. Roggisch" wrote: > Are you sure? For me on python2.5, it works as advertised: > > from __future__ import with_statement > > def test(outf): >     with outf: >         outf.write("test\n") >     try: >         outf.write("test\n") >         assert False, "Not closed" >

Re: "file" does not work with the "with" statement!

2009-12-10 Thread Michele Simionato
On Dec 10, 11:59 am, Christian Heimes wrote: > In Python 2.5 you have to implement your own __enter__ and __exit__ > methods if you subclass from file. The file.__exit__ function doesn't > call f.close(). Yes, that was my problem. -- http://mail.python.org/mailman/listinfo/python-list

"file" does not work with the "with" statement!

2009-12-10 Thread Michele Simionato
I have just discovered that the syntax with file(name, 'w') as f: do_something(f) does not close the file at the end of the with statement! On the contrary with open(name, 'w') as f: do_something(f) works fine. The docs say "When opening a file, it’s preferable to use open() instead of in

Re: Dangerous behavior of list(generator)

2009-12-16 Thread Michele Simionato
On Dec 14, 11:05 pm, Carl Banks wrote: > But to answer your question, I think "simple is better than complex" > rules the day.  Right now StopIteration stops an iteration, simple as > that.  Any fix would add complexity. +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: share dictionary between processes

2009-12-18 Thread Michele Simionato
On Dec 18, 8:48 am, blumenkraft wrote: > Hi, > > I want to share dictionary between two distinct processes. > > Something like this: > > first.py > import magic_share_module > > def create_dictionary(): >     return {"a": 1} > > magic_share_module.share("shared_dictionary", > creator.create_dictio

Re: Inheriting methods but over-riding docstrings

2010-01-19 Thread Michele Simionato
On Jan 16, 6:55 pm, Steven D'Aprano wrote: > I have a series of subclasses that inherit methods from a base class, but > I'd like them to have their own individual docstrings. The following is not tested more than you see and will not work for builtin methods, but it should work in the common cas

Re: Inheriting methods but over-riding docstrings

2010-01-20 Thread Michele Simionato
On Jan 21, 12:09 am, "Gabriel Genellina" wrote: > This is basically the same technique as in   > but there is   > a difference: you clone the function object *and* the code object it is   > based on. As I understand it, code objects are

counting lines of code

2010-01-20 Thread Michele Simionato
I need a small utility to count the lines of Python code in a directory, traversing subdirectories and ignoring comments and docstrings. I am sure there is already something doing that, what do you suggest? TIA, Michele Simionato -- http://mail.python.org/mailman

Re: counting lines of code

2010-01-20 Thread Michele Simionato
I did not known about cloc, it does more that I need, but it looks cool (it is perl and not Python, by who cares? ;) Thanks, Michele -- http://mail.python.org/mailman/listinfo/python-list

Re: counting lines of code

2010-01-20 Thread Michele Simionato
On Jan 21, 8:12 am, Ben Finney wrote: > Michele Simionato writes: > > I need a small utility to count the lines of Python code in a > > directory, traversing subdirectories and ignoring comments and > > docstrings. I am sure there is already something doing that, what do >

Re: counting lines of code

2010-01-21 Thread Michele Simionato
On Jan 21, 9:24 pm, Phlip wrote: > On Jan 20, 11:20 pm, Michele Simionato > wrote: > > > pylint does too many things, I want something fast that just counts > > the lines and can be run on thousands of files at once. > > cloc seems fine, I have just tried on 2,

Re: counting lines of code

2010-01-23 Thread Michele Simionato
On Jan 22, 7:51 pm, Phlip wrote: > On Jan 21, 9:00 pm, Michele Simionato > wrote: > > > Just for fun I have run cloc on our trunk: > > > SUM:                8743    272238    215871   1470139 x   1.84 = > > 2708354.95 > > Nice! > > My favorite version

Re: counting lines of code

2010-01-23 Thread Michele Simionato
On Jan 22, 10:30 pm, Steve Holden wrote: > >> Oh, sorry, did I have the wrong opinion? > > > You had a condescending attitude. > > Towards someone who is fairly obviously not a Python neophyte. > > Please don't think we are telling you you can't have any opinion you > like. Just don't expect to ge

Re: Function name unchanged in error message

2010-01-29 Thread Michele Simionato
On Jan 29, 2:30 pm, andrew cooke wrote: > Is there any way to change the name of the function in an error > message?  In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the same name) Us

Re: super() and multiple inheritance failure

2009-09-25 Thread Michele Simionato
On Sep 26, 4:36 am, Steven D'Aprano wrote: > I don't understand why I'm getting the following behaviour when using > super() with multiple inheritance. super is working as intended. If you do not want cooperative methods, don't use super and call directly the superclass. I usually recommend avoid

Re: Things to know about ‘super’ (was: super() a nd multiple inheritance failure)

2009-09-25 Thread Michele Simionato
On Sep 26, 6:56 am, Ben Finney wrote: > Michele Simionato writes: > > You may want to read "Things to know about super": > > >http://www.artima.com/weblogs/viewpost.jsp?thread=236275 > >http://www.artima.com/weblogs/viewpost.jsp?thread=236278 > >http://ww

Re: super() and multiple inheritance failure

2009-09-25 Thread Michele Simionato
On Sep 26, 8:02 am, "Gabriel Genellina" wrote: > If you decide at every invocation which method to call, it's a dispatcher;   > you may use a dictionary to map each alternative to the function to be   > invoked. If it only depends on the type of the argument, there is a hidden   > gem in pkgutil (

extracting info from media files

2009-11-07 Thread Michele Simionato
I would like to extract some simple info from media files, such as size, resolution, duration, codec. What's the simplest way to do it? Once in a time there was pymedia but I see the latest release is of February 2006. The solution should work on Linux and provide support for a large set of video f

Re: Python & Go

2009-11-12 Thread Michele Simionato
Well, Go looks like Python in the philosophy (it is a minimalist, keep it simple language) more than in the syntax. The one thing that I really like is the absence of classes and the presence of interfaces (I have been advocating something like that for years). I am dubious about the absence of exc

Re: Python & Go

2009-11-12 Thread Michele Simionato
I forgot to post a link to a nice analysis of Go: http://scienceblogs.com/goodmath/2009/11/googles_new_language_go.php -- http://mail.python.org/mailman/listinfo/python-list

Re: #define (from C) in Python

2009-11-12 Thread Michele Simionato
On Nov 12, 5:43 pm, Santiago Romero wrote: > Is there a Python version of C's language #define statements? > > Example: > > #define ReadMem( (x) )    memory[ (x) ] > >  Instead of using a function, when you call to ReadMem(), the code is > INCLUDED, (no function is called, the "compiler" just subs

Re: Vote on PyPI comments

2009-11-13 Thread Michele Simionato
On Nov 13, 4:39 pm, Chris Withers wrote: > > PyPI grew a commenting and rating system a while back, apparently in > response to requests from users. However, since it's been rolled out, > there's been a backlash from package maintainers who already have > mailing lists, bug trackers, etc for their

Re: Python & Go

2009-11-13 Thread Michele Simionato
On Nov 14, 4:38 am, Paul Rubin wrote: > It seems a little weird to me that they (Google) are concerned with > the speed of the compiler, indicating that they plan to write enormous > programs in the language.  I've heard they use a 1000-node cluster to > compile their

Re: Python & Go

2009-11-14 Thread Michele Simionato
On Nov 14, 12:26 pm, kj wrote: > > The two goals of replacing C with "something more modern" and at > the same time have a "nearly zero learning curve" seem to me mutually > negating.  The closer to zero the learning curve is, the closer to > C/C++, and therefore the less modern, that language wil

Re: Python & Go

2009-11-14 Thread Michele Simionato
On Nov 14, 7:18 pm, John Nagle wrote: >      Leaving out exceptions was a mistake.  Exceptions are well understood > now, > and they're far better than the usual "ignore errors" approach one sees in > lamer > C programs. I am also surprised about the lack of exceptions. I could infer that Rob P

Re: Python & Go

2009-11-14 Thread Michele Simionato
On Nov 15, 3:00 am, Terry Reedy wrote: > It seems to me that generators are already 'channels' that connect the > calling code to the __next__ method, a semi-coroutine based on the body > of the generator function. At present, the next method waits until an > object is requested. Then it goes into

Re: Python & Go

2009-11-14 Thread Michele Simionato
Let me add a quote from the FAQ: """ Why does Go not have exceptions? Exceptions are a similar story. A number of designs for exceptions have been proposed but each adds significant complexity to the language and run-time. By their very nature, exceptions span functions and perhaps even goroutine

Re: Vote on PyPI comments

2009-11-15 Thread Michele Simionato
On Nov 15, 5:17 am, Steven D'Aprano wrote: > On Fri, 13 Nov 2009 07:53:05 -0800, Michele Simionato wrote: > > I am skeptical about the utility of both rating and comments. If > > somebody wants to know > > if a package is good, she should ask here. > > Becaus

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Michele Simionato
On Nov 20, 4:18 am, Peng Yu wrote: > I'm wondering if there is something similar to list comprehension for > dict Yes, but only in Python 3: >>> {(i, x) for i, x in enumerate('abc')} {(0, 'a'), (1, 'b'), (2, 'c')} -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Michele Simionato
Wanting the same methods to be attached to different classes often is a code smell (perhaps it is not your case and then use setattr as others said). Perhaps you can just leave such methods outside any class. I would suggest you to use a testing framework not based on inheritance (i.e. use nose or

<    3   4   5   6   7   8   9   >