Re: count items in generator

2006-05-14 Thread George Sakkis
Delaney, Timothy (Tim) wrote: > George Sakkis wrote: > > > Paul Rubin wrote: > > > >> [EMAIL PROTECTED] (Cameron Laird) writes: > >>> For that matter, would it be an advantage for len() to operate > >>> on iterables? > >> > >>

Re: the tostring and XML methods in ElementTree

2006-05-17 Thread George Sakkis
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > I wanted to see what would happen if one used the results of a tostring > > method as input into the XML method. What I observed is this: > > a) beforeCtag.text is of type > > b) beforeCtag.text when printed displays: I'm confused > > c) afte

Re: How to customize getattr(obj, prop) function ?

2006-05-17 Thread George Sakkis
Pierre wrote: > Hi, > > Sorry in advance, english is not my main language :/ > > I'd like to customize the result obtained by getattr on an object : if > the object has the requested property then return it BUT if the object > doesn't has actually this property return something else. > > In my cas

Re: Beautiful parse joy - Oh what fun

2006-05-17 Thread George Sakkis
Here's one way to do it: import re _any_re = re.compile('.+') d = {} for row in BeautifulSoup(html).fetch('tr'): columns = row.fetch('td') field = columns[1].firstText(_any_re).rstrip(' \t\n:') value = ' '.join(text.rstrip() for text in columns[2].fetchText(_an

Re: Question about exausted iterators

2006-05-17 Thread George Sakkis
Christophe wrote: > Is there a good reason why when you try to take an element from an > already exausted iterator, it throws StopIteration instead of some other > exception ? I've lost quite some times already because I was using a lot > of iterators and I forgot that that specific function param

Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.

2006-05-17 Thread George Sakkis
glomde wrote: > i I would like to extend python so that you could create hiercical > tree structures (XML, HTML etc) easier and that resulting code would be > more readable than how you write today with packages like elementtree > and xist. Given that python doesn't have syntactic sugar for somet

Feature request: sorting a list slice

2006-05-18 Thread George Sakkis
It would be useful if list.sort() accepted two more optional parameters, start and stop, so that you can sort a slice in place. In other words, x = range(100) x.sort(start=3, stop=-1) would be equivalent to x[3:-1] = sorted(x[3:-1]) but more efficient and without repeating the slice twice.

Re: Feature request: sorting a list slice

2006-05-18 Thread George Sakkis
Fredrik Lundh wrote: > George Sakkis wrote: > >> It would be useful if list.sort() accepted two more optional >> parameters > > > useful for what? what's the use case ? > > > Although there is a use case (see below), I don't think it's s

Re: how could I get all email address in a html page?

2006-05-18 Thread George Sakkis
dongdong wrote: > how could I get all email address in a html page? Have any modle can do > this? > like the htmldata.urlextract . As if there arent' enough spammers already... -- http://mail.python.org/mailman/listinfo/python-list

Re: the tostring and XML methods in ElementTree

2006-05-19 Thread George Sakkis
Stefan Behnel wrote: > George Sakkis wrote: > > Fredrik Lundh wrote: > > > >> [EMAIL PROTECTED] wrote: > >> > >>> I wanted to see what would happen if one used the results of a tostring > >>> method as input into the XML method. Wha

Re: Feature request: sorting a list slice

2006-05-19 Thread George Sakkis
Heiko Wundram wrote: > Am Donnerstag 18 Mai 2006 19:27 schrieb George Sakkis: > > It would be useful if list.sort() accepted two more optional > > parameters, start and stop, so that you can sort a slice in place. > > I've just submitted: > > http://sourceforge.n

Re: python vs perl lines of code

