Re: overriding methods - two questions

2007-11-19 Thread George Sakkis
On Nov 19, 7:44 am, Bruno Desthuilliers wrote: > George Sakkis a écrit : > > > > > On Nov 16, 5:03 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > >> On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: > >

Re: Simple eval

2007-11-18 Thread George Sakkis
= atom(next, token) next() # Skip key-value delimiter (':') token = next() out[key] = atom(next, token) token = next() if token == ',': token = next() return out raise SyntaxError('malformed expression (%r)' % token) Regards, George -- http://mail.python.org/mailman/listinfo/python-list

Re: class='something' as kwarg

2007-11-17 Thread George Sakkis
of code for such a common operation. Instead, you can pass a string for attrs instead of a dictionary. The string will be used to restrict the CSS class. """ http://www.crummy.com/software/BeautifulSoup/documentation.html#Searching%20by%20CSS%20class George -- http://mail.python.org/mailman/listinfo/python-list

Re: Interfaces.

2007-11-16 Thread George Sakkis
s) are pretty close to interfaces and have been accepted for Python 3 (http:// www.python.org/dev/peps/pep-3119/). Personally I don't see any tangible benefit in having "pure" interfaces in additon to ABCs. George -- http://mail.python.org/mailman/listinfo/python-list

Re: overriding methods - two questions

2007-11-16 Thread George Sakkis
the same signature in __init__. For all other methods though, given that you have an instance x so that isinstance(x, ContinuedFraction), the client should be able to say x.foo(arg, kwd=v) without having to know whether x.__class__ is ContinuedFraction. If not, you have a leaky abstraction [1], i.e.

Re: Trouble with subprocess.call(...) and zsh script (OSError: [Errno 8] Exec format error)

2007-11-13 Thread Michael George Lerner
On Nov 11, 3:25 pm, Rob Wolfe <[EMAIL PROTECTED]> wrote: Hi Rob, > Michael GeorgeLerner<[EMAIL PROTECTED]> writes: > > > Hi, > > > (Python 2.5, OS X 10.4.10) > > I have a program called pdb2pqr on my system. It is installed so that > > "pdb2pqr" is in my path and looks like: > > > #\!/bin/zsh -f

Trouble with subprocess.call(...) and zsh script (OSError: [Errno 8] Exec format error)

2007-11-11 Thread Michael George Lerner
Hi, (Python 2.5, OS X 10.4.10) I have a program called pdb2pqr on my system. It is installed so that "pdb2pqr" is in my path and looks like: #\!/bin/zsh -f /sw/share/pdb2pqr/pdb2pqr.py "$@" When I call it via this script: #!/usr/bin/env python import subprocess import tempfile args = ('/sw/bin/

Re: Poor python and/or Zope performance on Sparc

2007-11-03 Thread George Sakkis
;mpstat" are bored at 0% load. You are probably not aware of Python's Global Interpeter Lock: http://docs.python.org/api/threads.html. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it possible to use a instance property as a default value ?

2007-11-01 Thread George Sakkis
f.Buf_wp = 0 @revaluatable def Draw(self, x1 = Deferred('self.Buf_rp'), x2 = Deferred('self.Buf_wp')): return (x1,x2) p = PlotCanvas() p.Buf_rp = 2 p.Buf_wp = -1 print p.Draw(), p.Draw(x2='foo') HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: XML DOM, but in chunks

2007-10-31 Thread George Sakkis
ularly > > like the ElementTree library for accessing the data. Is there a way > > to have ElementTree read only one record of the data at a time? > > Have you tried `iterparse()`? > > Ciao, > Marc 'BlackJack' Rintsch Detailed docs at http://effbot.org/zo

Re: 3 number and dot..

2007-10-31 Thread George Sakkis
panded & splitted (and maybe even commented) with a > VERBOSE, to improve readability, maybe somethign like: > > \d {1,3} > (?=# lockahead assertion > (?: \d {3} )+ $ # non-group > ) > > Bye, > bearophile That's 3 times faster on my box and works f

Re: A Python 3000 Question

2007-10-31 Thread George Sakkis
doing it once only. That > is not relevant to the question of whether len() should be a function or > a method. No disagreement here; I didn't bring up performance and it's not at all a reason I consider len() as a function to be a design mistake. What I dispute is Neil's asse

Re: A Python 3000 Question

2007-10-31 Thread George Sakkis
On Oct 31, 8:44 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-10-30, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > >> On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTE

Re: A class question

2007-10-30 Thread George Sakkis
On Oct 28, 6:01 am, Donn Ingle <[EMAIL PROTECTED]> wrote: > Is there a way I can, for debugging, access the instance variable name from > within a class? Shouldn't this be in a FAQ somewhere? It's the second time (at least!) it comes up this week. George -- http://m

Re: A Python 3000 Question

2007-10-30 Thread George Sakkis
seq)', 'seq = range(100)').timeit() > 0.20332271187463391 > >>> timeit.Timer('seq.__len__()', 'seq = range(100)').timeit() > > 0.48545737364457864 Common mistake; try this instead: timeit.Timer('seqlen()', 'seq = range(100); seqlen=seq.__len__').timeit() George -- http://mail.python.org/mailman/listinfo/python-list

Re: Readline and record separator

2007-10-30 Thread George Sakkis
several '\n' and when I use > readline it does NOT read the whole my record. > So If I could change '\n' as a record separator for readline, it > would solve my problem. > Any idea? > Thank you > L. Check out this recipe, it's pretty generic: http://asp

Re: A Python 3000 Question

2007-10-29 Thread George Sakkis
objects, and duck-typing, things like > len() being a function rather than a method make perfect sense. Does the fact that index() or split() are methods make perfect sense as well? I guess after some time using Python it does, but for most unbiased users the distinction seems arbitrary. George -- http://mail.python.org/mailman/listinfo/python-list

Re: A Python 3000 Question

2007-10-29 Thread George Sakkis
urn value is >=0 ? That also looks odd in a dynamic language with a "we're all adults here" philosophy and much less hand-holding in areas that matter more (e.g. allowed by default comparisons between instances of different types - at least that's one of the warts Python 3 gets right). George -- http://mail.python.org/mailman/listinfo/python-list

Re: simple question on dictionary usage

2007-10-28 Thread George Sakkis
x27;E')`` is a little safer than ``s[0] == 'E'`` as the former > returns `False` if `s` is empty while the latter raises an `IndexError`. A string slice is safe and faster though: if s[:1] == 'E'. George -- http://mail.python.org/mailman/listinfo/python-list

Re: how to creating html files with python

2007-10-27 Thread George Sakkis
his is quite typical, and practically required for web development. As Diez pointed out, your main problem will be which of the dozen or so template packages to pick. Depending on your criteria (expressive power, syntax close to python, performance, stability etc.) you may narrow it down to a h

Re: python project ideas

2007-10-25 Thread George Sakkis
On Oct 25, 6:12 am, Stefan Behnel <[EMAIL PROTECTED]> wrote: > Template engines are amongst the things that seem easy enough to look at the > available software and say "bah, I'll write my own in a day", but are complex > enough to keep them growing over years until they become as huge and > inacc

Re: about functions question

2007-10-24 Thread George Sakkis
On Oct 25, 2:28 am, NoName <[EMAIL PROTECTED]> wrote: > I try it: > > def b(): > ... > a() > ... > > def a(): > ... > b() > ... > > b() > it's not work. It sure does. Please post full code and error message, something else

Re: Mobile Startup looking for sharp coders

2007-10-24 Thread George Sakkis
On Oct 24, 2:42 pm, Vangati <[EMAIL PROTECTED]> wrote: > Plusmo is Hiring! > > (snipped) > > Recruiting Agencies: Please do not send us unsolicited resumes. > Plusmo does not consider resumes from any agencies. Lame company headhunters: Please do not send us unsolicited spamvertisments irrelevant

Re: Better writing in python

2007-10-24 Thread George Sakkis
On Oct 24, 10:42 am, [EMAIL PROTECTED] wrote: > On Oct 24, 4:15 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > > > > > On Oct 24, 2:02 pm, [EMAIL PROTECTED] wrote: > > > > On Oct 24, 7:09 am, Alexandre Badez <[EMAIL PROTECTED]> wrote: > > > > > I'm just wondering, if I could write a in a "better" way

Re: transforming list

2007-10-23 Thread George Sakkis
need one more append outside the loop (if report_item: report.append(report_item)). > I feel this solution is not that good, can I make this more pythonic?! Sure; get familiar with a swiss-knife module, itertools, and in particular for this task, groupby: from operator import itemgetter from itertools import groupby, chain def group_roster(rows, num_stats=12): # group the rows by their first two elements # Caveat: the rows should already be sorted by # the same key for key,group in groupby(rows, itemgetter(0,1)): stats = [0.0] * num_stats for row in group: if row[2]: stats[int(row[2])-1] = float(row[3]) yield list(chain(key,stats)) if __name__ == '__main__': import csv for row in group_roster(csv.reader(open('roster.txt'))): print row HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: TeX pestilence (was Distributed RVS, Darcs, tech love)

2007-10-22 Thread George Neuner
lar its syntax, on esthetical grounds, sucks in >major ways. No one except you thinks TeX is a "computer language". >Btw, a example of item 4 above, is Python's documentation. Fucking >asses and holes. Watch your language, there are children present. George -- for email reply remove "/" from address -- http://mail.python.org/mailman/listinfo/python-list

Re: Distributed RVS, Darcs, tech love

2007-10-20 Thread George Neuner
On Sun, 21 Oct 2007 01:20:47 -, Daniel Pitts <[EMAIL PROTECTED]> wrote: >On Oct 20, 2:04 pm, llothar <[EMAIL PROTECTED]> wrote: >> > I love math. I respect Math. I'm nothing but a menial servant to >> > Mathematics. >> >> Programming and use cases are not maths. Many mathematics are >> the wor

Re: Noob questions about Python

2007-10-17 Thread George Sakkis
quot;' for func in bin2dec, bin2dec_2, bin2dec_3: name = func.__name__ timer = timeit.Timer('__main__.%s(bin)' % name, setup) print '%s: %s' % (name, timer.timeit()) ### Without Psyco bin2dec: 17.6126108206 bin2dec_2: 7.57195732977 bin2dec_3: 5.46163297291 ### With Psyco bin2dec: 17.6995679618 bin2dec_2: 8.60846224869 bin2dec_3: 0.16031255369 George -- http://mail.python.org/mailman/listinfo/python-list

Re: Order by value in dictionary

2007-10-17 Thread George Sakkis
e > > time when holding up the invariant when inserting key/values into the > > dictionary. > > Actually, I somehow read the FOR and ITERATOR above as something like this: > > entries = sorted(a.items(), key=lambda v: v[1])[:100] > > The gist of my statement above is nontheless the same: if you want sorted > results, you need to sort... > > Diez If you want the top 100 out of 100K, heapq.nlargest is more than an order of magnitude faster. George -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: magnitude 0.9.1

2007-10-16 Thread George Sakkis
On Oct 16, 7:35 am, Laurent Pointal <[EMAIL PROTECTED]> > > How does it compare to the scalar module ? > (seehttp://russp.us/scalar.htm) or the Unum module (http://home.scarlet.be/be052320/Unum.html) ? -- http://mail.python.org/mailman/listinfo/python-list

Re: groupby() seems slow

2007-10-15 Thread George Sakkis
mport timeit > > t = timeit.Timer("test3()", "from __main__ import test3, key, data") > print t.timeit() > t = timeit.Timer("test1()", "from __main__ import test1, data") > print t.timeit() > > --output:--- > 42.791079998 > 19.012

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-14 Thread George Sakkis
ke 'abc', the remaining portion will be 'bc', then 'c', > than '', but never [] so you 'll never stop. > > Try: > > if xs == []: > return [] > elif xs == '': > return '' > else: > ... The '

Re: The fundamental concept of continuations

2007-10-14 Thread George Neuner
ry with them their execution context. This allows them to used directly for things like user-space threading. George -- for email reply remove "/" from address -- http://mail.python.org/mailman/listinfo/python-list

Re: ConnectionClosedError

2007-10-13 Thread George Sakkis
re I am guessing... I don't create explicitly any thread in my server code but Pyro itself is multithreaded. Unfortunately I don't have the resources to start digging in Pyro's internals.. George -- http://mail.python.org/mailman/listinfo/python-list

Re: test if email

2007-10-12 Thread George Sakkis
On Oct 12, 4:59 pm, brad <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > On Oct 12, 2:55 pm, Florian Lindner <[EMAIL PROTECTED]> wrote: > >> Hello, > >> is there a function in the Python stdlib to test if a string is a valid > >> email address? > > here's a Perl re example... I don't know

[Pyro] ConnectionClosedError

2007-10-12 Thread George Sakkis
ll the server and restart it but obviously this is not ideal. Is there a way to either prevent or at least recover automatically the server when it hangs ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: Declarative properties

2007-10-12 Thread George Sakkis
similar to > improve performance. "best way you know how from a Software Engineering" != "best way to do it in less flexible languages that will go unnamed, such as Java" You seem to conflate these two. George -- http://mail.python.org/mailman/listinfo/python-list

Re: decorating container types (Python 2.4)

2007-10-12 Thread George Sakkis
tuation. > > Thanks > Tim Unfortunately __getattr__ is not called for special attributes; I'm not sure if this is by design or a technical limitation. You have to manually delegate all special methods (or perhaps write a metaclass that does this for you). George -- http://mail.python.org/mailman/listinfo/python-list

Re: Top 10 Caribbean island destinations

2007-10-11 Thread george . smith78
lol :) another one on baseball : 90% of the game is physical, the other half is mental. GS [EMAIL PROTECTED] On Oct 11, 7:32 pm, willshak <[EMAIL PROTECTED]> wrote: > on 10/11/2007 10:14 PM Audio expert said the following: > > > Now I know where NOT to go. > > TOO crowded for me. > > No one goes

Re: Declarative properties

2007-10-11 Thread George Sakkis
On Oct 11, 7:04 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > You could take it even further by removing the need to repeat the > attribute's name twice. Currently this can done only through > metaclasses but in the future a class decorator would be even > better: Reply

Re: Declarative properties

2007-10-11 Thread George Sakkis
ormat % name) return type(cls,bases,attrdict) return meta class Person(object): __metaclass__ = PropertyMaker('name', format='__%s__') def __init__(self, name): self.name = name print self.__name__ George -- http://mail.python.org/mailman/listinfo/python-list

Re: The fundamental concept of continuations

2007-10-11 Thread George Neuner
one-shot continuations (exceptions or non-local returns) are the next most common form used, even in Scheme. Upward continuations can be stack implemented. On many CPU's, using the hardware stack (where possible) is faster than using heap allocated structures. For performance, some Scheme compil

Re: Keeping track of subclasses and instances?

2007-10-10 Thread George Sakkis
D(C1,C2): pass items = [A(),B1(),B2(),C1(),C1(),D(),A(),B2()] print ' * Instances per class' for c in iter_descendant_classes(A): print c, list(iter_instances(c)) print ' * Instances per class (after delete)' del items for c in iter_descendant_classes(A): print c, list(iter_instances(c)) HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: for loop question

2007-10-10 Thread George Sakkis
gt; >>> > > -tkc Or generalized for arbitrary iterables, number of items at a time, combination function and stopping criterion: from itertools import islice, takewhile, repeat def taking(iterable, n, combine=tuple, pred=bool): iterable = iter(iterable) return takewhile(pred,

Re: Fwd: NUCULAR fielded text searchable indexing

2007-10-10 Thread George Sakkis
On Oct 10, 11:08 am, [EMAIL PROTECTED] wrote: > Why apologize? If someone doesn't like the name given to a piece of > software by its author(s), screw them. If I find the software useful, > I'll use it. Even if its called 'bouncingBetty'. Or 'Beautifu

Re: The fundamental concept of continuations

2007-10-09 Thread George Neuner
I don't have this author's name, nor can Google find it at the moment. I have a copy though (~2MB) - if you are interested, contact me by email and I'll send it to you. Also Google for free CS books. Many older books (including some classics) that have gone out of print have been released electronically for free download. George -- for email reply remove "/" from address -- http://mail.python.org/mailman/listinfo/python-list

Re: property question

2007-10-08 Thread George Sakkis
could be very > complicated. Thanks a lot. > > Manu I haven't needed to use it myself so far, but PyCells (http:// pycells.pdxcb.net/) seems it might fit the bill. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem of Readability of Python

2007-10-07 Thread George Sakkis
lasses > so that the above is pretty much all you need to write: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502237 > > STeVe For immutable records, you may also want to check out the named tuples recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/500261 George -- http://mail.python.org/mailman/listinfo/python-list

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-03 Thread George Neuner
On Wed, 03 Oct 2007 23:07:32 +0100, [EMAIL PROTECTED] wrote: >George Neuner wrote: >> Symbolism over substance has become the mantra >> of the young. > >"Symbolism: The practice of representing things by means of symbols or >of attributing symbolic meanings or signif

Re: racism kontrol

2007-10-03 Thread George Sakkis
I read this somewhere, don't remember where.. it goes like: "He's not really mean... he is just a little prejudiced against anything that breathes." :-) George -- http://mail.python.org/mailman/listinfo/python-list

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-03 Thread George Neuner
On Wed, 3 Oct 2007 18:20:38 + (UTC), [EMAIL PROTECTED] (Bent C Dalager) wrote: >In article <[EMAIL PROTECTED]>, >George Neuner wrote: >>On Wed, 3 Oct 2007 09:36:40 + (UTC), [EMAIL PROTECTED] (Bent C >>Dalager) wrote: >> >>> >>>Only if yo

Re: Class design question

2007-10-03 Thread George Sakkis
On Oct 3, 2:27 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Oct 3, 1:04 pm, Adam Lanier <[EMAIL PROTECTED]> wrote: > > > > > Relatively new to python development and I have a general question > > regarding good class design. > > > Say I have

Re: Class design question

2007-10-03 Thread George Sakkis
oo(object): # XXX this is a class instance, shared by all Foo instances; # XXX probably not what you intended params = [ ] def __init__(self, *args): # uncomment the following line for instance-specific params # self.params = [] for arg in args: if not isinstance(arg, Bar): # let the Bar constructor to do typechecking or whatnot arg = Bar(arg) self.params.add(arg) HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: spam kontrol

2007-10-03 Thread George Sakkis
On Oct 3, 12:59 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > hii > ý think you know spam page is the most pest for net user. ...closely followed in the second position by incoherent misspelled posts in silly IM-speak. -- http://mail.python.org/mailman/listinfo/python-list

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-03 Thread George Neuner
for this man to retire so they could write and speak the way they wanted rather than having to be "correct". Dictionaries used to be the arbiters of the language - any word or meaning of a word not found in the dictionary was considered a colloquial (slang) use. Since the 1980's, an entry in the dictionary has become little more than evidence of popularity as the major dictionaries (OED, Webster, Cambridge, etc.) will now consider any word they can find used in print. George -- for email reply remove "/" from address -- http://mail.python.org/mailman/listinfo/python-list

Re: Combine two dictionary...

2007-10-02 Thread George Sakkis
sum: dsum[key] = value else: dsum[key] += value return dsum Surprisingly (?), this turns out to be faster than using dict.get(key, 0) instead of the explicit if/else. George -- http://mail.python.org/mailman/listinfo/python-list

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-01 Thread George Neuner
ked. Redo from start. Our [US] legal system is fucked ... more so with respect to patents, but copyrights aren't far behind. The US Congress just revisited patent law to make it less of a land grab - we'll have to wait and see how the USPTO interprets the new rules - but copyright law has

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-01 Thread George Neuner
beer" nearly always come with a catch or implied >obligation? It means you have to bring the chips. George -- for email reply remove "/" from address -- http://mail.python.org/mailman/listinfo/python-list

Re: Using fractions instead of floats

2007-09-30 Thread George Sakkis
was it rejected? and for what? Is internet down today ? http://pypi.python.org/pypi/clnum/1.2 http://www.python.org/dev/peps/pep-0239/ George -- http://mail.python.org/mailman/listinfo/python-list

Re: Can you please give me some advice?

2007-09-30 Thread George Sakkis
On Sep 30, 2:54 pm, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: > > Errhhh. guys.. I think .kr means Korea so he would speak > Korean, not Chinese In this case, http://kr.diveintopython.org/html/index.htm might be more useful ;-) George -- http://mail.python.org/m

Re: Can you please give me some advice?

2007-09-30 Thread George Sakkis
to Python" has been translated in Chinese: http://www.woodpecker.org.cn/diveintopython/ Hope it helps, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Program inefficiency?

2007-09-29 Thread George Sakkis
n soup.findAll('a'): for attr in 'href','name': val = a.get(attr) if val: a[attr] = val.replace(' ','_') print soup George -- http://mail.python.org/mailman/listinfo/python-list

Re: question about for cycle

2007-09-29 Thread George Sakkis
t can generate tuples *lazily*. > Sometime it maybe a waste to generate all possible combinations of i,j first. It doesn't; read about generator expressions at http://www.python.org/dev/peps/pep-0289/ George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 migration plans?

2007-09-28 Thread George Sakkis
can be "adopted" by someone else. > > Python doesn't have any of this. And that's far more of a problem > than Python 3.x. Does Perl support extension modules, and if so, are they so prevalent as in Python ? Either case, bringing up CPAN is moot in this case; nothing can force an external open source contributor to maintain or provide binaries for his packages. How is this a problem of the *language* ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 migration plans?

2007-09-28 Thread George Sakkis
RTFM! and the like. Which shows once again that you're trying to break the world record of being wrong in as many sentences as possible: http://mail.python.org/mailman/listinfo/tutor You would do yourself (and others) a favor by migrating there for a few weeks or months. George --

Re: ValueError: too many values to unpack

2007-09-27 Thread George Sakkis
how many elements there are actually present: print string.split(line, "\t") By the way, most functions of the string module are deprecated in favor of string methods; the above is better written as print line.split("\t") HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Properties and Objects...

2007-09-24 Thread George V. Neville-Neil
At Sun, 23 Sep 2007 19:01:04 -0300, Gabriel Genellina wrote: > > En Sat, 22 Sep 2007 15:06:38 -0300, George V. Neville-Neil > <[EMAIL PROTECTED]> escribi�: > > > I have been trying to switch this over to using properties, which seem > > at first glance to be cl

Re: Factory function with keyword arguments

2007-09-22 Thread George Sakkis
the only difference the flag makes is the keyword argument, you can either factor the common part out in another function called by foo or (if performance is crucial) create foo dynamically through exec: def factory(flag): kw = flag and 'spam' or 'ham' exec '''def foo(obj, arg): return obj.method(%s=arg)''' % kw return foo George -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting rid of bitwise operators in Python 3?

2007-09-22 Thread George Sakkis
of "ok, apparently bit fiddling is important for some classes of problems but so are regular expressions. Are bit operations so frequent and/or important to grant them around a dozen of operators while there are none for regexps ?" George -- http://mail.python.org/mailman/listinfo/python-list

Properties and Objects...

2007-09-22 Thread George V. Neville-Neil
pcs.Field("type", 16) pcs.Packet.__init__(self, [dst, src, type], bytes = bytes) self.description = inspect.getdoc(self) which was much more straightforward for someone to understand and to code. Since one of the project goals is to have the creation of new packets classes be as easy as possible I would like to be able to do something closer to the above. Best, George -- http://mail.python.org/mailman/listinfo/python-list

Re: I could use some help making this Python code run faster using only Python code.

2007-09-21 Thread George Sakkis
for learning purposes, perhaps you should be thinking it the other way around: how fast is fast enough ? Optimizing just for the sake of optimization, without a specific performance goal in mind, is not the most productive way to do things (again, leaving learning motivations aside). George -- h

Re: I could use some help making this Python code run faster using only Python code.

2007-09-20 Thread George Sakkis
table.__getitem__, line)) def scramble_dict_imap(line): return ''.join(imap(scramble_table.__getitem__, line)) if __name__=='__main__': funcs = [scramble, scramble_listcomp, scramble_gencomp, scramble_map, scramble_imap, scramble_dict, scramble_dict_map, scramble_dict_imap] s = 'abcdefghijklmnopqrstuvwxyz' * 100 assert len(set(f(s) for f in funcs)) == 1 from timeit import Timer setup = "import __main__; line = %r" % s for name in (f.__name__ for f in funcs): timer = Timer("__main__.%s(line)" % name, setup) print '%s:\t%.3f' % (name, min(timer.repeat(3,1000))) George -- http://mail.python.org/mailman/listinfo/python-list

frange() question

2007-09-20 Thread George Trojan
e(count)) I am puzzled by the parentheses in the last line. Somehow they make frange to be a generator: >> print type(frange(1.0, increment=0.5)) But I always thought that generators need a keyword "yield". What is going on here? George -- http://mail.python.org/mailman/listinfo/python-list

Re: Extracting xml from html

2007-09-18 Thread George Sakkis
ained module in a single file. "Installing" it can be as simple as having it in the same directory of your module that imports it. Given that you can do in 2 lines what took you around 15 with lxml, I wouldn't think it twice. George -- http://mail.python.org/mailman/listinfo/python-list

Re: simple regular expression problem

2007-09-17 Thread George Sakkis
act "a list of strings from a text", you want to extract specific elements from an XML data source. There are several standard and non standard python packages for XML processing, look for them online. Here's how to do it using the (3rd party) BeautyfulSoup module: >>> from BeautifulSoup import BeautifulStoneSoup >>> BeautifulStoneSoup(s).findAll('organisatie') [ 28996 , 28997 ] HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3K or Python 2.9?

2007-09-14 Thread George Sakkis
SomeFunction(self, someParameter): >self.someParameter = someParameter If one *really* wants this, it is doable in python too: http://www.voidspace.org.uk/python/weblog/arch_d7_2006_12_16.shtml#e583 George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Database Apps

2007-09-11 Thread Harry George
emy (I'm back and forth on that. Mostly stay with straight SQL). Of course, as long as you write DBI2 compliant code, your app doesn't much care which DBMS you use. The postgresql payoff is in admin functionality and scaling and full ACID. -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list

Py2.5.1 on Ubuntu AMD X2, unicode problems

2007-09-11 Thread Harry George
is in fact undefined. 1. If I onfigure with unicode=ucs2, does all this go away and I get a working system (efficient or not) on my 64-bit machine? 2. Can you point to a configure (and maybe patch) process which leads to a clean "make altinstall". -- Harry George PLM Engi

Re: Speed of Python

2007-09-07 Thread George Sakkis
g(m+2) z3=log(m+3) z4=log(m+4) z5=log(m+5) z6=log(m+6) z7=log(m+7) z8=log(m+8) z9=log(m+9) return z9 HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing a tuple to a function as multiple arguments

2007-09-06 Thread George Sakkis
tion. The number > of elements in the tuple will not always be the same. > > T = A,B,C,D,... > > Is there a way that I can pass the contents of the tuple to the function > without explicitly indexing the elements? Yes: myfunc(*T) More details at http://docs.python.org/tut/

Re: Text processing and file creation

2007-09-06 Thread George Sakkis
in g) or a bit less cryptically: import itertools as it for chunk,enum_lines in it.groupby(enumerate(open('input.txt')), lambda (i,line): i//5): open("output.%d.txt" % chunk, 'w').writelines(line for _,line in enum_lines) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Sip4.7

2007-09-06 Thread Harry George
p-4.7/siplib' gcc -c -pipe -fPIC -O2 -w -I. -I/usr/local/include/python2.5 -o siplib.o siplib.c gcc -c -pipe -fPIC -O2 -w -I. -I/usr/local/include/python2.5 -o qtlib.o qtlib.c gcc -c -pipe -fPIC -O2 -w -I. -I/usr/local/include/python2.5 -o threads.o threads.c gcc -c -pipe -fPIC -O2 -w -I. -I/usr/local/include/python2.5 -o objmap.o objmap.c g++ -c -pipe -fPIC -O2 -w -I. -I/usr/local/include/python2.5 -o bool.o bool.cpp g++ -shared -Wl,--version-script=sip.exp -o sip.so siplib.o qtlib.o threads.o objmap.o bool.o gmake[1]: Leaving directory `/usr2/src/qt/sip-4.7/siplib' -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list

Re: SSL Issue

2007-09-06 Thread Harry George
with verification of both client and server certificates. If that is where you are going, let me know what works. -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is overtaking Perl

2007-09-04 Thread George Sakkis
he graph, it seems more accurate to say that Perl is undertaking > >Python. > > Jean-Paul And to make it even more accurate, "Perl is undertaking Python in India", since that's where the difference in favor of Python comes from. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Important Research Project

2007-09-01 Thread George Sakkis
On Sep 1, 7:13 am, "E.D.G." <[EMAIL PROTECTED]> wrote: > "E.D.G." <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Important Research Project (Related to computer programming) > > > Posted by E.D.G. on August 30, 2007 [EMAIL PROTECTED] > > This effort was not successful.

Re: Latest models of Gibson guitars

2007-08-19 Thread George
[EMAIL PROTECTED] wrote: > On 19 kol, 19:34, [EMAIL PROTECTED] wrote: >> Reviews of latest models of best guitars, fender, gibson, yamaha, and >> many more, with pictures and prices. >> >> http://spam-guitars.blogspot.com/ >> >> And if you want to win a free guitar go here >> >> http://spamguitars.

Re: SQLObject 0.7.8

2007-07-27 Thread george williams
- Original Message - From: "Oleg Broytmann" <[EMAIL PROTECTED]> To: "Python Announce Mailing List" <[EMAIL PROTECTED]>; "Python Mailing List" Sent: Thursday, July 26, 2007 7:23 AM Subject: SQLObject 0.7.8 > Hello! > > I'm pleased to announce the 0.7.8 release of SQLObject. > > What is

Re: is_iterable function.

2007-07-26 Thread George Sakkis
flatten_nostr([1, [[[2, 'hello']], (4, u'world')]])) By the way, it's bad design to couple two distinct tasks: flattening a (possibly nested) iterable and applying a function to its elements. Once you have a flatten() function, deeply_mapped is reduced down to itertools.imap. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: first, second, etc line of text file

2007-07-25 Thread George Sakkis
table. > > Is there a simpler way? If all you need is sequential access, you can use the next() method of the file object: nextline = open(textfile).next print 'First line is: %r' % nextline() print 'Second line is: %r' % nextline() ... For random access, the easiest

Re: is_iterable function.

2007-07-25 Thread George Sakkis
or n in iter(lambda:random.randrange(10), 0): print n More generally, iter(callable, sentinel) is just a convenience function for the following generator: def iter(callable, sentinel): while True: c = callable() if c == sentinel: break yield c George -- http://mai

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread George Sakkis
> I know the * operator. However, a 'partial unpack' does not seem to > > work. > > > def g(): > > return (1,2) > > > def f(a,b,c): > > return a+b+c > > > f(*g(),10) will return an error. > > > Do you know how to get that to work? > > > Thanks, > > cg > > As I mentioned, you can access the elements individually using square > brackets. The following works: > > f(g()[0], g()[1], 10) > > But it's not clear. Unfortunately, I'm not seeing much else for tuple > unpacking except the obvious: > > a,b=g() > f(a,b,10) > > Mike Or if you'd rather write it in one line: f(*(g() + (10,))) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Base class for file-like objects? (a.k.a "Stream" in Java)

2007-07-25 Thread George Sakkis
at least planned for Python 3.0? > > Thanks for any suggestions, > Boris Dušek > > P.S.: The code should finally look in esence something like this: > > if isinstance(f, file): >pass > elif isinstance(f, string): >f = urllib.urlopen(f) > else: >raise "...&q

Re: [ANN] Python documentation team looking for members!

2007-07-21 Thread george williams
Take me off mailing list thank you george - Original Message - From: "Georg Brandl" <[EMAIL PROTECTED]> Newsgroups: comp.lang.python.announce To: <[EMAIL PROTECTED]> Sent: Saturday, July 21, 2007 4:10 AM Subject: [ANN] Python documentation team looking for me

Re: class C: vs class C(object):

2007-07-20 Thread George Sakkis
llowing feature, which by the way disproves the assertion that "new-style classes can do anything Classic classes did": class Classic: pass class NewStyle(object):pass for o in Classic(),NewStyle(): o.__str__ = lambda: 'Special method overriding works on instances!' print '%s object: %s' % (o.__class__.__name__, o) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Posted messages not appearing in this group

2007-07-19 Thread George Sakkis
ts haven't appeared (yet) at the google group but they show up on the mailing list: http://mail.python.org/pipermail/python-list/2007-July/thread.html George -- http://mail.python.org/mailman/listinfo/python-list

Re: Issue with CSV

2007-07-19 Thread Harry George
d csv, b) check the loaded structure's data against the new data-on-disk to find changed files, c) update the structure appropriately, d) write out the resulting new csv. -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list

Re: Break up list into groups

2007-07-18 Thread George Sakkis
test 3: error > test 4: error > 16.23 usec/pass > > `getgropus2' fails test 0 because it produces a reversed list. That > can easily be fixed by re-reversing the output before returning. But, > since it is by far the slowest method, I didn't bother. > > `getgroups3' is a method I got from another post in this thread, just > for comparison. > > >From my benchmarks it looks like getgroups1 is the winner. I didn't > > scour the thread to test all the methods however. Here's a small improvement of getgroups1, both in time and memory: from itertools import islice def getgroups4(seq): idxs = [i for i,v in enumerate(seq) if v&0x80] idxs.append(None) return [seq[i:j] for i,j in izip(idxs, islice(idxs,1,None))] George -- http://mail.python.org/mailman/listinfo/python-list

Re: merge two ranges

2007-07-18 Thread George Sakkis
rlap(a, b) # output:None > print getOverlap(b, a) # output: None > > any easy way of doing this? It's not really hard to come up with a quick and dirty solution; however if this isn't a homework or a toy program, take a look at the interval module (http://cheeseshop.python.org/pypi/interval/1.0.0) for a more thought-out design. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementaion of random.shuffle

2007-07-18 Thread George Sakkis
e you're waiting... Wow, can you make a coffee in.. 57ms ? $ time python -c "for n in xrange(2**19937 + 1): random.random()" Traceback (most recent call last): File "", line 1, in OverflowError: long int too large to convert to int real0m0.057s user0m0.050s

Re: Compiling python2.5 on IBM AIX

2007-07-17 Thread George Trojan
- Version: 08.00..0010 Intermediate Language 060405.07 Driver 060518a Date: Thu May 18 22:08:53 EDT 2006 - I suspect the trailing comma is the issue. Googling for "xlc enumerator trailing comma" gave me http://sources.redhat.com/ml/gdb/1999-q1/msg00136.html which says "AIX 4.2.0.0 xlc gives an error for trailing commas in enum declarations". George -- http://mail.python.org/mailman/listinfo/python-list

<    3   4   5   6   7   8   9   10   11   12   >