ou need
(unittest, doctest, py.test, nose, ...)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
it has already happened).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
"I think DbC is good" and I said "I don't think
so".
I would not call that an attack. If you want to see an attack, wait
for
Alex replying to you observations about the low quality of code at
Google! ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I would like to upload a tab-separated file to a Google spreadsheet
from Python. Does anybody
have a recipe handy? TIA,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ade up) example
where .__metaclass__ gives
the wrong result:
In [9]: class M(type): pass
...:
In [10]: class B: __metaclass__ = M
:
In [11]: B.__metaclass__ = None # now the hook is set to None, but the
metaclass does not change
In [12]: B.__class__
Out[12]:
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 2, 7:05 am, Russ <[EMAIL PROTECTED]> wrote:
> Someone please correct me if I am wrong,
> but I think PEP adds only to the libraries.
You are wrong, PEPs also add to the core language. Why don't you give
a look
at the PEP parade on python.org?
Michele Si
On Sep 2, 7:13 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> iapain <[EMAIL PROTECTED]> wrote:
> > On Aug 31, 5:40 pm, Michele Simionato <[EMAIL PROTECTED]>
> > wrote:
> > > I would like to upload a tab-separated file to a Google spreadsheet
> > >
#x27;processing' module in PyPI.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
> En Fri, 31 Aug 2007 17:58:24 -0300, Lamonte Harris <[EMAIL PROTECTED]>
> escribi?:
>
> > I've searched Google, and other search engines to try to find out how
> > super() works. Can someone explain in short detail how super() works? I
> > may and may not need to know this information, but it is
is already
> exists, please let me know. Thanks.
Check out the decorator module at
http://www.phyast.pitt.edu/~micheles/python/documentation.html
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
corated function, my problem is running doctests on functions using an
> > imported decorator. Having to implement the decorator in every source
> > module
> > isn't very practical.
I cannot reproduce your problem. Using functools.wraps
the __module__ attribute is set cor
r.signal = lambda : os.kill(os.getpid(), sig)
return handler
return handler_decorator
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ugh
> >>> test()
> 'works!'
> """
> return "works!"
>
> if __name__ == '__main__':
> import doctest
> doctest.testmod()
>
Ok, I could not see the code before (Google groups as getting worse as
the time goes by). It looks like you are right, it is a bug in
doctest.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
e way to do what the original poster wants:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
if meth == 'DELETE':
...
else:
raise ValueError('Unknown HTTPMethod %r!!' % meth)
...
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
def a0040(): global self; self.disablePLmessages([self.dev]);
> def a0050(): global self; self.dev.testH.writePLram((PL.BCAL12<<8));
Look at generative tests in py.test or nose: they are a much
better solution for what you are doing.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
including to non-multi-process solutions.
>
> Thanks for your comments, I searched old posts for a while, various
> other Python info-sources, and couldn't find an answer.
> --
> don
Have a look at the 'processing' module.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
e built-in dict. Nonetheless, I still find it
> worth using for the convenience it offers.
>
> Do other Python programmers feel this lack? Is this worth a PEP?
>
Yes, this is a serious lack in the standard library.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
cal code full of
> 'self.'s breaking up the equations.
You can always use aliases
a = self.a
u = self.u
...
or even s = self
or play games with dictionaries.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 12, 2:42 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
> In fact, I'm not sure what people mean by ordered dicts. I assume they
> mean the keys are ordered, not the values. But ordered by what? Insertion
> orde
On Sep 12, 3:54 pm, Mark Summerfield <[EMAIL PROTECTED]>
wrote:
> On 12 Sep, 13:46, Michele Simionato <[EMAIL PROTECTED]>
>
> Actually I meant by key order, so insertion order doesn't matter at
> all. If you need a dictionary-like data structure that respects
> inse
ass of the instance, or to play trick such as
def removed_method(self):
raise NotImplementedError
self.test1 = removed_method.__get__(self)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ferent name to it: for instance it becomes cls when you are
inside a classmethod.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
s.dis(co1)
print 'bytecode for test2'
dis.dis(co2)
t = Test()
assert t.test1() == t.test2()
It is still a hack, since one is not supposed to mess around
with bytecodes, but at least it seems to work ;) [warning:
I have not tested it more than you see]
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ious
version, not on
the reloaded version, but you cannot pretende miracles from reload! ;)
You can also look at Michael Hudson's recipe
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164
for a clever approach to automatic reloading.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
r n, v in dic.iteritems():
if isinstance(v, FunctionType):
dic[n] = addlocalvar(v, 'CurrentClass', name)
return super(_CurrentClassEnabled, mcl).__new__(mcl, name,
bases, dic)
class CurrentClassEnabled:
__metaclass__ = _CurrentClassEnabled
Enjoy!
is kind of games is for prototyping
in current Python
features that are candidate for inclusion in future versions of
Python, but this was
what Raymond asked. However, there is also the fun of it ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 9, 5:18 pm, Lou Pecora <[EMAIL PROTECTED]> wrote:
> I have noticed that using from xxx import * can lead to problems when
> trying to access variables in the xxx module.
``from xxx import *`` is intended to be used in the interactive
interpreter
only.
Michele Simiona
is the
way I bought it from Amazon 5 years ago (dunno if it is still
available now, but
you never know).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
received :)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
received :)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
received :)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 12, 5:28 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> "Michele Simionato" <[EMAIL PROTECTED]> writes:
> > Any pointer would be well received :)
>
> Dunno about those libs but it helps to understand the mathematical
> options. Numerical Recip
()).replace('\n',''))
Or use one of the many safe_eval recipes out there, for instance
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
rtran because of its a high level
> language nature, so what are the advantages of using Python for
> creating number crunching apps over Fortran??
> Thanks
> Chris
The standard way is to perform the number crunching in Fortran and to
use
Python as glue. See for instance the scipy proje
_ does not seem to get
> the code in A's class scope in its arguments AFAICS, so I guess that
> code is run before the class is created?
>
> Cheers,
>
__init__ is run after class creation. What does not work exactly?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
hink I even filed a documentation bug for
that years ago, and I wrote an entire paper on the subject that
however I never published since I never felt 100% confident
with super (and I had other fishes to fry ;)
I realize now that I was wrong in not publishing it.
You can find the draft (warning: it
itself is certainly something we do want to keep, whatever
> some may argue.
Well, I am personally *against* multiple inheritance (i.e. IMO it
gives more
troubles than advantages)
>
> The goal is to call the correct "next" method according to MRO. Indeed,
> it could have bee
that the order of the methods depends on the second argument to
super, the instance,
so there is no useful concept of the superclass of the first argument
of super.
I rest my case.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
somewhere very near here, what is
> misleading is the prominence of A, which isn't really the most
> important class involved.)
>
Happily A (and B too) will become invisible in Python 3000.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 19, 8:14 pm, Ed Leafe <[EMAIL PROTECTED]> wrote:
> On Sep 19, 2007, at 6:52 AM, Michele Simionato wrote:
>
> > Well, I am personally *against* multiple inheritance (i.e. IMO it
> > gives more troubles than advantages)
>
> For the sorts of examples that
On Sep 20, 4:55 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Michele Simionato <[EMAIL PROTECTED]> writes:
> > I am not against mixins (even if I am certainly very much against
> > the *abuse* of mixins, such as in Zope 2). What I would advocate
> > (but I rea
g us very little for the point of view of mixins; OTOH,
multiple inheritance is giving us a lot of headaches for
what concerns cooperative methods.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 20, 5:41 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Michele Simionato <[EMAIL PROTECTED]> writes:
> > Ben Finney wrote:
> > > What do you see as an appropriate use of mixin classes, and what
> > > an abuse?
>
> > An example of fine usage of
On Sep 20, 6:52 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Michele Simionato <[EMAIL PROTECTED]> writes:
> > Since the language we have does have multiple inheritance, let's
> > use it to implement mixins.
> > ...
> > So, multiple inheritance is giving
On Sep 20, 4:31 pm, "Marshall T. Vandegrift" <[EMAIL PROTECTED]>
wrote:
> Michele Simionato <[EMAIL PROTECTED]> writes:
> > I am not against mixins (even if I am certainly very much against the
> > *abuse* of mixins, such as in Zope 2). What I would advocate
_name = [base for base in bases
if hasattr(base, nam)]
if any_base_has_name:
print "AlreadyDefinedNameWarning: " + nam
return type(name, bases, dic)
f = sys._getframe(1)
f.f_locals["__metaclass__"] = makecls
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
do not speak too well of Pylons, so if you thing I am wrong feel
free to correct me here ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
id. For instance, if you
Google a bit you should find the rants of the Quixote people
against Zope. I share their position.
I did not talk about TG because I see it as being very close to
Pylons and everybody is saying they will be unified in the near
future, so it would be a waste of effort to discuss TG per se.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
erious test of SQLAlchemy for a
couple of years, but never found the time :-(
Do you (or something else) have something to say about Beaker?
I looked at the source code and it seems fine to me, but I have
not used it directly, not stressed it. I need a
production-level WSGI session middleware and
On Oct 6, 12:57 pm, Bruno Desthuilliers
> Michele Simionato a écrit :
>
> > I looked at the source code and it seems fine to me, but I have
> > not used it directly, not stressed it. I need a
> > production-level WSGI session middleware and I wonder what the
> >
so for the moment I think
they will stay in Zope.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
nguage should be a non issue. Any half
> decent framework should allow you to use any other templating engine
> with ease.
> ... even python as you seem to prefer
>
Yes, the choice of templating language is a non-issue. Maybe
I should have removed my considerations on the subject in
my es
at recently Raymond Hetting said in
this list that he wanted to submit a PEP to remove __del__ from
Python 3000 (I don't know if this will ever happen tough).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 7, 1:14 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Sun, 07 Oct 2007 16:38:23 +, Michele Simionato wrote:
> > On Oct 7, 12:26 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
> >> Drop all those
On Oct 7, 11:28 pm, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Sun, 07 Oct 2007 12:55:29 -0700, Alex Martelli wrote:
> >> What should I do when my objects need to perform some special
> >> processing when they are freed, if I shouldn't use __del__?
>
> > The solid, reliable way is:
>
> > from
On Oct 8, 12:27 am, [EMAIL PROTECTED] (Aahz) wrote:
>
> Aaaugh! Don't use __slots__!
+1 QOTW ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
e just a question: suppose I want
to measure the memory allocation of a million of records made
with ctypes vs the memory allocation of equivalent
records made with __slots__, how do I measure it? Say on Linux,
Mac and Windows?
If ctypes records are more efficient than __slots__ records,
I will ask for deprecation of __slots__ (which is something
I wanted from the beginning!).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 7, 6:14 pm, Istvan Albert <[EMAIL PROTECTED]> wrote:
> On Oct 7, 12:24 pm, Michele Simionato <[EMAIL PROTECTED]>
> wrote:
>
> > Here we disagree: I think that a programmer should know what he
> > is using.
>
> My point was that they should not *need*
On Oct 10, 5:57 am, [EMAIL PROTECTED] wrote:
> Since you are starting a new project you may want to look into
> something new and different
>
> http://mdp.cti.depaul.edu/examples
Well, the name is certainly appealing to an old gauge field theorist
like myself ;)
Michele Simiona
4 because of some C libraries I need, so I
cannot even consider
a framework based on Python 2.5 for the moment :-(
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ipe does what you want, with the intent of providing
automatic finalization of the instances, but you should be able
to tweak it to do everything you wish:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/523007
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
f this little issue with the cleanup mechanism
(which BTW is shared
also by the weak references callback mechanism).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 12, 10:23 pm, Massimo Di Pierro <[EMAIL PROTECTED]>
wrote:
>
> P.S. Michele Simionato. I have heard your name before? Is it possible
> we have met in Pisa in 1990-1996? I am also a Quantum Field Theorist
> and there is not many of us.
That is definitely possible, even i
an to support it in Paste and if yes when (I mean, in a
month,
in a year, in three years?)
3. if you already have thought of a migration plan and, in that case,
what your strategy would likely be.
Thanks for sharing,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
browse this list you will find many discussions. Basically if you do
funclist = []
for i in 1,2,3:
def f():
print i
funclist.append(f)
you will get funclist[0]() == funclist[1]() == funclist[2]() == 3 (you
get the latest
binding of "i"). As you see, it has nothing to do with lamb
:
def f(i=i):
print i
funclist.append(f)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Which is the best approach to use in such case?
> Could someone point me in the right direction?
Twisted has Tkinter integration. If you don't want to use Twisted, you
could
run the asyncore loop in a separated thread with respect to the
Tkinter mainloop.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
umber, int) and number >= 0
b = []
while number:
b.append(str(number % N))
number /= N
return ''.join(reversed(b))
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
"""
> > assert 2 <= N <= 10
> > assert isinstance(number, int) and number >= 0
>
> if number == 0:
> return "0"
>
> > b = []
> > while number:
> > b.append(str(number % N))
> >
also included with Paste?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ks to Bruno and the others you know everything about
attribute access in Python. Still, you may be interested in this
recipe, which involves __setattr__ and non __getattribute__:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
.
>
> What??
>
> Can someone please throw some light on whats the current state of the art?
See http://www.python.org/dev/peps/pep-3119
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
had no success, but pearls of PEAK
are having an enormous impact. This is yet another example of
"simple is better than complex" and the ultimate reason why AOP
a la Java was a dead idea from the beginning. Too invasive.
If you want to have success, you must start from simple
things.
Mich
t my "up arrow" history working...
Google for "rlwrap".
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
abily use the
traditional registry you discussed
before (too much magic here).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
func, create=False)
works exactly as functools.update_wrapper (i.e. copies__doc__,
__module__,etc. from func to wrapper without
preserving the signature), whereas update_wrapper(wrapper, func,
create=True) creates a new wrapper
with the right signature before copying the attributes.
Michele
rver which is in the standard
library
(starting from Python 2.5+), have a look at Paste and write your own
solution.
At the least this is the way I did it.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
(f, textwidget):
textwidget.insert('end', f.readline())
textwidget.after(interval, displayfile, f, textwidget)
if __name__ == '__main__':
st = ScrolledText()
st.pack()
displayfile(sys.stdin, st)
st.mainloop()
$ python showlog.py < mylogfile.log
list.
>
>
> I am sure there is an elegant way how to do this, could you give me any
> hints???
>
def __init__(self, **kw):
vars(self).update(kw)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I am curious ... how this compare to SQLAlchemy?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
, Ian Bicking) asking to fix that.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
n
(other than in the test suite). However, class methods are still useful
in other places, for example, to program inheritable alternate
constructors.
"""
So, I stand my point.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
nt Management Systems such as Zope for
this kind of things.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
cycle.next().next()
except StopIteration:
pass
root.after(50, next, cycle)
root.after(0, next, itertools.cycle(downloader.downloads))
root.mainloop()
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
esort to kill -9, and I *hate*
that. Especially since kill -9 does not
honor try .. finally statements.
In short, I prefer to avoid threads, *especially* for the simplest
things.
I use threads only when I am forced to, typically when I am using a
multithreaded framework
interacting with a dat
d
is a three-liner, but it is not already there, nor standard :-(
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
quot;IOError: bad file descriptor" from Python, and broken pipe
> error from program_b. How do I do this right?
>
> Thanks,
> Bahadir
Use the subprocess module, see the examples here:
http://docs.python.org/dev/lib/node539.html
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 1, 1:43 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On 31 Jan 2007 22:02:36 -0800, Michele Simionato <[EMAIL PROTECTED]> wrote:
> >Another thing I miss is a facility to run an iterator in the Tkinter
> >mainloop: since Tkinter is not thread-safe,
>
; into the same problem at all, so I'm curious.)
>
> Steve
I have seen breakage in Zope, due to the switch from old-style
exceptions to new-style
exceptions.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
same reason
I don't like excessive inheritance, it is too easy to get lost when
debugging
code written by somebody else. But probably I am just overreacting due
to my
exposure to Zope ...
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ice that
checking for the existance
of the needed method is better than using isinstance, since it gives
you much more
freedom for innerobj. Do not require more than you need.
HTH,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ing on here ? I mean, what is actually
> happens if you omit the parenethesis as you just did ? I understand
> that it does not call the method, but what is really doing ??
See http://users.rcn.com/python/download/Descriptor.htm for more than
you ever wanted
to know about attribute access i
turns have their own attributes, and so on. In other words, nested
is better
than flatten ;)
Michele Simionato
P.S. Of course I mean situations where the methods can be meaningfully
grouped
together, which I find is the most common case.
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 8, 4:05 pm, [EMAIL PROTECTED] wrote:>
> Composition is great when you know how largish classes are going to be
> composed ahead of time and/or already have the pieces available in the form
> of other classes you want to reuse. I use this fragment-by-multiple-
> inheritance (I hesitate to ca
th):
setattr(cls, meth.__name__, meth)
return meth
return attach_meth
@attach_to(pointer_to_c)
@classmethod
def from_param(cls, value):
... do something ...
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
look at this recent thread:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/77fc9888e43bac46/1df3bcbfb785395c?lnk=gst&q=download+simionato&rnum=1&hl=en#1df3bcbfb785395c
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
inner object.
Hope you can find some useful trick for solving your problem.
Michele Simionato
import sys, cmd, traceback, inspect
try: # Python 2.5
from functools import update_wrapper
except ImportError:
def update_wrapper(wrapper,
wrapped,
assigned
use them int if the constant was zero and lambda otherwise. If they
wanted
to use itertools.repeat(const).next they should prove me that the
speed
increase is absolutely significant in their actual use case and
they should put a big comment in the code explaining why they
preferred
the cryptic defau
works, but when
you start having dozens of methods inherited from different sources,
your code will
become to look as spaghetti code.
This is why in general I (as many people here) suggest delegation over
inheritance.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
401 - 500 of 896 matches
Mail list logo