BTW, what it your use case? I have yet to see a single compelling use
case for multiple inheritance, so I am
curious of what your design is.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
s, annoyances.
Whereas I recommend the first lecture about iterators and generators
to everybody, take in account than the second and especially the
third lecture may cause your head to explode. I do not take any
responsability in that case.
"""
Michele
iterables too.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ad and written MI hierarchies that could have
much better written without MI. Finally, let me say that cooperative
methods are terrible for maintenance. Nowadays, I tend to use MI just
for debugging (yes, a mixing is convenient, if not compelling, for
adding debugging functionality to a class).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I would say reStructuredText is the preferred format
for documenting Python code. Google is your friend.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
opy of the
original one
>>> it1.next()
1
In general you can use the idiom
it = check(it) # check for emptiness
if it:
# do something
This time I have checked the examples here with my doctester
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410052 ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Do you mean setattr?
setattr(A, meth_name, lambda self: type(self))
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
You should read the documentation and this:
http://www.catb.org/~esr/faqs/smart-questions.html
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
-style
classes and more).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
find it here:
http://www.phyast.pitt.edu/~micheles/python/decorator.zip
It is released under the Python licence.
Let me know if you are using it and if you would like further
additions/improvements/changes/etc.
Feeback is welcome!
Michele Simionato
--
http://mail.python.org
nks to the original source code, so I can see it with
a click.
I can feed to "minidoc" whole packages (it works recursively on
subpackages, so everything is documented).
It was unvaluable in my struggle with Zope.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
an reach the documentation
for that name with a click.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
on
>Ps... I like your physics link page. :)
That page is old, I am no more in physics, but I still have that
account for free
and I am lazy, so I am keeping it ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
These days I use generators instead of StringIO, i.e.
instead of
print >> out, mystring
I just write
yield mystring
and then I "".join the generator.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
b.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip
You can also define a custom super that
does not give an error when the superclass doesn't have the
corresponding method (I posted an example
some time ago to somebody complaining for the same reason).
Michele Sim
are
preserved;
3. the signature of the original function is preserved (this one is
nontrivial).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
for testing border cases I would have never imagined!
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ans of an assert statement?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
...
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Yep, I was wondering about irrelevant things, there is no problem in
this case,
actually.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ary/l-pymeta2/index.html
http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
If you really want, you can customize the object system
to automatically call __init__, via a custom metaclass.
There is an example in my ACCU lectures (cooperative_init.py):
http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip
Michele Simionato
--
http
ended with my
application. Any suggestion?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
This looks interesting, but I need an example here. What would be the
command
to open Konqueror to a given page and to post a form with given
parameters?
kde.org has tons a material, but I am getting lost and I don't find
anything
relevant to my simple problem.
Mi
n [4]: sh["f"]=f
In [5]: sh.close()
In [6]: sh=shelve.open("x.shelve")
In [7]: sh["f"]
Out[7]:
You may want to experiment a bit.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
You should read the metaclass book, if you can find it.
For the reference, see
http://www-106.ibm.com/developerworks/linux/library/l-pymeta.html
http://www-128.ibm.com/developerworks/linux/library/l-pymeta2/index.html
Michele Simionato
--
http://mail.python.org/mailman
BTW, since this is a bit off-topic anyway, how do I recover
files accidentally removed? Is there a free tool that works
on FAT/NTFS and ext2/ext3?
Thanks,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
The problem is that Google gives me too many non-relevant hits.
I just would like something like this:
$ rm what-I-think-is-an-useless-file
ACK! It was not that useless!!
$ recover what-I-think-is-an-useless-file
Michele Simionato
--
http://mail.python.org/mailman/listinfo
>From a purist perspective the distinction
statements/expressions is a mistake.
However, if your primary concerns is readability,
it makes sense, since it enforces ifs, try.. excepts, etc.
to be consistently written for all coders. This definitely
helps code review.
Michele Simion
If you are curious, the MRO algorithm is explained here:
http://www.python.org/2.3/mro.html
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
You could generate your report in reStructuredText
format (Google is your friend) and then convert
them in HTML, PS, PDF, etc.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
d):
makedirs(head, mode)
if tail == curdir: # xxx/newdir/. exists if
xxx/newdir exists
return
mkdir(name, mode)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
*we*
>are building the world. This is a huge fundamental difference!
It looks like you do not have a background in Physics research.
We *do* build the world! ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Magnus Lycka:
> While scientists do build and create things,
> the ultimate goal of science is understanding. Scientists build
> so that they can learn. Programmers and engineers learn so that
> they can build.
Well put! I am going to add this to my list of citations :)
ys distinguish between Science (=what we know)
and Research (=what we do not know). Research is performed
with all methods except the scientific one, even if we don't
tell the others ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
t;a")
print Foo("b")
Michele Simionato
P.S. don't do it!
--
http://mail.python.org/mailman/listinfo/python-list
sometimes TIFFReader
instances. Explicit is better than implicit and all that.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ramming; on the other hand, I think that even
now there
is a 1% of people extremely interested in turning on or off a pixel.
I don't think anything significant changed in the percentages.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
don't see the connection.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
rom my
>overall experience I infer, that it is not only possible
>but has sometimes even better chances for success,
>because one is not overloaded with the ballast of deep
>understanding which can not only be useful but also
>hinder from fast progress.
FWIW, this is also my experience.
h a shallow knowledge
is a useful skill ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Your position reminds me of this:
http://www.pbm.com/~lindahl/real.programmers.html
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ere removed, Python would have closures still)
and it is
shows idioms which are now deprecated or that have better alternative
using
list or generator-expressions, generators, and the itertools module.
So my advice
is to forget about that link and to read the standard library more ;)
Michel
passwd = 'bar'
auth_app = AuthBasicHandler(
myapp, 'app realm', only_for_foo)
(where myapp is your WSGI application, of course).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ard time coming up with resources and
> > examples for this. Does anyone have anything that could be helpful?
>
> I'd say the only decent ways are either using a full-featured framework
> (I favor Pylons) or write plain CGIs.
IMO there is a third way: use wsgiref and/or paste.
duction.
> Hoisting
> common subexpressious out of loops. Hoisting reference count updates out of
> loops. Keeping frequently used variables in registers. And elimination of
> many unnecessary dictionary lookups.
>
> Python could get much, much faster. Right now CPython is said to be 60X
> slower
> than C. It should be possible to get at least an order of magnitude over
> CPython.
>
>
John Nagle
This is already done in RPython:
http://codespeak.net/pypy/dist/pypy/doc/coding-guide.html#restricted-python
I was at the PyCon It conference the other day and one of the
PyPy people claimed that RPython is up to 300X faster than Python.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
lly view Scheme as a tool for
language designers only, or with people with interest in
language design and I don't use it for anything else.
I see Python or C as much better practical implementations
of Sussman's quote about minimalism than real Scheme (for
an example of real Scheme, I
On Jun 22, 5:05 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> Unit tests are not a magic wand that discover every problem that a
> program could possibly have.
+1 QOTW
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
se them, including people with a Scheme/Lisp background. That
should be
telling you something.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
s?
http://www.ikaaro.org/itools#itools.csv
HTH,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
on.
>
> --
> Lenard Lindstrom
> <[EMAIL PROTECTED]>
I would add to your list http://livelogix.net/logix/
and
http://www.fiber-space.de/EasyExtend/doc/main/EasyExtend.html
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Python-centric)
do not need macros.
Provocative-but-with-a-grain-of-salt-in-it-yours,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ave been wasted time.
So f1 is misleading code, and I consider misleading code
actually *worse* than wrong code, since it makes you waste
your time without a good reason.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Warnings...
x.py:4: Variable (longVarableName) not used
[I know you will not be satisfied with this, but pychecker is really
useful,
since it catches many other errors that no amount of macroprogramming
would
evere remove].
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
f forever (whereas a bug *has* to be
fixed, otherwise
the application does not work).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
r version.
Or possibly
try:
do_func = elmt.some_func
except AttributeError:
do_stuff()
else:
do_func()
(internally hasattr is doing that anyway).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 29, 6:44 am, Douglas Alan <[EMAIL PROTECTED]> wrote:
>
> I've written plenty of Python code that relied on destructors to
> deallocate resources, and the code always worked.
You have been lucky:
$ cat deallocating.py
import logging
class C(object):
def __init__(self):
logging.
On Jun 29, 3:42 pm, Douglas Alan <[EMAIL PROTECTED]> wrote:
> Michele Simionato <[EMAIL PROTECTED]> writes:
> >> I've written plenty of Python code that relied on destructors to
> >> deallocate resources, and the code always worked.
> > You have been
the reading and maintenance effort (see for
instance the nightmarish situation in Zope 2). To the OP I would
suggest to
consider containment instead, to consider using proxy objects,
__getattr__ and
other similiar tricks that usually do the job.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 4, 2:49 pm, [EMAIL PROTECTED] wrote:
> Dear all,
>
> what is the difference? Middleware?
Yes, and also the fact that you have a large choice of WSGI web
frameworks to choose
from. CGI looks so much 20th century ... ;)
Michele Simionato
--
http://mail.python.org/mailman
On Jul 5, 3:41 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
>
Alex already explained everything beautifully. I will just add a link
to
the definite guide to descriptors:
http://users.rcn.com/python/download/Descriptor.htm
Michele Simionato
(who spent lot of brain cycles studying descript
On Jul 5, 11:16 am, Alex Popescu <[EMAIL PROTECTED]>
wrote:
> Guys, I appreciate a lot your help and explanations. It looks like I
> have to read/play a bit more as some of the terms/ideas are pretty new
> to me (coming to Python with a 10 years Java bag, and only with a
> small dynlang bag - Ruby,
thon unittest framework should be old hat to you and not worth
looking at).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
If the read-only attribute has been implemented via a property, there
is a way
to write it, but you should tell us more about your case.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
than
Using my own decorator module (http://www.phyast.pitt.edu/~micheles/
python/documentation.html)
that would be
from decorator import decorator
@decorator
def log(f, *args, **kw):
result = f(*args, **kw)
print args, kw, result
return result
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
and use the mouse to move the sample points along
> the lines to tweak the sample locations if desired. Then output a file
> of X,Y coordinates for the samples.
You may look at dia for that.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
or now is to follow the good
advices you received, but keep in mind that there will be alternatives
in
the near future (such as interface checking/function overload).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
#x27;t care
too much about the look&feel you may consider starting with Tkinter.
Pros:
1. it is part of the standard library, and you already have it;
2. it is possibly the easiest/simplest GUI out there;
3. it runs pretty much everywhere with minimal fuss.
Michele Simionato
--
http:/
method was defined in self.__class__.__dict__.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 16, 7:18 am, Erik Jones <[EMAIL PROTECTED]> wrote:
> On Jul 15, 2007, at 11:23 PM, Michele Simionato wrote:
>
> > On Jul 16, 5:51 am, Erik Jones <[EMAIL PROTECTED]> wrote:
> >> Say you're given a call event frame for a method call. How can you
> >
ffering symbolic prices (i.e. Python T-shirts or
even silver plates) and
-1 for cash. You could use the cash to fund other kind of initiatives
(perhaps the forthcoming
Italian Python conference? http://www.pycon.it ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 26, 7:23 am, Michele Simionato <[EMAIL PROTECTED]>
wrote:
> I would be +1 for offering symbolic prices
Oops, I meant prizes!
M. S.
--
http://mail.python.org/mailman/listinfo/python-list
, you might
consider using the cmd module of the standard library instead. Then
you could implement your own
expansion, and you would have portability for non-Unix system too.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ny other
> > operations in my application from running, its sits dormant until it
> > runs the scheduled functions.
sched is meant to be used with threads. A probably better alternative
is to use an
asynchronous framework (i.e. Twisted or a GUI) and use the native
techniques
to schedule function
that
national (of course, not
exclusively). I would be happy with a conference for any nationality.
Each nation will have
its national speakers. EuroPython will have all Europe to chose
speakers from.
BTW, this year I will go both to PyCon It and EuroPython, last year I
went both to
PyUK and EuroPy
eld F(el)
In other words, is ``fibsquared(n).next()`` should return a value or a
generator object??
BTW, in spite of having a great tradition, the Fibonacci example sucks
as a motivation
for microthreading programming. You could show a simple state machine
instead.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ace characters (a blank or tab; **note**: bad idea to
include
newline in this!). Use of IS_CHARACTER_JUNK is recommended.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
them in the mainlooop if the current time is greater than
the scheduled time.
I had to add a time.sleep(.001) call in the default_action to avoid
consuming 100%
of the CPU in the loop.
I wonder if real mainloops are done in this way and how bad/good is
this implementation compared to a serious one.
On May 7, 4:39 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Michele Simionato <[EMAIL PROTECTED]> wrote:
> > I wonder if real mainloops are done in this way and how bad/good is
> > this implementation compared to a serious one. Any suggestion/hint/
> > advice
tion call. In that case as you say, I would be
better off with a select+timeout or a even with a queue+timeout, which
already do most of the job.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
p design here is not so bad.
Still I wanted to know what my alternatives were. And from this thread
I gather the impression that actually the only portable alternative is
using some
kind of select, unless I want to use threads, and in that case the
scheduler approach could be viable.
Anyway, that C10K p
On May 8, 11:23 am, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> I once played with the following module to do something similar.
That looks interesting, I will have a look at it.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
standard library) is intended for easy
development
and testing purposes, not for industrial strenght deployement. On the
other hand Zope 3 uses Twisted via WSGI as a business class server,
and I hear that mod_wsgi is slightly more performant than mod_python,
so those are the first options I would consider. But you could post on
the WSGI list for more.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ages.
We're still wondering if we're the busiest one of all the python/ruby
supported websites in the world.
Quixote runs on one dual-core home-made server (costed us US$1500).
We have three additional servers dedicated to lighttpd and mysql. We
use memcached extensively as well.
Douban.c
func(*args,**kw)
return update_wrapper(wrapper,func)
class P(object):
@classmethod
@trace
def c(cls):
print cls
p =P()
p.c()
Also, you can have a look to my own decorator module:
http://www.phyast.pitt.edu/~micheles/python/decorator.zip
HTH,
Michele Simionato
s
> topic.
>
> Thanks
> james
Look at the decorator page in the Python Wiki. There is also a paper
by
David Mertz on IBM DeveloperWorks. Finally, you may have a look at my
own work http://www.phyast.pitt.edu/~micheles/python/documentation.html
Michele Simionato
--
http:/
y
> program. Does python have something similar?
>
> Thanks,
> Geoffrey
I wished from something like that. What you can do at the
moment, is to comment or triple quote the code you
don't want to run.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
in subprocess and popen2, where __del__ updates the
list
of active processes.
So I am beginning to wonder if there exists good use cases for
__del__,
apart for debugging/checking purposes. Can you provide some?
Yes, you may take that as a challenge ;)
Michele Simionato
P.S. BTW, I should m
is the gc who does the real job. See
http://docs.python.org/ref/customization.html#l2h-175
Do you have reference cycles in your application? You should
tell us something more.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 10, 7:09 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> There were also a few recipes posted during this discussion that wrap
> weakrefs up a bit nicer so it's easier to use them in place of __del__:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/519635http://aspn.activestate.c
(ref)
cls.__finalize__(self)
fake = Impostor(self)
_refset.add(weakref.ref(fake, finalize))
return fake
def __finalize__(self):
pass
Hope you will enjoy it,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
r only) and having or not
having
a given syntactic sugar makes a difference between writing and not
writing
a given program. Having decorators in core Python makes us think
differently.
Have a look at David Mertz article
http://www.ibm.com/developerworks/linux/library/l-cpdecor.html
Michele S
On Aug 12, 9:14 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> Michele Simionato wrote:
> > On Aug 10, 7:09 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> >> There were also a few recipes posted during this discussion that wrap
> >> weakrefs up a bit nicer
upgrade path for current code
using __del__ does not look easy at all. Maybe we should be bold,
remove __del__ in Py3K, say to everybody to use 'with', and force
people to rewrite their code, ignoring the complaints from the
big frameworks guys (anyway, they are already complaining ;)
On Aug 13, 7:46 pm, Alexander Schmolck <[EMAIL PROTECTED]> wrote:
> Michele Simionato <[EMAIL PROTECTED]> writes:
> > Well, I argued may times that syntactic sugar is important (all Turing
> > complete languages differs by syntactic sugar only)
>
> Although I
looking at the source
code of IPShellEmbed I see that there is a
method .restore_system_completer() which is
called, but it seems to be not working. I am probably doing something
wrong, can somebody knowledgeable on IPython internals share some
light on that? TIA,
Michele Simionato
--
http
look at the shlex module in the standard
library
and to pyparsing. Looking at their source code should should give you
some
idea. BTW, since you are familiar with Lisp, I would recommend you
IPython
for a better interactive experience.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
self to know if there are users
of these frameworks (including AOP frameworks in Python) or
if they are just exercises.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 29, 8:45 am, Russ <[EMAIL PROTECTED]> wrote:
> I get the strong impression you don't really understand what
> programming by contract is.
>
> I have not yet personally used it, but I am interested in anything
> that can help to make my programs more reliable. If you are
> programming somethi
301 - 400 of 896 matches
Mail list logo