Re: Handy short cut for formatting elapsed time in floating point seconds

2007-04-21 Thread George Sakkis
took", secondsToStr(t2-t1),"seconds" > > and get nicely-formatted 0:00:12.345 style output. > > (I also posted this to the Python Cookbook.) > > -- Paul Cute... for obfuscated python contests :-) Whenever I needed this, a simple "Completed in %d minutes and %.1f seconds" % divmod(end-start, 60) was more than enough. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread George Sakkis
e classobjs defined in there? Or finding any constant strings in the > caller's module would also be just fine. Or is there a completely > different way to do such a thing? Yes, there is: use an ORM to do the SQL generation for you. Check out SQLAlchemy, it will buy you much more than what you asked for. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Command-line option equiv of PYTHONPATH

2007-04-27 Thread Harry George
decisions you want. archtool_path= os.getenv('ARCHTOOL_PATH') archtool_cfg = os.getenv('ARCHTOOL_CFG') sys.path.insert(0,archtool_path) import archtool exec "import archtool.%s as cfg" % archtool_cfg -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list

Re: Python ODBC

2007-04-30 Thread Harry George
bc are the main players. http://www.unixodbc.org/ http://www.iodbc.org/ 3. For *NIX you need python bindings. This is where mxODBC has operated (e.g., with iodbc). But there is an OSS effort at: https://sourceforge.net/projects/pyodb -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list

Subprocess with and without shell

2007-05-14 Thread George Sakkis
PE, stdout=PIPE) else: # this captures only stdout pipe = Popen(cmd, shell=False, stderr=PIPE, stdout=PIPE) # this prints the empty string if not run through the shell print "stderr:", pipe.stderr.read() # this prints correctly in both cases print "stdout:", pipe.stdout.re

Re: Subprocess with and without shell

2007-05-15 Thread George Sakkis
On May 15, 5:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> wrote: > > I'm trying to figure out why Popen captures the stderr of a specific > > command when it runs through the shell but not without it. IOW: > > &

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread George Sakkis
to it. Accepting this PEP would upset lots of people as it seems, and it's interesting that quite a few are not even native english speakers. George -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread George Sakkis
es? No, and I would refuse to maintain code that did use them*. George * Unless I start teaching programming to preschoolers or something. -- http://mail.python.org/mailman/listinfo/python-list

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-20 Thread George Sakkis
ew datasets with the same or similar structure but it soon gets tiring. I had a similar task recently so I wrote a general and efficient (at least as far as pure python goes) row transformer that does the repetitive work. Below are some examples from an Ipython session; let me know if this might be

Re: Python assignment loop

2007-05-20 Thread George Sakkis
s does, lookup for "list comprehensions". By the way, I hope these were shortened examples and you're not actually using names such as 'Class' or 'ClassXYZ' in your actual code... George -- http://mail.python.org/mailman/listinfo/python-list

Parallel/distributed generator

2007-05-23 Thread George Sakkis
able to do something along the following lines: def iterprimes(start=1, end=None): # ... yield prime # rpc-related initialization ... rpc_proxy = some_rpc_lib(iterprimes, start=1e6, end=1e12) for prime in proxy: print prime Is there any module out there that does anything close to this

Re: Parallel/distributed generator

2007-05-23 Thread George Sakkis
On May 23, 2:11 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > I'm looking for any existing packages or ideas on how to implement the > > equivalent of a generator (in the Python sense, i.e. > >http://www.python.org/dev

Re: Parallel/distributed generator

2007-05-23 Thread George Sakkis
On May 23, 2:11 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > I'm looking for any existing packages or ideas on how to implement the > > equivalent of a generator (in the Python sense, i.e. > >http://www.python.org/dev

Re: Parallel/distributed generator

2007-05-23 Thread George Sakkis
On May 23, 3:35 pm, [EMAIL PROTECTED] wrote: > On May 23, 11:00 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > I'm looking for any existing packages or ideas on how to implement the > > equivalent of a generator (in the Python sense, > > i.e.http:

Re: Parallel/distributed generator

2007-05-23 Thread George Sakkis
On May 23, 3:35 pm, [EMAIL PROTECTED] wrote: > On May 23, 11:00 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > I'm looking for any existing packages or ideas on how to implement the > > equivalent of a generator (in the Python sense, > > i.e.http:

Re: Parallel/distributed generator

