Re: Return value of an assignment statement?

2008-02-21 Thread George Sakkis
lement an augmented operator, "a `op`= b" translates to "a = a `op` b" for a binary operator `op`. There's no formal notion of mutable and immutable objects with respect to these operators; any class that doesn't implement them is "immutable" as far as augmented ass

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

2008-02-21 Thread George Sakkis
;python setup.py install" ? Even that is not strictly necessary for pure python packages; a user may just unpack the archive, cd to the extracted directory and execute the appropriate .py file(s). George -- http://mail.python.org/mailman/listinfo/python-list

Re: The big shots

2008-02-19 Thread George Sakkis
ing." > > French and Spanish have impersonal pronouns: "on" and "se", > > respectively. In English, they often come out as, "we", > > "they", and "you" a lot, on occasion a "one", and sometimes, > > even, I. &

Re: Why must implementing Python be hard unlike Scheme?

2008-02-18 Thread George Sakkis
guages minimality is not the top priority. Python is not an exception. > Does this have to be true? Beneath the more complex syntax are there > a few core design principles/objects/relationships to help in grokking > the whole thing? Got any related links? http://codespeak.net/pypy/dist/p

Re: The big shots

2008-02-18 Thread George Sakkis
that you have been mostly replying to your own posts here in c.l.py, which indicates that the lack of responses has nothing to do with the supposed snobbishness of the "big shots". George -- http://mail.python.org/mailman/listinfo/python-list

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: Critique of first python code

2008-02-17 Thread George Sakkis
if I had to write one, I would use isiterable = lambda x: hasattr(x, '__iter__') or hasattr(x, '__getitem__') In Python 3 it will be isinstance(x, Iterable). George -- http://mail.python.org/mailman/listinfo/python-list

Re: flattening a dict

2008-02-17 Thread George Sakkis
les) semantics if it is passed a single argument. Currently chain() is useful for 2 or more arguments; chain(x) is equivalent to iter(x), there's no reason to use it ever. On the downside, this might break backwards compatibility for cases like chain(*some_iterable) where some_iterable has

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: 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/

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: ways to declare empty set variable

2008-02-12 Thread George Sakkis
it even more a violation of principle-of-least-astonishment > that the '(foo)' form doesn't give a one-element tuple literal. The reason being, of course, that in this case '(1+2) * 3' would give a result several orders of magnitude more astonishing, so it's well worth the slight inconvenience of one-element tuples. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Critique of first python code

2008-02-08 Thread George Sakkis
yield next() if random()<0.5 else nest(igrow(depth,next,nest,random)) for e in igrow(depth,next,nest,random): yield e With this you can just as easily generate nested tuples (or other containers) instead of lists: nested = tuple(igrow(10, nest=tuple)) You may even avoid allocating nested containers altogether: from types import GeneratorType for x in igrow(10, nest=iter): if isinstance(x, GeneratorType): # process nested generator else: # x is an 'atom' HTH, George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-02-07 Thread George Sakkis
ather than bar" means "bar is never > chosen, foo is always chosen". Ok, the fix is easy: val = BETTER foo THAN bar ;-) Cobol-strikes-back-ly yours, George -- http://mail.python.org/mailman/listinfo/python-list

Re: getting all user defined attributes of a class

2008-02-07 Thread George Sakkis
includes attributes defined in superclasses, classes with __slots__, pseudo-attributes through __getattr__ and possibly more I've missed. George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-02-05 Thread George Sakkis
meworks include (or integrate with) an ORM layer, which in turn talks to a (relational) database. If you're sold on ZODB, you may want to evaluate Grok [1], a Web framework built on top of Zope 3 that doesn't seem to require knowledge of Zope internals. HTH, George [1] http://grok.zope.or

Re: Is it explicitly specified?

2008-02-04 Thread George Sakkis
u don't have > to wind up all the possible caller signatures to reflect that change. You might find handy a decorator I've written exactly for this scenario, reusing default arguments across functions: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440702 George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python feature request : operator for function composition

2008-02-03 Thread George Sakkis
(the result of G) to deserve a special operator ? George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-01-31 Thread George Sakkis
sect module to find the > intervals intersecting a given one. I haven't actually used it but from the short description this package seems to fit the bill: http://pypi.python.org/pypi/interval/1.0.0 George -- http://mail.python.org/mailman/listinfo/python-list

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: Removing Pubic Hair Methods

