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: decorating container types (Python 2.4)

2007-10-12 Thread George Sakkis
On Oct 11, 5:42 pm, [EMAIL PROTECTED] wrote: > Hi, > > I have a container class A and I want to add functionality to it by > using a decorator class B, as follows: > > class A(object): > def __len__(self): > return 5 > > class B(object): > def __init__(self, a): > self._a =

Re: Declarative properties

2007-10-12 Thread George Sakkis
On Oct 12, 2:55 pm, Dan Stromberg <[EMAIL PROTECTED]> wrote: > If you have a program that needs to perform well, you're much better off > coding your classes the best way you know how from a Software Engineering > perspective, and using pysco or shedskin or pypy or similar to > improve performance

[Pyro] ConnectionClosedError

2007-10-12 Thread George Sakkis
Didn't have much luck with this in the Pyro mailing list so I am trying here, just in case. I have a Pyro server running as a daemon process and occasionally (typically after several hours or days of uptime) a ConnectionClosedError is raised when a client calls a remote method. Both client and serv

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

Re: ConnectionClosedError

2007-10-13 Thread George Sakkis
On Oct 13, 4:21 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > > If restarting the server sorts it, why don't you run the server as a > subprocess in a higher level script, and exit with an error code > if the error strikes? Well as I mentioned the process doesn't exit, it is just unrespons

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

2007-10-14 Thread George Sakkis
On Oct 15, 2:30 am, Gary Herron <[EMAIL PROTECTED]> wrote: > Dmitri O.Kondratiev wrote: > > > The function I wrote (below) reverses lists all right: > > > def reverse(xs): > > if xs == []: > > return [] > > else: > > return (reverse (xs[1:])) + [xs[0]] > > > >>> reverse ([1,

Re: groupby() seems slow

2007-10-15 Thread George Sakkis
On Oct 15, 11:02 pm, 7stud <[EMAIL PROTECTED]> wrote: > I'm applying groupby() in a very simplistic way to split up some data, > but when I timeit against another method, it takes twice as long. The > following groupby() code groups the data between the "" strings: > > data = [ > "1.5","","2.5","3

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: Order by value in dictionary

2007-10-17 Thread George Sakkis
On Oct 17, 10:06 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: > > Abandoned wrote: > > >> Hi.. > >> I have a dictionary like these: > >> a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 > >> element > >> I want to sort this by value and i want to fir

Re: Noob questions about Python

2007-10-17 Thread George Sakkis
On Oct 17, 6:23 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 17, 10:58 pm, Ixiaus <[EMAIL PROTECTED]> wrote: > > > > > Thank you for the quick responses. > > > I did not know that about integer literals beginning with a '0', so > > thank you for the explanation. I never really use PHP except

Re: transforming list

2007-10-23 Thread George Sakkis
On Oct 23, 10:46 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > i have a list from a resultset like this > 1,"Chicago Bulls",,,"" > 2,"Cleveland Caveliers",,,"" > 4,"Detroit Pistons",1,"23686386.35" > 4,"Detroit Pistons",2,"21773898.07" > 4,"Detroit Pistons",3,"12815215.57" > 4,"Detroit Pistons

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: 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: 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 is wrong, not the cyclic reference. George -- http://mail.p

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: how to creating html files with python

2007-10-27 Thread George Sakkis
On Oct 27, 12:12 pm, "krishnakant Mane" <[EMAIL PROTECTED]> wrote: > I have one strange requirement, > I need to create html files through python and add some data from the > database. The only strange thing here is that you think this is a strange requirement :) This is quite typical, and pract

Re: simple question on dictionary usage

2007-10-28 Thread George Sakkis
On Oct 27, 8:58 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 27 Oct 2007 05:23:30 -0700, bearophileHUGS wrote: > > My take too :-) > > > dict(item for item in record.iteritems() if item[0][0] == 'E') > > ``s.startswith('E')`` is a little safer than ``s[0] == 'E'`` as the former

Re: A Python 3000 Question