2007-05-23 Thread George Sakkis
On May 23, 3:35 pm, [EMAIL PROTECTED] wrote: > On May 23, 11:00 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > I'm looking for any existing packages or ideas on how to implement the > > equivalent of a generator (in the Python sense, > > i.e.http:

Re: Parallel/distributed generator

2007-05-23 Thread George Sakkis
On May 23, 3:35 pm, [EMAIL PROTECTED] wrote: > On May 23, 11:00 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > I'm looking for any existing packages or ideas on how to implement the > > equivalent of a generator (in the Python sense, > > i.e.http:

Re: Parallel/distributed generator

2007-05-23 Thread George Sakkis
On May 23, 4:22 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On May 23, 2:58 pm, [EMAIL PROTECTED] wrote: > > > > > On May 23, 11:00 am, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > I'm looking for any existing packages or ideas on how to implem

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread George Sakkis
other way? > > W Yes; check out the following: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502243 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698 George -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Struggling again 'map'

2007-05-26 Thread George Sakkis
eld next() except StopIteration: num_left[0] -= 1 nextfuncs[i] = next = repeat(default).next yield next() while True: t = tuple(iter_next_tuple_values()) if not num_left[0]: break yield t # example lista = [

Storing tracebacks

2007-05-28 Thread George Sakkis
ssedRequestError() class UnprocessedRequestError(RuntimeError): pass So far it seems it works as expected but I'd like to know if this is error-prone and why. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing tracebacks

2007-05-29 Thread George Sakkis
On May 29, 9:46 am, [EMAIL PROTECTED] wrote: > On May 28, 10:46 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > I'm reading the docs on sys.exc_info() but I can't tell for sure > > whether I'm using it safely to get a snapshot of an exceptio

Re: Storing tracebacks

2007-05-29 Thread George Sakkis
On May 29, 1:21 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 29 May 2007 13:51:09 -0300, George Sakkis > <[EMAIL PROTECTED]> escribió: > > > The traceback module is handy if you want a text representation of the > > traceback, not the a

setting environment from shell file in python

2007-05-29 Thread George Trojan
xists... George -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools.groupby

2007-05-29 Thread George Sakkis
roupby(x, key=lambda div: div%n), [[] for _ in xrange(n)]) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Rats! vararg assignments don't work

2007-05-29 Thread George Sakkis
t suggested, > it isn't likely to be implemented. The first step would be to write a > PEP though. The time machine did it again: http://www.python.org/dev/peps/pep-3132/. George -- http://mail.python.org/mailman/listinfo/python-list

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

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

Re: is_iterable function.

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

Re: is_iterable function.

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

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

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

Re: first, second, etc line of text file

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

Re: SQLObject 0.7.8

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

Re: Important Research Project

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

Re: Python is overtaking Perl

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

Re: SSL Issue

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

Re: Sip4.7

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

Re: Passing a tuple to a function as multiple arguments

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

Re: Text processing and file creation

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

Re: Speed of Python

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

Py2.5.1 on Ubuntu AMD X2, unicode problems

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

Re: Python Database Apps

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

Re: Descriptor/Decorator challenge

2007-03-05 Thread George Sakkis
self.m() > > m = B() > m.am() # prints 'A.m' > m.bm() # prints 'B.m' > > - > > P.S. Here's a link to the descriptor how-to: >http://users.rcn.com/python/download/Descriptor.htm What would the semantics be if m is decorated as local only in A or only in B ? George -- http://mail.python.org/mailman/listinfo/python-list

Debugging segmentation faults

2007-03-07 Thread George Sakkis
I have a pure python program (no C extensions) that occasionally core dumps in a non-reproducible way. The program is started by a (non- python) cgi script when a form is submitted. It involves running a bunch of other programs through subprocess in multiple threads and writing its output in severa

Re: Bug in python!? persistent value of an optional parameter in function!

2007-03-07 Thread George Sakkis
table values from defaults. The fact that an object is mutable doesn't mean that the function will try to mutate it: def paintWall(ind, colormap={1:'red', 2:'blue', 5:'green'}): print "Let's paint the wall %s" % colormap[ind] George -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in python!? persistent value of an optional parameter in function!

2007-03-07 Thread George Sakkis
be the worst of both worlds. The main alternative to the > present behavior is re-computing the default value every time the > function is entered. One can do this is today's Python if he's so inclined, albeit with a more verbose syntax: http://aspn.activestate.com/ASP

