ble by providing a wrapper function for file and open (see
the Guards.py module).
IMO, it worth to be tried, and I don't see any other short-term, less hacky,
solution.
regards,
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33
hods.
And in python the reverse can be true :
class a(object) :
def __init__(self, ro_attr) : self.__attr = ro_attr
def _getAttr(self) :
"""A method which serves an attribute"""
return self.__attr
attr = property(_ge
class_)(val)) for class_, val in
csv.reader(file('config.csv')) ]
In [54]: [ (e, e.val) for e in l ]
Out[54]:
[(<__main__.Z object at 0xa76c218c>, 0),
(<__main__.Z object at 0xa76c260c>, 1),
(<__main__.Z object at 0xa76c256c>, '0'),
(<__main__.Z object at
into a readable not
one-liner code is left as an exercise :)
In [117]: print xmloutput
/home/moq/buc/2
mod2.py
200607131001
/home/moq/buc/1
mod2.py
200607131000
/home/moq/buc/1
mod3.py
200607131001
: import thread
In [34]: thread.start_new_thread(process, (p,)) and main.mainloop()
Of course the last line is tricky, the thread should be started by the
App(Tix.Tk) mainloop.
> Pasi
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyo
rrentframe()
In [48]: c.f_lineno
Out[48]: 1
In [49]: c.f_code.co_filename
Out[49]: ''
Of course, in the console, these are not truly relevant.
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
currentframe().f_code.co_filename)
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
name)
AttributeError: not defined or found in objects "work"
In [49]: Lion().isA(Worker)
Out[49]: False
In [50]: Lion(Worker).isA(Worker)
Out[50]: True
In [51]: Lion(Worker).work()
hard
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
start_new_thread(initFunc, params)
Toplevel.mainloop(self)
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
ry("testing string")
>
> Surely there are ways to make it shorter (But it's fast enough).
>
Maybe this one is more elegant :
In [305]: trans = {}
In [306]: for i in range(256) :
.: trans[chr(i)] = ''.join(i & 2**j and '1' or '0
figured
with: ../src/configure -v
--enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable
Le mardi 22 août 2006 23:15, Fredrik Lundh a écrit :
> Maric Michaud wrote:
> > The problem here, is that the strings in the set are compared by value,
> > which is not optimal, and I guess python compare them by adress ("s*n is
> > s*n" has the same complexity than
s address and then string equality.
>
Yes, furthermore, that is *exactly* what the python code is doing (see
my other post to Fredrik).
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
O, one proof I see is that you forgot the spaces after periods
in your first example, and it's even not easy to figure it out...
In fact this is a typical case I replace the first by the second, when the
string comes a little complex.
--
_
Maric Michaud
_
Aristote
ut what prevents to interpret literals as a call to __builtins__ objects and
functions ? optimization ? what else ?
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
feature of
__builtin__ module IMO (at less I expected it to work like this when I first
tried it).
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
def f(self) :pass
...: @expose
...: def g(self) :pass
...:
...:
exposed : g
In [8]: class b(a) :
...: @expose
...: def h(self) :pass
...:
...:
exposed : h
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
t;...couldn't python (in theory)...", I was discussing
if it would be possible for python (in some future version) to manage the
literals so that they use the constructors in the __builtin__ module, I
didn't say it works actually (I'm aware it's not the case).
--
___
"elegant
but not optimized" one.
--
_________
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
good IDE (didn't try Pydev).
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
False i expect this is not what you want)
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le Jeudi 01 Juin 2006 13:29, Maric Michaud a écrit :
> this exactly the same as :
>
> def f(self, val) :
> return x != 0
oops,
def f(self, val) :
return val != 0
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69
ppens to return a bound method.
I don't think it's about c-coded versus python-coded stuff, C1.f is a type,
C2.f is a method.
In [14]: class t : pass
:
In [15]: class u :
: f = t
:
:
In [16]: u().f()
Out[16]: <__main__.t instance at 0xa795a9ec>
class C2(C):
def __init__(self) :
self.f = lambda x: x != 0
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le Jeudi 01 Juin 2006 15:36, Christophe a écrit :
> self.x = self.__class__.f(0)
nope, this will result in a TypeError "unbound method must be called with
instance as first argument"
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tap
cs exists in python,
it's the 'is' assertion.
a is b
and then, do what you want with a (or b), a is b remains True.
THIS is the meaning of expr1 = expr2, but in computer science, this is not as
important as it is in pure logic (most languages do not even provide the 'is&
) *is* e
!!! this would not be very useful nor consistent I guess and prefer the one
used in python :
seq1 == seq2 => for all e in seq1, seq2[seq1.index(e) == e
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
l override
VAL in the instance :
In [2]: t=toto()
In [3]: t.VAL=4
In [4]: toto.VAL
Out[4]: 5
In [5]: t.__dict__
Out[5]: {'VAL': 4}
You must explicitly modify t.__class__.VAL or toto.VAL :
In [8]: t1, t2 = toto(), toto()
In [9]: t1.__class__.VAL = 4
In [10]: t2.VAL
Out[
hism, after all, classes are just instances of type).
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
to understand what happens.
But as Albert said before, don't do that !
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
rty(fget=lambda s : s.__strat, fset=__setStrategy)
The main purpose of this is to define a common API for all Strategies, and
this is really useful if you intend to manage many of them.
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le Lundi 05 Juin 2006 19:18, [EMAIL PROTECTED] a écrit :
> Any thoughts?
In [24]: a, b = (lambda : 'works like this'), (lambda a, b : (a,b))
In [25]: a(*())
Out[25]: 'works like this'
In [26]: b(4,3)
Out[26]: (4, 3)
--
_
Maric Michaud
_
Arist
Le Lundi 05 Juin 2006 19:40, Maric Michaud a écrit :
> Le Lundi 05 Juin 2006 19:18, [EMAIL PROTECTED] a écrit :
> > Any thoughts?
>
oups wanted to wirte this :
In [27]: a, b = (lambda : 'works like this'), (lambda *a : a)
In [28]: a(*())
Out[28]: 'works like th
ke this (untested) :
(assuming you have put your image data in a file-like object, ie. a StringIO,
named self._dled_img)
Label(self.frame, image=TkImage(Image.open(self._dled_img)))
--
_________
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426
d("myfile.txt", 0404)
rather,
>>> os.chmod("myfile.txt", 0400)
I guess.
or maybe you want something like this :
import os, stat
os.chmod("myfile.txt", os.stat("myfile.txt").st_mode - stat.S_IRGRP)
--
_
Maric Michaud
__
.
return new_result
if not hasattr(service, '_old_method') :
service._old_method = service.method
service.method = my_impl
once this file is imported, all future calls to "method" of service instances
will use my_impl.
--
_
Maric Michau
oto.BaseClass = SqliteAdapter, but you must ensure
that this code is imported before any other where classes inherit from
BaseClass. The one I porpose in my other post is robust, several packages can
even patch the same method with no side effects.
--
_
Maric Michaud
___
d its content are
lost. from the doc :
" The file has no directory entries associated with it and will be
automatically deleted once there are no file descriptors for the file."
You must maintain a reference to it in your program untill you don't need it
anymore.
ks, and if you don't need to flush the datas on disk (if
they fit in memory), you can use a file-like buffer (StringIO) instead of a
tmpfile, this will save resources.
This said, you should consider writing your temporary file in a directory
owned by you and not world writeable, which is
.Base) : pass
...:
In [3]: reload(temp)
Out[3]:
In [4]: class b(temp.Base) : pass
...:
In [7]: b.__base__, a.__base__, b.__base__ is a.__base__
Out[7]: (, , False)
In [8]: isinstance(a(), temp.Base), isinstance(b(), temp.Base)
Out[8]: (False, True)
--
_
Maric Michaud
_
that should work !
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
/media' not in x: continue
> icon = i
> dvc = x[11:-1]
> break
>
this will do exactly the same
for icon_file in (open(dskt + e) for e in os.listdir(dskt) if '.desktop' in
e) :
for line in icon_file :
if 'URL=/media' in line :
icon = icon.name
dvc = line[11:-1]
break
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
pair not in pairList:
> element.remove(l4)
> l5.append(element)
element ???
> print "l5 is",l5
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le Lundi 12 Juin 2006 09:07, Steve Holden a écrit :
> print "Content-Type: text\plain\n"
a typo I guess,
print "Content-Type: text/plain\n"
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
s this work in your case ?
def getl5():
pairList = [[1,2],[3,4],[3,5],[3,6],[9,7],[8,9],[8,7],[7,9],[11,10]]
l4 = [[4,2],[4,7],[4,10],[4,12],[9,2],[9,7],[9,10],[9,12],[11,2],[11,7]]
l4 = [ e for e in l4 if e in pairList ]
print "l5 is", l4
--
_
Maric Michaud
at if none of the pairs are
> in pairList, element = []. How can i do that?
element ?
I guess it's already the case with lst = [ e for e in lst if e in pairs ]
In [1]: lst = (1,2,3,4)
In [2]: pairs=(5,)
In [3]: lst=[e for e in lst if e in pairs]
In [4]: lst
Out[4]: []
--
___
strip(string.punctuation) for e in 're string2, ,string1'.split() ]"
10 loops, best of 3: 6.99 usec per loop
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
on my
debian)
In [69]: f = file ('samurai_tux.jpg')
In [70]: s = f.read(2)
In [71]: s == '\xff\xd8'
Out[71]: True
> Thanks,
> Ritesh
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
run = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
# Wait for the process to return
out, err = [ e.splitlines() for e in run.communicate() ]
return run.returncode, out, err
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le Mercredi 14 Juin 2006 12:41, Ritesh Raj Sarraf a écrit :
> Also,
> f = file ('some_file.jpg')
>
> throws an error.
> "str object is not callable"
stange, did you define a function named file ?
You can use open instead.
--
_
Ma
Le Mercredi 14 Juin 2006 13:14, Maric Michaud a écrit :
> or use a
> threaded version
here it is.
I did it just to validate my point and because i don't use threads very often
in python, some exercises can't hurt :)
def run(command):
import subprocess
run = subproce
newlines ('\n'), doesn't terminate the read call, you can stop the read
by typing ctrl+d at the beginnning of a new line in a normal unix terminal.
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
he problem with getting it from an attribute (returncode) ?
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
nd, the in oprerator is slower in these classes because of
the overhead of function calls (in StateLt there is also an overhead due to
internal lookup, IMO).
Converting to dicts and looking for keys is *really* and equally fast in all
cases, it does not depend on success or failure.
--
__
at the end of list: 28249 <- here
converting to dict : 79
in operator for a dict for 6 elements: 14
in operator at the beginning of list: 202
in operator at the end of list: 30472 <- and here
--
_________
Maric Michaud
_
Aristote - www.aristote.info
3 place des tap
(for new style classes as it seems we have not this overhead with old style
classes) should be the fist step...
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le Mardi 20 Juin 2006 12:09, Diez B. Roggisch a écrit :
> [i for i, equals in enumerate((x == y for x, y in zip(a, b))) if equals]
No needs to nest comprehensions, should be :
[ i for i, v in enumerate(zip(a, b)) if v[0] == v[1] ]
--
_
Maric Michaud
_
Arist
purpose the right test should be :
if not getattr(arg, '__iter__') and not getattr(arg, '__getitem__') :
raise ValueError('Function accepts only iterables') # or error handling
code
--
_
Maric Michaud
_
Aristote - www.aristote.i
Le Mardi 20 Juin 2006 13:28, Maric Michaud a écrit :
> if not getattr(arg, '__iter__') and not getattr(arg, '__getitem__') :
> raise ValueError('Function accepts only iterables') # or error handling
> code
oops, hasattr of course :
if not hasat
'z')
Out[27]: 'zzz'
is exactly the same as :
In [25]: str.__getattribute__('aaa', 'replace')('a', 'z')
Out[25]: 'zzz'
or even :
In [26]: object.__getattribute__('aaa', 'replace')('a', 'z')
Out[26]: 'zzz'
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
27;
> substr = ' ' # space
>
> I would like to get this list:
>[4, 8, 10, 17, 22]
>
> How can I do that without using "for i in mystring" which might be
> expensive for large strings?
>
> Thanks in advance,
> Nico
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
more efficient than Lundh's
>
> effbot's solution finds overlapping occurrences, whereas your solution
> finds non-overlapping occurrences.
Missed that.
> So efficiency comparisons are not valid.
Right, but anyway, the problem is more about memory usage.
Regards,
--
__
; self._x = value
> print self._x, 'Ok'
> x = property(fget = fget, fset = fset, doc= "It prints")
>
>
> print widget.x.__doc__
>
> w = widget()
> w.x = 5
> print w.x.__doc__
This is w.__class__.x.__doc__.
w.x return the value you put in se
Le Mercredi 21 Juin 2006 15:58, David Huard a écrit :
> On Wed, 21 Jun 2006 15:39:02 +0200, Maric Michaud wrote:
> > This is w.__class__.x.__doc__.
>
> Thanks,
>
> So in order to implement what I want, I should rather consider an
> ipython hack to print w.__class__.
ers, not a list of lists.
> Thanks,
> Josh
In [7]: min([3, 3, 1, 3])
Out[7]: 1
In [8]: min(min(e) for e in [ [3, 3], [3, 3, 1, 3], [3, 3, 3] ])
Out[8]: 1
regards,
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33
nterpreter
for attr in path[1:-1] :
target=getattr(target, attr)
target = getattr(target.__class__, path[-1], None)
if isinstance(target, property) :
new_eval_string += '.__class__'
ret
aba', 'aab', 'baa'])
In [6]: list(permute([1, 3, 3]))
Out[6]: [[1, 3, 3], [3, 1, 3], [3, 3, 1], [1, 3, 3], [3, 1, 3], [3, 3, 1]]
In [7]: set(permute([1, 3, 3])) # warning
---
exceptions.TypeError Traceback (most recent
call last)
/ho
lobal is usually the module level scope (where
no 'collect_methods' exists), and, in the case of a class definition, local
is the class __dict__ (the local namespace is not same the class and its
method).
But I'm not sure of what you really want : a list of all decorated methods of
all subclasses of a class, or a list of marked method in each class ?
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
ete_with_int', (Abstract,),
_attr_type=int)
In [125]: Concrete()._attr
Out[125]: 0
In [126]: type(Concrete)
Out[126]:
In [127]: type(Concrete())
Out[127]:
regards,
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le Vendredi 23 Juin 2006 17:09, Maric Michaud a écrit :
> Hmmm, rigourously speaking, metaclasses in OOP are classes whose instances
> are class.
Ooops, sorry i didn't notice you were calling type's __new__ (and not
object'sone).
--
_____
Maric Michaud
__
elif isinstance(v, ClassType) : print 'old style class : ', k
:
:
In [76]: find_classes(subprocess)
new style class : Popen
In [77]: find_classes(sys)
In [78]: find_classes(os)
old style class : _Environ
new style class : stat_result
old style class : error
new
_', ),
('__module__', '__main__'),
('foo', at 0xa79528ec>),
('__weakref__', ),
('__doc__', None)]
In [7]: a().foo()
Out[7]: True
or :
In [9]: setattr(a, 'bar', lambda s : False)
In [10]: a().bar()
Out[10]: False
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
rt types, sys
In [9]: isinstance(sys, types.ModuleType)
Out[9]: True
?
Seems rather explicit IMO.
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
gt; class instance that calls it into that new object. I hope I'm making
> sense here.
>
> Basically what I need is for the method to be able to find out the name
> of the instance, then I can just go to the globals dictionary to do the
> replacement.
>
> Advance thanks t
None
t.other_prop, u.other_prop
This.__dict__.items()
t.__dict__, u.__dict__
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
= lambda x, self=t, func=another_update : func(self, x)
In [33]: t.update
Out[33]: at 0xa7744aac>
So we have a function and know it (probably) belongs to the instance.
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 09
wich appear to be the ancestor of another).
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
y different patterns (delegation, composition,
strategy, etc.).
You should google on "design patterns" and make your choice.
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le mardi 27 juin 2006 06:21, Bruno Desthuilliers a écrit :
> Maric Michaud a écrit :
> (snip)
>
> > In OOP Methods are defined in *classes* not in any arbitrary object
>
> Chapter and verse, please ? AFAIK, the first O in OOP stands for
> "object", not for &qu
uage.
'if len(container) :" means "if container's length is not zero", while "if
container :" means "if container is empty".
Using the second is far better because a random container can implement a
faster algorithm to test its emptiness
ot;*9 % tuple(range(9)) % nested_dict_wrapper(complex_dict)
-------
exceptions.KeyError Traceback (most recent
call last)
/home/maric/
/home/maric/ in __getitem__(self, v)
KeyError: '8 not found in dict and subdicts'
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
s is the case you can't use import machinery,
You could go that way :
#temp.py
A=0
def test_execfile() : print A
In [1]: d={}
In [2]: execfile('temp.py',d, d)
In [3]: d['test_execfile']
Out[3]:
In [4]: d['test_execfile']()
0
In [5]: d['A&
: print 'c'
.:
.:
In [143]: class D(B,C) : pass
.:
In [147]: super.__getattribute__(super(D,D()), 'sup')()
b
In [148]: super.__getattribute__(super(B,D()), 'sup')()
c
In [149]: super.__getattribute__(super(C,D()), 'sup')()
a
Hope this is clear.
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
n [154]: type.mro(A)
Out[154]: [, ]
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
:
:
In [25]: A.__class__
Out[25]:
In [26]: A().__class__
Out[26]:
In [27]: isinstance(A(), list) # ouch !
Out[27]: True
In [29]: type(A())
Out[29]:
In [30]: type(A()).mro()
Out[30]: [, ]
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
6
-
exceptions.AttributeErrorTraceback (most recent
call last)
/home/maric/
AttributeError: can't set attribute
In [49]: ib=b()
In [50]: print ib.p
None
In [51]: ib.p = 5
In [52]: print ib.p
5
In [53]: ib._p
Out[53]: 5
--
def setx(self, v) : self._x = v
...: p=LateBindingProperty(getx, setx)
...:
...:
In [5]: class B(A) :
...: def setx(self, v) : A.setx(self, 2*v)
...:
...:
In [8]: a=A()
In [9]: a.p = 5
In [10]: a.p
Out[10]: 5
In [11]: a._x
Out[11]: 5
In [12]: b=B()
In [13]: b.p=5
In [14]: b.p
Out[1
t;API only" usage of abstract classes
like in Java nad its interfaces.
> You may have classes with undefined methods (they may raise
> NotImplementedError).
C++ "pure virtual methods" is only the C++ way of doing something which is a
more general concept in OOP.
--
__
to work with such complex situations, but it seems to me that
partial implementation is not a bad choice, specifically in regard to duck
typing.
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
CTED] ven sep 08 13:55:46:~$ python -c 'import os
> print os.path.expanduser("~")
> '
/etc
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/python-list
Le vendredi 08 septembre 2006 13:56, Maric Michaud a écrit :
> [EMAIL PROTECTED] jeu sep 07 09:17:51:~/test$ export HOME=/etc
> [EMAIL PROTECTED] ven sep 08 13:53:17:/home/maric/test$ cd ~
> [EMAIL PROTECTED] ven sep 08 13:53:22:~$ pwd
> /etc
> [EMAIL PROTECTED] ven sep 08 13:55:
values = ( d[k] for k in sorted_keys )
In [150]: for vals in chain([sorted_keys], izip(*sorted_values)) :
.: print '%5s'*len(d) % vals
.:
.:
0123456 7 89
1111111111
012
e, block = {}, ""
for line in commands :
line=line[:-1]
if not line : continue
if line[0].isspace() :
block += '\n' + line
continue
else :
if block.strip() :
exec block in namespace
block = line
exec block i
same as :
In [40]: eval(compile('x=5', '', 'exec'))
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 4 26 88 00 97
Mobile: +33 6 32 77 00 21
--
http://mail.python.org/mailman/listinfo/python-list
Stef Mientki a écrit :
> hi Bruno,
>
> after study it carefully,
> it's much more complex than I thought
> (I can't understand it completely, which is of less importance).
> Your solution works great,
> but I need one little extension,
> which I can create, but just at the cost of a lot of code.
>
Larry Bates a écrit :
> Gerardo Herzig wrote:
>> Hi all. Im looking for the pyGoogle for making google searchs y a python
>> script. The thing is, all im founding is an AJAX api, but the
>> application ill use is NOT a web app. So, someone know if there is a
>> pure python api that i can download a
Alan Franzoni a écrit :
> Il 23 May 2007 04:53:55 -0700, Siah ha scritto:
>
> [cut]
>
> No.
>
> It's because the *body* of the function gets evaluated every time the
> function is called, while the *definition* of the function gets evaluated
> just once, when the function is 'declared'.
>
> You
Pierre Quentel a écrit :
> On 27 mai, 22:55, erikcw <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I'm trying to turn o list of objects into a dictionary using a list
>> comprehension.
...
>
> entries = dict([ (int(d.date.strftime('%m')),d.id) for d in links] )
>
> With Python2.4 and above you can use a
Ben Finney a écrit :
> Paul McGuire <[EMAIL PROTECTED]> writes:
>
>> It is a bit reassuring that I am not the only one who turns a blind
>> eye to this part of the PEP, that l_c_w_u bothers others as well.
>
> I see similar support for lower_case, and opposition to
> camelCase. It's nice that we'
I'm really sorry, for all that private mails, thunderbird is awfully
stupid dealing with mailing lists folder.
Gabriel Genellina a écrit :
> En Sun, 27 May 2007 22:39:32 -0300, Joe Ardent <[EMAIL PROTECTED]> escribió:
>
>
> - iterate backwards:
>
> for i in range(len(names)-1, -1, -1):
>f
1 - 100 of 214 matches
Mail list logo