For running the new executable in a
subprocess fork() and exec() are needed. I think, that's a bad example.
These APIs are actually well-designed.
nd
--
Gefunden auf einer "Webdesigner"-Seite:
> Programmierung in HTML, XML, WML, CGI, FLASH <
# André Mal
* Johannes Bauer wrote:
> The pre-check version is about 42% faster in my case (0.75 sec vs. 1.3
> sec). Curious. This is Python 3.2.3 on Linux x86_64.
A lot of time is spent with dict lookups (timings at my box, Python 3.2.3)
in your inner loop (150 times...)
#!/usr/bin/python3
import re
pa
* André Malo wrote:
> * Johannes Bauer wrote:
>
>> The pre-check version is about 42% faster in my case (0.75 sec vs. 1.3
>> sec). Curious. This is Python 3.2.3 on Linux x86_64.
>
> A lot of time is spent with dict lookups (timings at my box, Python 3.2.3)
> in you
* Tom P wrote:
> consider a nested loop algorithm -
>
> for i in range(100):
> for j in range(100):
> do_something(i,j)
>
> Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
> some other values i = N and j = M, and I want to iterate through all
> 10,000 value
* Roy Smith wrote:
> The third is that I never use methods I can't figure out how to
> pronounce.
here: strip'time
nd
--
Flhacs wird im Usenet grundsätzlich alsfhc geschrieben. Schreibt man
lafhsc nicht slfach, so ist das schlichtweg hclafs. Hingegen darf man
rihctig ruhig rhitcgi schreiben, we
* Chris Angelico wrote:
> Hopefully this will be a step up from Rick's threads in usefulness,
> but I'm aware it's not of particularly great value!
>
> How do you pronounce PyPI? Is it:
> * Pie-Pie?
> * Pie-Pip, but without the last p? (same as above but short i)
> * Pie-Pea-Eye?
> * Something el
* Steven D'Aprano wrote:
> For a 21st century programming language or data format to accept only one
> type of quotation mark as string delimiter is rather like having a 21st
> century automobile with a hand crank to start the engine instead of an
> ignition. Even if there's a good reason for it (
* Steven D'Aprano wrote:
> On Thu, 05 Apr 2012 23:08:11 +0200, André Malo wrote:
>
>> * Steven D'Aprano wrote:
>>
>>> For a 21st century programming language or data format to accept only
>>> one type of quotation mark as string delimiter is rather
* Grzegorz Staniak wrote:
> On 06.04.2012, rusi wroted:
>
>> There should be one-- and preferably only one --obvious way to do it.
>
> Then again, practicality beats purity.
Yes.
If you ever grepped for, say, the usage of dictionary keys in a bigger
application, you might agree, that having mu
me)
finally:
del testedmodule.file
self.assertEqual(result, expected)
(if you're using open, replace .file with .open)
(testedmodule is of course the module where the file call happens)
nd
--
die (eval q-qq[Just Another Perl Hacker
]
;-)
# André Malo, <http://www.perlig.de/> #
--
http://mail.python.org/mailman/listinfo/python-list
* "Iain King" <[EMAIL PROTECTED]> wrote:
> Ah, doh! Of course. Oh well then... still, doesn't python's RE
> engine support named groups? That would be cumbersome, but would allow
> you to go above 100...
The named groups are built on top of numbered captures. They are mapped by the
parser and
* TK <[EMAIL PROTECTED]> wrote:
> sys.stdout = codecs.lookup('utf-8')[-1](sys.stdout)
> What does this line mean?
"Wrap stdout with an UTF-8 stream writer".
See the codecs module documentation for details.
nd
--
http://mail.python.org/mailman/listinfo/python-list
* Duncan Booth <[EMAIL PROTECTED]> wrote:
> metiu uitem wrote:
>
> > Say you have a flat list:
> > ['a', 1, 'b', 2, 'c', 3]
> >
> > How do you efficiently get
> > [['a', 1], ['b', 2], ['c', 3]]
>
> That's funny, I thought your subject line said 'list of tuples'. I'll
> answer the question in t
* Kay Schluehr wrote:
> you might initialize self.storedAttr with empty dicts and fill them
> later:
>
> self.soredAttr = [{}]*10
> for entry in self.storedAttr:
> entry.update(self.drawAttr)
As a matter of fact, you're doing the same ;-)
In [1]: x = [{}] * 10
In [2]: x[0]['a'] = 1
In [3]
* "Qiangning Hong" <[EMAIL PROTECTED]> wrote:
> I want to apply TDD (test driven development) on my project. I am
> working on a class like this (in plan):
>
> # file: myclass.py
> import _extmod
>
> class MyClass(object):
> def __init__(self):
> self.handle = _extmod.open()
>
>
* "lothar" <[EMAIL PROTECTED]> wrote:
> this response is nothing but a description of the behavior i reported.
Then you have not read my response carefully enough.
> as to whether this behaviour was intended, one would have to ask the module
> writer about that.
No, I've responded with a view o
* "lothar" <[EMAIL PROTECTED]> wrote:
> no - in the non-greedy regex
> <1st-pat>*?
>
> <1st-pat>, and are arbitrarily complex patterns.
The "not" is the problem. Regex patterns are expressed positive by
definition (meaning, you can say, what you expect, but not what you
don't expect). In oth
* Martin Körner <[EMAIL PROTECTED]> wrote:
> I am using email module for creating mails with attachment (and then
> sending via smtplib).
>
> If the name of the attachment file is longer than about 60 characters
> the filename is wrapped in the Content-Disposition header:
>
> Content-Dispositi
"''' raises a TypeError, though.
nd
--
sub the($){+shift} sub answer (){ord q
[* It is always 42! *] }
print the answer
# André Malo # http://pub.perlig.de/ #
--
https://mail.python.org/mailman/listinfo/python-list
* gry wrote:
> I might want to replace '(max|min|cos|sqrt|ceil' with "public.\1", but
> only with probability 0.7. I looked and looked for some computed
> thing in re's that I could stick and expression, but could not find
> such(for good reasons, I know).
> Any ideas how to do this? I would go
b{q~Another~},sub{q~Perl~},sub{q~Hacker~});
my $japh = q[sub japh { }]; print join #
[ $japh =~ /{(.)}/] -> [0] => map $_ -> () #André Malo #
=> @japh;# http://www.perlig.de/ #
--
http://mail.python.org/mailman/listinfo/python-list
l Hacker
:-)
# André Malo, <http://www.perlig.de/> #
--
http://mail.python.org/mailman/listinfo/python-list
proaches in the wings, I may be about washed up.
grmpf. Just reached 143 chars / 2 lines ;-)
There seems to be some more room for optimization...
nd
--
package Hacker::Perl::Another::Just;print
[EMAIL PROTECTED] split/::/ =>__PACKAGE__]}~;
# André Malo # http://pub.perlig.de #
--
http:/
* rbt wrote:
> Is it possible to write an re that _only_ matches email addresses?
No. The only way to check if the matched thing is a mail address is to send
a mail and ask the supposed receiver whether he got it.
The grammar in RFC 2822 nearly matches anything with an @ in it. So, how
accurate
* Carl Banks wrote:
> I'm suddenly curious if there are any cases at all where
> greediness changes whether it finds a match.
nope, per definitionem ;-)
greedy := longest leftmost match
nd
--
die (eval q-qq[Just Another Perl Hacker
]
;-)
# André Malo, <http://www.perlig.d
* none wrote:
> classMyObject:
[...]
> As you can see, the _getProperty() method gets called properly when I do
> 'o.value' but 'o.value = 123' does not seem to use the property
> stucture. I can't figure out why 'o.value=123' does not call
> _setProperty()
>
> Any ideas?
property only wor
Ben Finney wrote:
> Ben Finney <[EMAIL PROTECTED]> writes:
>
>> Now, when I write unit tests for my program (i.e. a Python module
>> designed to be run as a command), it can still be imported safely
>> into my unit tests, and all the code gets covered by test cases
>> except the three-line stanza
initalized
once instead of each time they're taken into account.
nd
--
die (eval q-qq[Just Another Perl Hacker
]
;-)
# André Malo, <http://pub.perlig.de/> #
--
http://mail.python.org/mailman/listinfo/python-list
Astan Chee wrote:
> Hi,
> I just tried to do
> eval('00052') and it returned 42.
> Is this a known bug in the eval function? Or have I missed the way eval
> function works?
You know, it's just the answer to the ultimate question of Life, the
universe, and everything.
SCNR, nd
--
http://mail.py
n as hints, not a final
verdict. Think about them (you did, as you asked here ;-). Either correct
or ignore them (typically done by locally or even globally disabling them).
Do some fine-tuning using a config matching your own requirements. The
defaults are, well, just defaults.
nd
--
die (eval q-qq[Just Another Perl Hacker
]
;-)
# André Malo, <http://pub.perlig.de/> #
--
http://mail.python.org/mailman/listinfo/python-list
* [EMAIL PROTECTED] wrote:
> I'm using a tp_getattro function to call into a C library and get
> values the the lib keeps track of. This works:
[...]
> Thats great but I also want to expose some instance methods and I'm
> having trouble.
>
> But when I set tp_methods nothing shows up? If I uns
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return NULL;
PyErr_Clear();
}
else
return tmp;
/* your code */
}
- or -
explicitly define __getattr__ in tp_methods (instead of tp_getattro), which
only gets called on unknown attributes then.
nd
--
die (eva
* [EMAIL PROTECTED] wrote:
> Hi,
>
> I am having trouble figuring out how to set up an object to be
> scriptable through the C API. An example of what I am attempting to
> do:
>
obj = foo.Foo()
obj["key"]
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: unsu
* kai wrote:
> I use the ConfigPaserver from Python.
> how can I use/save/read values with ";" (start comment) and the value
> blank?
> When I write (set) my config file often the part behind the ";"
> disappears.
> e.g.
> myKey = startMyValue ; endMyValue
You can't. The ConfigParser tre
* Steven D'Aprano wrote:
> On Sun, 03 Feb 2008 15:31:49 -0800, Paul Boddie wrote:
>
>> I don't know whether I can offer much better advice than others, but I
>> have noticed that a lot of my own code has moved in the direction of not
>> having specific default values in function/method signatures
* George Sakkis wrote:
> On Feb 4, 6:53 am, André Malo <[EMAIL PROTECTED]> wrote:
>> Consider the function being part of a bigger system, where it's called
>> from another function or method which should "inherit" the default value
>> of the fu
Jesse Aldridge wrote:
> I've got a module that I use regularly. I want to make some extensive
> changes to this module but I want all of the programs that depend on
> the module to keep working while I'm making my changes. What's the
> best way to accomplish this?
Don't ;-)
If the changes are
skunkwerk wrote:
> I've got a python program written for the django web framework that
> starts about 100 threads. When I start the server, it sometimes eats
> up 100% of the CPU for a good minute or so... though none of the
> threads are CPU-intensive
>
> doing a strace on the program, i found
= p:
r.append(x[s:p])
s = p
print r
$ python2.4 foo.py
['walter', " ' ", 'cruz']
$ python2.5 foo.py
['walter', " ' ", 'cruz']
$
nd
--
$_=q?tvc!uif)%*|#Bopuifs!A`#~tvc!Xibu)%*|qsjou#Kvtu!A`#~tvc!KBQI!)*|
fy stuff like _init and _fini.
Nah. It's just looking for the init function required by the python module
loader. See: http://docs.python.org/ext/methodTable.html
nd
--
die (eval q-qq:Just Another Perl Hacker
:-)
# André Malo, <http://www.perlig.de/> #
--
http://mail.python.org/mailman/listinfo/python-list
;
my $japh = q[sub japh { }]; print join #
[ $japh =~ /{(.)}/] -> [0] => map $_ -> () #André Malo #
=> @japh;# http://www.perlig.de/ #
--
http://mail.python.org/mailman/listinfo/python-list
41 matches
Mail list logo