2006-05-20 Thread George Sakkis
Edward Elliott wrote: > John Bokma wrote: > > > Edward Elliott <[EMAIL PROTECTED]> wrote: > > > >> A little out-of-order execution seems useful here. ;) > > > > No, not interested in a pissing contest. Your statement that the Perl > > community encourages importing is *encouraged* (over using OO w

Re: python vs perl lines of code

2006-05-20 Thread George Sakkis
John Bokma wrote: > "George Sakkis" <[EMAIL PROTECTED]> wrote: > > > Not trying to be as ass, but can you take this offline or at least in > > a perl newsgroup ? Arguing on a particular fact or speculation about > > the perl community is rather unproductive

Re: python vs perl lines of code

2006-05-20 Thread George Sakkis
John Bokma wrote: > "George Sakkis" <[EMAIL PROTECTED]> wrote: > > > John Bokma wrote: > > > >> "George Sakkis" <[EMAIL PROTECTED]> wrote: > >> > >> > Not trying to be as ass, but can you take this offline or at leas

Re: python vs perl lines of code

2006-05-21 Thread George Sakkis
John Bokma wrote: > Funny though, how you have a problem with a thread that side steps to Perl > only for 4 or 5 postings, but have no problem with a hit & run post in 5 > groups to spamvertize a site. > > Have fun with the pondering btw. > > -- > John MexIT: http://

Re: PEP-xxx: Unification of for statement and list-comp syntax

2006-05-21 Thread George Sakkis
Felipe Almeida Lessa wrote: > Em Dom, 2006-05-21 às 11:52 -0700, gangesmaster escreveu: > > > Today you can archive the same effect (but not necessarily with the same > > > performance) with: > > > > > > for node in (x for x in tree if x.haschildren()): > > > > > > > true, but it has differen

Re: groupby

2006-05-22 Thread George Sakkis
Bryan wrote: > can some explain why in the 2nd example, m doesn't print the list [1, 1, 1] > which i had expected? > > > >>> for k, g in groupby([1, 1, 1, 2, 2, 3]): > ... print k, list(g) > ... > 1 [1, 1, 1] > 2 [2, 2] > 3 [3] > > > >>> m = list(groupby([1, 1, 1, 2, 2, 3])) > >>> m > [(1,

dict literals vs dict(**kwds)

2006-05-23 Thread George Sakkis
Although I consider dict(**kwds) as one of the few unfortunate design choices in python since it prevents the future addition of useful keyword arguments (e.g a default value or an orderby function), I've been finding myself lately using it sometimes instead of dict literals, for no particular reas

Re: dict literals vs dict(**kwds)

2006-05-23 Thread George Sakkis
Bruno Desthuilliers wrote: > George Sakkis a écrit : > > Although I consider dict(**kwds) as one of the few unfortunate design > > choices in python since it prevents the future addition of useful > > keyword arguments (e.g a default value or an orderby function), I'

Re: John Bokma harassment

2006-05-24 Thread George Sakkis
Alan wrote: > With apologies to Voltaire: > If Xah Lee did not exist, it would be necessary for John Bokma to > invent him. > > Xah and Bokma are both idiots, they truly deserve each other. The > sooner you killfile these two clowns, the happier you'll be. Well said, I couldn't put it better. -

Re: dict literals vs dict(**kwds)

2006-05-24 Thread George Sakkis
bruno at modulix wrote: > When all your keys are valid Python identifiers, and you may want to use > another dict-like instead of the builtin dict. It's easy to replace the > dict() factory in a function, class, or whole module : > > class MyDict(...): > # dict-like class > > dict = MyDict > > t

Re: John Bokma harassment

2006-05-24 Thread George Sakkis
Robert Boyd wrote: > On 24 May 2006 08:29:57 -0700, Rune Strand <[EMAIL PROTECTED]> wrote: > > > > > I can just declare my support. Reading Mr. Bokmas comments below [*] > > certainly makes my suport stronger. > > > > I sent an email in support of Xah, which I wouldn't have bothered to > do had I

Re: John Bokma harassment

2006-05-24 Thread George Sakkis
Geoffrey Summerhayes wrote: > "Bill Atkins" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > John Bokma <[EMAIL PROTECTED]> writes: > > > > [snip] > > > >> -- > >> John MexIT: http://johnbokma.com/mexit/ > >>personal page:

Re: how to clear up a List in python?

2006-05-25 Thread George Sakkis
vbgunz wrote: > I will not try and stop helping others because you don't like my > answers. I found a perfectly good way how not to do something that > wasn't exactly wrong anyway. if you can take another persons honest > attempt to help someone and twist it into something it is not, I can > only

Re: __getattr__ and functions that don't exist

2006-05-25 Thread George Sakkis
Erik Johnson wrote: > Thanks for your reply, Nick. My first thought was "Ahhh, now I see. That's > slick!", but after playing with this a bit... > > >>> class Foo: > ... def __getattr__(self, attr): > ... def intercepted(*args): > ... print "%s%s" % (attr, args) > ...

OLAP and pivot tables

2006-05-25 Thread George Sakkis
After a brief search, I didn't find any python package related to OLAP and pivot tables. Did I miss anything ? To be more precise, I'm not so interested in a full-blown OLAP server with an RDBMS backend, but rather a pythonic API for constructing datacubes in memory, slicing and dicing them, drilli

Re: Array?

2006-05-25 Thread George Sakkis
Dr. Pastor wrote: > I need a row of 127 bytes that I will use as a > circular buffer. Into the bytes (at unspecified times) > a mark (0 After some time the "buffer" will contain the last 127 marks > and a pointer will point the next "usable" byte. > What would be the Pythonic way to do the above?

Re: dict literals vs dict(**kwds)

2006-05-26 Thread George Sakkis
bruno de chez modulix en face wrote: > > and there's no compelling reason for dict(**kwds). > > Yes there is : this *is* the ordinary Python syntax - calling a type to > get an instance of it. The dict-litteral syntax is mostly syntactic > sugar. The thing is there are four (at least?) ways to g

Re: dict literals vs dict(**kwds)

2006-05-26 Thread George Sakkis
Duncan Booth wrote: > George Sakkis wrote: > > > 2) restricting in a more serious sense: the future addition of optional > > keyword arguments that affect the dict's behaviour. Google for "default > > dict" or "dictionary accumulator". > > Th

Re: dict literals vs dict(**kwds)

2006-05-26 Thread George Sakkis
Bruno Desthuilliers wrote: > George Sakkis a écrit : > > The thing is there are four (at least?) ways to get a dict instance: > > > > In [1]: d1={'name':'mike', 'age':23} > > > > In [2]: d2=dict(d1) > > > > In [3]: d3=di

Re: dict literals vs dict(**kwds)

2006-05-26 Thread George Sakkis
Duncan Booth wrote: > George Sakkis wrote: > > > Duncan Booth wrote: > > > >> George Sakkis wrote: > >> > >> > 2) restricting in a more serious sense: the future addition of > >> > optional keyword arguments that affect the dict&