2008-01-30 Thread George Sakkis
rong with apply(genital(), females), do you? > > `apply()` is deprecated. And ``genital(*females)`` looks a bit odd. :-) Well, that use case alone is enough to convince anyone that apply should stay :-) George -- http://mail.python.org/mailman/listinfo/python-list

Pickling dynamically generated classes

2008-01-25 Thread George Sakkis
different process unless RecordTypeFactory is called with the same arguments so that "the same" class is generated in the other process as well. Essentially what I'm missing is a hook to call RecordTypeFactory with the same fields when an instance of the gen. class is to be unp

Re: Linux Journal Survey

2008-01-23 Thread George Sakkis
s your favorite scripting language? o Python o Perl (5 more choices) Python is much more than a "scripting language" (whatever this means, other than a semi-derogatory term used by clueless PHBs). Sorry, I'll pass. George -- http://mail.python.org/mailman/listinfo/python-list

Re: pairs from a list

2008-01-23 Thread George Sakkis
m and the context. For small well- defined algorithmic type problems, I just assume it's intellectual curiosity or that performance really matters. If the same question was asked in the context of, say, a typical web application fetching data from a database and rendering dynamic pages, I migh

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

2008-01-23 Thread George Sakkis
other, you'd have to write > quite perverse code care about the difference. Even if for some reason I did want the result to be int, I would write it as "int(not f)". George -- http://mail.python.org/mailman/listinfo/python-list

Re: pairs from a list

2008-01-23 Thread George Sakkis
now, what he wanted as a child, what's the meaning of one's life and so on. After a couple of minutes the guy cuts him and asks again: - "Man, what do you want, burger or hot dog?" - "Oh, a hot dog". Sometimes you want to see the tree right in front of you, not the whole damn forest. George -- http://mail.python.org/mailman/listinfo/python-list

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-22 Thread George Sakkis
(perceived) social value and other reasons. And since you like metaphors, here's another one: caring about efficient code only when you need it is like keeping notes for a course only for the material to be included in the final exams, skipping the more encyclopedic, general knowledge

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-21 Thread George Sakkis
est pure Python version happens to be among the most elegant and concise, unlike other languages where optimization usually implies obfuscation. George -- http://mail.python.org/mailman/listinfo/python-list

Re: pairs from a list

2008-01-21 Thread George Sakkis
se the print statement is just illustrative.) > What is the fastest way? (Ignore the import time.) Look up the timeit module and test yourself the various alternatives; that's the most reliable way to tell for sure. George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-01-21 Thread George Sakkis
sort), so > that records with the same key are all brought together. Then you can > process the files sequentially. Seconded. Unix sort can do external sorting [1] so your program will work even if the files don't fit in memory. Once they are sorted, itertools (especially groupby) is y

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: Default attribute values pattern

2008-01-21 Thread George Sakkis
s (like x and y) *after* the call to super __init__ while new attributes (like z, a and b) *before* the call. Mixing it up will either raise a runtime error for passing an unknown argument to the parent, or (worse) set the parent's default instead of the child's. So for the common attribute setting case it involves more error-prone boilerplate code. George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-01-21 Thread George Sakkis
uding you after a few weeks/months). If you want to save a few keystrokes, you may use 'n' instead of 'node' or use an editor with easy auto completion. By the way, is there any particular reason for generating the XML programmatically like this ? Why not have a separate template and use one of the dozen template engines to populate it ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: object scope

2008-01-20 Thread George Sakkis
; > local name. > > Thank you. Does python have so-called 'block scope' object? No, it doesn't; in most cases that you may care, a name's scope is either local or global*. > or if you can,please show me the doc for python's object scope. http://www.network-the

Default attribute values pattern

2008-01-19 Thread George Sakkis
utes have to repeated in derived classes: class Derived(Base): x = 1 z = '' def __init__(self, **kwds): super(Derived,self).__init__(**kwds) print 'In Derived.__init__' Is this a good way of doing it ? Is there a better p

Re: Efficient processing of large nuumeric data file

2008-01-18 Thread George Sakkis
, so it seems to me that some kind of array > (numpy?) would be more efficient, but the upper bound changes in each > file. Yes, dict is the right data structure; since Python 2.5, collections.defaultdict is an alternative. numpy is good for processing numeric data once they are already in arrays, not for populating them. George -- http://mail.python.org/mailman/listinfo/python-list

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: Loop in a loop?

