Re: object.enable() anti-pattern

2013-05-11 Thread André Malo
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

Re: Why is regex so slow?

2013-06-18 Thread André Malo
* 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

Re: Why is regex so slow?

2013-06-18 Thread André Malo
* 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

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread André Malo
* 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

Re: Parsing ISO date/time strings - where did the parser go?

2012-09-08 Thread André Malo
* 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

Re: PyPI - how do you pronounce it?

2012-01-30 Thread André Malo
* 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

Re: Python Gotcha's?

2012-04-05 Thread André Malo
* 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 (

Re: Python Gotcha's?

2012-04-06 Thread André Malo
* 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

Re: Python Gotcha's?

2012-04-08 Thread André Malo
* 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

Re: unittest of file-reading function

2005-10-18 Thread André Malo
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

Re: more than 100 capturing groups in a regex

2005-10-26 Thread André Malo
* "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

Re: codecs

2005-11-15 Thread André Malo
* 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

Re: Converting a flat list to a list of tuples

2005-11-22 Thread André Malo
* 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

Re: Lists & "pointers"

2005-07-23 Thread André Malo
* 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]

Re: unittest help

2005-03-24 Thread André Malo
* "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() > >

Re: re module non-greedy matches broken

2005-04-03 Thread André Malo
* "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

Re: re module non-greedy matches broken

2005-04-04 Thread André Malo
* "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

Re: email: Content-Disposition and linebreaks with long filenames

2005-04-13 Thread André Malo
* 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

Re: About some problem

2014-01-03 Thread André Malo
"''' 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

Re: replace random matches of regexp

2011-09-08 Thread André Malo
* 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

Re: python coding contest

2005-12-25 Thread André Malo
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

Re: python coding contest

2005-12-26 Thread André Malo
l Hacker :-) # André Malo, <http://www.perlig.de/> # -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2005-12-26 Thread André Malo
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:/

Re: a more precise re for email addys

2006-01-18 Thread André Malo
* 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

Re: re.match -- not greedy?

2006-11-19 Thread André Malo
* 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

Re: Problem with Property

2006-02-25 Thread André Malo
* 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

Re: Program __main__ function

2007-03-13 Thread André Malo
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

Re: List Behavior when inserting new items

2007-01-29 Thread André Malo
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

Re: eval('000052') = 42?

2007-02-21 Thread André Malo
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

Re: PyLint results?

2006-04-21 Thread André Malo
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

Re: C API - tp_getattro and tp_methods

2006-04-24 Thread André Malo
* [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

Re: C API - tp_getattro and tp_methods

2006-04-24 Thread André Malo
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

Re: C API []-style access to instance objects

2006-04-26 Thread André Malo
* [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

Re: ConfigParser: values with ";" and the value blank

2006-05-05 Thread André Malo
* 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

Re: Is it explicitly specified?

2008-02-04 Thread André Malo
* 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

Re: Is it explicitly specified?

2008-02-05 Thread André Malo
* 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

Re: Best way to modify code without breaking stuff.

2008-06-04 Thread André Malo
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

Re: lots of futex_wait calls

2008-06-06 Thread André Malo
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

Re: regex \b behaviour in python

2008-06-19 Thread André Malo
= 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!)*|

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread André Malo
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

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-28 Thread André Malo
; 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