Re: PUDGE - Project Status, Alternative Solutions

2006-05-26 Thread George Sakkis
Ilias Lazaridis wrote: > Is there a similar tool available, with which I can generate python > documentation / websites or both based on templates and reST? rest2web (http://www.voidspace.org.uk/python/rest2web/) seems relevant, though the latest version is 0.4alpha so I'm not sure if it's stabl

Re: Array? Please help.

2006-05-27 Thread George Sakkis
Diez B. Roggisch wrote: > Dr. Pastor schrieb: > > I need a row of 127 bytes that I will use as a > > circular buffer. Into the bytes (at unspecified times) > > a mark (0 > After some time the "buffer" will contain the last 127 marks. > > (A pointer will point to the next byte to write to.) > > What

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread George Sakkis
On Dec 30, 4:12 pm, Istvan Albert <[EMAIL PROTECTED]> wrote: > On Dec 30, 3:29 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > One "recipe" is extracting blocks from text files that are delimited by a > > special start and end line. > > Neat solution! > > I actually need such function

Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread George Sakkis
On Dec 29, 9:14 pm, bukzor <[EMAIL PROTECTED]> wrote: > Here's the answer to the > question:http://www.python.org/doc/faq/general/#why-are-default-values-shared-... > > It looks like Guido disagrees with me, so the discussion is closed. Note that the FAQ mainly explains *what* happens, not *why*

Re: TIOBE declares Python as programming language of 2007!

2008-01-07 Thread George Sakkis
On Jan 7, 9:27 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On Jan 7, 12:53 pm, Berco Beute <[EMAIL PROTECTED]> wrote: > > > Cool! We knew it would happen one day :) > > What could be the reason? Python 3? Jython 2.2? Java's loss of > > sexiness? > > Python eats Perls lunch as a scripting languag

Re: Python's great, in a word

2008-01-07 Thread George Sakkis
On Jan 7, 8:09 am, [EMAIL PROTECTED] wrote: > I'm a Java guy who's been doing Python for a month now and I'm > convinced that > > 1) a multi-paradigm language is inherently better than a mono-paradigm > language > > 2) Python writes like a talented figure skater skates. > > Would you Python old-ti

Re: Python too slow?

2008-01-10 Thread George Sakkis
On Jan 10, 3:37 am, Bruno Desthuilliers wrote: > I fail to see how the existence of JIT compilers in some Java VM changes > anything to the fact that both Java (by language specification) and > CPython use the byte-code/VM scheme. Because these "some Java VMs" with JIT compilers are the de facto

Re: Python too slow?

2008-01-11 Thread George Sakkis
On Jan 11, 8:59 am, Bruno Desthuilliers wrote: > George Sakkis a écrit : > > > > > On Jan 11, 4:12 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > > >> George Sakkis a écrit : > > >>> On Jan 10, 3:37 am, Bruno Desthuilliers wrote: > &g

Re: Python too slow?

2008-01-11 Thread George Sakkis
On Jan 11, 4:12 am, Bruno Desthuilliers wrote: > George Sakkis a écrit : > > > On Jan 10, 3:37 am, Bruno Desthuilliers wrote: > > >> I fail to see how the existence of JIT compilers in some Java VM changes > >> anything to the fact that both Java (by language sp

Re: Python too slow?

2008-01-11 Thread George Sakkis
On Jan 11, 9:41 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> > writes: > > > fact 1: CPython compiles source code to byte-code. > > fact 2: CPython executes this byte-code. > > fact 3: Sun's JDK compiles source code to byte-code. > > fact 4: Sun's JDK execu

Import and execfile()

2008-01-11 Thread George Sakkis
I maintain a few configuration files in Python syntax (mainly nested dicts of ints and strings) and use execfile() to read them back to Python. This has been working great; it combines the convenience of pickle with the readability of Python. So far each configuration is contained in a single stand

Re: alternating string replace

2008-01-11 Thread George Sakkis
On Jan 9, 6:34 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > cesco <[EMAIL PROTECTED]> wrote: > > Hi, > > > say I have a string like the following: > > s1 = 'hi_cat_bye_dog' > > and I want to replace the even '_' with ':' and the odd '_' with ',' > > so that I get a new string like the following: >

Re: Import and execfile()

2008-01-11 Thread George Sakkis
On Jan 11, 5:24 pm, Mike Meyer <[EMAIL PROTECTED]> wrote: > On Fri, 11 Jan 2008 14:05:11 -0800 (PST) George Sakkis <[EMAIL PROTECTED]> > wrote: > > > I maintain a few configuration files in Python syntax (mainly nested > > dicts of ints and strings) and us

Re: Import and execfile()

2008-01-11 Thread George Sakkis
On Jan 11, 6:54 pm, Mitko Haralanov <[EMAIL PROTECTED]> wrote: > On Fri, 11 Jan 2008 14:05:11 -0800 (PST) > > George Sakkis <[EMAIL PROTECTED]> wrote: > > # trying to set the configuration: > > CFG = {} > > execfile('path/to/some_config.py&#

Re: NotImplimentedError

2008-01-14 Thread George Sakkis
By the way, why do we need both NotImplementedError and the NotImplemented singleton object ? Couldn't we have just one of them ? -- http://mail.python.org/mailman/listinfo/python-list

Re: super, decorators and gettattribute

2008-01-14 Thread George Sakkis
On Jan 12, 6:56 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 12 Jan 2008 15:47:05 -0500, Mike Meyer wrote: > > There's an apparently common bug here: you don't want to pass super > > self.__class__, but the class that the method is bound to. > > Given an instance met

SyntaxError: 'import *' not allowed with 'from .'

2008-01-14 Thread George Sakkis
Unless I missed it, PEP 328 doesn't mention anything about this. What's the reason for not allowing "from .relative.module import *' ? George -- http://mail.python.org/mailman/listinfo/python-list

Dynamical scoping

2008-01-14 Thread George Sakkis
What's the best way to simulate dynamically scoped variables ala Lisp ? The use case is an open-ended set of objects that need to access the same piece of information (e.g. a dict, a ConfigParser object, a logger etc.). I know that the "proper" OO and functional way is to pass the information expl

Re: SyntaxError: 'import *' not allowed with 'from .'

2008-01-14 Thread George Sakkis
On Jan 14, 6:01 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > Unless I missed it, PEP 328 doesn't mention anything about this. > > What's the reason for not allowing "from .relative.module import *' &g

Re: import from question

2008-01-14 Thread George Sakkis
On Jan 14, 4:22 pm, iu2 <[EMAIL PROTECTED]> wrote: > Hi all > > I've got three files: > > file a1.py: > > the_number = None > > file a2.py: > > import a1 > > def init(): > a1.the_number = 100 > > file a3.py: > > from a1 import the_number > import a2 > > a2.init() > pr

Re: NotImplimentedError

2008-01-14 Thread George Sakkis
On Jan 14, 5:39 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > I think of NotImplemented as equivalent to None; it's useful as a > sentinel value to set an attribute to in (e.g.) an abstract class. My guess would be that it is more of an implementation performance decision than semantic. Checking 'i

Re: Perl Template Toolkit: Now in spicy new Python flavor

2008-01-15 Thread George Sakkis
On Jan 15, 3:15 pm, Joshua Kugler <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I'd like to inform the Python community that the powerful and popular > > Template Toolkit system, previously available only in its original > > Perl implementation, is now also available in a beta Python >

Re: Data mapper - need to map an dictionary of values to a model

2008-01-15 Thread George Sakkis
On Jan 14, 7:56 pm, Luke <[EMAIL PROTECTED]> wrote: > I am writing an order management console. I need to create an import > system that is easy to extend. For now, I want to accept an dictionary > of values and map them to my data model. The thing is, I need to do > things to certain columns: > >

Re: Data mapper - need to map an dictionary of values to a model

2008-01-15 Thread George Sakkis
On Jan 15, 6:53 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > name_tranformer = lambda input: dict( >zip(('first_name', 'last_name'), >input['name'])) Of course that should

Re: assigning values in python and perl

2008-01-16 Thread George Sakkis
On Jan 16, 10:34 pm, "J. Peng" <[EMAIL PROTECTED]> wrote: > I just thought python's way of assigning value to a variable is really > different to other language like C,perl. :) > > Below two ways (python and perl) are called "pass by reference", but > they get different results. > > (snipped) Pyt

Re: next line (data parsing)

2008-01-16 Thread George Sakkis
On Jan 17, 12:01 am, Scott David Daniels <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hi there, > > I'm struggling to find a sensible way to process a large chuck of > > data--line by line, but also having the ability to move to subsequent > > 'next' lines within a for loop. I was hopi

Re: next line (data parsing)

2008-01-16 Thread George Sakkis
On Jan 17, 12:42 am, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jan 17, 12:01 am, Scott David Daniels <[EMAIL PROTECTED]> > wrote: > > > > > [EMAIL PROTECTED] wrote: > > > Hi there, > > > I'm struggling to find a sensible way to process a

Re: assigning values in python and perl

2008-01-16 Thread George Sakkis
On Jan 17, 1:03 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > Python's parameter passing is like passing a pointer in C/C++. > > [snip] > > It's not (I repeat NOT) like passing a pointer in C. Please > readhttp://effbot.o

Re: assigning values in python and perl

2008-01-17 Thread George Sakkis
On Jan 17, 1:59 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > Posting a counter-example where the difference is clearly shown would > > be more vastly useful than referring to a list of long obscure usenet > > posts with practically no e

Re: Loop in a loop?

2008-01-17 Thread George Sakkis
On Jan 17, 12:25 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Jan 17, 4:38 pm, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > > Now there are very certainly smart solutions using itertools, but the > > one I cooked is way too ugly so I'll leave this to itertools masters !-) > > Here's my ef

Re: Loop in a loop?

2008-01-17 Thread George Sakkis
On Jan 17, 7:13 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > And if the iterables don't necessarily support len(), here's a more > > general solution: > > Not trying to pick on you personally but there&

Re: Efficient processing of large nuumeric data file

2008-01-18 Thread George Sakkis
On Jan 18, 12:15 pm, David Sanders <[EMAIL PROTECTED]> wrote: > Hi, > > I am processing large files of numerical data. Each line is either a > single (positive) integer, or a pair of positive integers, where the > second represents the number of times that the first number is > repeated in the da

Default attribute values pattern

2008-01-19 Thread George Sakkis
A situation that often comes up is having to initialize several instance attributes that accept a default value. For a single class, passing the default values in __init__ is fine: class Base(object): def __init__(self, x=0, y=None): self.x = x self.y = y For i

Re: object scope

2008-01-20 Thread George Sakkis
On Jan 21, 12:16 am, "J. Peng" <[EMAIL PROTECTED]> wrote: > Dennis Lee Bieber 写道: > > >The scope of "name" is the entire function; lacking a "global name" > > statement, AND being on the left side of an assignment, it is a function > > local name. > > Thank you. Does python have so-called 'blo

Re: is it possible to set namespace to an object.

2008-01-21 Thread George Sakkis
On Jan 21, 1:56 pm, glomde <[EMAIL PROTECTED]> wrote: > On 21 Jan, 18:59, Wildemar Wildenburger > > > > <[EMAIL PROTECTED]> wrote: > > glomde wrote: > > > Hi, > > > > is it somehow possible to set the current namespace so that is in an > > > object. > > > [snip] > > > set namespace testObj > > > Na

Re: Default attribute values pattern

2008-01-21 Thread George Sakkis
On Jan 19, 6:02 pm, "David Tweet" <[EMAIL PROTECTED]> wrote: > Hello, > > Seems to me that setattrs sort of assumes that you want to have all your > initialization arguments set as attributes of the same name. I would think > you'd sometimes want to be able to process the extra arguments inside of

Re: is it possible to set namespace to an object.

2008-01-21 Thread George Sakkis
On Jan 21, 2:52 pm, glomde <[EMAIL PROTECTED]> wrote: > On 21 Jan, 20:16, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Jan 21, 1:56 pm, glomde <[EMAIL PROTECTED]> wrote: > > > > On 21 Jan, 18:59, Wildemar Wildenburger > > > > &

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread George Sakkis
On Jan 21, 4:45 pm, Paul Rubin wrote: > "p." <[EMAIL PROTECTED]> writes: > > 1. Has anyone done anything like this before, and if so, do you have > > any advice? > > Sort all the files with an external sort utility (e.g. unix sort), so > that records with the same key are

Re: pairs from a list

2008-01-21 Thread George Sakkis
On Jan 21, 10:20 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > I want to generate sequential pairs from a list. > Here is a way:: > > from itertools import izip, islice > for x12 in izip(islice(x,0,None,2),islice(x,1,None,2)): > print x12 > > (Of course the print statement is just ill

Re: pairs from a list

2008-01-21 Thread George Sakkis
On Jan 22, 12:15 am, Paddy <[EMAIL PROTECTED]> wrote: > On Jan 22, 3:20 am, Alan Isaac <[EMAIL PROTECTED]> wrote:> I want to generate > sequential pairs from a list. > <> > > What is the fastest way? (Ignore the import time.) > > 1) How fast is the method you have? > 2) How much faster does it nee

Re: pairs from a list

2008-01-22 Thread George Sakkis
On Jan 22, 1:34 pm, Paddy <[EMAIL PROTECTED]> wrote: > On Jan 22, 5:34 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Jan 22, 12:15 am, Paddy <[EMAIL PROTECTED]> wrote: > > > > On Jan 22, 3:20 am, Alan Isaac <[EMAIL PROTECTED]> wro

Re: pairs from a list

2008-01-22 Thread George Sakkis
On Jan 23, 1:39 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Given the human psychology displayed involved, in the absence of > definitive evidence one way or another it is a far safer bet to assume > that people are unnecessarily asking for "the fastest" out of a misguided > and often ignoran

Re: pairs from a list

2008-01-23 Thread George Sakkis
On Jan 23, 4:37 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 22 Jan 2008 23:33:00 -0800, George Sakkis wrote: > > As I mentioned already, I consider the seeking of the most efficient > > solution a legitimate question, regardless of whether a "dumb"

Re: pairs from a list

2008-01-23 Thread George Sakkis
On Jan 23, 1:30 pm, Paddy <[EMAIL PROTECTED]> wrote: > I've heard quality expressed as "meeting requirements", which I think > is apt. Falling short of requirements everyone knows doesn't give a > quality result, but equally 'exceeding' requirements also detracts > from quality (as does not knowin

Re: Why not 'foo = not f' instead of 'foo = (not f or 1) and 0'?

2008-01-23 Thread George Sakkis
On Jan 23, 4:06 am, Gary Herron <[EMAIL PROTECTED]> wrote: > However there *is* a (subtle) difference between > not f > and > (not f and 1) or 0 > > The first produces a boolean value, and the second produces an int > value, but since one is a subclass of the other, you'd have to write > quite

Re: pairs from a list

2008-01-23 Thread George Sakkis
On Jan 23, 4:48 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > As for your other points, I think we're actually very much in agreement, > except for your tolerance of random posters asking what I believe is an > incoherent question: "what's the fastest way to do ...?". It seem

Re: Linux Journal Survey

2008-01-23 Thread George Sakkis
On Jan 23, 8:14 pm, [EMAIL PROTECTED] wrote: > The annual Linux Journal survey is online now for any Linux users who > want to vote for Python. http://www.linuxjournal.com/node/1006101 ... 18. What is your favorite programming language? (15 choices, Python not included) 19. What is your favor

Pickling dynamically generated classes

2008-01-25 Thread George Sakkis
The Fine Manual mentions that pickle works for classes that are defined at the top level of a module. Is there a way to extend this behavior so that I can pickle and unpickle instances of dynamically generated classes ? Longer version: I have a function RecordTypeFactory(fields, ...) that dynamica

Re: Removing Pubic Hair Methods

2008-01-30 Thread George Sakkis
On Jan 30, 5:03 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 30 Jan 2008 15:29:45 +0100, Wildemar Wildenburger wrote: > > Gerardo Herzig wrote: > >> I will use genital().extend(), thats for shure ^^ > > > Well, you never go wrong with apply(genital(), females), do you? > > `app

Re: Removing Pubic Hair Methods

2008-01-30 Thread George Sakkis
On Jan 30, 9:27 pm, MRAB <[EMAIL PROTECTED]> wrote: > On Jan 31, 1:09 am, George Sakkis <[EMAIL PROTECTED]> wrote:> On Jan 30, 5:03 > pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > > On Wed, 30 Jan 2008 15:29:45 +0100, Wildemar

Re: How to identify which numbers in a list are within each others' range

2008-01-31 Thread George Sakkis
On Jan 31, 7:11 pm, Paul Rubin wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > True... Any lighter-weight implementation of > > sets out there? That is, one that would defer > > use of resources until actually needed -- > > somewhat akin to the distinction

Re: Python feature request : operator for function composition

2008-02-03 Thread George Sakkis
On Feb 3, 12:09 am, Kay Schluehr <[EMAIL PROTECTED]> wrote: > As you know, there is no operator for function composition in Python. > When you have two functions F and G and want to express the > composition F o G you have to create a new closure > > lambda *args, **kwd: F (G (*args, **kwd)) > >

Re: Is it explicitly specified?

2008-02-04 Thread George Sakkis
On Feb 4, 6:53 am, André Malo <[EMAIL PROTECTED]> wrote: > * Steven D'Aprano wrote: > > On Sun, 03 Feb 2008 15:31:49 -0800, Paul Boddie wrote: > > >> I don't know whether I can offer much better advice than others, but I > >> have noticed that a lot of my own code has moved in the direction of not

Re: What is the most simple, quicket, yet most powerful python Web-Framework?

2008-02-05 Thread George Sakkis
xkenneth wrote: > For the DB backend I'm planning on using ZODB. ZODB is actually > quite amazing, and after using it, I honestly can't think of a > reason for using a SQL database. Well, one reason is that this probably rules out most of your options since most web frameworks include (or integra

Re: getting all user defined attributes of a class

2008-02-07 Thread George Sakkis
On Feb 7, 1:42 pm, Amit Gupta <[EMAIL PROTECTED]> wrote: > Thanks. What I found is: If I call iterate over the __dict__ of the > instance of the class, I only get user-atttributes and not built-in > attributes. I have an instance of that class, anyway, so this will do. > However, I wonder if I am

Re: Why does list have no 'get' method?

2008-02-07 Thread George Sakkis
On Feb 7, 4:25 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 07 Feb 2008 15:59:13 +0100, Wildemar Wildenburger wrote: > > Arnaud Delobelle wrote: > >> Personally, between > > >> * foo if foo else bar > >> * foo or bar > > >> I prefer the second. Maybe it could be spelt

Re: Critique of first python code

2008-02-08 Thread George Sakkis
On Feb 8, 3:40 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Feb 8, 7:20 pm, "Zack" <[EMAIL PROTECTED]> wrote: > > > > > Hi all. I'm just starting to pick up python. I wanted to play with nested > > lists so first I wrote a little bit of code to create arbitrarily nested > > lists (grow). T

Re: ways to declare empty set variable

2008-02-12 Thread George Sakkis
On Feb 12, 7:02 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > > Ben Finney wrote: > > [...] > > > > Note that '()' is syntactically null. Parentheses don't declare a > > > tuple literal, commas do. Parentheses are for grouping within > > > expressions, not s

Re: ways to declare empty set variable

2008-02-12 Thread George Sakkis
On Feb 12, 9:30 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > On Feb 12, 7:02 pm, Ben Finney <[EMAIL PROTECTED]> > > wrote: > > > That makes it even more a violation of > > > principle-of-least-astonish

Re: XML pickle

2008-02-13 Thread George Sakkis
On Feb 13, 4:43 pm, [EMAIL PROTECTED] wrote: > Readability of the Pickle module. Can one export to XML, from cost > of speed and size, to benefit of user-readability? Take a look at gnosis.xml.pickle, it seems a good starting point. George -- http://mail.python.org/mailman/listinfo/python-list

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread George Sakkis
On Feb 16, 12:15 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Ilias Lazaridis wrote: > > Essence: > > Spam spam spam spam... > > I just looked at your resume. What is Abstract Project Management? A branch of Analysis Paralysis Vaporware. -- http://mail.python.org/mailman/listinfo/python-list

Re: Critique of first python code

2008-02-17 Thread George Sakkis
On Feb 17, 10:17 am, Matthew Marshall <[EMAIL PROTECTED]> wrote: > Dan Bishop wrote: > > I will say, however, that hasattr(item, '__iter__') isn't a perfect > > way of checking whether an object is iterable: Objects that just > > define __getitem__ are iterable too (e.g., UserList). > > Speaking of

Re: flattening a dict

2008-02-17 Thread George Sakkis
On Feb 17, 7:51 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > BTW, I keep using the idiom itertools.chain(*iterable). I guess that > during function calls *iterable gets expanded to a tuple. Wouldn't it > be nice to have an equivalent one-argument function that takes an > iterable of iterabl

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-18 Thread George Sakkis
On Feb 18, 6:56 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > > Dear Ilias, > > > Post in a single reply. > > He has to, in hopes to gain the traction he desires Was the pun intended ? ;-) -- http://mail.python.org/mailm

Re: The big shots

2008-02-18 Thread George Sakkis
On Feb 19, 12:08 am, [EMAIL PROTECTED] wrote: > The problem did not seem to be miscommunication, rather bias. IMHO it's partly because of the obscurity of the ideas and the code you suggest, and partly because of the poor job you do to explain them. By the way, you may have noticed that you have

Re: Why must implementing Python be hard unlike Scheme?

2008-02-18 Thread George Sakkis
On Feb 19, 1:15 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm learning Scheme and I am amazed how easy it is to start building a > half baked Scheme implementation that somewhat works. > > After knowing Python for *years* I have no idea how to actually > implement the darn thing. >From

Re: The big shots

2008-02-19 Thread George Sakkis
On Feb 19, 5:25 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-02-19, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Even on my emperical claims, I'm wrong 90% of the time. On > > the subjective ones, I'm not only wrong that much, but no one > > else want to hear, or even can verify th

Re: Is there a way to "link" a python program from several files?

2008-02-21 Thread George Sakkis
On Feb 21, 1:58 am, [EMAIL PROTECTED] (Edward A. Falk) wrote: > In article <[EMAIL PROTECTED]>, > > BlueBird <[EMAIL PROTECTED]> wrote: > > >I wrote a small wiki page to sum-up my findings about such typical > >problem: > > >http://www.freehackers.org/Packaging_a_python_program > > Excellent refer

Re: Return value of an assignment statement?

2008-02-21 Thread George Sakkis
On Feb 21, 7:21 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > Jeff Schwab wrote: > >> [EMAIL PROTECTED] wrote: > > [...] > >>> Now there's no reason to feel nervous about this. All you have to > >>> remember is that Python never copy anything unless explicitely asked > >>> fo

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