2008-01-17 Thread George Sakkis
able).next for iterable in iterables] pending = size = len(iterables) while True: slice = [None] * size for i in xrange(size): try: slice[i] = getnext[i]() except StopIteration: pending -= 1 if not pending: return

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: 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: 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: next line (data parsing)

2008-01-16 Thread George Sakkis
ften, you may extract it to a general grouping function such as http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/521877: import re for line in iterblocks(source, start = lambda line: line.startswith('Schedule HOST'), end = lambda line: re.search(r'^ \s*Total',line), skip_delim=False): process(line) George -- http://mail.python.org/mailman/listinfo/python-list

Re: assigning values in python and perl

2008-01-16 Thread George Sakkis
int x[] = {1,2,3}; test(x); for (int i=0; i<3; i++) { printf("%d ", x[i]); } } $ gcc -std=c99 test.c $ ./a.out -1 2 3 Hope this helps, George -- http://mail.python.org/mailman/listinfo/python-list

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: Data mapper - need to map an dictionary of values to a model

2008-01-15 Thread George Sakkis
viding the overall task to smaller bits that can be documented, tested and reused separately. For anything more sophisticated, you have to constrain what are the possible transformations that can happen. I did something similar for transforming CSV input rows (http://pypi.python.org/pypi/csvutils/) so that it's easy to specify 1-to-{0,1} transformations but not 1-to-many or many-to-1. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

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

2008-01-15 Thread George Sakkis
s either. :) As someone who has used Template Toolkit quite a bit, > I must say that is is quite cool. Congrats on a job well done! > > j How does it compare with other "mainstream" Python template engines such as Cheetah, Mako, etc. ? Unless I missed it, the documentation covers the Perl version only. George -- http://mail.python.org/mailman/listinfo/python-list

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: import from question

2008-01-14 Thread George Sakkis
> 100 > > Why doesn't it work in the first version of a3.py? > > Thanks, > iu2 Try to guess what the following snippet prints, run it, and see if you guessed correctly: s = {'a':None} x = s['a'] s['a'] = 1 print x The same mechanism applies to what "from ... import" does. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

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

Dynamical scoping

2008-01-14 Thread George Sakkis
the information explicitly but that's less maintenable in the long run. Also this is in a web environment so the information can't be really global (though within-thread global should be fine). Is there some standard pattern for this scenario ? George -- http://mail.python.org/mailman/listinfo/python-list

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

Re: super, decorators and gettattribute

2008-01-14 Thread George Sakkis
ses: from inspect import getmro def getdef(obj,attr): try: objattrs = obj.__dict__ except AttributeError: objattrs = obj.__slots__ if attr in objattrs: return obj for cls in getmro(obj.__class__): if attr in cls.__dict__: return cls >>> g

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: DEK's birthday

2008-01-12 Thread George Neuner
On Sat, 12 Jan 2008 12:03:49 -0800 (PST), [EMAIL PROTECTED] wrote: >On Jan 10, 9:57 am, Jim <[EMAIL PROTECTED]> wrote: >> DEK celebrates 70 today. >> >> I doubt he'll read this but I'll say it anyway: Happy Birthday! >> >> Jim Hefferon > >Donald Knuth is a son of a bitch who made a lot of money fr

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: 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: alternating string replace

2008-01-11 Thread George Sakkis
n = islice(cycle(':,'), len(parts)-1) > return ''.join(interleave(parts, punctuation)) > > s1 = 'hi_cat_bye_dog' > print punctuate(s1) > > # Or as a one-liner (once you have interleave): > > print ''.join(list(interleave(s1.split('

Import and execfile()

2008-01-11 Thread George Sakkis
27;path/to/some_config.py', CFG) Traceback (most recent call last): ... ImportError: No module named master_config I understand why this fails but I'm not sure how to tell execfile() to set the path accordingly. Any ideas ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python too slow?

