Re: Speed ain't bad

2004-12-31 Thread Reinhold Birkenfeld
Craig Ringer wrote: > On Fri, 2004-12-31 at 11:17, Jeremy Bowers wrote: > >> I would point out a couple of other ideas, though you may be aware of >> them: Compressing all the files seperately, if they are small, may greatly >> reduce the final compression since similarities between the files can

Re: Parsing a search string

2004-12-31 Thread Reinhold Birkenfeld
Freddie wrote: > Happy new year! Since I have run out of alcohol, I'll ask a question that I > haven't really worked out an answer for yet. Is there an elegant way to turn > something like: > > > moo cow "farmer john" -zug > > into: > > ['moo', 'cow', 'farmer john'], ['zug'] > > I'm trying t

Re: Anonymus functions revisited : tuple actions

2005-03-25 Thread Reinhold Birkenfeld
Ron_Adam wrote: > What if you could: > > x = lambda{ x, y: x+y} > Hmm comma creates a problem here. so... >>> from __future__ import braces SyntaxError: not a chance >>> Reinhold ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Anonymus functions revisited : tuple actions

2005-03-26 Thread Reinhold Birkenfeld
Ron_Adam wrote: > On Fri, 25 Mar 2005 18:58:27 +0100, Reinhold Birkenfeld > <[EMAIL PROTECTED]> wrote: > >>Ron_Adam wrote: >> >>> What if you could: >>> >>> x = lambda{ x, y: x+y} >>> Hmm comma creates a problem here. so... >

Re: Embedding Python

2005-03-26 Thread Reinhold Birkenfeld
Heiko Wundram wrote: > Am Samstag, 26. März 2005 20:43 schrieb Mark Tolonen: >> On my system, for whatever reason, the .so library isn't present. I have >> the python-devel package installed. > > I actually can't believe this; do > > ldconfig -p|grep "python" Or, use ldd =python to exactly di

Re: Python slogan, was Re: Grouping code by indentation - feature or ******?

2005-03-27 Thread Reinhold Birkenfeld
Kent Johnson wrote: >> Wikiquote is nice. I missed it because I googled for Mark Twain and parts of >> the Churchill quote -- for that I'm now convinced it is as wikiquote gives >> a slightly longer excerpt and the date and location of the speech (November >> 11, 1947, in the House of Commons). >

Re: Grouping code by indentation - feature or ******?

2005-03-27 Thread Reinhold Birkenfeld
Jacob Lee wrote: > About slices: > > I agree that Python's slice boundaries (some_list[a:b] being all elements > with a <= index < b) are counterintuitive at first. But this method does > satisfy some handy properties, the first of which being: > l[:n] + l[n:] = l And best of all, this is true

Re: Grouping code by indentation - feature or ******?

2005-03-27 Thread Reinhold Birkenfeld
Javier Bezos wrote: > MetaFont explains this by saying that the index > doesn't refer to a character but to a position > between characters, which when traslated to Python > would mean: > >s t r i n g > ^ ^ ^ ^ ^ ^ ^ > 0 1 2 3 4 5 6 > > so that [1:2] is "t

Re: list-comprehension and map question (simple)

2005-03-27 Thread Reinhold Birkenfeld
Charles Hartman wrote: > On Mar 27, 2005, at 11:50 AM, Nicolas Évrard wrote: > >>> >>> I hope the question is clear enough. I have a feeling I'm ignoring a >>> simple technique . . . >> >> lambda ! >> >> map(lambda x: timestwo(getlength(x)), ...) > > Ah, lambda! I've heard so much bad-mouthing

Re: Help with splitting

2005-04-03 Thread Reinhold Birkenfeld
George Sakkis wrote: > If you don't want any null strings at the beginning or the end, an > equivalent regexp is: > whitespaceSplitter_2 = re.compile("\w+|\s+") whitespaceSplitter_2.findall("1 2 3 \t\n5") > ['1', ' ', '2', ' ', '3', ' \t\n', '5'] whitespaceSplitter_2.findall(

Re: workaround for generating gui tools

2005-04-09 Thread Reinhold Birkenfeld
Harlin Seritt wrote: > Benedict, > > Best to hand-code your code ;-) -- even GUI. This is kind of why I like > Tkinter so much. Good luck. Have to disagree strongly. It's evil anyway (for more complex applications) to put GUI construction in your code. GUI should be described appropriately in da

Re: singleton objects with decorators

2005-04-12 Thread Reinhold Birkenfeld
Uwe Mayer wrote: > Tuesday 12 April 2005 06:36 am Steven Bethard wrote: >> Uwe Mayer wrote: >>> I've been looking into ways of creating singleton objects. >> >> It strikes me that I've never wanted or needed a singleton object. >> Would you mind sharing your use case? I'm just curious. > > I am

Re: pre-PEP: Suite-Based Keywords