2007-10-29 Thread George Sakkis
On Oct 29, 5:49 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > I was just reading > |http://docs.python.org/dev/3.0/whatsnew/3.0.html > > which says nothing about such a change, except for one in the opposite > direction: o.next() changes to next(o) which in turn calls o.__next__(), > just as len

Re: A Python 3000 Question

2007-10-29 Thread George Sakkis
On Oct 29, 9:35 pm, Michael L Torrie <[EMAIL PROTECTED]> wrote: > brad wrote: > > Not complaining. len is simple and understandable and IMO fits nicely > > with split(), strip(), etc... that's why I used it as an example, but > > list(), etc. could be used as examples as well: > > > a_string.list()

Re: Readline and record separator

2007-10-30 Thread George Sakkis
On Oct 30, 8:21 am, Johny <[EMAIL PROTECTED]> wrote: > Is it possible to change record separator when using readline? > As far as I know readline reads characters until found '\n' and it is > the end of record for readline. > My problem is that my record consits several '\n' and when I use > readli

Re: A Python 3000 Question

2007-10-30 Thread George Sakkis
On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: > > > This is a FAQ: > >http://effbot.org/pyfaq/why-does-python-use-methods-for-some-function... > > Holy Airy Persiflage Batman! > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:

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://mail.python.org/mailman/listi

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 Python 3000 Question

2007-10-31 Thread George Sakkis
On Oct 31, 6:13 pm, Steven D'Aprano > What you have measured is a local optimization that is only useful when > you have a tight loop with lots of calls to the same len(): > > Len = sequence.__len__ > while Len() < 10: > foo(sequence) Exactly what timeit() does, a tight loop. > But what

Re: 3 number and dot..

2007-10-31 Thread George Sakkis
On Oct 31, 7:32 pm, [EMAIL PROTECTED] wrote: > Hrvoje Niksic: > > > I'm surprised that no one has proposed a regex solution, such as: > > I presume many Python programmers aren't much used in using REs. > > > >>> import re > > >>> re.sub(r'\d{1,3}(?=(?:\d{3})+$)', r'\g<0>.', str(1234567)) > > '1.23

Re: XML DOM, but in chunks

2007-10-31 Thread George Sakkis
On Oct 31, 4:43 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 31 Oct 2007 20:24:43 +, Sean Davis wrote: > > I have some very large XML files that are basically recordsets. I > > would like to access each record, one-at-a-time, and I particularly > > like the ElementTree lib

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