2008-01-11 Thread George Sakkis
ntion or configuration, and with > 100% compatibility, so it doesn't compare well to Python accelerators > like psyco. Plus, IIRC Java's JIT is not limited to optimizing special cases, while psyco helps primarily with number-crunching code (admittedly an important special case) and

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-10 Thread George Sakkis
rs are the de facto standard used by millions; the spec is pretty much irrelevant (unless you're a compiler writer or language theorist). George -- http://mail.python.org/mailman/listinfo/python-list

Re: Pet Store

2008-01-08 Thread George Maggessy
Yeap. It is. I'm looking for something like that app. Smth that I could base my future developments on. On Jan 8, 1:47 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 07 Jan 2008 22:21:53 -0800, George Maggessy wrote: > > I'm an experience Ja

Pet Store

2008-01-07 Thread George Maggessy
quot;Java Pet Store" apps, I think that would help me to fill up some gaps in my learning process. Does anybody know any app like that? Cheers, George -- http://mail.python.org/mailman/listinfo/python-list

User Group

2008-01-07 Thread George Maggessy
Hi Guys, Is there a python user group in the bay area? Cheers, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's great, in a word

2008-01-07 Thread George Sakkis
ter skates. > > Would you Python old-timers try to agree on a word or two that > completes: > > The best thing about Python is ___. ... it's a pleasure to write *and* read. ... it keeps simple things simple and makes hard things doable. ... it's the language that sucks t

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: Choosing a new language

2007-12-30 Thread George Neuner
On Fri, 28 Dec 2007 22:07:12 -0800 (PST), [EMAIL PROTECTED] wrote: >Ada is airline/dod blessed. Airline blessed maybe. The DOD revoked its Ada only edict because they couldn't find enough Ada programmers. AFAIK, Ada is still the preferred language, but it is not required. George -- f

Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread George Sakkis
t instead of the common one. Unfortunately, many Pythoneers become so immersed with the language and whatever the current status quo is that they rarely question the rationale of the few counter-intuitive design choices. George -- http://mail.python.org/mailman/listinfo/python-list

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

2007-12-30 Thread George Sakkis
volved groupby() with an appropriate key function. The takewhile/dropwhile solution seems shorter and (maybe) easier to read but perhaps not as flexible and general. Regardless, it's a good example of takewhile/dropwhile. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Choosing a new language

2007-12-28 Thread George Neuner
ability to hot patch and continue. I know not everyone works in RT, but I can't possibly be alone in developing applications that are hard to restart effectively. That all said, online compilation such as in Lisp is only one of several ways of replacing running code. Whether it is the best w

Re: 5 queens

2007-12-24 Thread George Sakkis
3] >>> for c in combinations(xrange(4), 3): print c Traceback (most recent call last): File "combs.py", line 54, in for c in combinations(xrange(4), 3): print c File "combs.py", line 12, in combinations for cc in combinations(seq[i+1:], n-1): TypeError: sequence index must be integer, not 'slice' George -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a bug in int()?

2007-12-22 Thread George Sakkis
compiles without > complaint. I'm pretty sure any line of the form "name = 0x" was a > product of some form of programmer interruptus. :-) Are you a fiction writer by any chance ? Nice story but I somehow doubt that the number of lines of the form "name = 0x" ever written in Python is greater than a single digit (with zero the most likely one). George -- http://mail.python.org/mailman/listinfo/python-list

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

2007-12-20 Thread George Sakkis
t pyparsing parser. Here's the relevant thread: http://preview.tinyurl.com/2aeswn. Note that the builtin eval() is around 5x faster than this parser, and from the statement above, 50x faster than the pyparsing solution. George -- http://mail.python.org/mailman/listinfo/python-list

Re: New+old-style multiple inheritance

2007-12-19 Thread George Sakkis
or rather 4th party since "they" are the 3rd party here ;-)) module. Even if it's technically possible and the change doesn't break other things, I'd rather not have to maintain a patched version of the stdlib. George -- http://mail.python.org/mailman/listinfo/python-list

Re: New+old-style multiple inheritance

2007-12-19 Thread George Sakkis
andard exception classes were old-style so it's not safe to assume that you only have new style classes to worry about when the very standard library includes lots of legacy code. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Best idiom to unpack a variable-size sequence

2007-12-18 Thread George Sakkis
ficient and general (e.g. for infinite series) using itertools: from itertools import islice, chain, repeat def unpack(iterable, n, default=None): return islice(chain(iterable,repeat(default)), n) a, b, c = unpack(seq, 3) George -- http://mail.python.org/mailman/listinfo/python-list

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

2007-12-15 Thread George Sakkis
en't so many or compelling use cases for rationals as for decimals (mainly money counting). George -- http://mail.python.org/mailman/listinfo/python-list

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

