Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit :
On 2008-09-16, Maric Michaud [EMAIL PROTECTED] wrote:
all expressions that return something, return a new object,
That's not _quite_ true:
a=1
b=a.__add__(0)
a is b
True
;)
This is implementation specific
Le Tuesday 16 September 2008 16:57:26 Grant Edwards, vous avez écrit :
On 2008-09-16, Maric Michaud [EMAIL PROTECTED] wrote:
Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit :
On 2008-09-16, Maric Michaud [EMAIL PROTECTED] wrote:
all expressions that return something
to the original problem.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Friday 05 September 2008 19:36:56 Fredrik Lundh, vous avez écrit :
Maric Michaud wrote:
I suspect you are coming to conclusions a bit quickly, without taking the
pain of understanding the whole discussion.
I'm pretty sure I was the first one to post an answer in this thread,
and I
Le Monday 15 September 2008 16:45:12 Maric Michaud, vous avez écrit :
This is not sufficient for auto-responses, and given the following rfcs, it
would smart to both :
...
- add or modify the Return-Path and/or Reply-To header for badly
implemented auto-responders to point to list maintainer
Le Friday 05 September 2008 08:30:44 Fredrik Lundh, vous avez écrit :
Maric Michaud wrote:
You''ll often see for loops written like this :
for i in (e for e in iterable if predicate(e)) :
...
luckily, I don't. most people, when faced with that problem, writes it
in the obvious
Le Friday 05 September 2008 08:24:29 Fredrik Lundh, vous avez écrit :
Maric Michaud wrote:
premature optimization is the root of all evil
So is use by that statement by people who don't have the slightest idea
about what it actually means.
The full version is
We should forget about small
to find which function call exactly provoke the exception, the
simplest way is to trace execution flow with some print statments and using
non forking zope instance (runzope -d if I remember well).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
is to index upon insertion all keys in another
dict, so you get in final :
d = { kEy1 : 1, Key1 : 2}
indexes = { key1 : [kEy1, Key1 ] }
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python
Le Friday 05 September 2008 16:00:39 J. Cliff Dyer, vous avez écrit :
Please keep the discussion on-list.
Sorry for the private email, I sent it again to the list..
On Fri, 2008-09-05 at 15:36 +0200, Maric Michaud wrote:
Le Friday 05 September 2008 14:33:22 J. Clifford Dyer, vous avez écrit
()
f.someMethod()
bar()
again()
---
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
in s.items() : print name, value
...:
a 5
c ('foo', 'bar', 'baz')
The sync method may not work on all platform, maybe you'll have to close and
re-open the db file to write to disk.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
.
class foo(set):
... def __contains__(self, value):
... print value
...
a = foo((1,2))
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
.py, line 9, in module
_s_.add(bar())
TypeError: id() takes exactly one argument (0 given)
--
http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 4 26 88 00 97
Mobile: +33 6
Le Thursday 04 September 2008 23:35:18 Terry Reedy, vous avez écrit :
Maric Michaud wrote:
Le Thursday 04 September 2008 22:26:53 Ruediger, vous avez écrit :
class foo(list):
__hash__ = lambda x: id(x)
Wow ! You are really going on trouble with this, believe me there is a
real
the straightforward, read as pseudo-code, python expression.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
):
self._setvalue(val)
self._setsquare=pow(val,2)
Note that if one property can really be computed from another, this kind of
thing could be considered as bad design (except if the computation is heavy).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo
Le Wednesday 03 September 2008 16:44:10 Maric Michaud, vous avez écrit :
def _setsquare(self, v) :
# some extra logic here
self._square = s
def fsetsquare(self,s):
self._setsquare(s)
self._setvalue
(fgetvalue, fsetvalue)
def fgetsquare(self):
return self.value ** 2
def fsetsquare(self,s):
self.value = math.sqrt(s)
square = property(fgetsquare, fsetsquare)
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python
is a caching mechanism, and should be done knowingly,
in acceptance of all the complication it comes with.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Worker:
def __init__(self, employer):
from empmodule import Employer
if not isinstance(employer, Employer):
raise ValueError(Not an employer)
self.emp=employer()
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
be the syntax for modifying
an existing value, for example, what should be the result of two consecutive
assignements ?
d[5] = None
d[5] = 0
d[5] == [ None, 0 ] ??
What exactly are you trying to achieve ?
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
is created by the class factory, as well and I
unfortunately can't do that.
Thank you very much,
Steve
--
http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
() *is* an already made dict, very convenient for use locally and
read-only.
[155]: var1 = easy
[156]: var2 = proper
[157]: var3 = locals
[158]: print a %(var2)s and %(var1)s use of %(var3)s with %(var3)s() %
locals()
a proper and easy use of locals with locals()
--
_
Maric
modules name
guess what , it will have to be renamed in every import to it in all
modules --
(cf my previous comment).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
to module level functions, and we should always use
classmethods in place of them.
--
Thank you for your time.
--
http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
the right way. This is hard to do in C because you have no
way to trap an error which happen randomly in the program, ie. a segfault
will interrupt the execution anyway.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Friday 22 August 2008 15:03:21 Bruno Desthuilliers, vous avez écrit :
Maric Michaud a écrit :
Le Thursday 21 August 2008 09:34:47 Bruno Desthuilliers, vous avez écrit :
The point
is that EAFP conflicts with the interest of reporting errors as soon
as possible (on which much has been
]: interpolate((0, 0), (180, 45))
...[23]:
[0.0,
0.25,
0.5,
0.75,
44.5,
44.75,
45.0]
[29]: interpolate((80, 20), (180, 45))
[0.0,
0.25,
0.5,
0.75,
1.0,
1.25,
...
24.5,
24.75,
25.0]
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
')
a z e r t y
--
http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
a
login shell even in non-interactive session.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
by your environment. You won't need no extensions, just a standard
python installation, and your code will work with most mail delivery agent
and will run on all python supported platform.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
(the programer himself).
I'd say that everywhere exec/eval are used in a application/function/lib that
doesn't mean to interpret arbitrary and user provided python code, it is a
bad usage.
--
_
Maric Michaud
namedtuple.py
Description: application/python
--
http://mail.python.org
.
Not that complex, strength of ZODB is right here, this entirely covered by the
introduction to zodb (ZODB/ZEO programming guide), see userdb and chatter
examples.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org
with type('dynamic', (object,), {type_: type_})
def create_type(type_) :
class dynamic(object) :
type_ = type_
return dynamic
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
incompatibility with actual code.
This is exactly this case which would be a problem (your example raise an
error and is not exactly a running code):
G = 1
class A(object) :
G = 0
def f(self) : return G
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Calvin Spealman a écrit :
On Wed, Aug 13, 2008 at 7:41 PM, Maric Michaud [EMAIL PROTECTED] wrote:
I was not aware of any nested classes are unsupported before and didn't
consider nested classes as bad practice till now, even with the pickle
limitation (not every class are intended to be pickled
)
:
:
---
NameError Traceback (most recent call last)
/home/maric/ipython console in module()
/home/maric/ipython console in A()
/home/maric/ipython console in genexpr((f,))
NameError: global name 'l' is not defined
--
_
Maric Michaud
--
http
what I think).
The main point with open I think is to easy later evolution. While you could
override file name as well as open by a custom funcion, it's a bad idea
to override the name of the type because a simple isinstance(file_, file)
won't work anymore if you do so.
--
_
Maric
= 0, 1
a += b
a, b = b, a
s = foo
s = s.upper()
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
) :
...: def __repr__(self) : return type A
...:
...:
[2]: A
...[2]: type A
[3]: type('toto', (object,), {})
...[3]: class '__main__.toto'
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
of type, their instances are new
types.
For all tjis work together you must admit the following recursivity :
'type' is both a subclass and an instance of 'object' while 'object' is an
instance of 'type'.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Thursday 31 July 2008 16:46:28 Nikolaus Rath, vous avez écrit :
Maric Michaud [EMAIL PROTECTED] writes:
Can someone explain to me the difference between a type and a class?
If your confusion is of a more general nature I suggest reading the
introduction of `Design Patterns' (ISBN-10
with builtin types (written in C) you
coudn't do in pure python, exactly as you couldn't write recursive types
like 'object' and 'type'.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
quite clear if not amount : is testing the zero value of a
numerical value.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
.
Without ABC, to explicitly ensure amount is a scalar, just doing a int(amount)
or int(abs(amount)) if you want to deal with complex numbers too, at the
begining of the function is a common idiom.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
for example).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
about encoding)...
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Wednesday 30 July 2008 17:55:35 Aspersieman, vous avez écrit :
For parsing the mails I would recommend pyparsing.
Why ? email module is a great parser IMO.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Wednesday 30 July 2008 19:25:31 Diez B. Roggisch, vous avez écrit :
Maric Michaud wrote:
Le Wednesday 30 July 2008 17:55:35 Aspersieman, vous avez écrit :
For parsing the mails I would recommend pyparsing.
Why ? email module is a great parser IMO.
He talks about parsing the *content
of simplicity-efficiency. I said near the best one
because your __getattr__ isn't collaborative yet ! :).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
be just over or
just down by a small quantity.
On mine with 2.6 this typically give :
[26]: 0.5
...[26]: 0.5
[27]: 0.49
...[27]: 0.48999
[29]: 0.51
...[29]: 0.51001
[28]: 1.1
...[28]: 1.1001
[35]: round(0.5)
...[35]: 1.0
--
_
Maric Michaud
()
AttributeError: can't set attribute
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
.
The signature should be :
vectorstring move_slice(vectorstring vec, int start, int stop, int
dest)
or
vectorstring* move_slice(vectorstring* vec, int start, int stop, int
dest)
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
...
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
waitinig for system to be
operational and deliver them lazily. This is quite an easy thing to implement
(hint : use stdlib data structures that support multi threading from the
beginning).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
] * expected_size
# working with the datas while maintaining the effective currrently used size
Of course one could even subclass list and redefine __len__, append, and some
other methods to deal with this allocated by block list.
--
_
Maric Michaud
--
http://mail.python.org
...[11]: True
[12]: l[:] = [4]
[13]: l == g
...[13]: True
[14]: l is g
...[14]: True
[15]: g
...[15]: [4]
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
itertools.repeat(self.obj, len(self))
:
:
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
').read())
[50]: bounce.get_content_type()
...[50]: 'multipart/report'
[51]:
[52]: for i in bounce.get_payload() :
:if i.get_content_type() == 'message/delivery-status' :
: print i.get_payload()[1]['status']
:
:
5.0.0
--
_
Maric Michaud
: msg#00040',
'Cardiff Web Site Design, Professional web site design services ...',
'Python Properties',
'Frees lt; Programs lt; Python lt; Bin-Co',
'Torb: an interface between Tcl and CORBA',
'Royal Python Morphs',
'Python amp; Co']
--
_
Maric Michaud
--
http://mail.python.org
.
if not f.tell() :
print 'at the beginning of the file
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
like this :
from itertools import izip
...
def __add__(self, other) :
return Vector(x + y for x, y in izip(self, other))
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
with the simpler :
B = [ e for e in B if e*e not in A ]
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
breaking the logic of the template.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
that regexp
matching is the best tool for it.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
with octal conversion :)
[8]: oct2bin =
{'0':'000', '1':'001', '2':'010', '3':'011', '4':'100', '5':'101', '6':'110',
'7':'111'}
[9]: ''.join(oct2bin[e] for e in %o%35).lstrip('0')
...[9]: '100011'
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004
or
callable instances, there are many way to achieve this.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Monday 23 June 2008 13:51:34 John Machin, vous avez écrit :
On Jun 23, 9:16 pm, Maric Michaud [EMAIL PROTECTED] wrote:
Le Monday 23 June 2008 11:39:44 Boris Borcic, vous avez écrit :
John Machin wrote:
Instead of sum(a + b for a, b in zip(foo, bar))
why not use sum(foo) + sum(bar
it is better,
a shorthand for split(os.sep).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Text node
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
')
may be preferred.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
)
)
etc...
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Tuesday 17 June 2008 05:10:57 Maric Michaud, vous avez écrit :
The class complextiy problem is actually solved by :
inst_with_alg1 = MyClassUsingStrategies((algo1_strategy,),
(algo1_strategy,)) inst_with_alg1_alg2 = MyClassUsingStrategies
with dict, do(c_dict, u, v)
The result is pretty close now :
[EMAIL PROTECTED] 17:04:36:~$ ./test.py
with list 1.40726399422
with dict 1.63094091415
So why use list where the obvious and natural data structure is a
dictionnary ?
--
_
Maric Michaud
--
http://mail.python.org
Hello,
Le Friday 13 June 2008 17:55:44 Karsten Heymann, vous avez écrit :
Maric Michaud [EMAIL PROTECTED] writes:
So, writing C in python, which has dictionnary as builtin type,
should be considered more elegant ?
IMO that's a bit harsh.
harsh ? Sorry, I'm not sure to understand.
You
Le Friday 13 June 2008 18:55:24 Maric Michaud, vous avez écrit :
approximately the double amount of memory compared to the other.
I don't see how you came to this conclusion. Are you sure the extra list
take twice more memory than the extra dictionary ?
twice less, I meant, of course
',
'zlatan ibrahimovic ']
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
Le Wednesday 11 June 2008 09:08:53 Maric Michaud, vous avez écrit :
this is zlatan example.'
compare with 'this is zlatan example', 'z'=='.', false
compare with 'this is zlatan ', 'z'=='e', false
compare with 'this is zlatan', 'z'==' ', false
compare with 'this is ', zlatan==zlatan, true
Ah
or not is not computable. Static
analysis as they imply is just nonsense.
AFAIK, the efforts needed to make good static analysis are proven, by
experience, to be at least as time consuming than the efforts needed to make
good unit and dynamic testing.
--
_
Maric Michaud
--
http://mail.python.org
! you're just right, my first writing of this was :
for m in 'a', 'b', 'c' :
print [ t for t in type(i).mro() if m in t.__dict__ ]
which I carelessly ad wrongly rewrote using dir while posting.
Sorry.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
/mailman/listinfo/python-list
--
_
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
the reference on this
and super, it worths the effort.
--
_
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
(itertools.chain((something,), (someMethod(i) for i in some_list)))
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
()
--
_
Maric Michaud
_
--
http://mail.python.org/mailman/listinfo/python-list
I faced a strange behavior with generator expression, which seems like a bug,
for both
python 2.4 and 2.5 :
class A :
... a = 1, 2, 3
... b = 1, 2, 3
... C = list((e,f) for e in a for f in b)
...
Traceback (most recent call last):
File stdin, line 1, in module
File stdin, line
ai a écrit :
It assumes that there is a module A which have two global variables X
and Y. If I run import A in the IDLE shell, then I can use A.X and
A.Y correctly. But if I want to change the module A and then delete
the variable Y, I find I can use A.Y just the same as before!
It's unlikely
samwyse a écrit :
George Sakkis wrote:
On May 29, 11:33 pm, Matimus [EMAIL PROTECTED] wrote:
Your attemtp:
[code]
first, rest = arglist[0], arglist[1:]
[/code]
Is the most obvious and probably the most accepted way to do what you
are looking for. As for adding the fucntionality you
Steve Howell a écrit :
--- Carsten Haese [EMAIL PROTECTED] wrote:
On Sun, 2007-05-27 at 07:30 +, OKB (not
okblacke) wrote:
Underscores are harder to type than any
alphanumeric character.
This is a discussion about underscores versus
capital letters denoting
the word
Orlando Döhring a écrit :
...
A = [ 3 7 5
0 4 2 ];
# in Python: A = [[3,7,5],[0,4,2]]
[B,IX] = sort(A,2)
# sort by rows
B =
3 5 7
0 2 4
IX =
1 3 2
1 3 2
# first line: 3 was formerly in the first position, 5
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 generator
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're both
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):
fname =
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.
Maybe
1 - 100 of 213 matches
Mail list logo