2007-11-01 Thread George Sakkis
On Nov 1, 4:55 pm, stef mientki <[EMAIL PROTECTED]> wrote: > Chris Mellon wrote: > > On Nov 1, 2007 3:18 PM, stef mientki <[EMAIL PROTECTED]> wrote: > > >> hello, > > >> I would like to use instance parameters as a default value, like this: > > >> class PlotCanvas(wx.Window): > >> def __init__(

Re: An iterator with look-ahead

2007-01-10 Thread George Sakkis
Neil Cerutti wrote: > For use in a hand-coded parser I wrote the following simple > iterator with look-ahead. I haven't thought too deeply about what > peek ought to return when the iterator is exhausted. Suggestions > are respectfully requested. As it is, you can't be sure what a > peek() => None

Fixed keys() mapping

2007-01-11 Thread George Sakkis
I wrote an 'fkdict' dict-like class for mappings with a fixed set of keys but I'm wondering if there's a simpler way to go about it. First off, the main motivation for it is to save memory in case of many dicts with the same keys, for example when reading from a csv.DictReader or constructing dict

Re: Fixed keys() mapping

2007-01-11 Thread George Sakkis
For what it's worth, I added it to the Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499373 George -- http://mail.python.org/mailman/listinfo/python-list

Re: Boilerplate in rich comparison methods

2007-01-12 Thread George Sakkis
Steven D'Aprano wrote: > I'm writing a class that implements rich comparisons, and I find myself > writing a lot of very similar code. If the calculation is short and > simple, I do something like this: > > > class Parrot: > def __eq__(self, other): > return self.plumage() == other.plu

Re: Class list of a module

2007-01-15 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Gabriel Genellina: > > >import inspect > > def getClassList(aModule): > > return [cls for cls in vars(aModule).itervalues() > > if inspect.isclass(cls)] > > This is short enough too: > > from inspect import isclass > getclasses = lambda module:

Re: How to determine what exceptions a method might raise?

2007-01-17 Thread George Sakkis
Ben Finney wrote: > Ed Jensen <[EMAIL PROTECTED]> writes: > > > it would be handy if there was something I could do in the > > interactive interpreter to make it tell me what exceptions the file > > method might raise (such as IOError). > > For what purpose would this be handy? Surely the benefit

Re: Iterator length

2007-01-18 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Often I need to tell the len of an iterator, this is a stupid example: > > >>> l = (i for i in xrange(100) if i&1) > > len isn't able to tell it: > > >>> len(l) > Traceback (most recent call last): > File "", line 1, in > TypeError: object of type 'generator' has no l

mmap caching

2007-01-21 Thread George Sakkis
I've been trying to track down a memory leak (which I initially attributed erroneously to numpy) and it turns out to be caused by a memory mapped file. It seems that mmap caches without limit the chunks it reads, as the memory usage grows to several hundreds MBs according to the Windows task manage

Re: Is any python like linux shell?

2007-01-21 Thread George Sakkis
Frank Potter wrote: > I learned some python in windows. > And now I've turned to linux. > I read a book and it teaches how to write shell script with bash, > but I don't feel like the grammar of bash. > Since I know about python, > I want to get a linux shell which use python grammar. > I searched

Re: mmap caching

2007-01-21 Thread George Sakkis
Nick Craig-Wood wrote: > George Sakkis <[EMAIL PROTECTED]> wrote: > > I've been trying to track down a memory leak (which I initially > > attributed erroneously to numpy) and it turns out to be caused by a > > memory mapped file. It seems that mmap caches withou

Re: mmap caching

2007-01-21 Thread George Sakkis
Martin v. Löwis wrote: > George Sakkis schrieb: > > I've been trying to track down a memory leak (which I initially > > attributed erroneously to numpy) and it turns out to be caused by a > > memory mapped file. It seems that mmap caches without limit the chunks > &g

Re: mmap caching

2007-01-22 Thread George Sakkis
Dennis Lee Bieber wrote: > On 21 Jan 2007 13:32:19 -0800, "George Sakkis" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > The file is written once and then opened as read-only, there's no > > flushing. So if cachi

Re: numpy or _numpy or Numeric?

2007-01-24 Thread George Sakkis
On Jan 24, 2:24 am, auditory <[EMAIL PROTECTED]> wrote: > I am a newbie here > > I am trying to read "space separated floating point data" from file > > I read about csv module by searching this group, > but I couldn't read space separated values with csv. > (which may be matter of course..) > > I

Re: assertions to validate function parameters

2007-01-25 Thread George Sakkis
On Jan 25, 11:54 am, Matthew Wilson <[EMAIL PROTECTED]> wrote: > Lately, I've been writing functions like this: > > def f(a, b): > > assert a in [1, 2, 3] > assert b in [4, 5, 6] > > The point is that I'm checking the type and the values of the > parameters. > > I'm curious how this does o

Re: dict.keys() ?

2007-01-26 Thread George Sakkis
On Jan 26, 10:04 pm, [EMAIL PROTECTED] wrote: > The PEP 3100:http://www.python.org/dev/peps/pep-3100/ > says: > > Return iterators instead of lists where appropriate for atomic type > methods (e.g. dict.keys(), dict.values(), dict.items(), etc.); iter* > methods will be removed. Better: make keys(

[Boost.Graph] graph.vertices property creates new objects

2007-01-29 Thread George Sakkis
I've just started toying with the python bindings of BGL and I'm puzzled from the following: >>> from boost.graph import Graph >>> g = Graph() >>> v = g.add_vertex() >>> g.vertices.next() == v True >>> g.vertices.next() is v False It seems that the vertices iterator creates new vertex objects ev

Re: Overloading the tilde operator?

2007-02-01 Thread George Sakkis
On Feb 2, 12:49 am, James Stroud <[EMAIL PROTECTED]> wrote: > Ben Finney wrote: > > > The Python runtime parser is designed to parse Python, not some > > arbitrary language that someone chooses to implement in Python. > > You haven't addressed why the limitation isn't arbitrary. Indeed, and that'

Re: Fixed length lists from .split()?

2007-02-02 Thread George Sakkis
On Feb 1, 2:40 pm, Bob Greschke <[EMAIL PROTECTED]> wrote: > This idiom is what I ended up using (a lot it turns out!): > > Parts = Line.split(";") > Parts += (x-len(Parts))*[""] > > where x knows how long the line should be. If the line already has > more parts than x (i.e. [""] gets multiplied

Re: Python does not play well with others

2007-02-02 Thread George Sakkis
On Feb 2, 2:41 pm, Paul Rubin wrote: > "Chris Mellon" <[EMAIL PROTECTED]> writes: > > How about because thats what you pay them for? Seriously. Do you even > > think about what you're saying? Python needs to move MySQL (and only > > MySQL, of course) into the core becaus

Re: How much introspection is implementation dependent?

2007-02-02 Thread George Sakkis
On Feb 2, 6:56 pm, James Stroud <[EMAIL PROTECTED]> wrote: > Hello, > > I wanted to automagically generate an instance of a class from a > dictionary--which might be generated from yaml or json. I came up with this: > > (snip) > > == > > #! /usr/bin/env python > > # automagical constructor > def c

Re: Where Does One Begin?

2007-02-02 Thread George Sakkis
On Feb 2, 3:39 pm, Mister Newbie <[EMAIL PROTECTED]> wrote: > I have no programming experience. I want to learn Python so I can make > simple, 2D games. Where should I start? Can you recommend a good book? > > Thank you. http://www.amazon.com/Game-Programming-Python-Development/dp/1584502584 --

Re: Checking default arguments

2007-02-03 Thread George Sakkis
On Feb 2, 1:30 pm, [EMAIL PROTECTED] (Igor V. Rafienko) wrote: > Hi, > > I was wondering whether it was possible to find out which parameter > value is being used: the default argument or the user-supplied one. > That is: > > def foo(x, y="bar"): > # how to figure out whether the value of y is

Re: Calling J from Python

2007-02-05 Thread George Sakkis
On Feb 5, 12:23 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Gosi wrote: > > On Feb 5, 2:59 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> Gosi wrote: > >> > It is quite easy to call J from Python > > >>http://groups.google.com/group/J-Programming/browse_thread/thread/5e8... > > >>

Re: Calling J from Python

2007-02-09 Thread George Sakkis
On Feb 9, 9:20 pm, [EMAIL PROTECTED] wrote: > ant: > > > and in debugging it far outweighs the time you'd spend on all > > of that typing in a clean but more verbose language such as Python. > > Typing time counts a bit too. A language like Java is even more > verbose than Python, and that probably

Complex HTML forms

2007-02-17 Thread George Sakkis
I'd like to gather advice and links to any existing solutions (e.g. libraries, frameworks, design patterns) on general ways of writing complex web forms, as opposed to the typical {name:value} flat model. A particular case of what I mean by complex is hierarchical forms. For instance, a form that c

Re: Complex HTML forms

2007-02-18 Thread George Sakkis
On Feb 18, 4:44 am, Gregor Horvath <[EMAIL PROTECTED]> wrote: > George Sakkis schrieb: > > > I'd like to gather advice and links to any existing solutions (e.g. > > libraries, frameworks, design patterns) on general ways of writing > > complex web forms, as oppos

Re: exec "def.." in globals(), locals() does not work

2007-02-19 Thread George Sakkis
On Feb 19, 10:52 pm, [EMAIL PROTECTED] wrote: > How do I use exec? Before you ask this question, the one you should have an answer for is "why do I (think I) have to use exec ?". At least for the example you gave, you don't; Python supports local functions and nested scopes, with no need for exec:

Bypassing __setattr__ for changing special attributes

2007-02-19 Thread George Sakkis
I was kinda surprised that setting __class__ or __dict__ goes through the __setattr__ mechanism, like a normal attribute: class Foo(object): def __setattr__(self, attr, value): pass class Bar(object): pass >>> f = Foo() >>> f.__class__ = Bar >>> print f.__class__ is Foo True Is

Re: Bypassing __setattr__ for changing special attributes

2007-02-20 Thread George Sakkis
On Feb 20, 7:57 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 19 Feb 2007 23:18:02 -0800, Ziga Seilnacht wrote: > > George Sakkis wrote: > >> I was kinda surprised that setting __class__ or __dict__ goes through > >> the __setattr__ mechanism, lik

Re: Bypassing __setattr__ for changing special attributes

2007-02-20 Thread George Sakkis
On Feb 20, 3:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 20 fév, 05:39, "George Sakkis" <[EMAIL PROTECTED]> wrote: > > > I was kinda surprised that setting __class__ or __dict__ goes through > > the __setattr__ mechanism, like a norm

Re: modifying a list while iterating through

2007-02-25 Thread George Sakkis
On Feb 25, 8:12 pm, [EMAIL PROTECTED] wrote: > consider the following working loop where Packet is a subclass of > list, with Packet.insert(index, iterable) inserting each item in > iterable into Packet at consecutive indexes starting at index. > > i=0 > while(i if packet[i:i+5]==Pa

Subprocess timeout

2007-02-28 Thread George Sakkis
I'm trying to use a threaded timeout decorator (http:// aspn.activestate.com/ASPN/Cookbook/Python/Recipe/483752) to spawn a subprocess with a timeout. On a linux box runnning python 2.5 I get "OSError: [Errno 10] No child processes" on wait(); running the same program on a different box (again linu

Re: Tuples vs Lists: Semantic difference (was: Extract String From Enclosing Tuple)

2007-02-28 Thread George Sakkis
On Feb 28, 10:45 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Bjoern Schliessmann <[EMAIL PROTECTED]> writes: > > I know tuples as immutable lists ... > > That's a common misconception. And this catch phrase, "that's a common misconception", is a common aping of the BDFL's take on this. As severa

Re: Poor python and/or Zope performance on Sparc

2007-11-03 Thread George Sakkis
On Nov 3, 9:35 am, joa2212 <[EMAIL PROTECTED]> wrote: > Result: Almost even worse. The application is not scaling at all. > Every time you start a request it is hanging around on one cpu and is > devouring it at about 90-100% load. The other 31 CPUs which are shown > in "mpstat" are bored at 0% lo

Re: overriding methods - two questions

2007-11-16 Thread George Sakkis
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: > >> Question 1: > > >> Given that the user of the API can choose to override foo() or not, how > >> can I control the signature that they use? > > > W

Re: Interfaces.

2007-11-16 Thread George Sakkis
On Nov 15, 8:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Does anyone know what the state of progress with interfaces for python > (last I can see ishttp://www.python.org/dev/peps/pep-0245/) No progress AFAIK for Python 2.x but Abstract Base Classes (ABCs) are pretty close to interface

Re: class='something' as kwarg

2007-11-17 Thread George Sakkis
On Nov 17, 3:45 am, "Vladimir Rusinov" <[EMAIL PROTECTED]> wrote: > Hello! > > I'm using beautiful soup html parser, and I need to get all ' class=g>...' tags. > It can be done by: > > import BeautifulSoup as BSoup > > ... > > soup = BSoup(page) > for div in soup.findAll('div', class='g'): > >

Re: Simple eval

2007-11-18 Thread George Sakkis
On Nov 18, 8:24 pm, greg <[EMAIL PROTECTED]> wrote: > Tor Erik Sønvisen wrote: > > Comments, speedups, improvements in general, etc are appreciated. > > You're doing a lot of repeated indexing of token[0] > and token[1] in your elif branches. You might gain some > speed by fetching these into loca

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: the annoying, verbose self

2007-11-23 Thread George Sakkis
On Nov 23, 7:21 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > On Nov 23, 2007 11:54 PM, Steven D'Aprano > > The correct solution to your example is to get rid of the attribute > > lookups from the expression completely: > > No it is not. The "solution" is nothing more than a silly band-aid >

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-24 Thread George Sakkis
On Nov 24, 4:59 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 24 Nov 2007 03:44:59 -0800, Licheng Fang wrote: > > On Nov 24, 7:05 pm, Bjoern Schliessmann > [EMAIL PROTECTED]> wrote: > >> Licheng Fang wrote: > >> > I find myself frequently in need of classes like this for two > >> > rea

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-24 Thread George Sakkis
On Nov 24, 7:42 pm, Steven D'Aprano > > To the OP: yes, your use case is quite valid; the keyword you are > > looking for is "memoize". You can find around a dozen of recipes in the > > Cookbook and posted in this list; here's one starting point: > >http://aspn.activestate.com/ASPN/Cookbook/Python

Re: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread George Sakkis
On Nov 26, 2:04 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Donn Ingle a écrit : > > >>I see someone already showed you eval. Eval is evil. Don't use it. > >>Especially if the functions are coming to you from a public URL! > > > Yes, I suggested to him (by email) this: > > > thisinstanc

Re: "Python" is not a good name, should rename to "Athon"

2007-12-01 Thread George Sakkis
On Dec 1, 9:06 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > Pythons are big, non-poisonous snakes good for keeping the rats out > of a system I'm looking forward to Spider(TM), the first bug-free language ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: "Python" is not a good name, should rename to "Athon"

2007-12-04 Thread George Sakkis
On Dec 3, 12:50 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > I know this because I've been through it myself. When I tell people > that I use Python, I often qualify it by pointing out that it is used > extensively at Google. In other words, I'm banking on the reputation > of Google to offset the go

Re: Python surpasses Perl in TIOBE index

2007-12-04 Thread George Sakkis
On Dec 4, 10:08 am, [EMAIL PROTECTED] wrote: > This is *not* an attempt to start yet another Python-versus- > AnyOtherProgrammingLanguage flame war, but I thought people might be > interested in this: > > http://www.tiobe.com/tpci.htm > > Marc Cool (assuming these numbers actually mean something),

Re: Python surpasses Perl in TIOBE index

2007-12-04 Thread George Sakkis
On Dec 4, 11:07 am, Paul Rudin <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > Even more amazing is the rate C++ is losing ground: > >http://www.tiobe.com/tiobe_index/C__.html > > I don't really find surprising that low level lan

Re: Python surpasses Perl in TIOBE index

2007-12-05 Thread George Sakkis
On Dec 5, 7:34 am, BlueBird <[EMAIL PROTECTED]> wrote: > On Dec 4, 4:08 pm, [EMAIL PROTECTED] wrote: > > > This is *not* an attempt to start yet another Python-versus- > > AnyOtherProgrammingLanguage flame war, but I thought people might be > > interested in this: > > >http://www.tiobe.com/tpci.htm

Re: Job Offer: Python Ninja or Pirate!

2007-12-10 Thread George Sakkis
On Dec 10, 2:11 pm, Stargaming <[EMAIL PROTECTED]> wrote: > On Mon, 10 Dec 2007 16:10:16 +0200, Nikos Vergas wrote: > > [snip] > > >> Problem: In the dynamic language of your choice, write a short program > >> that will: > >> 1. define a list of the following user ids 42346, 77290, 729 (you can >

Re: Job Offer: Python Ninja or Pirate!

2007-12-11 Thread George Sakkis
On Dec 10, 11:07 pm, Stargaming <[EMAIL PROTECTED]> wrote: > On Mon, 10 Dec 2007 19:27:43 -0800, George Sakkis wrote: > > On Dec 10, 2:11 pm, Stargaming <[EMAIL PROTECTED]> wrote: > >> On Mon, 10 Dec 2007 16:10:16 +0200, Nikos Vergas wrote: > > >> [snip]

Re: Is a "real" C-Python possible?

2007-12-12 Thread George Sakkis
On Dec 12, 2:18 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On Dec 12, 7:34 am, sturlamolden <[EMAIL PROTECTED]> wrote: > > I am not sure why a new type annotation syntax was needed Python 3: > > Because people care about a feature when there is @syntax. Good point; the inverse is not true thou

Re: Is a "real" C-Python possible?

2007-12-12 Thread George Sakkis
On Dec 12, 4:09 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > Curiously, whenever property syntax is discussed the > discussion loses track and is dragged away by needless side > discussions. Just look at Stephen Bethards withdrawn PEP 359 [1] in > which he finally muses about replacing the class

Re: Is a "real" C-Python possible?

2007-12-12 Thread George Sakkis
On Dec 12, 4:09 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > I vaguely remember a discussion a few years ago, where someone made > the quite reasonable suggestion of introducing some kind of > thunk_statement: > > class A(object): > foo = property: > def fget(self): > retu

Re: Is a "real" C-Python possible?

2007-12-12 Thread George Sakkis
On Dec 12, 1:12 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > Kay Schluehr wrote: > > class A(object): > > foo = property: > > def fget(self): > > return self._foo > > def fset(self, value): > > self._foo = value > > > which was translated as follows

Re: Is a "real" C-Python possible?

2007-12-12 Thread George Sakkis
On Dec 12, 2:23 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Dec 12, 2007 12:53 PM, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Dec 12, 1:12 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > > Kay Schluehr

Re: efficient data loading with Python, is that possible possible?

2007-12-12 Thread George Sakkis
On Dec 12, 5:48 pm, [EMAIL PROTECTED] wrote: > Hi, I am pretty new to Python and trying to use it for a relatively > simple problem of loading a 5 million line text file and converting it > into a few binary files. The text file has a fixed format (like a > punchcard). The columns contain integer,

Re: Python for Java programmer

2007-12-14 Thread George Sakkis
On Dec 14, 11:53 am, Nirav Thaker <[EMAIL PROTECTED]> wrote: > Yo Group, > > I'm excited to learn Python as new language coming year, I consider > myself good Java developer and, not so unusually, with very limited > experience with dynamic programming languages such as Python or Ruby. > > I have s

Re: Job Offer: Python Ninja or Pirate!

2007-12-14 Thread George Sakkis
On Dec 14, 9:57 am, Stargaming <[EMAIL PROTECTED]> wrote: > On Tue, 11 Dec 2007 08:57:16 -0800, George Sakkis wrote: > > Closer, but still wrong; for some weird reason, __import__ for modules > > in packages returns the top level package by default; you have to use > &

ANN: csvutils 0.1

2007-12-15 Thread George Sakkis
csvutils is a single Python module for easily transforming csv (or csv- like) generated rows. The release is available at http://pypi.python.org/pypi/csvutils/0.1. Regards, George What is csvutils? The standard csv module is very useful for parsing tabular data in CSV fo

Re: About Rational Number (PEP 239/PEP 240)

2007-12-15 Thread George Sakkis
On Dec 15, 6:52 pm, greg <[EMAIL PROTECTED]> wrote: > So while rationals might be useful to have available for > some things, you should have to explicitly ask for them. > Returning rationals from '/' applied to integers would > be a bad idea, for example. >From my reading of the PEP, it doesn't

Re: Best idiom to unpack a variable-size sequence

2007-12-18 Thread George Sakkis
On Dec 18, 12:49 pm, ram <[EMAIL PROTECTED]> wrote: > Here's a little issue I run into more than I like: I often need to > unpack a sequence that may be too short or too long into a fixed-size > set of items: > > a, b, c = seq # when seq = (1, 2, 3, 4, ...) or seq = (1, 2) > > What I usually d

Re: New+old-style multiple inheritance

2007-12-19 Thread George Sakkis
On Dec 18, 3:16 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Dec 18, 10:08 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > We are trying to monkey-patch a third-party library that mixes new and > > old-style classes with multiple inheritance. > > New library? Geez, if people are dumb

Re: New+old-style multiple inheritance

2007-12-19 Thread George Sakkis
On Dec 19, 12:01 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > They should have converted the > old-style to new when they decided to derive from both types (it's not > like that's terribly difficult). Unless perhaps the old-style class is part of an stdlib or 3rd party (or rather 4th party since

Re: Is there a simple way to parse this string ?

2007-12-20 Thread George Sakkis
On Dec 19, 8:44 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > I think the last thread of this nature also cited a similar tool by > the effbot, which he describes > here:http://www.effbot.org/zone/simple-iterator-parser.htm. > This parser is about 10X faster than the equivalent pyparsing parser.

Re: Is this a bug in int()?

2007-12-22 Thread George Sakkis
On Dec 22, 5:03 pm, [EMAIL PROTECTED] wrote: > Tokenizer accepts "0x" as zero. Spec says its an error not to have at > least one hex digit after "0x". > > This is a more serious bug than I had originally thought. Consider > this: > > Joe types "security_code = 0x" and then goes off to the Guardian

Re: 5 queens

2007-12-24 Thread George Sakkis
On Dec 23, 7:04 am, Steven D'Aprano wrote: > def combinations(seq, n): > if n == 0: > yield [] > else: > for i in xrange(len(seq)): > for cc in combinations(seq[i+1:], n-1): > yield [seq[i]]+cc > > >>> for c in combinations(range(4), 3): > > ...

Decoupling fields from forms in Django

2006-05-10 Thread George Sakkis
Didn't have much luck in the Django list, so I'm posting it here just in case anyone has come up with this problem. Django maintains two parallel hierarchies of field classes, one related to models that correspond to table columns and one that maps these fields to forms. This works ok for the admi

Re: retain values between fun calls

2006-05-13 Thread George Sakkis
Gary Wessle wrote: > Hi > > the second argument in the functions below suppose to retain its value > between function calls, the first does, the second does not and I > would like to know why it doesn't? and how to make it so it does? > > thanks > > # it does > def f(a, L=[]): > L.append(a) >

Re: count items in generator

2006-05-13 Thread George Sakkis
BartlebyScrivener wrote: > Still new. I am trying to make a simple word count script. > > I found this in the great Python Cookbook, which allows me to process > every word in a file. But how do I use it to count the items generated? > > def words_of_file(thefilepath, line_to_words=str.split): >

Re: do/while structure needed

2006-05-13 Thread George Sakkis
John Salerno wrote: > 1 random.shuffle(letters) > 2 trans_letters = ''.join(letters)[:len(original_set)] > 3 trans_table = string.maketrans(original_set, trans_letters) > > So what I'd like to do is have lines 1 and 2 run once, then I want to do > some comparison between original_set and trans_let

SQl to HTML report generator

2006-05-14 Thread George Sakkis
I'm kinda surprised that while many web frameworks provide both some ORM and a template language, they do very little to combine them into higher level blocks, like report generation. So I'm wondering if I have missed any toolkit out there that can 1) take a SQL select (either raw or the equivalent

Re: count items in generator

2006-05-14 Thread George Sakkis
Paul Rubin wrote: > [EMAIL PROTECTED] (Cameron Laird) writes: > > For that matter, would it be an advantage for len() to operate > > on iterables? > >print len(itertools.count()) > > Ouch!! How is this worse than list(itertools.count()) ? -- http://mail.python.org/mailman/listinfo/python-l

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