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
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
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
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
-20)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f=open('txt')
>>> for l in f :
... print l,
... print "rest : " + f.read()
...
foo
Traceback (most recent call last):
File &qu
ctically
this is rarely needed).
Python is alot about conventions, please read and follow the PEP 8 :
http://www.python.org/dev/peps/pep-0008/
--
_
Maric Michaud
--
http://mail.python.org/mailman/listinfo/python-list
tead of using the
straightforward readline method ?
>>> import sys
>>> l=sys.stdin.readline()
>>> while(l) :
... print l,
... l=sys.stdin.readline()
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +
uld be really appreciated.
regards,
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
Mobile: +33 632 77 00 21
--
http://mail.python.org/mailman/listinfo/python-list
it strong enough ?
--
_____
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
Mobile: +33 632 77 00 21
--
http://mail.python.org/mailman/listinfo/python-list
r
> way of doing this?
Why not :
In [4]: s="010203040506"
In [5]: print s[4:6] + s[2:4] + s[0:2] + s[6:]
030201040506
?
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
Mobile: +33 632 77 00 21
--
http://mail.python.org/mailman/listinfo/python-list
hreaded code take significantly longer to execute."
Very interesting point, this is exactly the sort of thing I'm looking for. Any
valuable link on this ?
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
Mobile
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
nal package):
A/__init__.py
A/B/__init__.py
A/B/C.py
X/__init__.py
X/B/__init__.py
X/B/C.py
just write in X/__init__.py :
import A.B.C, B.C
A.B.C = B.C
and all "from A.B import C" following an import of X will return X.B.C.
This is how we "monkeypatch" products in Zope.
-
Le Lundi 15 Mai 2006 19:24, Roy Smith a écrit :
> d = {}
> d.reserve (10*1000*1000)
d={}.fromkeys(xrange(5*10**6)) ?
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
--
http://mail.python.org/mailman/listinfo/
ill be probably big" but can't predict what keys will be
in.
--
_
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
eval func (the local one is not
in the scope of b defintion)
try this :
exec s // like exec s in globals(), locals()
eval("b(2)") // like , eval("b(2)", globals(), locals())
or if you to keep this dictionnary as a specific scope in your appplication :
exec s in ns
eval(&q
s : s._x
: setX = lambda s, v : setattr(s, '_x', mystr(v))
: X = property(getX, setX)
:
:
In [14]: r=myrow()
In [15]: r.X = 'toto'
In [16]: r.X
Out[16]: 'toto'
In [17]: type(r.X)
Out[17]:
--
_
M
bute(self):
return self._attr
attr = vprop('Attribute')
class Derived(Base):
def getAttribute(self):
return 2*self._attr
--
_
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
('frwiki-20060511-abstract.xml')
Out[20]:
In [21]: myFile('frwiki-20060511-abstract.xml').myreadline()
yo
In [22]:
--
_
Maric Michaud
_
Aristote - www.aristote.info
3 place des tapis
69004 Lyo
Le Jeudi 25 Mai 2006 00:07, Dan Bishop a écrit :
> If I try to write something like:
>
> num_weeks = time_diff / datetime.timedelta(days=7)
because it has no meaning, what you want is :
num_weeks = time_diff.days / 7
or
num_weeks = (time_diff / 7).days
--
_____
Mari
return td.days * 24* 3600 * 10**6 +
td.seconds * 10 ** 6 + td.microseconds
def toseconds(td) : return float(tomicroseonds(td)) / 10 ** 6
tominute, tohours, todays, toweeks, etc...
and use float and int / and % operators.
This is an easy and clean implementation IMHO.
--
_
define some
helper functions like this :
def tomicroseconds(td) :
return td.days * 24* 3600 * 10**6 +
td.seconds * 10 ** 6 + td.microseconds
def toseconds(td) : return float(tomicroseonds(td)) / 10 ** 6
tominute, tohours, todays, toweeks, etc...
and use float and int / and % operat
elf.setattr(v)
attr = property(fget=__gattr, fset=__sattr)
But, this is too verbose for me, I would opt for the lambda syntax :).
_
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
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
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
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
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
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
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
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
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.
((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
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
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
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
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
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
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
provide sequences of datas as
iterators when they can grow in size.
--
_
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
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
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]:
at import
time to avoid the rather time consuming parsing stage.
--
_
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', '
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
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
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
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
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
.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
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
itor could
modify them without breaking the logic of the template.
--
_
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
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
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
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
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
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
--
AttributeErrorTraceback (most recent call last)
/home/maric/ in ()
AttributeError: can't set attribute
--
_
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
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
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
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
>>[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
x27;t respect RFCs (notably 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 I
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
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
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
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
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
e_, file)
won't work anymore if you do so.
--
_
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
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
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
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
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
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.
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
-l -c ..., the -l option forces a
login shell even in non-interactive session.
--
_
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
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
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
= 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,
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
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
;
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
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
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
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(
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
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
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)
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._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
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
>>>[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
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
[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
--
_
101 - 200 of 214 matches
Mail list logo