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 t
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 an
ame integer in some
implementation is unrelated to the original problem.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
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]> wrot
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=
foo()
> f.someMethod()
>
> class again():
> def __init__(self):
> f = foo()
> f.someMethod()
>
> bar()
> again()
> ---
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
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
e keys are case-sensitive, so this is not an option,
the only way to do it fast 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-list
here something else I should do in order to have more clues
> ("Read The Fine Manual (tm)" is an acceptable answer)
You can try 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 ins
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.
>
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 peop
.lower()] = (key,whatever)
>
"premature optimization is the root of all evil"
I don't recall the OP wanted a (a bit) faster solution to his problem in
counterpart of memory loss and syntax complication.
If the OP's proposal seems already messy, how about ths one :
if lib.lower() not in ( e[0] for e in stage_map.items() ) :
...
> - Chris
>
> > --
> > http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
an one brain cycle
to achieve. Try the regexp solution and make your choice, more than often, I
keep the straightforward, "read as pseudo-code", python expression.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
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
[EMAIL PROTECTED]:~> python test01.py
> Traceback (most recent call last):
> File "test01.py", line 9, in
> _s_.add(bar())
> TypeError: id() takes exactly one argument (0 given)
>
> --
> http://mail.python.org/mailman/listinfo/python-list
--
_
ay to go is one like Diez show you in a previous post.
> >>> class foo(set):
> ... def __contains__(self, value):
> ... print value
> ...
> >>> a = foo((1,2))
> >>>
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
>>>[1]: import shelve
>>>[2]: s = shelve.open('db')
>>>[3]: for name, value in s.items() : print name, value
...:
b 4.0
a 5
c ('foo', 'bar')
>>>[5]: del s['b']
>>>[6]: s['c'] += ('baz',)
&g
it's an optimization problem,
duplicating such a data 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
self._val=val
value = property(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
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)
>
def fsetsquare(self,s):
self._setsquare(s)
self._setvalue = math.sqrt(s)
def _setvalue(self, val):
# some extra logic here
self._internalval=val
def fsetvalue(self, val):
self._setvalue(val)
ert into 'table1' values (?, ?)", ('ddd', '4
street')).rowcount
...[114]: 1
>>>[115]: for i in db.execute("select * from 'table1' where name
like '___'") : print i
.:
(u'ddd', u'3 street')
(u'ddd', u'4 street')
>>>[116]: db.execute("insert into 'table1' values (?, ?)", ('ddd', '4
street')).rowcount
---
IntegrityErrorTraceback (most recent call last)
/home/maric/ in ()
IntegrityError: columns name, address are not unique
>
> Steve
> [EMAIL PROTECTED]
> --
> http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
ctures in pure python), but what would 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.py
self.worker.answerCall(message)
if __name__ == "__main__":
emp=Employer()
emp.callWorker("report to work")
workmodule.py
--
class Worker:
def __init__(self, employer):
from empmodule import Employer
if not isinstance(
ng for too long to see it.
>
> http://mail.python.org/pipermail/python-list/2007-June/446601.html
> shows a somewhat comparable constellation and it was a good guideline.
> But there, the function 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
hints, and/or suggestions are greatly appreciated,
>
>
> Carson
> --
> http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
;
It is a common advice that staticmethod should not exist in python, as they do
nothing compared 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
stated anything
> > that appears to be a problem with how Python works. If two different
> > modules import the same third module, there is no big performance
> > penalty. The initialization code for the third module is only
> > executed on the first import, and the cost of havi
quot;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 Michaud
--
http://mail.python.org/mailman/listinfo/python-list
= float(b[1] - a[1]) / (b[0] - a[0])
return [ slope * float(i) for i in xrange(b[0]-a[0] + 1) ]
:
>>>[23]: 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,
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
rollback unwanted changes, and application logic to
continue execution 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
access emails directly on the Exchange server via standard python modules
poplib or imaplib, my preferred choice if one of these protocols are
supported by your environment. You won't need no extensions, just a standard
python installation, and your code will work with most mail deliv
-l -c ..., the -l option forces a
login shell even in non-interactive session.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
h
> > string except the first.
>
> Or use the str.join method:
>
> print "\t".join(list("avtRsf"))
>
Not related to OP's question, but why one would want to convert a string to a
list to make it iterable ?
>>>[3]: print '\t'.join('azerty')
a z e r t y
> --
> http://mail.python.org/mailman/listinfo/python-list
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
provided by the user, this is legal and perfect use of exec
because here the user is a trusted one (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.
on most application.
But,
> The problem is more complex than you think.
>
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.o
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 cla
without introducing a subtle 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://m
a in range(5) for b in l)
(2) This won't work as it would with nested functions, you need to build the
new calss directly 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
, 6,
7, 8]
>>>[78]: class A(object) :
l = list( a for a in range(5) )
m = list( e + f for f in range(5) for e in l )
:
:
-------
NameError Traceback (most recent call last)
/home/maric/ in ()
/home/maric/ in A()
/home/maric/ in ((f,))
NameError: global name 'l' is not defined
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
e_, file)
won't work anymore if you do so.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
nk of the following lines :
a, b = 0, 1
a += b
a, b = b, a
s = "foo"
s = s.upper()
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
here.
> >>> int
>
>
>
> >>> myint
>
>
>
> despite int and myint having the same metaclass. So if the
> representation is really defined in the 'type' metaclass, then
> type.__repr__ has to make some kind of distinction between int and
> myint, so they cannot be on absolute equal footing.
You're right, type(int) is type, the way it renders differently is a detail of
its implementation, you can do things 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
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 r
ey can be instantiated and they produce objects (ordinary object in
general) with theirslef as a type.
- metatypes or metaclass, are subclasses of "type", their instances are new
types.
For all tjis work together you must admit the following recursivity :
'type' is both a
at the means is that int is not a user type but a builtin type,
instances of int are not types (or classes) but common objects, so its nature
is the same as any classes.
The way it prints doesn't matter, it's just the __repr__ of any instance, and
the default behavior for instances of type is to return '', but it
can be easily customized.
>>>[1]: class A(object) :
...: class __metaclass__(type) :
...: def __repr__(self) : return ""
...:
...:
>>>[2]: A
...[2]:
>>>[3]: type('toto', (object,), {})
...[3]:
--
_
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 I
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
x27;t respect RFCs (notably about encoding)...
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
>>[61]: b, c
...[61]: ([[1, 0], 3], [[1, 0]])
This is if you want to make a true copy (called deep copy) that you'll have to
do extra steps (using copy module for example).
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
ist). And a reader would probably not see your intention
here (he already expect a scalar due to the name of the variable).
This is exactly the problem ABC is intended to solve.
Without ABC, to explicitly ensure amount is a scalar, just doing a int(amount)
or int(abs(amount)) if you want to deal
also wrong assuming that because amount compare to zero, it
can be added to sample.
If you want to make type checking just check the type or convert your
parameter to an int, but the test "== 0" is of no help here.
The only valuable point I see for this idiom is to make more explicit I
e)
def __getattr__(self, name) :
try : return old_one(self, name)
except AttributeError :
try : g = super(class_, self).__getattr__
except : raise AttributeError('no more __getattr__')
return g(name)
if not getattr(C, '_C_fixed__', False) :
C._C_fixed__ = C.__getattr__
C.__getattr__ = collaborative_getattr(C, '_C_fixed__')
That said, if your class C is a real facade for its ancestors A and B (A and B
won't appear at all in the hierarchies of your subclasses), your solution is
near the best one in terms 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
8999
>>>[29]: 0.51
...[29]: 0.51001
>>>[28]: 1.1
...[28]: 1.1001
>>>[35]: round(0.5)
...[35]: 1.0
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
--
AttributeErrorTraceback (most recent call last)
/home/maric/ in ()
AttributeError: can't set attribute
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
The signature should be :
vector move_slice(vector& vec, int start, int stop, int
dest)
or
vector move_slice(vector& vec, int start, int stop, int
dest)
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
self.obj = obj
def __len__(self) : return self.size
def __iter__(self) : return itertools.repeat(self.obj, len(self))
:
:
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
ist[:] = new_list" these are same i
> think ?
Not at all, try to figure out what happen with the following :
>>>[3]: l=[]
>>>[4]: g=[]
>>>[5]: l == g
...[5]: True
>>>[6]: l is g
...[6]: False
>>>[7]: l = [4]
>>>[8]: l is g
...[8]: False
>>>[9]: l == g
...[9]: False
>>>[10]: l = g
>>>[11]: l is g
...[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
ge, as a pure python
optimization for dealing with long list, to replace an algorithm with a lot
of append by something like this :
mark = object()
datas = [ mark ] * expected_size
# working with the datas while maintaining the effective currrently used size
Of course one could even subclass list
need to have a
logging procedure which queue the message 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
s to be out of memory and begin to swap,
while it's not, of course, an issue with python lists...
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
itor could
modify them without breaking the logic of the template.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
t b
else:
B.remove(b)
.:
.:
1
2
3
4
5
>>>[176]: B
...[176]: [1, 2, 3, 4, 5]
Note that this can be easily done 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
.py :
ModuleOptions = {}
othermodule.py :
import mymodule
mymodule.ModuleOptions['Verbose'] = True
or if you think encapsulation is important :
mymodule.py :
_ModuleOptions = {}
def get_option(opt) :
return _ModuleOptions[opt]
And you're done.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
s rather ugly.
Finally, to come to a more functionnal style the method could have been
written 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
d be written "f.tell()"
and "not f.tell()" in python.
if not f.tell() :
print 'at the beginning of the file"
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
sub('<.+?>', '', e) for e in re.findall('.*?',
res) ]
...[229]:
['Python Gallery',
'Coffret Monty Python And Co 3 DVD : La Premi\xe8re folie des Monty ...',
'Re: os x, panther, python & co: msg#00041',
'Re: os x, panth
e.get_payload() :
....: if i.get_content_type() == 'message/delivery-status' :
: print i.get_payload()[1]['status']
:
:
5.0.0
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
rackets is the character '|', so there is no reason for it to appears twice.
Very complicated regexps are always evil, and a two or three stage filtering
is likely to do the job with good, or at least better, readability.
But once more, what are you trying to do ? This is not even clear that regexp
matching is the best tool for it.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
looping with a hex->bin lookup table
> would be probably much faster than the general baseconvert from the
> recipe.
>
> What do you think?
Something like that, less typing with octal conversion :)
>>>[8]: oct2bin =
{'0':'000', '
at import
time to avoid the rather time consuming parsing stage.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
xml = """
"""
In [89]: def print_nodes(node) :
print node
if node.attributes :
for n, v in node.attributes.items() : print n, v
for i in node.childNodes : print_nodes(i)
:
:
In [94]: dom = parseString(xml)
In [95]:
print "%-6s %3s %2s %4s%-7s" % tuple(items)
In python, str objects have a splitlines method for portability it is better,
a shorthand for split(os.sep).
--
_
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 zi
provide sequences of datas as
iterators when they can grow in size.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
what "compilation" means in python, just don't use it, use closures or
callable instances, there are many way to achieve this.
--
_
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 = MyClassUsi
eth1(self, arg) :
for i in self._meth1_strategies :
i.do_init(...)
for i in self._meth1_strategies :
i.do_job(...)
for i in self._meth1_strategies :
i.do_finalize(...)
...
The class complextiy problem is actually solved by :
inst_with_alg1 = MyClassUsingStrategies((algo1_strategy,), (algo1_strategy,))
inst_with_alg1_alg2 = MyClassUsingStrategies(
(algo1_strategy,),
(algo2_strategy,)
)
inst_with_alg12 = MyClassUsingStrategies(
(algo1_strategy, algo2_strategy),
(algo1_strategy, algo2_strategy)
)
etc...
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
one
more step, can be considered as premature optimisation and the one liner :
''.join(e for in string_ if e not in 'chars')
may be preferred.
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
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
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 bi
((u[r%3000], random.randint(0,1)) for r in range(5*10**6))
print "with list", do(c_list, u, v)
print "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/mailman/listinfo/python-list
cally, wether a program has bugs 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.
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 w
hould do this according to regexcoach but it seems to send my
computer into 100%CPU-power and not closable.
"""
In [172]: list(e[0] for e in re.findall("((\w+\s*)+)", s, re.M) if
re.findall('zlatan\s+ibrahimovic', e[0], re.I))
Out[172]:
['i want to find a in a big string a sentence containing Zlatan\nIbrahimovic
and some other text',
'ie return the first sentence containing the name Zlatan Ibrahimovic',
'zlatan ibrahimovic ']
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
if meth_name in ty.__dict__:
> return ty
> return None
>
> Cheers,
> Allen
>
Oh ! 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
http://mail.python.org/mailman/listinfo/python-list
A one liner, though it's a bit lispy :
list(itertools.chain((something,), (someMethod(i) for i in some_list)))
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
erence 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
remember the last time I used re module in production code in
python (unlike in perl or shell).
>
> Thanks
> L.
> --
> 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 32 77 00 21
--
http://mail.python.org/mailman/listinfo/python-list
each in dir(hbar.decorator()):
print each
hbar.decorator().p()
hbar.decorator().inc()
hbar.decorator().p()
hb2 = HBar2(5)
hb2.p()
hb2.p2()
hb2.inc()
hb2.p()
hb2.p2()
hb2.inc2()
hb2.p()
hb2.p2()
--
_
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 "", line 1, in
File "", line 4, in A
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 unl
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
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 fi
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 d
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
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'
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
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
1 - 100 of 214 matches
Mail list logo