:-(
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ctionCalls
def f():
pass
f()
f()
f()
help(f)
The whole point of the decorator module is that the signature of
the original function is left unchanged (i.e. in this case the
decorated f is still a thunk, not a generic function f(*args, **kw)).
HTH,
Michele Simionato
lo",))
and T("$obj").substitute(obj="hello") give the same output
(this potentially hides type bugs).
So, take this as a bug report if the behavior is not intended and
as a feature request if the current behaviour is the intended
one ;)
Michele Simionato
P.S. at the end, the problem is that string interpolation with
positional arguments is somewhat of a hack, but fixing this will
have to wait until Python 3000 ...
--
http://mail.python.org/mailman/listinfo/python-list
;, "", "", "", "exit"]:
print c.send(cmd)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
a bit
lacking and you have
to discover many things by trial and errors.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
uot;errors
should never pass silently". May be. You are free to post
the bug report and look at the opinions of the developers. I am happy
enough with the current behavior and I would just
update the docs.
Michele Simionato
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
w__"
if you are interested).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Colin:
> It seems to me that __new__ should probably be deprecated for mutable
> classes.
Certainly not! It is useful for mutable classes too. One just must be
careful.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ivalent of the .after() method in pygtk?
BTW, is there any intro to pygtk thought for Tkinter users?
TIA,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
A Singleton class is there to be inherited from; a singleton instance
like the one you define is pretty much useless (unless I misunderstand
your intentions).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
t, as I
> generally don't, it's close to usable.)
FWIW, you can count me about the people who (re)wrote this same thing
(actually with some difference, since I wanted to keep the order, so
I used nested lists instead of nested dictionaries, but the idea was
similar). I would welcome some module in the standard library to store
hierarchical data.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
You were on the right track before: look at the tutor
mailing list ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
okbook for more examples.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
What about bsddb? On most Unix systems it should be
already installed and on Windows it comes with the
ActiveState distribution of Python, so it should fullfill
your requirements.
--
http://mail.python.org/mailman/listinfo/python-list
The documentation hides this fact (I missed that) but actually python
2.3+ ships
with the pybsddb module which has all the functionality you allude too.
Check at the test directory for bsddb.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
s with it.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
What happens if for any reason the application crashes?
Locked files will stay locked or not? And if yes, how do I
unlock them?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
to implement it myself, but maybe I was wrong afterall ...
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ppens in the case of a power failure?
Am I left with locked files floating around?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Ok, I have yet another question: what is the difference
between fcntl.lockf and fcntl.flock? The man page of
my Linux system says that flock is implemented independently
of fcntl, however it does not say if I should use it in preference
over fcntl or not.
Michele Simionato
--
http
ons (remove the setgid bit) before trying to read or write to
it.
Of course, that might be a bit tricky if the system is hung :-(
"""
so lockf locks do not look completely harmless ...
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
standardization in this area.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Just to clarify, before people start pointing out their preferred
templating language: I am NOT asking for
a template system. I am asking for something on the
lines of HTMLGen, where you just use pure Python.
--
http://mail.python.org/mailman/listinfo/python-list
2&x=3&z=&y=4"
print parse_qsl(QS)
print parse_qsl(QS, keep_blank_values=True)
which gives
[('x', '1'), ('y', '2'), ('x', '3'), ('y', '4')]
[('x', '1'), ('y', '2
LTag()
.tableheader = ["field1", "field2"]
.tablebody = [["a1", "a2"],
. ["b1", "b2"]]
.html_header = [html.tr(html.th(el) for el in tableheader)]
.html_table = [html.tr(html.td(el) for el in row) for row in tablebody]
.print html.table(html_header + html_table)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
etween logic and presentation just
putting the
routines generating the HTML pages in a separate module, no need to use
a
different language.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
$ pydoc -g
M.S.
--
http://mail.python.org/mailman/listinfo/python-list
.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
)
finally: # for instance, if CTRL-C is called
counter.stop()
And this is the CGI viewer:
#!/usr/bin/python
import os
print "Content-type: text/plain\n"
print "Counter: %s" % os.environ["COUNTER"]
Pretty bare-bone ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879
--
http://mail.python.org/mailman/listinfo/python-list
Looking at the "calendar" module in the standard library may help.
Also, "pydoc calendar" is your friend.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
origin ...
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
it again so might as well move
it out of
>the way.
+1 for this idea. The summary looks much better now :)
Keep the good work going,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ey_tex
t_to_keyinfo
return keyseq_to_keyinfo(keytext[1:-1])
File "C:\Python24\Lib\site-packages\readline\keysyms.py", line 163,
in keyseq_
to_keyinfo
res.append(char_to_keyinfo(keyseq[0], control, meta, shift))
File "C:\Python24\Lib\site-packages\readline\keysyms.py", line 111,
in char_to
_keyinfo
raise ValueError, 'bad key'
ValueError: bad key
Any hints on what is causing this and the cure?
TIA,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
That line seems right. The function is
def char_to_keyinfo(char, control=False, meta=False, shift=False):
vk = VkKeyScan(ord(char))
if vk & 0x == 0x:
print 'VkKeyScan("%s") = %x' % (char, vk)
raise ValueError, 'bad key'
if vk & 0x100:
shift = True
if vk & 0x200:
con
No, I don't even know how to get it under Windows (usually I use
Linux). Switching to the US keyboard
does not help, anyway. I get the same error.
Michele
--
http://mail.python.org/mailman/listinfo/python-list
Well, this is ugly as the sin but it seems to work, at least for the
moment:
vk = VkKeyScan(ord(char))
if vk == -1: # ugly fix for backtips
vk = 96
I will write to Gary Bishop to point out this issue with the Italian
keyboard and see if he has some decent
solution.
Michele
I asked myself the same question and I am not convinced
that using 'super' with one argument really makes sense
(i.e. IMO it is more a liability than an asset). BTW, I have a set
of notes on the tricky aspects of 'super' you may be interested in.
Michele
super(D, D).f()
D.f()
Just using super(D).f() would not work. ``super`` with only one
argument is
a recipe for headaches.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
define ``__getitem__`` directly, but only
indirectly via delegation (i.e. overriding ``__getattribute__``),
then the second form (i.e. ``type(x).__getitem__(x,y)``) works but
not the first one (i.e. ``x[y]`` raises an error).
Michele Simionato
--
http://mail.python.org/m
t the ACCU conference, so I want to
make
sure I use the rigth terminology.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ere already such links but I missed them).
Would you agree with Leif's definition that iterable is
any x such that iter(x) does not raise an error? On top
of my head I don't find any counter example and it
is the kind of definition I had in mind.
Michele Simionato
--
http
Or, just to impress Lispers,
>>> def add(x,y):
... return x + y
>>> closures = []
>>> for i in range(10):
...closures.append(add.__get__(i))
...
>>> closures[5](1000)
1005
Remember, in Python do not have functions, we have descriptors! ;)
ide the scope).
So this idiom
a = ""
for i in range(10):
if i == 5: a = "5 was reached"
print a
would not work. So, as I said, there are pros and contros.
Personally, I like better the Scheme way (what I do not like
in Scheme is the issue of inner defines vs. tople
> I'm surprised that Michele
>hasn't yet referenced the thread where we exposed the gory details, as
>was his custom for a while :-)
>Message-ID: <[EMAIL PROTECTED]>, for >this particular
>aspect, in case anyone gives a monkey's left testicle.
I had forgot the title of that thread and also I wante
But then why he agreed to have the loop variable disappear outside a
generator comprehension?
I think there is something more than a backward compatibility concern.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
s=super(B)
...
>>> help(C)
Traceback (most recent call last):
...
... lots of stuff here
...
File "/usr/lib/python2.4/pydoc.py", line 1290, in docother
chop = maxlen - len(line)
TypeError: unsupported operand type(s) for -: 'type' and 'int'
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Twisted and Zope already use interfaces. You can download
the interface package and use it in you project.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
F. Petitijean:
> ManagerInterface is a module not a class !
Yes, but the error message could be improved (at least for the sake of
people
not knowing the internal working of Python). Do you care to fill a bug
report?
Michele Simionato
--
http://mail.python.org/mailman/listi
Now they use the same interface package. For the other
questions: google is your friend. (try "zope interfaces"
then "twisted interfaces").
--
http://mail.python.org/mailman/listinfo/python-list
.
Just my 2 Eurocents,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ictionaries
already have lots of methods and I would think twice before adding new
ones; expecially
methods that may turn out not that useful in the long range, or easily
replaceble by
user code.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
mind about a few new functions
in an utility module.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
frameworks.
Depending on your distribution, this may be already available. For instance
in Mandrake 10.1 I just tried
# urpmi python-twisted
and it downloaded twisted 1.3. Seems to work too.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
flush()
write( '\x08' * len(msg) )
time.sleep( self.DELAY )
write( ' ' * len(msg) + '\x08' * len(msg) )
flush()
def stop( self ):
self.running = 0
self.join()
if __name__=="__main__":
it in the standard Popen class. I am surprised
it is not there. Any comments?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
etup)
try: print t.repeat(number=n)
except: t.print_exc()
You can import it with "from timeit_ import timeit" and it gives you access to
your __main__ program namespace.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
table of contents,
indices, etc. Conversions to many formats (Latex, DocBook, etc.) would be
welcome. Does something like that already exists? Alternatively, I would need
some hierarchical Wiki with the ability of printing its contents in an
structured way.
Michele Simionato
--
http
self.setdefault(key, defaultfactory())
return defdict
d = defaultdict(int)()
d["x"] += 1
d["x"] += 1
d["y"] += 1
print d
d = defaultdict(list)()
d["x"].append(1)
d["x"].append(2)
d["y"].append(1)
print d
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I am not sure how safe it is, but on Linux I have just copied
subprocess.py
in my 2.3 installation and it worked in all the cases I tried.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
w I have forgot nearly everything ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I think you may find Alex Martelli's PyCon slides somewhere
on the net. The black magic slides discuss this issue. But I
think the fix he suggests is not dissimilar from what you
are already doing. I don't remember exactly now, but
it is always worth a look.
Michele Simionato
ass
if there is a real need for it.
Paraphrasing Occam, I would say "don't multiply base classes without
necessity" ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
d setters and making properties from them).
I typically use a property factory function, or a custom descriptor.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
This is spectacular! :)
Is there a way to make it to work from environments (such as emacs)
where stdin is special?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Just give (as root)
# urpmi python-devel
(assuming you have configured urpmi properly, Google
for "easy urpmi").
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Michael Spencer:
> Alternatively, you could provide factory functions to construct the
defaultdict.
> Someone (Michele?) recently posted an implementation of this
Yes, here is the link for the ones who missed that thread:
http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/a0b
defaultdict.__init__ you would just call dict.__init__
and not thirdpartdict.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Not to be rude, but you are on the wrong list and your question is ill
formulated:
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.zope.org/Resources/MailingLists
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
ing with CLOS classes, which are pretty
slim, since the (multi)methods are defined outside
them?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I have realized today that defining decorators for functions
with generic signatures is pretty non-trivial.
Consider for instance this typical code:
#
def traced_function(f):
def newf(*args, **kw):
print "calling %s with args %s, %s" % (f.__name__, args, kw)
return f(*args, *
I said it was very little tested! ;)
This should work better:
#
def _signature_gen(varnames, n_default_args, n_args,
rm_defaults=False):
n_non_default_args = n_args - n_default_args
non_default_names = varnames[:n_non_default_args]
default_names = varnames[n_non_default_args:n_args]
Yes, this is essentially the same idea. You compile the codestring to
bytecode,
whereas I just evalue the codestring to a lambda function. We are
essentially implementing a runtime macro by hand. I wonder if there is
any alternative
approach to get the same result, without manipulation of the sourc
:
def __init__(self):
print "C2.__init__"
class D(C1, C2):
def __init__(self):
print "D.__init__"
D()
# you get
# B.__init__
# C2.__init__
# C1.__init__
# D.__init__
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Google for "Hettinger interface checking": the first hit
is the cookbook recipe you are looking for.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
"
But what about threads? If a single program open a shelve and many
threads
try to write simultaneously to it, do I get an error? I would say yes,
but after various attempts, I cannot get it, at least on Linux, where
shelve is using dbhash as database. Can somebody share any light,
please?
Look at the comment in the code! I have posted the "decorate" module in
the this
decorator thread:
http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/60f22ed33af5dbcb/b7239b45da6a67ab#b7239b45da6a67ab
--
http://mail.python.org/mailman/listinfo/python-list
Dirk wrote:
> So I dug through the documentation and found that new-style classes
> compute a monotonic linearization of the inheritance graph, observing
>local precedence order, using the algorithm also used in Dylan
> described here:
>http://www.webcom.com/haahr/dylan/linearization-oopsla96.html
the
same parameters, I am returned an instance of the already opened
database).
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
special case. It also gives you
plenty of use case to illustrate it, even to beginner programmers.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I did not put memoize on __new__. I put it on the metaclass __call__.
Here is my memoize:
def memoize(func):
memoize_dic = {}
def wrapped_func(*args):
if args in memoize_dic:
return memoize_dic[args]
else:
result = func(*args)
mem
Me too :-(
I have already submitted my issues with the Italian keyboard
on WinXP with no great success. It works on Linux, but this
is not of a big help since my plan was to use ipython -p pysh on
Windows as a replacement of the shell :-(
Michele Simionato
--
http://mail.python.org
Uhm? If I pass different parameters I want to have
different instances. The Singleton behaviour is recovered
only when I pass always the same arguments, in
particular when I pass 0-arguments:
>>> class Foobar:
... __metaclass__ = Memoize
...
>>> Foobar()
<__main__.Foobar object at 0xb7defbcc>
Switching to the US keyboard did not help for me.
--
http://mail.python.org/mailman/listinfo/python-list
feel that:
1) separation of concerns is of the utmost importance;
2) classes should be kept as short as possible.
Notice that in this design getters and setters are
really hidden from the user, which may be or may be
not what you want.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
port SF 729913
The discussion around the bug report is worth reading,
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
od and actually they were surprised of how easy was to make the
port.
All in all, pretty good news, people! It seems a pretty good moment
to be a Python programmer!
I have something else to say, but I will make another post for that.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
enlets. They are extremely cool,
I don't know where I want to use them yet, but I am pretty sure I'll
figure out something eventually ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
developers
are familiar with Zope 3 yet). Quixote too has a small
number of developers, but at least it is easy and you
don't need much help to work with it.
Michele Simionato
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
$ python -i myscript.py
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I would also look at CherryPy, the new 2.0 version seems pretty
interesting
(I have not tried it, but I have seen a short presentation at the ACCU
conference,
and it looks really trivial to use).
--
http://mail.python.org/mailman/listinfo/python-list
red of
components, hundreds of thousand of lines of code) or small?
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
d small, in theory. But in practice
there is, so I use Zope at work and Quixote at home ;)
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Any class has a .__module__ attribute giving the name
of the module where the class was defined, so you
need something like
[c for c in globals() if inspect.isclass(c) and c.__module__ ==
"__main__"]
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
Uwe Mayer:
> Why does the "print" statement return a syntax error here?
Google for "Python regrets" where Guido admits that
'print' should have been a function.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
I have not access to Guido's time machine!
M. S.
--
http://mail.python.org/mailman/listinfo/python-list
I think doctest believes the line starting with ... is
a continuation line in a multiline statement.
--
http://mail.python.org/mailman/listinfo/python-list
I would file a bug report/documentation bug/feature
request or whatever to sourceforge.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
On Thursday, September 3, 2015 at 6:55:06 PM UTC+2, Palpandi wrote:
> Hi All,
>
> Is there any module available in python standard library for XML binding? If
> not, any other suggestions.
>
> Which is good for parsing large file?
> 1. XML binding
> 2. Creating our own classes
>
>
> Thanks,
>
Years ago I wrote strait: https://pypi.python.org/pypi/strait
I wonder who is using it and for what purpose, since surprisingly enough it has
50+ downloads per day. For me it was more of an experiment than a real project.
--
https://mail.python.org/mailman/listinfo/python-list
101 - 200 of 896 matches
Mail list logo