Re: Python for Java programmer

2007-12-14 Thread George Sakkis
eal of exposure to language and class library, So it would > be great if anyone would suggest such framework as well. > > Looking forward for suggestions Python community! You may want to check out these first: http://dirtsimple.org/2004/12/python-is-not-java.html http://www.razorvine.ne

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 > &

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

2007-12-12 Thread George Sakkis
nd) is not supported. > > I hope I am missing something. I really like Python but if there is no > way to process data efficiently, that seems to be a problem. 20 times slower because of garbage collection sounds kinda fishy. Posting some actual code usually helps; it's hard to tell for sure otherwise. George -- http://mail.python.org/mailman/listinfo/python-list

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: Is a "real" C-Python possible?

2007-12-12 Thread George Sakkis
efinition Pythonic since it was conceived by the BDFL.It is also certainly an improvement over the current common practice of polluting the class namespace with private getters and setters. Still it's a kludge compared to languages with builtin support for properties. George -- http://mail.python.org/mailman/listinfo/python-list

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

2007-12-12 Thread George Sakkis
> def fget(self): > return self._foo > def fset(self, value): > self._foo = value That's almost identical to a recipe I had written once upon a time, without requiring a syntax change: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698 George --

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

2007-12-12 Thread George Sakkis
t comparable to the decorator syntax sugar, if not more. Alas, it was too much ahead of its time.. who knows, it might revive on some 3.x version. George -- http://mail.python.org/mailman/listinfo/python-list

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

2007-12-12 Thread George Sakkis
nt; the inverse is not true though: time and time again people cared about some syntax for properties without any change so far. The result is a handful of different ways to spell out properties; python 2.6 will add yet another variation (http://mail.python.org/pipermail/ python-dev/2007-October/075

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: Job Offer: Python Ninja or Pirate!

2007-12-10 Thread George Sakkis
ect magic! :-) > > Output should be: > > | Chicago: 3 > | Fort Lauderdale: 1 > | Jersey City And South Florida: 1 > | New York: 1 Alas, it's not: AttributeError: 'module' object has no attribute 'dom' Here's a working version, optimized for char length (one line, 241 chars): import urllib as U,elementtree.ElementTree as E;c=[E.parse(U.urlopen('http://api.etsy.com/feeds/xml_user_details.php? id=%d'%u)).findtext('//city')for u in 71234,729,42346,77290,729,729];print'\n'.join('%s: %s'% (i,c.count(i))for i in set(c)) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python surpasses Perl in TIOBE index

2007-12-05 Thread George Sakkis
rowing too: http://www.ohloh.net/languages/compare?measure=commits&percent=&l0=perl&l1=php&l2=python&l3=-1&l4=-1&commit=Update George -- http://mail.python.org/mailman/listinfo/python-list

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-04 Thread George Sakkis
tually mean something), but this has more to do with Perl's fall than Python's increase: http://www.tiobe.com/tiobe_index/Perl.html. Even more amazing is the rate C++ is losing ground: http://www.tiobe.com/tiobe_index/C__.html George -- 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
Never occured to you that the goofiness of the name "Google" is at least an order of magnitude greater than Python. And FYI, Google didn't start out with the popularity it enjoys today, it gained it *despite* the silly name. Thanks God it was created by geeks and not clueless PHBs like

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: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread George Sakkis
ain specific toy language, which might well turn out to be less expressive than necessary for the given problem domain. I guess Lisp/Scheme would be even more suited for this task but then again there's a Web framework (TurboGears), an ORM (SqlAlchemy) an RPC middleware (Pyro) and a dozen more batteries, both standard and 3rd party. Can't think of anything better than Python for this project. George -- http://mail.python.org/mailman/listinfo/python-list

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

2007-11-24 Thread George Sakkis
> use more of it. If you bothered to click on that link you would learn that memoization can be used to save space too and matches OP's case exactly; even the identity tests work. Self-importance is bad enough by itself, even without the ignorance, but you seem to do great in both. George -- http://mail.python.org/mailman/listinfo/python-list

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

2007-11-24 Thread George Sakkis
osts. 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/Recipe/413717. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: the annoying, verbose self

2007-11-23 Thread George Sakkis
either of these is true for Python. I certainly wouldn't consider better a solution that required declaring local variables (e.g. "local x = 0"). George -- http://mail.python.org/mailman/listinfo/python-list

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