2005-04-16 Thread Reinhold Birkenfeld
Brian Sabbey wrote: > Here is a pre-PEP for what I call "suite-based keyword arguments". The > mechanism described here is intended to act as a complement to thunks. > Please let me know what you think. > > Suite-Based Keyword Arguments > - > > Passing complicated ar

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Reinhold Birkenfeld
Bengt Richter wrote: > Stretching for it, using my latest and greatest ;-) > > y = f(**:: >x = 1 >y = 'y for f' > )*g(**:: >x = 'x for g' >y = 'y for g' >def foo(): return 'foo for g' > ) > > Note that there is no pr

Re: unicode "em space" in regex

2005-04-17 Thread Reinhold Birkenfeld
Xah Lee wrote: > "Regular expression pattern strings may not contain null bytes, but can > specify the null byte using the \number notation." > > What is meant by null bytes here? Unprintable chars?? and the "\number" > is meant to be decimal? and in what encoding? The null byte is a byte with t

Re: re module methods: flags(), pattern()

2005-04-17 Thread Reinhold Birkenfeld
Xah Lee wrote: > Python re module has methods flags and pattern. How to use these > exactly? > > e.g. i tried > > print patternObj.flags() > > and the error is some "int object is not callable". Where do you read "methods"? Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: pre-PEP: Suite-Based Keywords

2005-04-18 Thread Reinhold Birkenfeld
Bengt Richter wrote: > On Sun, 17 Apr 2005 15:25:04 +0200, Reinhold Birkenfeld <[EMAIL PROTECTED]> > wrote: >>> Note that there is no problem adding other parameters, because :: is >>> just >>> a unary expression returning dict subtype i

Re: Variables variable

2005-04-19 Thread Reinhold Birkenfeld
Adriano Monteiro wrote: > Hi folks, > > Someone know how to make variables variable like in PHP? > It's something like this: > > $a = 'hi' > $$a = 'testing' > echo $hi > 'testing' You are most certainly wanting to use dictionaries. Or, if you work with attributes of an object, use getattr. Rei

Re: goto statement

2005-04-20 Thread Reinhold Birkenfeld
John Bokma wrote: > Mage wrote: > >> praba kar wrote: >> >>>Dear All, >>> >>> In Python what is equivalent to goto statement >>> >>> >>> >> You shouldn't use goto in high-level languages. > > Nonsense Thank you! Above all your claim is well justified. These brilliant arguments you have put

Re: goto statement

2005-04-20 Thread Reinhold Birkenfeld
Maxim Kasimov wrote: > Robert Kern wrote: >> Maxim Kasimov wrote: >> >>> Simon Brunning wrote: >>> On 4/20/05, Maxim Kasimov <[EMAIL PROTECTED]> wrote: > it would be quite useful for debuging porposes How does goto help you to remove bugs? I can cer

Re: goto statement

