On Sat, 24 Nov 2007 14:09:04 +0100, Ton van Vliet wrote:
> On 24 Nov 2007 08:48:30 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]>
> wrote:
>
>>On Sat, 24 Nov 2007 09:12:34 +0100, Ton van Vliet wrote:
>>
>>> Just bringing up something I sometimes m
On Sat, 24 Nov 2007 08:27:56 -0800, samwyse wrote:
> On Nov 24, 7:50 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Sat, 24 Nov 2007 02:54:27 -0800, samwyse wrote:
>> > On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]&g
rings. If you don't
do this explicitly Python tries to encode as ASCII and fails if there's
anything non-ASCII in the string. The `encode()` method is your friend.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
Out[83]: >
In [84]: type(Parrot.cmethod)
Out[84]:
In [85]: Parrot.__dict__['cmethod']
Out[85]:
In [86]: type(Parrot.__dict__['cmethod'])
Out[86]:
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
plit function, but this mini-monster wouldn't properly get
> split up due to those random quotations postgresql returns to me.
I hope you don't use Python to access the database, get a tuple back,
convert it to a string and then try to break up that string into a list!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
e time.
If the function looking style would be adopted for 2.x, do *you* want to
explain confused newbies why they can write::
print('hello!')
but this acts "strange":
print('hello, my name is ', name)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
!
>>
>>Wasn't Ra the Sun god?
>>
>
> He meant quetzatcoatl. We could rename the language.
That name is already taken in the programming language domain. There's a
Tiny C compiler for 6510 based targets:
http://www.kdef.com/geek/vic/quetz.html
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
re's an alternative way with the `functools.partial()`
function:
from functools import partial
# ...
msg = Button(win,
text='Write Something',
command=partial(salutation, tree))
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
turn item...
>
> Yuck.
I guess Duncan's point wasn't the construction of the dictionary but the
throw it away part. If you don't keep it, the loop above is even more
efficient than building a dictionary with *all* lines of the file, just to
pick one value afterwards.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
er it's easy but
providing functions in the standard library for arbitrary date calculation
involving years is not so easy.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
he decision is easy -- everything on an
object is an attribute. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 08 Dec 2007 00:34:06 -0800, MonkeeSage wrote:
> I think he means callable attributes (methods) and non-callable
> attributes (variables).
But not every callable attribute is a method.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
object bindings and methods are objects.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
>>>> n += 1
>>>> n
> 2
>>>> ++n
> 2
There is no syntax error. It is just some unary pluses "chained". Maybe
unexpected but no syntax error.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
;
dictionary with a tuple of both as keys:
data = dict(((i, j), randint(0, 10)) for i in xrange(11) for j in xrange(11))
And just for completeness: The given data in the example can be stored in a
list of lists of course:
data = [[randint(0, 10) for dummy in xrange(11)] for dummy in xrange(11)]
In [469]: a = collections.defaultdict(int)
In [470]: callable(a.default_factory)
Out[470]: True
In [471]: a.default_factory(42)
Out[471]: 42
`a.default_factory` is callable but hardly a method of `a` or `defaultdict`
but a "data attribute" that happens to be callable.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ke it as ugly and unusable as you can. Spend the time you planned
for writing documentation for this task. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
obal line_ptr
> 69 global char_ptr
> ...
> 75 line_ptr = 0
> 76 char_ptr = 0
> ...
> 109 def get_toks( text ):
> 110 while line_ptr < last_line:
> ...
> So when is a global var global?
When you declare it ``global`` *in the function*. ``global`` on module
level ha
ful than the real default. What is the
> reasoning behind NOT using this as the default implementation for a
> dict in python?
How's that more useful in the general case? Maybe if you come from a
language where some default value pops up if the key is not present you
are used to write code in a way that exploits this fact. But in the
general case!? I need `defaultdict` not very often but want to know if a
key is not present in a dictionary. Because most of the time that's a
special condition or error that has to be handled or signaled up the call
chain.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 11 Dec 2007 17:58:37 -0800, mariox19 wrote:
> If I am supposed to send messages to Tkinter objects only from the
> main thread, how can I get the letters to appear 1 per second?
Take a look at the `after()` method on widgets.
Ciao,
Marc 'BlackJack'
On Tue, 11 Dec 2007 20:08:21 -0300, Gabriel Genellina wrote:
> data = [row for row in csv.reader(..)]
A bit shorter::
data = list(csv.reader(..))
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
rst
> '\0' are counted.
If you want to deal with bytes better open the file in binary mode.
Windows alters line endings and stops at a specific byte (forgot the
value) otherwise.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
= [do_something(item) for item in old]
Or:
new = map(do_something, old)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
tarting to parse XML with regular expressions you are
making the very same mistake. XML may look somewhat simple but
producing correct XML and parsing it isn't. Sooner or later you stumble
across something that breaks producing or parsing the "naive" way.
Ciao,
Marc
implement it. :-)
`itertools.groupby()` might be handy.
And you have to think about digits in the source if that's allowed.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
arBasic for the conversion.
Full story:
http://www.xml.com/pub/a/2006/01/11/from-microsoft-to-openoffice.html
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 17 Dec 2007 06:20:23 -0800, vimal wrote:
>i have a list of numbers
>
> say a = [1,-1,3,-2,4,-6]
>
> how should i check for negative values in the list
In [6]: a = [1, -1, 3, -2, 4, -6]
In [7]: any(n < 0 for n in a)
Out[7]: True
Ciao,
Marc 'Blac
e other program will say:
> tok = Toker( text_array )
> tokens = tok.tokenize()
>
> So how does the constructor make the array of strings available to the
> tokenize() method?
Assuming the `__init__()` above belongs to the `Toker` class then the
`tokenize()` method can access it via `self.text`
rom_file()` method
inherited from class `A` is called but with `B` as the first argument so
it returns an instance of `B`.
A staticmethod is just a function attached to a class without any "magic".
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
on is
sufficient or if the `strategy` needs some state that must be preserved
between calls to the strategy object.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
in Australia and he told me two
>>
>> I'm thinking a list comprehension...
>
> Possibly some filter(map()) for the really orthodox believers...
And ``ifilter(imap(…))`` for the reformists.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
another `ham`.
> 8) W:995:sendStringToSocket: Used builtin function 'map'
>Is that a problem?
`map` is "deprecated" in favor of list comprehensions. A matter of taste…
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, 雷 wrote:
> suggest add do while loop in later version
Please also suggest a clean syntax for this. :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
"ancestors" so you can
build an object hierarchy. Missing attributes are looked up in the
"ancestors" and one can explicitly look up the inheritance tree with
``super``. There are no classes, just four objects. Convention in naming
and usage makes two of them something like templates or "classes" for new
objects but they are in no way special.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ch line as it is ouput, not all of the lines at termination,
> which is what is happening.
>From the Python side you can only control Python's input buffer but not
the output buffer of the external program you are starting. I guess that
programs buffers its output.
Ciao,
Marc &
the chained
iterators::
new_list = pipe(grep('larch'), grep('parrot', 'v')), list)(my_list)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
s, **t)
return d
class A:
@b
def a(x, y, z):
print y, z
x.e(23)
def e(u, v):
print u, v
class B:
def e(v, w):
print 'spam', v, w
A.e = e
x = A()
x.a('answer', 42
ind out yourself by just trying that code.
Running this::
b = 3
def adding(a):
print a + b
adding(5)
Puts out 8 as expected.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ago. IIRC, disabling some other program or service
> fixed it for one MS victem.
IIRC it was something like an NTP daemon that caused the clock to "jump"
a little and (Window's) sleep was confused.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
The "jump" of the system clock might confuse the systems `sleep`
implementation.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
cing `file` as a synonym was the possibility to
inherit from builtins. Inheriting from `open` looks quite strange.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ybe
duck typing. :-)
SCNR,
Marc 'BlackJack' Rintsch
[1] http://www.cybersalt.org/cleanlaugh/images/03/ducktape.htm
--
http://mail.python.org/mailman/listinfo/python-list
r line in lines:
file.write(line)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ause it depends on the details
> of the operating system you're using. On Unix, you can seek to a specific
> place in a file, write a single character, seek to EOF, and you've done an
> in-place single character edit of the file.
Why seeking to EOF after writing the byte?
and connected with the
caller's history of `champagne.drink()` calls. The `person.is_pretty`
property is most definitely linked to that call history in many instances.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ing bytes are all
ASCII. And of course you can use that escape prefix as often as you want
within a string of ASCII byte values.
http://en.wikipedia.org/wiki/ISO-2022-JP#ISO_2022_Character_Sets
> I.e. in practice (in a context limited to the encoding in question)
> should this be considered as a data loss, or should these strings be
> considered "equivalent"?
Equivalent I would say. As Unicode they contain the same characters.
Just differently encoded as bytes.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
der IDLE. Any help or explanation would be appreciated.
You are not closing the file so the buffered data is not written to disk.
To call a function you need the parenthesis, otherwise you are just
referencing it without any effect.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
maybe it should not be a class. Maybe a function returning
`Article`\s would be enough. This is not Java, not everything has to be
stuffed into classes.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
to yell at you. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
tswith(start_marker),
lines))
Maybe these functions usually don't turn up in code that can be called
"recipes" so often but are useful for themselves.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ngth and all elements at the corresponding
indexes compare equal, the lists are considered equal.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
nning a 500odd page ebook
> through one of those scripts might not be such a good idea.
Heuristics? Neither PDF nor HTML know "chapters". So it might be
guesswork or just in your head.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 02 Jan 2008 03:24:56 -0800, vedrandekovic wrote:
> Here is sample of my simple script with wxpython and modules:
> subprocess,threading, directpython...
Are you accessing the GUI from threads?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman
into decimal and confirm that they match.
The right direction would be the tutorial in the docs I guess:
http://docs.python.org/tut/tut.html
What do you mean by the "hexadecimal form"? `id()` returns ordinary
`int`\s and not strings.
Ciao,
Marc 'BlackJack' Rints
looking for a Python web framework with a "Pet Store" tutorial?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
do whatever is needed to output the numbers from ``slow``
unbuffered or line buffered.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
are strings, adjust
> accordingly):
>
> s = "gmmscore -i %s -l %s -t %s -m %s -d %s -v %s -n %s -r %s" %
> (Input, List, modeltype, str(mixture), str(dimension), str(vfloor),
> str(number), str(results))
>
> subprocess.Popen([s])
Here you are trying to start
[1]
> IndexError: list index out of range
>
> Anyone could shed me a light on this?
The real list you used had at least one string without a '=' in it. The
list given above doesn't raise that exception:
In [102]: mylist=['','tom=boss','mike=manager
a solution that works?
> Any suggestions? Any help will be appreciated :)
My suggestion would be: use one of the many already existing templating
systems.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ance, the method will
> not get "self" as parameter.
You are not adding a method but a function. Take a look at
`types.MethodType()` to create a method from a function, instance, and
class.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
to
the clients for execution. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
)
> and .__len__, str() and .__str__. Do you maybe know what's the
> rationale behind not following that convention by getattr?
I think you are confusing `__getattr__` and `__getattribute__` here!
`getattr()` maps to `__getattr__()`, it's `__getattribute__` that's
differen
nd remaining part of the text is not read.
You have to open the file in binary mode ('rb'/'wb') instead of text mode
('r'/'w') to stop Windows from interpreting the EOF character this way.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
or if that import is not the very
first statement in a source file.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
e works well.But what's the instance of "oops"? where is it
> coming from? I'm totally confused on it.thanks.
`oops` is bound to the `ValueError` or `TypError` object if `float()`
raises such an exception.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
it's all greek. I grew up with C function pointers, and they
> always work.
>
> robert
Suppose `func` is a C function pointer, then
foo = func;
and
foo = func();
have different meanings. It's just the same in Python. First is the
function itself, second *calls* the function.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
x.X as X.
Then you shoot down the idiomatic answer I guess. That's what most people
do.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ou!
You *can* just do ``lala.split()``:
In [97]: lala = 'LNAME PASTA ZONE'
In [98]: lala.split()
Out[98]: ['LNAME', 'PASTA', 'ZONE']
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
AX wants bytes, not a decoded string. Don't decode it
yourself.
> However, I use another text editor to convert the file to utf-8 and
> SAX will parse the content successfully.
Because now you feed SAX with bytes instead of a unicode string.
Ciao,
Marc 'BlackJack'
ls that can get the data from command line or files treat
a single - as file name special with the meaning of: read from stdin.
So the interface if `fui.py` would be:
1. ./fui.py *.a
2. ls *.a | ./fui.py -
3. ls *.a | ./fui.py *.b -
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
mbership
testing and "nested comparison" of those structures. There is no ``is``
involved.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
are you sure that the
> > subprocess is flushing its buffers so you can recognize it's time to
> > provide more input?
>
> The subprocess in a purely passive position: it is an interpreter: I
> send it commands and I read the answers. The python side is in charge.
This
keyword parameters inside the
> function.
> any hints ?
Impossible. Dictionaries are unordered.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
you do that?
>
> I thought it might be compile(), but apparently not.
Maybe `bytecodehacks`_ + `psyco`, or PyPy!?
.. _bytecodehacks: http://sourceforge.net/projects/bytecodehacks/
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
that you confuse unicode and utf-8. Are you sure you are qualified to ask
such a question in the first place!? :-þ
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
640k, it's
>> easy to state that there is no limit. :)
>
> Huh? I used DOS sort to sort files much bigger than 640K.
That was an allusion to a quote misattributed to Bill Gates about DOS:
640K ought to be enough for anybody.
http://en.wikiquote.org/wiki/Bill_Gates#Misattributed
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
vert the GBK string to unicode string, what
> should I do to make SAX work?
Decode it and then encode it to utf-8 before feeding it to the parser.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
. The byte code is *interpreted*
by Python, not compiled to assembler. If you want to know how this
happens get the C source code of the interpreter and don't waste your time
with disassembling `python.exe`. C is much easier to read and there are
useful comments too.
Ciao,
Marc '
On Sun, 27 Jan 2008 11:23:20 +, over wrote:
> Don't fucking tell me about assembler, you asshole. I can read
> disassembled code in my sleep.
Yes you can read it, but obviously you don't understand it.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.o
e, there's almost always a rational explanation. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 27 Jan 2008 16:00:42 +, Peter Pei wrote:
> "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> On Sun, 27 Jan 2008 05:32:40 +, Peter Pei wrote:
>>
>>> You didn't understand my que
es line buffering but if it is
connected to a pipe or redirected to a file it chooses block buffering
instead.
In such cases the `pexpect` module might be a solution.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
code. Can be used for other
things as well.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
e twice and measure the time of the second
call. IIRC psyco needs at least one call to analyze the function, so the
first call is not speed up.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
decode('latin-1')
> but to no avail.
In [388]: 'Fr\u00f8ya'.decode('unicode-escape')
Out[388]: u'Fr\xf8ya'
In [389]: print 'Fr\u00f8ya'.decode('unicode-escape')
Frøya
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
nt and not a function. So the way you wrote
it with parentheses is a bit misleading.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
odd. :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
Fallback is the hash of the identity of an object:
In [415]: class A(object): pass
.:
In [416]: a = A()
In [417]: hash(a)
Out[417]: 161029068
In [418]: hash(id(a))
Out[418]: 161029068
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
formance?
What about `psyco.unbind()`?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
mentation will become
> 'range' at that time.
The point wasn't `range` vs. `xrange` but the arguments (1,n) vs. (n).
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
... del go.count
> ... return False
> ... go.count -= 1
> ... return True
> ...
>>>> while go(3):
> ... print 'hello'
> ...
> hello
> hello
> hello
>>>>
Please try:
while go(3):
while go(3):
print 'Think about it...'
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
appears to be working OK as is, but I would welcome any &
> all suggestions for improving it or making it more idiomatic.
As already said, that ``while`` loop should be a ``for`` loop. But if you
put `m_abbrevs` into a `list` you can replace the loop with a single call
to its `index()` method: ``dlist[1] = m_abbrevs.index(dlist[1]) + 1``.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 04 Feb 2008 09:43:04 +, Odysseus wrote:
> In article <[EMAIL PROTECTED]>,
> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
>> def extract_data(names, na, cells):
>> found = dict()
>
> The problem with initializing the
s are done at the same time. That's what I meant by people
> going through the doors. Maybe it was more clear in my head.
But my timing shows that method two is slower on my computer. So there is
no obvious winner.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ne explain why the code which does more work
> takes less time?
Can't confirm this (Linux, Python 2.5):
Method 1: 15.380897998809814
Method 2: 18.085366010665894
I guess it's really all about the disk IO as my system monitor applet
shows that almost all of the time is spend in the kernel and very little
in user space.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
test functions or to
reuse the code from other scripts.
>> def extract_data(names, na, cells):
>>
>> and
>>
>> return
>
> What should it return? A Boolean indicating success or failure? All the
> data I want should all have been stored in the &quo
each
> time.
It doesn't hold. Read the code again. The total count of "open door" and
"close door" is the same in both cases.
It's
for every person:
open his door; push him through the door; close his door
vs.
for every person:
open his doo
core. Clearly, not generally
> applicable. -- But, from __future__ import does change syntax.
Why not simply writing a function?
def execute_parallel(f, A):
for args in A:
start_new_thread(target=f, args=args)
def f(x):
normal_suit(x)
parallel(f, A)
Ciao,
Marc
rectly access the "raw" memory.
To the OP: Since Python 2.5 the `ctypes` module is another way to
interface with "native" code in dynamic libraries from the standard
library.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 04 Feb 2008 21:58:46 +, Steven D'Aprano wrote:
> On Mon, 04 Feb 2008 17:08:02 +0000, Marc 'BlackJack' Rintsch wrote:
>
>>> Surprisingly, Method 2 is a smidgen faster, by about half a second over
>>> 500,000 open-write-close cycles. It's no
1201 - 1300 of 1811 matches
Mail list logo