Re: Debugging segmentation faults

2007-03-07 Thread George Sakkis
ial problem in general, but in my case every thread is exclusively responsible for the subprocesses it forks; no subprocess is inherited from the main thread or is shared in among the worker threads. George -- http://mail.python.org/mailman/listinfo/python-list

Automagically log changes in table

2007-03-17 Thread George Sakkis
;modified_by", and every write operation on it would automatically record the time and the id of the user who did the addition or change (I'm not sure how to deal with deletions let's leave this for now). Has anyone done something like that or knows where to start from ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: Automagically log changes in table

2007-03-17 Thread George Sakkis
This information is part of the context (e.g. an http request), not stored persistently somewhere. It should be doable at the framework/orm level but I'm rather green on Turbogears/SQLAlchemy. George -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension help

2007-03-18 Thread George Sakkis
ne reverse: > > first_word = line.split(' ', 1)[0] > last_word = line.rsplit(' ', 1][-1] > db[first_word] = last_word I'd guess the following is in theory faster, though it might not make a measurable difference: first_word = line[:line.i

Re: list comprehension help

2007-03-18 Thread George Sakkis
RAM boxes and setting a big buffer (1GB or more) reduces the wall time by 30 to 50% compared to the default value. BerkeleyDB should have a buffering option too, make sure you use it and don't synchronize on every line. Best, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Help in Placing Object in Memory

2007-03-27 Thread Harry George
o python script share a common object? > For the CPU to use the object, it needs to be in RAM. But it is possible to save the RAM image onto disk, and then bring it back later. The common approach is called "pickling", though there are several variants on this: http://docs.pyth

Re: Numeric Soup

2007-03-28 Thread Harry George
and numarray. > scipy > > provides a bunch of computational routines (linear algebra, optimization, > > statistics, signal processing, etc.) built on top of numpy. > > Thank you. > > Also see gsl and its python binding. http://www.gnu.org/software/gsl/ http://

Re: is laziness a programer's virtue?

2007-04-17 Thread George Neuner
ably impossible. > >Perhaps somebody could ask the chinese government to put him in jail >for "hurting international society" :) That's going to be tough because, according to his web page, he's living in a Honda Civic somewhere in Illinois, USA. http://xahlee.org/PageTw

Re: Python 3K or Python 2.9?

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

Re: simple regular expression problem

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

Re: Extracting xml from html

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

frange() question

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

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

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

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

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

Re: Getting rid of bitwise operators in Python 3?

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

Re: Factory function with keyword arguments

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

Re: ValueError: too many values to unpack

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

Re: Python 3.0 migration plans?

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

Re: Python 3.0 migration plans?

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

Re: question about for cycle

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

Re: Program inefficiency?

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

Re: Can you please give me some advice?

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

Re: Can you please give me some advice?

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

Re: Using fractions instead of floats

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

Re: The Modernization of Emacs: terminology buffer and keybinding

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

Re: The Modernization of Emacs: terminology buffer and keybinding

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

Re: Combine two dictionary...

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

Re: The Modernization of Emacs: terminology buffer and keybinding

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

Re: spam kontrol

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

Re: Class design question

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

Re: Class design question

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

Re: The Modernization of Emacs: terminology buffer and keybinding

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

Re: racism kontrol

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

Re: The Modernization of Emacs: terminology buffer and keybinding

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

Re: Problem of Readability of Python

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

Re: property question

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

Re: The fundamental concept of continuations

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

Re: Fwd: NUCULAR fielded text searchable indexing

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

Re: for loop question

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

Re: Keeping track of subclasses and instances?

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

Re: The fundamental concept of continuations

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

Re: Declarative properties

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

Re: 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: Top 10 Caribbean island destinations

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

Re: decorating container types (Python 2.4)

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

Re: Declarative properties

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

[Pyro] ConnectionClosedError

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

Re: 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
re I am guessing... I don't create explicitly any thread in my server code but Pyro itself is multithreaded. Unfortunately I don't have the resources to start digging in Pyro's internals.. George -- http://mail.python.org/mailman/listinfo/python-list

Re: The fundamental concept of continuations

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

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

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

Re: groupby() seems slow

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

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

Re: Noob questions about Python

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

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