2005-04-20 Thread Reinhold Birkenfeld
Maxim Kasimov wrote: >> >> Use multi-line string literals. >> >> ''' > > it will not help if there is another ''' or/and """ inside of code block Yes, but how often do you use them? And aren't you consistent in the choice of your quotes? >> This whole 'code' is "commented out", and you can >>

Re: goto statement

2005-04-20 Thread Reinhold Birkenfeld
Maxim Kasimov wrote: > f..., i don't requesting that "goto" was available in next versions of > python, > but i'm saying if it will be so, it will be easy and quickly _debug_ some > skripts, > _not only_ for commenting If you want, you can always use the goto module. Reinhold, no, I

Re: What's the difference between these 2 statements?

2005-04-20 Thread Reinhold Birkenfeld
ATSkyWalker wrote: > What's the difference between these 2 statements? > > If you have a String s="12345" > > s[len(s)::-1] = "54321" > > But > > s[len(s):0:-1] = "5432" > > Why? What's the difference? What number then can I use as the end of > the slice if I were to supply all 3 parameters?

Re: What's the difference between these 2 statements?

2005-04-20 Thread Reinhold Birkenfeld
tiissa wrote: > Reinhold Birkenfeld wrote: >> ATSkyWalker wrote: >> >>>What's the difference between these 2 statements? >>> >>>If you have a String s="12345" >>> >>>s[len(s)::-1] = "54321" >>> >>

Re: Why Python does *SLICING* the way it does??

2005-04-21 Thread Reinhold Birkenfeld
Antoon Pardon wrote: > I sometimes think python should have been more explicite here, > using a marker for the start-index and end-index, may '^' and > '$'. So if you wanted the last element you had to write: > > lst[$] > > And for the next to last element: > > lst[$ - 1] > > > This would

Re: goto statement

2005-04-21 Thread Reinhold Birkenfeld
Maxim Kasimov wrote: >1) goto exempts from necessity to install new software > (it is critical for remote working, for example, installing X11 may be > impossible at all) Attributing the need for a language feature to restrictions of your ambience is hilarious. Reinhold -- http://mail.pytho

Re: Why Python does *SLICING* the way it does??

2005-04-21 Thread Reinhold Birkenfeld
Antoon Pardon wrote: > Op 2005-04-21, Reinhold Birkenfeld schreef <[EMAIL PROTECTED]>: >> Antoon Pardon wrote: >> >>> I sometimes think python should have been more explicite here, >>> using a marker for the start-index and end-index, may '^' and &

Re: Why Python does *SLICING* the way it does??

2005-04-22 Thread Reinhold Birkenfeld
Roy Smith wrote: > import types > > class slicableDict (dict): > def __getitem__ (self, index): > if type (index) == types.SliceType: > d2 = slicableDict() > for key in self.keys(): > if key >= index.start and key < index.stop: >

Re: Why Python does *SLICING* the way it does??

2005-04-22 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: > Other possibility, probably faster when almost all keys in the range are in > the dictionary: > > class sdict(dict): > def __getitem__(self, index): > if isinstance(index, slice): > d = {} > for k

Re: goto statement

2005-04-22 Thread Reinhold Birkenfeld
Grant Edwards wrote: > On 2005-04-21, Sergei Organov <[EMAIL PROTECTED]> wrote: > >> Well, I'm writing for embedded realtime systems in C/C++ and >> have never encountered a single need to use goto. > > I have encountered situations in C programs where the best > thing to use

Re: goto statement

2005-04-22 Thread Reinhold Birkenfeld
Grant Edwards wrote: > On 2005-04-21, Sergei Organov <[EMAIL PROTECTED]> wrote: >> Grant Edwards <[EMAIL PROTECTED]> writes: >> >>> On 2005-04-21, Peter Maas <[EMAIL PROTECTED]> wrote: >>> > Maxim Kasimov schrieb: >>> >> but what if i just can't to do this becouse i'm working thrue ssh, and >>> >>

Re: Question on metaclasses

2005-04-24 Thread Reinhold Birkenfeld
Diez B. Roggisch wrote: >> class Foo(type): >> def __new__(cls, name, bases, dict): >> >> for k,v in [(k, v) for k,v in dict.items() if callable(v)]: >> cls.wrap(k,v,cls.get_directives(v), dict) >> >> return super(Foo, self).__new__(self, name, bases, dict) > > Th

Re: postgresql modules and performance

2005-04-24 Thread Reinhold Birkenfeld
Mage wrote: > Hello, > > I started to write my PostgreSQL layer. I tried pyPgSQL and PyGreSQL. I > made a *very minimal* performance test and comparsion with the same > thing in php. Table "movie" has 129 record and many fields. > > I found PyGreSQL / DB-API / fetchall horrible slow (32

Re: Question on metaclasses

2005-04-24 Thread Reinhold Birkenfeld
Steffen Glückselig wrote: > Are wrap and get_directives somehow built-in? I couldn't find > references to them. > > I've noticed, too, that using __new__ I can manipulate the dictionary > resulting in the behavior I intented. > > I'd rather like to know: Why does it work in __new__ but not in > _

Re: Question on metaclasses

2005-04-24 Thread Reinhold Birkenfeld
Diez B. Roggisch wrote: > Reinhold Birkenfeld wrote: > >> Diez B. Roggisch wrote: >>>> class Foo(type): >>>> def __new__(cls, name, bases, dict): >>>> >>>> for k,v in [(k, v) for k,v in dict.items() if callable(v)

Re: What's do list comprehensions do that generator expressions don't?

2005-04-26 Thread Reinhold Birkenfeld
Mike Meyer wrote: > The question under these circumstances is then: do you want bare > genexp to mean something? Right now, it's a syntax error. But there's > no reason you couldn't have: > >y = x for x in stuff I like y = (x for x in stuff) as it is, it's way more readable. Reinhold --

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Reinhold Birkenfeld
Dan Christensen wrote: > Roel Schroeven <[EMAIL PROTECTED]> writes: > >> There's no level 12 yet though. > > Now there's a 12 and a 13 (at least!). Anyone solved 12? Hints? thanks, Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Reinhold Birkenfeld
John Hazen wrote: > * [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2005-05-02 05:10]: >> Any hints on level 6 ? >> There is "zip" in the page source, "ZIp" in the >> image data, but have no clue what to do with them >> - tried many things :). > > Have you found the zip file yet? > > (I did, and I stil

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Reinhold Birkenfeld
darren kirby wrote: > quoth the Ganesan Rajagopal: >> I am stuck on level 3. I've tried every re that I can think of. Some body >> give me a clue. >> >> Ganesan >> >> -- >> Ganesan Rajagopal > t = /text of page source.../ re.findall('[a-z][A-Z]{3}[a-z]{1}[A-Z]{3}[a-z]', t) > > You shoul

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-03 Thread Reinhold Birkenfeld
Dan Bishop wrote: > Well, I'd deal them into 2 piles, and... > > Damn! That was an obscure hint! > > Now, how do I open *.gfx files? You don't directly. Hint: gfx stands for? ** SPOILER Graphic*s*. -- http://m

Re: Question about mutexes

2005-06-01 Thread Reinhold Birkenfeld
Jan Danielsson wrote: > In OS/2 C, I would do this: > > main() > { > ... > DosCreateMutexSem(NULL, &hmtx, 0UL, FALSE); > ... > } > > thread() > { > ... > DosRequestMutexSem(hmtx); > > Locked! > > DosReleaseMutexSem(hmtx); > ... > } > > How would I go about doing that in Python? I think you wi

Re: pickle alternative

2005-06-01 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: > Andrew Dalke wrote: >> This is with Python 2.3; the stock one provided by Apple >> for my Mac. > > Ahh that is the difference. I'm running Python 2.4. I've checked my > benchmarks on a friends machine, also in Python 2.4, and received the > same results as my machine. >

Re: decimal and trunkating

2005-06-02 Thread Reinhold Birkenfeld
F. Petitjean wrote: > Le Thu, 02 Jun 2005 19:59:08 +1000, Timothy Smith a écrit : >> i want to trunkate 199.999 to 199.99 > > round(199.999, 2) # 2 digits after the decimal point Wrong. This will yield 200.00. >> do i really have to use floats to do this? > > 19.999 is a float : > type(19.99

Re: decimal and trunkating

2005-06-02 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Reinhold Birkenfeld wrote: >> He is speaking of Decimals... >> >> d = Decimal("199.999") >> d._round(5, decimal.ROUND_DOWN) > > Is one really supposed to call the underscore methods like that? Umm... no, I think not ;) But

Re: Two questions

2005-06-02 Thread Reinhold Birkenfeld
Richard Lewis wrote: > On 2 Jun 2005 06:45:18 -0700, [EMAIL PROTECTED] said: >> Hi, >> >> I've developed in several other languages and have recently found >> Python and I'm trying to use it in the shape of the PythonCard >> application development tool. >> >> My two questions: >> >> 1. What is

Re: mix up a string

2005-06-05 Thread Reinhold Birkenfeld
rbt wrote: > What's the best way to take a string such as 'dog' and mix it up? You > know, like the word jumble in the papers? ODG. I thought something like > mix = random.shuffle('dog') would do it, but it won't. Any tips? py> def shuffled(s): ... l = list(s) ... random.shuffle(l) ...

Re: the python way?

2005-06-06 Thread Reinhold Birkenfeld
Grops wrote: > Hi All, > > I've been lurking the list for a month and this is my first post. I am > hoping this post is appropriate here, otherwise, my apologies. > > I'm somewhat new to Python, (I'm reading all the tutorials I can find, > and have read through Andre Lessa's Developers Handb

split up a list by condition?

2005-06-06 Thread Reinhold Birkenfeld
Hi, while writing my solution for "The python way?", I came across this fragment: vees = [c for c in wlist[::-1] if c in vocals] cons = [c for c in wlist[::-1] if c not in vocals] So I think: Have I overlooked a function which splits up a sequence into two, based on a condition? Such as

Re: the python way?

2005-06-07 Thread Reinhold Birkenfeld
Andrew Dalke wrote: > Reinhold Birkenfeld wrote: >> To make it short, my version is: >> >> import random >> def reinterpolate2(word, vocals='aeiouy'): >> wlist = list(word) >> random.shuffle(wlist) >> vees = [c for c in wlist[::-

Re: split up a list by condition?

2005-06-07 Thread Reinhold Birkenfeld
Raymond Hettinger wrote: >>> while writing my solution for "The python way?", I came across this >>> fragment: >>> vees = [c for c in wlist[::-1] if c in vocals] >>> cons = [c for c in wlist[::-1] if c not in vocals] >>> >>> So I think: Have I overlooked a function which splits up a sequence >>> i

Re: split up a list by condition?

2005-06-07 Thread Reinhold Birkenfeld
Duncan Booth wrote: > Reinhold Birkenfeld wrote: > >> Hi, >> >> while writing my solution for "The python way?", I came across this >> fragment: >> >> vees = [c for c in wlist[::-1] if c in vocals] >> cons = [c for c in

Re: without shell

2005-06-10 Thread Reinhold Birkenfeld
Donn Cave wrote: >> Not according the the docs: >> >> Also, for each of these variants, on Unix, cmd may be a >> sequence, in which case arguments will be passed directly to >> the program without shell intervention (as with os.spawnv()). >> If cmd is a string it will be passed to the she

<    1   2   3