Re: Mathematica 7 compares to other languages

2008-12-10 Thread Stef Mientki
On 12/10/08, Xah Lee <[EMAIL PROTECTED]> wrote:
> On Dec 8, 5:25 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
>> Lest anyone doubt that problem size is important for comparing program
>> run times, consider ...
>
> just in case there's any doubt:
>
> Simply change these lines in Jon's program:
>
> Main[9, 512, 4] to Main[9, 512, 4.]
>
> and it will run faster.
>
Who said Mathematica was a high level language ?
cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to get a beep, OS independent ?

2008-12-10 Thread Duncan Booth
Grant Edwards <[EMAIL PROTECTED]> wrote:

> On 2008-12-09, greg <[EMAIL PROTECTED]> wrote:
>> Duncan Booth wrote:
>>
>>> If I'm logged in to one of my servers in a large datacentre
>>> then I don't what that system to beep as that would be pretty
>>> useless.
>>
>> It also might cause the datacentre operators some
>> consternation when one of their servers starts mysteriously
>> beeping...
> 
> If they can hear it.  Those tiny fans they put in rack-mount
> stuff are awfully loud.
> 

http://www.thinkgeek.com/gadgets/electronic/8c52/


-- 
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: memory leak?

2008-12-10 Thread Gabriel Rossetti

Terry Reedy wrote:

Gabriel Rossetti wrote:


I ran these tests on linux 2.6 (ubuntu 8.04) using python 2.5.2.


Have you tried the much newer 2.6?  2.5.3 will be out soon with some 
bug fixes.


Thanks for the reply Terry, I just tried the pyserial example with 
python 2.6 and it still has the same problem, here's the output (I just 
copy/pasted the example in a running python2.6 interactive interpreter) :


test1 at 09:19am :

$ ps waux | grep python2.6
1000  6730  0.2  0.4   6176  4120 pts/12   S+   09:17   0:00 python2.6

if I try the SIGUSR1 method :
$ kill -SIGUSR1 6730


# DEBUG: The object count is : 12536


test2 at 09:25am :

$ ps waux | grep python2.6
1000  6730  0.0  0.9  12360 10168 pts/12   S+   09:17   0:00 python2.6

and the SIGUSR1 method gives me :


# DEBUG: The object count is : 25089



I also tried freeing the received string (del t) explicitly but the 
results are unchanged.


Thank you,
Gabriel
--
http://mail.python.org/mailman/listinfo/python-list


Curses Blank Background

2008-12-10 Thread Damian Johnson
Does anyone know how to instruct the Python curses bindings to leave the
background alone (use the default terminal background)? I'm interested in
keeping my semi-transparent background which curses can't replicate. This
question was raised on this list before (
http://mail.python.org/pipermail/python-list/2001-July/094581.html) but it
never got a reply. From the ncurses man page it looks like this
functionality would be mapped to -1 but the Python curses module uses -1 for
ERR. I'm new to curses so my apologies if I'm missing something obvious.
Cheers! -Damian
--
http://mail.python.org/mailman/listinfo/python-list


filter iterable based on predicate take from another iterable

2008-12-10 Thread [EMAIL PROTECTED]
Hi,

is there is a neat way to select items from an iterable based on
predicates stored in another iterable without zipping? I can do
something like this:

import itertools
foo = range(10)
# select even numbers
bar = map(lambda i: i%2, foo)
foobarselected = itertools.ifilterfalse(lambda t: t[0], itertools.izip
(bar,foo))
# for simplicity I want to work with the single item list, not the
zipped one
fooselected = list(t[1] for t in foobarselected)

However, it would be nice to have a function combining the last two
instructions. Something like
itertools.ifilterother(bar, foo) -> yield iterator with items from foo
where bar is true

Thanks! Bernhard
--
http://mail.python.org/mailman/listinfo/python-list


Re: filter iterable based on predicate take from another iterable

2008-12-10 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> is there is a neat way to select items from an iterable based on
> predicates stored in another iterable without zipping? I can do
> something like this:
> 
> import itertools
> foo = range(10)
> # select even numbers
> bar = map(lambda i: i%2, foo)
> foobarselected = itertools.ifilterfalse(lambda t: t[0], itertools.izip
> (bar,foo))
> # for simplicity I want to work with the single item list, not the
> zipped one
> fooselected = list(t[1] for t in foobarselected)
> 
> However, it would be nice to have a function combining the last two
> instructions. Something like
> itertools.ifilterother(bar, foo) -> yield iterator with items from foo
> where bar is true

I think it's a good approach to keep the number of primitives low. I find
the list comprehension combined with izip() quite readable:

[v for f, v in izip(bar, foo) if not f(v)]

Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: memory leak?

2008-12-10 Thread Gabriel Rossetti

Gabriel Rossetti wrote:

Terry Reedy wrote:

Gabriel Rossetti wrote:


I ran these tests on linux 2.6 (ubuntu 8.04) using python 2.5.2.


Have you tried the much newer 2.6?  2.5.3 will be out soon with some 
bug fixes.


Thanks for the reply Terry, I just tried the pyserial example with 
python 2.6 and it still has the same problem, here's the output (I 
just copy/pasted the example in a running python2.6 interactive 
interpreter) :


test1 at 09:19am :

$ ps waux | grep python2.6
1000  6730  0.2  0.4   6176  4120 pts/12   S+   09:17   0:00 
python2.6


if I try the SIGUSR1 method :
$ kill -SIGUSR1 6730


# DEBUG: The object count is : 12536


test2 at 09:25am :

$ ps waux | grep python2.6
1000  6730  0.0  0.9  12360 10168 pts/12   S+   09:17   0:00 
python2.6


and the SIGUSR1 method gives me :


# DEBUG: The object count is : 25089



I also tried freeing the received string (del t) explicitly but the 
results are unchanged.


Thank you,
Gabriel

Apparently the memory goes up when I use the SIGUSR1 code, If I don't 
call it, it seams to work fine, my original memory leak must come from 
somewhere else then. sorry for the spam.


Gabriel
--
http://mail.python.org/mailman/listinfo/python-list


Re: Mathematica 7 compares to other languages

2008-12-10 Thread Jon Harrop
Stef Mientki wrote:
> Who said Mathematica was a high level language ?

Xah is using what he calls "highlevelness" as an excuse for poor
performance.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u
--
http://mail.python.org/mailman/listinfo/python-list


Re: Announcement: MindTree for Python beta -- feedback appreciated

2008-12-10 Thread greg

Johann Spies wrote:

 % /usr/local/bin/python3.0 MindTree.pyw 
Traceback (most recent call last):

  File "MindTree.pyw", line 2, in 
from future_builtins import *
ImportError: No module named future_builtins


Hmmm... does this mean that Python3 has no future? :-)

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to report progress at fixed intervals

2008-12-10 Thread eric
Don't mind if I give my shot ?

def work(i):
"""
Dummy process function, which takes a random time in the interval
0.0-0.5 secs to execute
"""
print "Work step %d" % i
time.sleep(0.5 * random.random())

def workAll(work, verbose=True, max_iter=20, progress_interval=1.0):
'''
pass the real job as a callable
'''
progress = time.time()
for i in range(max_iter): # do the requested loop
work(i)
if verbose:
print "Work through all %d steps reporting progress every
%3.1f secs..." %(max_iter, progress_interval)
interval = time.time()-progress
if interval>progress_interval:
print "Processed %d of %d at pace %s" % (i, max_iter,
interval)
progress +=interval


if __name__=="__main__":
workAll(work, False)


It's works fine, and the "pace" is 'almost' the required one. You earn
a no-thread-mess, and cleaner alg.

But the loop is controlled by the caller (the WorkAll function) this
is also called ass-backward algorithm, and you cannot expect
algorithms to be assbackward (even if it's the best way to implement
them).

You can use the yield statement, to turn  easilly your alg into a
nice, stopable assbackward algo:

def work():
"""
Dummy process function, which takes a random time in the interval
0.0-0.5 secs to execute
"""
for i in range(50):
print "Work step %d" % i
time.sleep(0.5 * random.random())
yield i # kind-of "publish it and let the caller do whatever
it want s (good practice anyway)


def workAll(work, verbose=True, max_iter=20, progress_interval=1.0):
'''
pass the real job as a generator
'''
progress = time.time()
i = 0
for w in work: # do the requested loop
if verbose:
print "Work through all %d steps reporting progress every
%3.1f secs..." %(max_iter, progress_interval)
interval = time.time()-progress
if interval>progress_interval:
print "Processed %d at pace %s" % (w, interval)
progress +=interval
if i>=max_iter:
work.close()
i+=1


if __name__=="__main__":
workAll(work(), False) # note the calling difference


hope it helps.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to report progress at fixed intervals

2008-12-10 Thread Slaunger
On 10 Dec., 12:08, eric <[EMAIL PROTECTED]> wrote:
> Don't mind if I give my shot ?
>
> def work(i):
>     """
>     Dummy process function, which takes a random time in the interval
>     0.0-0.5 secs to execute
>     """
>     print "Work step %d" % i
>     time.sleep(0.5 * random.random())
>
> def workAll(work, verbose=True, max_iter=20, progress_interval=1.0):
>     '''
>     pass the real job as a callable
>     '''
>     progress = time.time()
>     for i in range(max_iter): # do the requested loop
>         work(i)
>         if verbose:
>             print "Work through all %d steps reporting progress every
> %3.1f secs..." %(max_iter, progress_interval)
>         interval = time.time()-progress
>         if interval>progress_interval:
>             print "Processed %d of %d at pace %s" % (i, max_iter,
> interval)
>             progress +=interval
>
> if __name__=="__main__":
>     workAll(work, False)
>
> It's works fine, and the "pace" is 'almost' the required one. You earn
> a no-thread-mess, and cleaner alg.
>
> But the loop is controlled by the caller (the WorkAll function) this
> is also called ass-backward algorithm, and you cannot expect
> algorithms to be assbackward (even if it's the best way to implement
> them).
>
> You can use the yield statement, to turn  easilly your alg into a
> nice, stopable assbackward algo:
>
> def work():
>     """
>     Dummy process function, which takes a random time in the interval
>     0.0-0.5 secs to execute
>     """
>     for i in range(50):
>         print "Work step %d" % i
>         time.sleep(0.5 * random.random())
>         yield i # kind-of "publish it and let the caller do whatever
> it want s (good practice anyway)
>
> def workAll(work, verbose=True, max_iter=20, progress_interval=1.0):
>     '''
>     pass the real job as a generator
>     '''
>     progress = time.time()
>     i = 0
>     for w in work: # do the requested loop
>         if verbose:
>             print "Work through all %d steps reporting progress every
> %3.1f secs..." %(max_iter, progress_interval)
>         interval = time.time()-progress
>         if interval>progress_interval:
>             print "Processed %d at pace %s" % (w, interval)
>             progress +=interval
>         if i>=max_iter:
>             work.close()
>         i+=1
>
> if __name__=="__main__":
>     workAll(work(), False)     # note the calling difference
>
> hope it helps.

Hi eric,

No, I certainly don't mind you giving a try ;-)

I actually started out doing something like your first version here,
but I am a little annoyed by the fact that the progress report
interval is not a sure thing. For instance in my real applications, I
have seldomly occuring work steps, which may take significantly longer
than the progress_interval, and I'd like to let it keep reporting
that, oh, I am still woking, albeit on the same work step, to maintain
a sense of the script being alive.

I like you generator approach though.

Anyway, I have now given my own proposal another iteration based on
what I have seen here (and my personal preferences), and I have come
up with this:

 src ===
"""
Test module for testing generic ways of displaying progress
information
at regular intervals.
"""
import random
import threading
import time

def work(i):
"""
Dummy process function, which takes a random time in the interval
0.0-0.5 secs to execute
"""
print "Work step %d" % i
time.sleep(0.5 * random.random())


def workAll(verbose=True, max_iter=20, progress_interval=1.0):

class ProgressReporter(threading.Thread):

def __init__(self):
threading.Thread.__init__(self)
self.setDaemon(True)
self.i = 0
self.max = max_iter
self.start_timer = verbose
self.progress_interval = progress_interval

def run(self):
while self.start_timer:
print "Processed %d of %d." % (self.i + 1, self.max)
time.sleep(self.progress_interval)

p = ProgressReporter()

if verbose:
print "Work through all %d steps reporting every %3.1f
secs..." % \
(max_iter, progress_interval)
p.start()

for i in xrange(max_iter):
work(i)
p.i = i

if verbose:
print "Finished working through %d steps" % max_iter

if __name__ == "__main__":
workAll()

= end src 

I like this much better than my own first attempt in my initial post
on this thread.

-- Slaunger

--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread Paul Boddie
On 10 Des, 00:00, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
>
> Go right ahead. Write your experimental language, and if people like it,
> they'll use it. That's what Guido did, all those years ago. But don't
> turn Python into a hodgepodge of "features" that most people consider
> misfeatures.

If you consult the public record, you'll see that I'm probably more
conservative than most when it comes to adding features. Indeed, one
of the principal benefits I see in Python 3.0 is that the hordes of
people wanting to add new stuff to Python will now focus on that
flavour of the language and not Python 2.x. However, as I pointed out
in another message, keyword conflicts have been a problem for the
language designers for some time, and more powerful parser technology
might have been able to help out.

[...]

> I think it is childish to reject the Zen just because it's the Zen. Good
> advice doesn't cease to be good advice just because people tell you it's
> good advice, even if some people are awfully strident about it.

I object to the Zen being trotted out every time someone questions any
aspect of Python's design (language or implementation) which isn't
being reworked elsewhere (say, in Python 3, where apparently the Zen
can be suspended), especially when the parts of the Zen being quoted
lack pertinence when compared to a properly formulated response to the
original inquiry.

Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: Mathematica 7 compares to other languages

2008-12-10 Thread Almar Klein
2008/12/10 Xah Lee <[EMAIL PROTECTED]>

> Jon Harrop moron wrote:
> > Only for trivial input and not for the challenge you were given.
>
> what challenge?
>
> > That code is evaluated once to build the scene. There is no point in
> > optimizing it.
>
> The point is optimizing your incompetence.
>
> > That performance issue only affects trivial problems and, in particular,
> > does not affect the problem you were trying to solve.
>
> solve your mom?
>
>
What challange? Euhm, I think that was pretty clear.
And you're constantly insulting people, not responding to their arguments.
Not a particularly nice way to behave in a news group such as this.

>Also, all you did is talking bullshit.
>You, kept on babbling.
I think YOU are the one who is talking crap here. You are too afraid to
admid
you failed the challange (probably because you think so high of yourself).
You
try to cover it with crap and insults.

Cheers,
  Almar
--
http://mail.python.org/mailman/listinfo/python-list


Using the `email' module in a bazaar plugin

2008-12-10 Thread Julian Smith
I don't seem to be able to use the `email' module from within a bazaar
plugin. Other modules work ok, e.g. nntplib.

Here's my plugin, cut-down to show just the email problem:

  import sys
  print 'sys.version', sys.version

  import nntplib
  n = nntplib.NNTP( 'jsmith-ubuntu2' )
  print n

  import email
  m=email.MIMEText.MIMEText('text of email')

- and here's the output when i run any bazaar command:

  > bzr status
  sys.version 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
  [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]
  
  'module' object has no attribute 'MIMEText'
  Unable to load plugin 'js_notify' from '/home/jsmith/.bazaar/plugins'
  ...

The plugin runs fine on its own, it's only when loaded into Bazaar that things
go wrong.

I thought perhaps this could be caused by the `email' module's use of
LazyImporter. I've tried various things such as `from email.mime.text import
MIMEText', and they fail in similar ways.

I'm using bzr-1.9, python 2.5.2, on Ubuntu-8.xx.

Does anyone have any ideas ?

Thanks,

- Julian

-- 
http://op59.net/
--
http://mail.python.org/mailman/listinfo/python-list


Re: StringIO in 2.6 and beyond

2008-12-10 Thread Bill McClain
On 2008-12-10, ajaksu <[EMAIL PROTECTED]> wrote:
> On Dec 9, 5:24 pm, Bill McClain <[EMAIL PROTECTED]>
> wrote:
> > On 2008-12-09, MRAB <[EMAIL PROTECTED]> wrote:
> >
> > > In Python 2.x unmarked string literals are bytestrings. In Python 3.x
> > > they're Unicode. The intention is to make the transition from 2.x to 3.x
> > > easier by adding some features of 3.x to 2.x, but without breaking
> > > backwards compatibility (not entirely successfully!).
> >
> > It is a bit ugly. In 2.6 StringIO won't take bytestrings, so I apply u'x'. 
> > But
> > in 3.0 u'x' will be gone and I'll have to change the code again.

> Try:

> from __future__ import unicode_literals

That works for:

output.write('First line.\n')

...but not for:

   print('Second line.', file=output)

Maybe a combination of this and functools.partial as was suggested before. At
least the necessary edits would be at the top of the program.

-Bill
-- 
Sattre Press  Tales of War
http://sattre-press.com/   by Lord Dunsany
[EMAIL PROTECTED] http://sattre-press.com/tow.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Google Groups in bad odour

2008-12-10 Thread Steven D'Aprano
On Wed, 10 Dec 2008 02:20:24 -0800, Frank Millman wrote:

> Unfortunately it seems that their newsgroup does not have a mail
> gateway, so I cannot use gmane. (Please correct me if I am wrong). I
> will therefore have to find a suitable news client. Any recommendations?

Pan and KNode.


-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


[OT] Google Groups in bad odour

2008-12-10 Thread Frank Millman
Hi all

I know there have been complaints about spam on Google Groups over the
last few months, with some members rejecting all traffic from them.

You might be interested in this comment I got in a reply from someone
on comp.os.linux.setup -

"If you want to be read by a wider audience, you really want to post
from
someplace other than Google Groups.  Many (most?) readers of the
Linux
lists kill everything from there automatically."

Unfortunately it seems that their newsgroup does not have a mail
gateway, so I cannot use gmane. (Please correct me if I am wrong). I
will therefore have to find a suitable news client. Any
recommendations?

Frank Millman
--
http://mail.python.org/mailman/listinfo/python-list


Re: Don't you just love writing this sort of thing :)

2008-12-10 Thread Tim Rowe
2008/12/9 Ethan Furman <[EMAIL PROTECTED]>:

> Not all code has to be written for everyone.  Not all code will be read by
> the masses.  Some code you write for yourself... an expression of who you
> are, how you think...
>
> While my own quirks are not as visually entertaining, I think it's another
> mark in Python's favor that such self-expression is possible, and
> functional.
>
> Yes, Lawrence, I do love writing fun code.

I did once get into a rivalry with a Perl programmer over
obfusticating a coding exercise. I knew from the start that I had no
chance, but I was impressed with how close-run I could make it with
Python. Fun, yes, but no way anything I would consider for code that
is actually going to be /used/ in any way whatsoever!


-- 
Tim Rowe
--
http://mail.python.org/mailman/listinfo/python-list


Re: forcing future re-import from with an imported module

2008-12-10 Thread Gabriel Genellina
En Tue, 09 Dec 2008 23:27:10 -0200, _wolf <[EMAIL PROTECTED]>  
escribió:



how can i say, approximately, "re-import the present module when it is
imported the next time, don’t use the cache" in a simple way? i do not
want to "reload" the module, that doesn’t help.


I'd say you're using modules the wrong way then. The code inside a module  
is executed *once*, and that's by design. If you want to execute something  
more than once, put that code inside a function, and call it as many times  
as you want.


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-10 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

> On Dec 9, 10:04 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote:
>> So, why do you think apt and not setuptools is The Right Way(tm)?
> 
> I like to keep > 1 Python on my computer.
> 
> 1. First, there's the system Python, which is installed by my OS and
> which I try not to mess with too much. I'm guessing Ubuntu uses this
> Python for various system jobs, preferences apps, etc. I try to only
> use apt with *this* Python.


Start using virtualenv. You need to install that single package, and you can
create as many python-instances (derived of your system's python of course)
that you like. And inside these, mess around with setuptools as much as you
like.
 
> 2. Then there's my *own* Python. Maybe installed in ``/opt/py-i.j.k,
> or---more likely---``~/opt/py-i.j.k``. *This* is the one where I've
> previously made regular use of setuptools and ``easy_install``. If I
> break this one somehow, it doesn't foul up my system Python in any
> way, and it's easy to scrap it and start anew if I like.
> 
> So, I'd like to get my *system* Python back to its "fresh out of the
> Ubuntu showroom" condition and remove *that* setuptools.
> 
> As an aside, I'm a bit struck by how long the setuptools/easy_install
> manuals are, and a bit dismayed at the lack of an easy_install
> uninstall command. Thinking of trying life for a while without
> setuptools/easy_install. Will have to see how far I get. :)

To *long* manuals? So far I haven't heard that complaint in the FOSS
world...

Diez

Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread Paul Boddie
On 9 Des, 19:23, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
>
> So hold up a second. I'm out of line for calling someone on making a
> trollish post that's not relevant to the topic, and for being pretty
> late to the party even with the part that *was* on topic, and for
> (even in the original post) going the ad-hominem route by not so
> subtly implying that Python is an ivory tower language that's not good

I believe the term was "ivory-tower thinking".

> enough for people with real problems - a clearly false statement by
> any standards, and doubly offensive from someone who *is* using it for
> real problems and who himself is a less than shining example of

You're wide of the mark now, since the complainant was referring to
motivations in the the design of the language, not the relevance of
the language outside academia (where it is also highly relevant, by
the way).

> responsible software management, but the OPs lapse into ranting in
> response to trite but accurate answers to a question he could have
> answered for himself, in detail, had he bothered to read the threads
> from the time when the issue actually matter is a reasonable response
> that we should support and validate?

Trite but accurate? References to the Zen of Python were trite and
peripheral at best, especially since the actual reasons (some actually
being offered, aside from "get used to it", which isn't a reason) are
mostly pragmatic. I think at that point, the complainant is justified
in questioning the priorities of the core developers, even though he
knows that there's no recourse at this point. The most you can blame
him for in that respect is not starting a new thread about those
topics, and it's not as if he's the first to air his grievances about
those things, is it?

> Sometimes you're not  a crusader for thinking differently and change
> by confrontation and speaking truth to power. Sometimes you're just an
> asshole.

I think you managed to enter this thread without revealing any
particular insight in the matter, so I suppose name-calling was the
most we could expect from you at this point.

> For clarification: The OPs original complaint is legitimate, if dated
> and partially his own fault. His phrasing of the problem, the tone and
> content of his email, and his lapse into flaming when he wasn't
> immediately hailed as a herald of sanity is not legitimate.

If people would confine themselves to the matters under discussion
without taking an adversarial position - after all, it's not as if the
guy just dropped in to flame everyone having never used Python - there
wouldn't be any need for anyone to lapse into flaming, tantrums or
name-calling, would there? You wouldn't even need to apologise for
calling the guy a troll, now, would you?

Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: pickling a circular object inherited from list

2008-12-10 Thread Klaus Kopec

Ned Deily wrote:

In article <[EMAIL PROTECTED]>,
 Klaus Kopec <[EMAIL PROTECTED]> wrote:

What did I do wrong?

Old Python version? :)
Seems to work in 3.0 (don't have 2.6 currently to check but IMO it's
fixed there as well).
It works for me with v3.0 as well, but not with v2.6.1 (same error as 
stated before for v2.4).


Is there any way to fix this in v2.6.1 or even v2.4? Right now I cannot 
switch to v3.0 because I depend on several not compatible packages 
(numpy, biopython, ...)


It looks like your example can be made to work by either specifying 
pickle protocol 2 or by switching to cPickle.




Using pickle protocol 2 solved the problem. Thank you all for helping me 
out!


--
http://mail.python.org/mailman/listinfo/python-list


Re: Using the `email' module in a bazaar plugin

2008-12-10 Thread Matt Nordhoff
Julian Smith wrote:
> I don't seem to be able to use the `email' module from within a bazaar
> plugin. Other modules work ok, e.g. nntplib.
> 
> Here's my plugin, cut-down to show just the email problem:
> 
>   import sys
>   print 'sys.version', sys.version
> 
>   import nntplib
>   n = nntplib.NNTP( 'jsmith-ubuntu2' )
>   print n
> 
>   import email
>   m=email.MIMEText.MIMEText('text of email')
> 
> - and here's the output when i run any bazaar command:
> 
>   > bzr status
>   sys.version 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
>   [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]
>   
>   'module' object has no attribute 'MIMEText'
>   Unable to load plugin 'js_notify' from '/home/jsmith/.bazaar/plugins'
>   ...
> 
> The plugin runs fine on its own, it's only when loaded into Bazaar that things
> go wrong.
> 
> I thought perhaps this could be caused by the `email' module's use of
> LazyImporter. I've tried various things such as `from email.mime.text import
> MIMEText', and they fail in similar ways.
> 
> I'm using bzr-1.9, python 2.5.2, on Ubuntu-8.xx.
> 
> Does anyone have any ideas ?
> 
> Thanks,
> 
> - Julian

The built-in email module is probably getting shadowed by another one
(perhaps bzrlib.plugins.email?), so "import email" is importing the
wrong module. You'll have to rename it to something else.

Have your plugin print email.__path__ to see which module it is.
-- 
--
http://mail.python.org/mailman/listinfo/python-list


Re: SequenceMatcher bug ?

2008-12-10 Thread rdmurray

On Tue, 9 Dec 2008 at 22:15, eliben wrote:

On Dec 10, 4:12?am, [EMAIL PROTECTED] wrote:

On Mon, 8 Dec 2008 at 23:46, eliben wrote:

This is about Python 2.5.2 - I don't know if there were fixes to this
module in 2.6/3.0



I think I ran into a bug with difflib.SequenceMatcherclass.
Specifically, its ratio() method. The following:



SequenceMatcher(None, [4] + [10] * 500 + [5], [10] * 500 + [5]).ratio
()



returns 0.0



While the same with 500 replaced by 100 returns .99... something
Looking at the code ofSequenceMatcherthere's some caching going on
when the sequences are longer than 200 elements (and indeed, I can
reproduce the bug above 200 but not below). Can anyone confirm that
this misbehaves and suggest a workaround ?


Python 2.5.2 (r252:60911, Sep 29 2008, 20:34:04)
[GCC 4.3.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>> from 
difflib importSequenceMatcher

SequenceMatcher(None, [4] + [10] * 500 + [5], [10] * 500 +
[5]).ratio()


0.99900299102691925



Strange. I could reproduce the problem both on ActiveState Python
2.5.2 for Windows, and in the online Try Python evaluator:

http://try-python.mired.org/


My system is Gentoo, which installs python from source.  Maybe gentoo
applies patches that the binary releases don't have.

--RDM--
http://mail.python.org/mailman/listinfo/python-list


Flushing PyQt's Event Queue

2008-12-10 Thread ff
Hi, I am writing an app which models growth of a system over time
visually which is activated by button clicks, and when the loop
finishes running i dont want any events [mainly clicking on buttons]
that happened during the loop to be put into action since then it may
run multiple times without the user realising what they have done,

is there way to flush the event queue when the loop has finished??

ff
--
http://mail.python.org/mailman/listinfo/python-list


Re: getting error...... Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 370, in open_workbook biff_version = bk.getb

2008-12-10 Thread JodyGnumeric
On Dec 8, 9:02 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Dec 9, 12:19 pm, JodyGnumeric <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Dec 8, 5:54 am, John Machin <[EMAIL PROTECTED]> wrote:
>
> > > On Dec 8, 6:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> > > > En Fri, 05 Dec 2008 02:31:01 -0200, pk sahoo <[EMAIL PROTECTED]>  
> > > > escribió:
>
> > > > > hallo everybody,
> > > > > when i am running the following command
>
> > > >  import xlrd
> > > >  book=xlrd.open_workbook("C:\\a.xls")
>
> > > > > i am getting the following error..
>
> > > > > *Traceback (most recent call last):
> > > > >   File "", line 1, in 
> > > > >   File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 370, in
> > > > > open_workb
> > > > > ook
> > > > >     biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
> > > > >   File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 1323, in
> > > > > getbof
> > > > >     raise XLRDError('Expected BOF record; found 0x%04x' % opcode)
> > > > > xlrd.biffh.XLRDError: Expected BOF record; found 0x3f3c*
>
> > > > Looks like your a.xls file is not an Excel file (one of the formats  
> > > > supported by xlrd).
> > > > As 0x3f3c corresponds to the characters ' > > > file.
>
> > > This can be verified easily by opening the file with a simple-minded
> > > text editor (e.g. Notepad) ... if the first two lines are
> > > """
> > > 
> > > 
> > > """
> > > then it's an Excel 2003 XML Spreadsheet that's been manually(?)
> > > renamed from .xml to .xls.
>
> > > The current xlrd release supports only the binary ("BIFF") format .xls
> > > files created by Excel 3.0 to Excel 2003. The next release (due out
> > > Real Soon Now) will support Excel 2.1 and 2.0 formats [don't ask].
> > > Very soon after that will come support for Excel 2007 .xlsx which is a
> > > bunch of XML files inside a ZIP file. Support for Excel 2003
> > > "SpreadsheetML" is way down the to-do list.
>
> > > If the OP wants to be able to read the file with xlrd:
> > > (1) Open it with Excel 200[37] and save as a .xls file
> > > or (2) rename it to .xml, start OpenOffice.org Calc, click on File,
> > > click on Open, click on "Files of type", choose "Microsoft Excel 2003
> > > XML (*.xml)" from the (long, unsorted) drop-down list, ..., and save
> > > as etc etc. Gnumeric is not an option.
>
> > > HTH,
> > > John
>
> > Gnumeric can read this format. 'MS Excel (tm) 2003 SpreadsheetML'
>
> [Gnumeric 1.9.1 on Windows XP]
>
> I'm sorry; I thought I'd exhausted every possible way of trying to
> open it. After looking at the file open dialogue box again, I've
> spotted the "Advanced" button. Here is what you need to do:
>
> Have the file named whatever.xls. Click on File / Open , navigate to
> correct directory, click on Advanced, choose 'MS Excel (tm) 2003
> SpreadsheetML' from the File-type drop-down list, choose the file,
> click on OK. Anything else (Simple (non-Advanced), naming it
> whatever.xml, ...) produces no response, yes that's zero bits of
> information, not even a Bt! noise :-(
>
> *AND* when it does open up, a date cell defined by
>   
>    
>   
> ...
>  ss:Type="DateTime">1999-12-31T00:00:00.000
>
> is displayed as "00ort 31at1999" :-(

Please send the file to bugzilla.gnome.org it sounds like I need to
improve the probe function function for this format and add support
for the magic named formats.
--
http://mail.python.org/mailman/listinfo/python-list


Re: filter iterable based on predicate take from another iterable

2008-12-10 Thread James Stroud

Peter Otten wrote:

[EMAIL PROTECTED] wrote:


is there is a neat way to select items from an iterable based on
predicates stored in another iterable without zipping? I can do
something like this:

import itertools
foo = range(10)
# select even numbers
bar = map(lambda i: i%2, foo)
foobarselected = itertools.ifilterfalse(lambda t: t[0], itertools.izip
(bar,foo))
# for simplicity I want to work with the single item list, not the
zipped one
fooselected = list(t[1] for t in foobarselected)

However, it would be nice to have a function combining the last two
instructions. Something like
itertools.ifilterother(bar, foo) -> yield iterator with items from foo
where bar is true


I think it's a good approach to keep the number of primitives low. I find
the list comprehension combined with izip() quite readable:

[v for f, v in izip(bar, foo) if not f(v)]

Peter


If you want an iterator without requiring making a list, you can simply 
use parentheses instead of brackets:


agenerator = (v for f, v in izip(bar, foo) if not f(v))

This is perfectly lazy but not immune to problems when foo or bar is 
changed before the generator is fully consumed.


James



--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: StringIO in 2.6 and beyond

2008-12-10 Thread Jean-Paul Calderone

On 10 Dec 2008 11:58:37 GMT, Bill McClain <[EMAIL PROTECTED]> wrote:

On 2008-12-10, ajaksu <[EMAIL PROTECTED]> wrote:

On Dec 9, 5:24 pm, Bill McClain <[EMAIL PROTECTED]>
wrote:
> On 2008-12-09, MRAB <[EMAIL PROTECTED]> wrote:
>
> > In Python 2.x unmarked string literals are bytestrings. In Python 3.x
> > they're Unicode. The intention is to make the transition from 2.x to 3.x
> > easier by adding some features of 3.x to 2.x, but without breaking
> > backwards compatibility (not entirely successfully!).
>
> It is a bit ugly. In 2.6 StringIO won't take bytestrings, so I apply u'x'. But
> in 3.0 u'x' will be gone and I'll have to change the code again.



Try:



from __future__ import unicode_literals


That works for:

   output.write('First line.\n')

...but not for:

  print('Second line.', file=output)

Maybe a combination of this and functools.partial as was suggested before. At
least the necessary edits would be at the top of the program.


See http://bugs.python.org/issue4618, there's a comment with a workaround
for this problem.

Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using the `email' module in a bazaar plugin

2008-12-10 Thread Julian Smith
On Wed, 10 Dec 2008 12:13:28 +
Matt Nordhoff <[EMAIL PROTECTED]> wrote:

> Julian Smith wrote:
> > I don't seem to be able to use the `email' module from within a bazaar
> > plugin. Other modules work ok, e.g. nntplib.
> > 
> > Here's my plugin, cut-down to show just the email problem:
> > 
> >   import sys
> >   print 'sys.version', sys.version
> > 
> >   import nntplib
> >   n = nntplib.NNTP( 'jsmith-ubuntu2' )
> >   print n
> > 
> >   import email
> >   m=email.MIMEText.MIMEText('text of email')
> > 
> > - and here's the output when i run any bazaar command:
> > 
> >   > bzr status
> >   sys.version 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
> >   [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]
> >   
> >   'module' object has no attribute 'MIMEText'
> >   Unable to load plugin 'js_notify' from '/home/jsmith/.bazaar/plugins'
> >   ...
> > 
> > The plugin runs fine on its own, it's only when loaded into Bazaar that 
> > things
> > go wrong.
> > 
> > I thought perhaps this could be caused by the `email' module's use of
> > LazyImporter. I've tried various things such as `from email.mime.text import
> > MIMEText', and they fail in similar ways.
> > 
> > I'm using bzr-1.9, python 2.5.2, on Ubuntu-8.xx.
> > 
> > Does anyone have any ideas ?
> > 
> > Thanks,
> > 
> > - Julian
> 
> The built-in email module is probably getting shadowed by another one
> (perhaps bzrlib.plugins.email?), so "import email" is importing the
> wrong module. You'll have to rename it to something else.
> 
> Have your plugin print email.__path__ to see which module it is.

Ah, you're quite right.

Curiously, email.__path__ is:

  /usr/lib/python2.5/site-packages/bzrlib/plugins/email

- but sys.path is:

['/usr/bin', '/usr/lib/python25.zip', '/usr/lib/python2.5', 
'/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', 
'/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', 
'/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', 
'/usr/lib/python2.5/site-packages/PIL', 
'/usr/lib/python2.5/site-packages/gst-0.10', 
'/var/lib/python-support/python2.5', 
'/usr/lib/python2.5/site-packages/gtk-2.0', 
'/var/lib/python-support/python2.5/gtk-2.0']

- i.e. no occurrence of `/usr/lib/python2.5/site-packages/bzrlib/plugins'.

So i guess bazaar is redefining __import__() to look in the the plugins
directory first, or something.

Anyway, I can get things to work with the following:

  import imp
  email = imp.load_module( 'email', *imp.find_module( 'email', sys.path))

Many thanks,

- Julian

-- 
http://op59.net/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Announcement: MindTree for Python beta -- feedback appreciated

2008-12-10 Thread Marc 'BlackJack' Rintsch
On Wed, 10 Dec 2008 23:47:05 +1300, greg wrote:

> Johann Spies wrote:
> 
>>  % /usr/local/bin/python3.0 MindTree.pyw
>> Traceback (most recent call last):
>>   File "MindTree.pyw", line 2, in 
>> from future_builtins import *
>> ImportError: No module named future_builtins
> 
> Hmmm... does this mean that Python3 has no future? :-)

It is just not built in.  So it is easier to change the future by 
replacing the module.  ;-)

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-10 Thread David Cournapeau
On Wed, Dec 10, 2008 at 12:04 PM, Chris Rebert <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 6:49 PM,  <[EMAIL PROTECTED]> wrote:
>> On Ubuntu, I accidentally manually installed setuptools
>> http://pypi.python.org/pypi/setuptools/0.6c9 (by running the .egg file
>> as a shell script via sudo), and now realize I should just be using
>> apt to take care of my system Python packages.
>
> Really, why? setuptools has more Python packages/programs available
> and updates faster than Debian.
> It's also likely that some of the Debian Python packages are installed
> using setuptools anyway.
> So, why do you think apt and not setuptools is The Right Way(tm)?

Setuptools is certainly not the right way to install packages
system-wide on debian, it is very likely to break the whole thing.
dpkg is a real package installer, with uninstallation feature, correct
dependency handling: if you start installing things with setuptools
there, dpkg cannot know anymore how to manage your system. That's why
it is generally a very bad idea to install things which are not
managed by dpkg in /usr - be it python or something else BTW. It is a
much better practice to install from source into /usr/local, or your
$HOME, etc... Anywhere which is not /usr.

David
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is 3.0 worth breaking backward compatibility?

2008-12-10 Thread Lie Ryan
On Tue, 09 Dec 2008 17:25:59 -0500, Benjamin Kaplan wrote:

> On Tue, Dec 9, 2008 at 3:56 PM, Lie Ryan <[EMAIL PROTECTED]> wrote:
> 
>> On Sun, 07 Dec 2008 21:48:46 +, Tim Rowe wrote:
>>

>> >
>> > But that's what a major release number does for you. Modula2 was
>> > quite a break from Modula. Think of Python3.0 it as a new language,
>> > if you like, that's inspired by Python2. You can stay with Python2 or
>> > you can adopt the new language. That way you won't have to think of
>> > it in terms of breaking any sort of backwards compatibility because
>> > there is no backwards ;-)
>> >
>> > --
>> > Tim Rowe
>>
>> Actually I noticed a tendency from open-source projects to have slow
>> increment of version number, while proprietary projects usually have
>> big version numbers.
>>
>> Linux 2.x: 1991 Python 3.x.x: 1991. Apache 2.0: 1995. OpenOffice.org
>> 3.0: acquired by Sun at 1999. GIMP 2.x: 1995. Wine 1.x: 1993.
>>
>>
> Wine actually timed the 1.0 release to be at about t the 15th "birthday"
> of the project.

15 years is a very long time to get to version 1.0, many other (usually 
commercial or commercial-oriented front of a software) software release 
version 1.0 after 2-3 years of development, often shorter. wine has been 
used by a lot of people, not only a few internal developers and beta 
testers.

> 
>> Compare with
>> Windows: NT 3.1-NT 6.x: 1993. Visual Studio 97, 6.0, .NET, .NET 2003,
>> .NET 2005, 2008: 1997. Photoshop (11 versions to CS4): 1987. Microsoft
>> Office 3, 4, 95, 97, 2000, XP, 2003, 2007: 1990. Flash MX, 9, CS 1-4.
>> iTunes 8: 2001. RealPlayer 4-11: 1995. Macintosh 1.0-9: 1984-2001, X.5:
>> 2001. Winzip 12.0: early 1990s.
>>
>>
> Just to note: Office 2007 is also known as Office 12, if you want to
> look at version numbers. Also, Mac OS hasn't increased the major version
> number past 10 since they switched from their own proprietary kernel to
> using the open-source Darwin.
> 
> 
> 
>> Interestingly, many linux _distro_ also inhibit this quick version
>> number change. Fedora 10, Ubuntu is 2 years old, version 8 (they start
>> from version 6 not 1).
>>
>>
> That's because 8 isn't the verison number- it's the year the version was
> released (8.10 is October 2008, not the 10th update to version 8).

I know about that, but in my definition (and Wikipedia's), it is still 
the version number (maybe I forget to put a footnote). My point is that 
commercial software and commercial front of a free software (linux 
distros, Cedega 6.1) prefers having big version numbers.



--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread Rasmus Fogh

Rhamphoryncus wrote:
> You grossly overvalue using the "in" operator on lists.

Maybe. But there is more to it than just 'in'. If you do:
>>> c = numpy.zeros((2,))
>>> ll = [1, c, 3.]
then the following all throw errors:
3 in ll, 3 not in ll, ll.index(3), ll.count(3), ll.remove(3)
c in ll, c not in ll, ll.index(c), ll.count(c), ll.remove(c)

Note how the presence of c in the list makes it behave wrong for 3 as
well.

> It's far more
> common to use a dict or set for containment tests, due to O(1)
> performance rather than O(n).  I doubt the numpy array supports
> hashing, so an error for misuse is all you should expect.

Indeed it doees not. So there is not much to be gained from modifying
equality comparison with sets/dicts.

> In the rare case that you want to test for identity in a list, you can
> easily write your own function to do it upfront:

> def idcontains(seq, obj):
> for i in seq:
> if i is obj:
> return True
> return False

Again, you can code around any particular case (though wrappers look like
a more robust solution). Still, why not get rid of this wart, if we can
find a way?


---
Dr. Rasmus H. Fogh  Email: [EMAIL PROTECTED]
Dept. of Biochemistry, University of Cambridge,
80 Tennis Court Road, Cambridge CB2 1GA, UK. FAX (01223)766002
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread Rasmus Fogh

Rhodri James wrote:
> On Mon, 08 Dec 2008 14:24:59 -, Rasmus Fogh  wrote:

>> On the minus side there would be the difference between
>> '__equal__' and '__eq__' to confuse people.

> This is a very big minus.  It would be far better to spell __equal__ in
> such a way as to make it clear why it wasn't the same as __eq__,
> otherwise
> you end up with the confusion that the Perl "==" and "eq" operators
> regularly cause.

You are probably right, unfortunately. That proposal is unlikely to fly.
Do you think my latest proposal, raising BoolNotDefinedError, has better
chances?

---
Dr. Rasmus H. Fogh  Email: [EMAIL PROTECTED]
Dept. of Biochemistry, University of Cambridge,
80 Tennis Court Road, Cambridge CB2 1GA, UK. FAX (01223)766002
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread MRAB

Aaron Brady wrote:

On Dec 9, 12:40 pm, MRAB <[EMAIL PROTECTED]> wrote:

Aaron Brady wrote:

On Dec 9, 8:28 am, MRAB <[EMAIL PROTECTED]> wrote:
snip

In some languages (I think Delphi is one of them - it's been a while!)
some words which would normally be identifiers have a special meaning in
certain contexts, but the syntax precludes any ambiguity, and not in a
difficult way. "as" in Python was one of those.
I certainly wouldn't want something like PL/I, where "IF", "THEN" and
"ELSE" could be identifiers, so you could have code like:
 IF IF = THEN THEN
 THEN = ELSE;
 ELSE
 ELSE = IF;
Seehttp://en.wikipedia.org/wiki/PL/I_(programming_language).

snip
That is, 'certainly' doesn't change the meaning of your statement
any.  You wouldn't want it, but King George III didn't want the
American Revolution.

It's called emphasis.


I just take you to have meant, then, +1 on excluding keywords from
identifiers.  You said it the long way though, so I thought I missed
something deeper, that didn't come across.

IIRC, most computer languages have an LL(1) grammar, which means that 
when they are parsed you need to look at only the next word. If you're 
about to parse a statement and the next word is "IF" then you know it's 
an IF-statement, if it's an identifier then it's either a call or an 
assignment statement (OK, you don't know exactly what kind of statement 
it is at that point, but it works out just fine!).


In the example from PL/I, "IF" could be the start of an IF-statement "IF 
 THEN" or an assignment statement "IF = ". It's a 
bit more tricky for the parser as well as the programmer.


Life is easier if words having special meanings are reserved.

However, that doesn't mean that all special words /must/ be reserved 
(pragmatism beats purity). Sometimes the syntax makes it clear and 
unambiguous, so you can get away with not making it a reserved word. The 
word "as" in Python doesn't need to be reserved because the syntax 
precludes ambiguity, but it's the only such word in the language, so 
it's just tidier to make it reserved too.

--
http://mail.python.org/mailman/listinfo/python-list


Re: StringIO in 2.6 and beyond

2008-12-10 Thread pruebauno
On Dec 10, 6:58 am, Bill McClain
<[EMAIL PROTECTED]> wrote:
> On 2008-12-10, ajaksu <[EMAIL PROTECTED]> wrote:
>
> > On Dec 9, 5:24 pm, Bill McClain <[EMAIL PROTECTED]>
> > wrote:
> > > On 2008-12-09, MRAB <[EMAIL PROTECTED]> wrote:
>
> > > > In Python 2.x unmarked string literals are bytestrings. In Python 3.x
> > > > they're Unicode. The intention is to make the transition from 2.x to 3.x
> > > > easier by adding some features of 3.x to 2.x, but without breaking
> > > > backwards compatibility (not entirely successfully!).
>
> > > It is a bit ugly. In 2.6 StringIO won't take bytestrings, so I apply 
> > > u'x'. But
> > > in 3.0 u'x' will be gone and I'll have to change the code again.
> > Try:
> > from __future__ import unicode_literals
>
> That works for:
>
>     output.write('First line.\n')
>
> ...but not for:
>
>    print('Second line.', file=output)
>
> Maybe a combination of this and functools.partial as was suggested before. At
> least the necessary edits would be at the top of the program.
>
> -Bill
> --
> Sattre Press                                      Tales of 
> Warhttp://sattre-press.com/                      by Lord Dunsany
> [EMAIL PROTECTED]        http://sattre-press.com/tow.html

I think this combination might do the trick (I don't have 2.6 to test
it right now):

from __future__ import print_function
from __future__ import unicode_literals
from functools import partial
import io
print = partial(print, sep=" ", end="\n")
out = io.StringIO()
print("hello", file=out)

What puzzles me is the documentation in 2.6 and 3.0:
In 2.6 it says: "The StringIO object can accept either Unicode or 8-
bit strings". Why does it fail with old str objects then?
Why is there no documentation for StringIO in 3.0?
--
http://mail.python.org/mailman/listinfo/python-list


Re: StringIO in 2.6 and beyond

2008-12-10 Thread pruebauno
On Dec 10, 10:06 am, [EMAIL PROTECTED] wrote:
> On Dec 10, 6:58 am, Bill McClain
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > On 2008-12-10, ajaksu <[EMAIL PROTECTED]> wrote:
>
> > > On Dec 9, 5:24 pm, Bill McClain <[EMAIL PROTECTED]>
> > > wrote:
> > > > On 2008-12-09, MRAB <[EMAIL PROTECTED]> wrote:
>
> > > > > In Python 2.x unmarked string literals are bytestrings. In Python 3.x
> > > > > they're Unicode. The intention is to make the transition from 2.x to 
> > > > > 3.x
> > > > > easier by adding some features of 3.x to 2.x, but without breaking
> > > > > backwards compatibility (not entirely successfully!).
>
> > > > It is a bit ugly. In 2.6 StringIO won't take bytestrings, so I apply 
> > > > u'x'. But
> > > > in 3.0 u'x' will be gone and I'll have to change the code again.
> > > Try:
> > > from __future__ import unicode_literals
>
> > That works for:
>
> >     output.write('First line.\n')
>
> > ...but not for:
>
> >    print('Second line.', file=output)
>
> > Maybe a combination of this and functools.partial as was suggested before. 
> > At
> > least the necessary edits would be at the top of the program.
>
> > -Bill
> > --
> > Sattre Press                                      Tales of 
> > Warhttp://sattre-press.com/                     by Lord Dunsany
> > [EMAIL PROTECTED]        http://sattre-press.com/tow.html
>
> I think this combination might do the trick (I don't have 2.6 to test
> it right now):
>
> from __future__ import print_function
> from __future__ import unicode_literals
> from functools import partial
> import io
> print = partial(print, sep=" ", end="\n")
> out = io.StringIO()
> print("hello", file=out)
>
> What puzzles me is the documentation in 2.6 and 3.0:
> In 2.6 it says: "The StringIO object can accept either Unicode or 8-
> bit strings". Why does it fail with old str objects then?
> Why is there no documentation for StringIO in 3.0?

OK I found StringIO it is called io.StringIO now.
--
http://mail.python.org/mailman/listinfo/python-list


Re: SequenceMatcher bug ?

2008-12-10 Thread Gabriel Genellina

En Wed, 10 Dec 2008 12:00:30 -0200, <[EMAIL PROTECTED]> escribió:

On Tue, 9 Dec 2008 at 22:15, eliben wrote:

On Dec 10, 4:12 am, [EMAIL PROTECTED] wrote:

On Mon, 8 Dec 2008 at 23:46, eliben wrote:

This is about Python 2.5.2 - I don't know if there were fixes to this
module in 2.6/3.0



I think I ran into a bug with difflib.SequenceMatcherclass.
Specifically, its ratio() method. The following:



SequenceMatcher(None, [4] + [10] * 500 + [5], [10] * 500 + [5]).ratio
()



returns 0.0



While the same with 500 replaced by 100 returns .99... something
Looking at the code ofSequenceMatcherthere's some caching going on
when the sequences are longer than 200 elements (and indeed, I can
reproduce the bug above 200 but not below). Can anyone confirm that
this misbehaves and suggest a workaround ?


Python 2.5.2 (r252:60911, Sep 29 2008, 20:34:04)
[GCC 4.3.1] on linux2
Type "help", "copyright", "credits" or "license" for more  
information.>>> from difflib importSequenceMatcher

SequenceMatcher(None, [4] + [10] * 500 + [5], [10] * 500 +
[5]).ratio()


0.99900299102691925



Strange. I could reproduce the problem both on ActiveState Python
2.5.2 for Windows, and in the online Try Python evaluator:

http://try-python.mired.org/


My system is Gentoo, which installs python from source.  Maybe gentoo
applies patches that the binary releases don't have.


I can't reproduce the problem. I got exactly the same results (0.999...)  
with all the releases I have at hand, ranging from 3.0 back to 2.1.3, all  
on Windows.

And http://try-python.mired.org/ says the same thing.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


ANN: python-ntlm - provides NTLM support, including an authentication handler for urllib2

2008-12-10 Thread Matthijs
Announcing: python-ntlm
http://code.google.com/p/python-ntlm/

python-ntlm is a library that provides NTLM support, including an
authentication
handler for urllib2.

This library allows you to retrieve content from (usually corporate)
servers protected with windows authentication (NTLM) using the python
urllib2.

For more details and downloads visit:
http://code.google.com/p/python-ntlm/


== Example Usage ==

import urllib2
from ntlm import HTTPNtlmAuthHandler

user = 'DOMAIN\User'
password = "Password"
url = "http://ntlmprotectedserver/securedfile.html";

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, password)
# create the NTLM authentication handler
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)

# create and install the opener
opener = urllib2.build_opener(auth_NTLM)
urllib2.install_opener(opener)

# retrieve the result
response = urllib2.urlopen(url)
print(response.read())
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread Luis Zarrabeitia

Quoting Rasmus Fogh <[EMAIL PROTECTED]>:
> Rhamphoryncus wrote:
> > You grossly overvalue using the "in" operator on lists.
> 
> Maybe. But there is more to it than just 'in'. If you do:
> >>> c = numpy.zeros((2,))
> >>> ll = [1, c, 3.]
> then the following all throw errors:
> 3 in ll, 3 not in ll, ll.index(3), ll.count(3), ll.remove(3)
> c in ll, c not in ll, ll.index(c), ll.count(c), ll.remove(c)
> 
> Note how the presence of c in the list makes it behave wrong for 3 as
> well.

I think I lost the first messages on this thread, but... Wouldn't be easier to
just fix numpy? I see no need to have the == return anything but a boolean, at
least on Numpy's case. The syntax 'a == b' is an equality test, not a detailed
summary of why they may be different, and (a==b).all() makes no little sense to
read unless you know beforehad that a and b are numpy arrays. When I'm comparing
normal objects, I do not expect (nor should I) the == operator to return an
attribute-by-attribute summary of what was equal and what wasn't.

Why is numpy's == overloaded in such a counter intuitive way? I realize that an
elementwise comparison makes a lot of sense, but it could have been done instead
with a.compare_with(b) (or even better, a.compare_with(b, epsilon=e)). No
unexpected breakage, and you have the chance of specifying when you consider two
elements to be equal - very useful. 

Even the transition itself could be done without breaking much code... Make the
== op return an object that wraps the array of bools (instead of the array
itself), give it the any() and all() methods, and make __nonzero__/__bool__
equivalent to all().

-- 
Luis Zarrabeitia
Facultad de Matemática y Computación, UH
http://profesores.matcom.uh.cu/~kyrie
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread M.-A. Lemburg
On 2008-12-10 16:40, Luis Zarrabeitia wrote:
> Quoting Rasmus Fogh <[EMAIL PROTECTED]>:
>> Rhamphoryncus wrote:
>>> You grossly overvalue using the "in" operator on lists.
>> Maybe. But there is more to it than just 'in'. If you do:
> c = numpy.zeros((2,))
> ll = [1, c, 3.]
>> then the following all throw errors:
>> 3 in ll, 3 not in ll, ll.index(3), ll.count(3), ll.remove(3)
>> c in ll, c not in ll, ll.index(c), ll.count(c), ll.remove(c)
>>
>> Note how the presence of c in the list makes it behave wrong for 3 as
>> well.
> 
> I think I lost the first messages on this thread, but... Wouldn't be easier to
> just fix numpy? I see no need to have the == return anything but a boolean, at
> least on Numpy's case. The syntax 'a == b' is an equality test, not a detailed
> summary of why they may be different, and (a==b).all() makes no little sense 
> to
> read unless you know beforehad that a and b are numpy arrays. When I'm 
> comparing
> normal objects, I do not expect (nor should I) the == operator to return an
> attribute-by-attribute summary of what was equal and what wasn't.
> 
> Why is numpy's == overloaded in such a counter intuitive way? I realize that 
> an
> elementwise comparison makes a lot of sense, but it could have been done 
> instead
> with a.compare_with(b) (or even better, a.compare_with(b, epsilon=e)). No
> unexpected breakage, and you have the chance of specifying when you consider 
> two
> elements to be equal - very useful. 

Rich comparisons were added to Python at the request of the
Numeric (now numpy) developers and they have been part of Python
a Numeric for many many years.

I don't think it's likely they'll change things back to the days
of Python 1.5.2 ;-)

> Even the transition itself could be done without breaking much code... Make 
> the
> == op return an object that wraps the array of bools (instead of the array
> itself), give it the any() and all() methods, and make __nonzero__/__bool__
> equivalent to all().

That would cause a lot of confusion on its own, since such an
object wouldn't behave in the same way as say a regular Python
list (bool([0]) == True).

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Dec 10 2008)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2008-12-02: Released mxODBC.Connect 1.0.0  http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread Bruno Desthuilliers

Lie a écrit :

On Dec 7, 2:38 am, "Warren DeLano" <[EMAIL PROTECTED]> wrote:

(snip)

As someone somewhat knowledgable of how parsers work, I do not
understand why a method/attribute name "object_name.as(...)" must
necessarily conflict with a standalone keyword " as ".  It seems to me
that it should be possible to unambiguously separate the two without
ambiguity or undue complication of the parser.


(snip)
>

And let things like:

filelike.print('lpt') # python 2.6
zipper.with('7z')
failure.try(alternative)
executecodeobject.if(True)
onfailure.break()

?


As far as I'm concerned, I'd find this perfectly acceptable - there's no 
possible confusion here. Now this wouldn't be very practical, since 
you'd have to define the functions outside the class (with a valid 
identifier) then bind them to the class.


But this is probably not going to happen anyway...
--
http://mail.python.org/mailman/listinfo/python-list


Maintaining signature in help(decorated function)

2008-12-10 Thread jelsas
Hi -- I can't seem to maintain the function signature when applying a
decorator.  I'm using functools.wraps.  Example:

>>> def mydecorator(fn):
... from functools import wraps
... # simple decorator
... @wraps(fn)
... def wrapped(*args, **kwargs):
... print 'i\'m wrapped!'
... return fn(*args, **kwargs)
... return wrapped
...
>>>
>>> @mydecorator
... def f(foo, bar):
... '''docstring for f'''
... pass
...
>>>
>>> help(f)

displays:

Help on function f in module __main__:

f(*args, **kwargs)
docstring for f

I would like to maintain f's signature in the help message, (foo, bar)
instead of (*args, **kwargs)

Thanks in advance!

--
http://mail.python.org/mailman/listinfo/python-list


Python music sequencer timing problems

2008-12-10 Thread badmuthahubbard
I've been trying to get the timing right for a music sequencer using
Tkinter.  First I just loaded the Csound API module and ran a Csound
engine in its own performance thread.  The score timing was good,
being controlled internally by Csound, but any time I moved the mouse
I got audio dropouts.
It was suggested I run the audio engine as a separate process, with
elevated/realtime priority and use sockets to tell it what to play,
and that way, too, people could set up servers for the audio on
different CPUs.  But I've found that the method I came up with for
timing the beats/notes is too slow (using threading.Timer on a
function that calls itself over and over), and the whole thing played
too slowly (and still gave me noise when moving the mouse).  I've been
using subprocesses, but I'm now wondering if sockets would or could
make a difference.

The overall goal is this: when the user wants to audition a piece,
create an audio engine process with elevated/realtime priority.  This
engine also has all the synthesis and sound processing rules for the
various instruments, due to the way Csound is structured.  Set up a
scheduler- possibly in another process, or just another thread- and
fill it with all the notes from the score and their times.  Also, the
user should be able to see a time-cursor moving across the piece so
they can see where they are in the score.  As this last bit is GUI,
the scheduler should be able to send callbacks back to the GUI as well
as notes to the audio engine.  But neither the scheduler nor the audio
engine should wait for Tkinter's updating of the location of the time-
cursor.  Naturally, all notes will have higher priorities in the
scheduler than all GUI updates, but they won't necessarily always be
at the same time.

So, I have a few ideas about how to proceed, but I want to know if
I'll need to learn more general things first:
1.
Create both the scheduler and the audio engine as separate processes
and communicate with them through sockets.  When all events are
entered in the scheduler, open a server socket in the main GUI process
and listen for callbacks to move the cursor (is it possible to do this
using Tkinter's mainloop, so the mouse can be moved, albeit
sluggishly, at the same time the cursor is moving continuously?); the
audio engine runs at as high priority as possible, and the scheduler
runs somewhere between that and the priority of the main GUI, which
should even perhaps be temporarily lowered below default for good
measure.

or

2.
Create the audio engine as an elevated priority process, and the
scheduler as a separate thread in the main process.  The scheduler
sends notes to the audio engine and callbacks within its own process
to move the GUI cursor.  Optionally, every tiny update of the cursor
could be a separate thread that dies an instant later.

3.
Closer to my original idea, but I'm hoping to avoid this.  All note
scheduling and tempo control is done by Csound as audio engine, and a
Csound channel is set aside for callbacks to update the cursor
position.  Maybe this would be smoothest, as timing is built into
Csound already, but the Csound score will be full of thousands of
pseudo-notes that only exist for those callbacks.  Down the road I'd
like to have notes sound whenever they are added or moved on the
score, not just when playing the piece, as well as the option of
adjusting the level, pan, etc. of running instruments.

It seems method 2 runs the risk of slowing down the timing of the
notes if the mouse moves around; but method 1 would require setting up
an event loop to listen for GUI updates from the scheduler.  I was
trying method 1 with subprocesses, but reading from the scheduler
process's stdout PIPE for GUI updates wasn't working.  I was referred
to Twisted and the code module for this, and haven't yet worked out
how to use them appropriately.

I don't mind a complex solution, if it is reliable (I'm aiming at
cross-platform, at least WinXP-OSX-Linux), but everything I try seems
to add unnecessary complexity without actually solving anything.  I've
been reading up on socket programming, and catching bits here and
there about non-blocking IO.  Seem like good topics to know about, if
I want to do audio programming, but I also need a practical solution
for now.

Any advice?

Thanks a lot.
-Chuckk
--
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Google Groups in bad odour

2008-12-10 Thread Peter Pearson
On Wed, 10 Dec 2008 02:20:24 -0800 (PST), Frank Millman wrote:
> . . . I will therefore have to find a suitable news client. Any
> recommendations?

I'm a happy user of slrn.

-- 
To email me, substitute nowhere->spamcop, invalid->net.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Maintaining signature in help(decorated function)

2008-12-10 Thread Michele Simionato
On Dec 10, 5:07 pm, jelsas <[EMAIL PROTECTED]> wrote:
> Hi -- I can't seem to maintain the function signature when applying a
> decorator.  I'm using functools.wraps.  Example:
>
> >>> def mydecorator(fn):
>
> ...     from functools import wraps
> ...     # simple decorator
> ...     @wraps(fn)
> ...     def wrapped(*args, **kwargs):
> ...             print 'i\'m wrapped!'
> ...             return fn(*args, **kwargs)
> ...     return wrapped
> ...
>
> >>> @mydecorator
>
> ... def f(foo, bar):
> ...     '''docstring for f'''
> ...     pass
> ...
>
>
>
> >>> help(f)
>
> displays:
>
> Help on function f in module __main__:
>
> f(*args, **kwargs)
>     docstring for f
>
> I would like to maintain f's signature in the help message, (foo, bar)
> instead of (*args, **kwargs)
>
> Thanks in advance!

You want the decorator module:
http://www.phyast.pitt.edu/~micheles/python/documentation.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Flushing PyQt's Event Queue

2008-12-10 Thread Chris Mellon
On Wed, Dec 10, 2008 at 6:30 AM, ff <[EMAIL PROTECTED]> wrote:
> Hi, I am writing an app which models growth of a system over time
> visually which is activated by button clicks, and when the loop
> finishes running i dont want any events [mainly clicking on buttons]
> that happened during the loop to be put into action since then it may
> run multiple times without the user realising what they have done,
>
> is there way to flush the event queue when the loop has finished??


This is a UI problem, not a programming problem. Instead of trying to
find a code solution to the problem, consider changing your UI so that
the actions aren't possible. For example, disable the buttons (perhaps
showing by showing a progress dialog box with a cancel button) while
the sim is running.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Google Groups in bad odour

2008-12-10 Thread Cousin Stanley

> 
> I will therefore have to find a suitable news client. 
> Any recommendations ?

Frank 

  You might try the python-based xpn news client 

  http://xpn.altervista.org/index-en.html

  To thine own snake be true  :-)


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

--
http://mail.python.org/mailman/listinfo/python-list


Re: To Troll or Not To Troll (aka: "as" keyword woes)

2008-12-10 Thread Nigel Rantor

James Stroud wrote:

Andreas Waldenburger wrote:

Is it me, or has c.l.p. developed a slightly harsher tone recently?
(Haven't been following for a while.)


Yep. I can only post here for about a week or two until someone blows a 
cylinder and gets ugly because they interpreted something I said as a 
criticism of the language and took it personally by extension. Then I 
have to take a 4 month break because I'm VERY prone to 
reciprocating--nastily. I think its a symptom of the language's 
maturing, getting popular, and a minority fraction* of the language's 
most devout advocates developing an egotism that complements their 
python worship in a most unsavory way.


I wish they would instead spend their energy volunteering to moderate 
this list and culling out some of the spam.


*No names were mentioned in the making of this post.


I joined this list some time ago, I am not a regular python user.

I have maintained my list subscription because when I'm bored the flames 
here are very entertaining.


I don't think I need to mention specifics really.

Oh, and the weekly thread about immutable default arguments is a 
cracker...more please.


  n
--
http://mail.python.org/mailman/listinfo/python-list


Re: Maintaining signature in help(decorated function)

2008-12-10 Thread jelsas
Thanks!  This is exactly what I needed.
--
http://mail.python.org/mailman/listinfo/python-list


cx_Oracle issues

2008-12-10 Thread huw_at1
Hey all. When using cx_Oracle to run a procedure like:

cursor.execute("select (obj.function(value)) from table where
id=blah")

I am getting the following error:

ORA-06502: PL/SQL: numeric or value error: character string buffer too
small ORA-06512: at line 1

Looking at cursor.description I get:

[('(obj.function(value))', , 4000, 4000, 0,
0, 1)]

Any tips - i have never seen this error before but am guessing that
the value being returned is too big for the buffer size set for the
cursor. the procedure fetches data from a LOB.

Any suggestions/confirmations?

Many thanks
--
http://mail.python.org/mailman/listinfo/python-list


Re: SequenceMatcher bug ?

2008-12-10 Thread eliben
> > My system is Gentoo, which installs python from source.  Maybe gentoo
> > applies patches that the binary releases don't have.
>
> I can't reproduce the problem. I got exactly the same results (0.999...)  
> with all the releases I have at hand, ranging from 3.0 back to 2.1.3, all  
> on Windows.

> Andhttp://try-python.mired.org/says the same thing.
>

What ? This can't be.

1. Go to http://try-python.mired.org/
2. Type
import difflib
3. Type
difflib.SequenceMatcher(None, [4] + [5] * 200, [5] * 200).ratio()

Don't you get 0 as the answer ?

The same with ActivePython on Windows ?

Here's a snapshot from my run on a Linux box:

Python 2.5.2 (r252:60911, Oct 20 2008, 09:11:31)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import difflib
>>>
>>> difflib.SequenceMatcher(None, [4] + [5] * 200, [5] * 200).ratio()
0.0

Executing exactly the same steps, do you not get 0.0 ?

--
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to report progress at fixed intervals

2008-12-10 Thread George Sakkis
On Dec 10, 2:50 am, Slaunger <[EMAIL PROTECTED]> wrote:
>
> Sorry, apparently I did not realize that at first sight. Anyway, I'd
> rather avoid using further external modules besides the standard
> batteries, as I would have to update several workstations with
> different OSes (some of which I do not have admin access to) to use
> the new module.

How is this different from writing your own module from scratch ? You
don't need admin access to use a 3rd party package.

George
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread Patrick Mullen
On Wed, Dec 10, 2008 at 6:57 AM, MRAB <[EMAIL PROTECTED]> wrote:
> Aaron Brady wrote:
>>
>> On Dec 9, 12:40 pm, MRAB <[EMAIL PROTECTED]> wrote:
>>>
>>> Aaron Brady wrote:

 On Dec 9, 8:28 am, MRAB <[EMAIL PROTECTED]> wrote:
 snip
>
> In some languages (I think Delphi is one of them - it's been a while!)
> some words which would normally be identifiers have a special meaning
> in
> certain contexts, but the syntax precludes any ambiguity, and not in a
> difficult way. "as" in Python was one of those.
> I certainly wouldn't want something like PL/I, where "IF", "THEN" and
> "ELSE" could be identifiers, so you could have code like:
> IF IF = THEN THEN
> THEN = ELSE;
> ELSE
> ELSE = IF;
> Seehttp://en.wikipedia.org/wiki/PL/I_(programming_language).

 snip
 That is, 'certainly' doesn't change the meaning of your statement
 any.  You wouldn't want it, but King George III didn't want the
 American Revolution.
>>>
>>> It's called emphasis.
>>
>> I just take you to have meant, then, +1 on excluding keywords from
>> identifiers.  You said it the long way though, so I thought I missed
>> something deeper, that didn't come across.
>>
> IIRC, most computer languages have an LL(1) grammar, which means that when
> they are parsed you need to look at only the next word. If you're about to
> parse a statement and the next word is "IF" then you know it's an
> IF-statement, if it's an identifier then it's either a call or an assignment
> statement (OK, you don't know exactly what kind of statement it is at that
> point, but it works out just fine!).
>
> In the example from PL/I, "IF" could be the start of an IF-statement "IF
>  THEN" or an assignment statement "IF = ". It's a bit
> more tricky for the parser as well as the programmer.
>
> Life is easier if words having special meanings are reserved.
>
> However, that doesn't mean that all special words /must/ be reserved
> (pragmatism beats purity). Sometimes the syntax makes it clear and
> unambiguous, so you can get away with not making it a reserved word. The
> word "as" in Python doesn't need to be reserved because the syntax precludes
> ambiguity, but it's the only such word in the language, so it's just tidier
> to make it reserved too.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

I don't have a huge stake in this, but I wouldn't mind a change to
allow anything proceeding a "." or preceeding a "(" to not be
identified as a keyword.  It is obvious to me a s a human reader that
something.if is quite a bit different than just a bare if.  And as far
as parsing technology goes, isn't it supposed to go for the biggest
match first?  I would not be for allowing bare keywords to be used in
the situations described above, but since we are so used to being able
to being able to have say, myclass.dir() or myclass.len() without them
overwriting the builtin functions, it makes sense to me to be able to
define a myclass.as() or myclass.with() without overwriting the
keywords.  Though I know the semantics behind these two things are
very different, the rules I go through when reading the code are very
similar.  The parser change might be a hassle, and it might not be
worth it at all of course, but from a conceptual point of view it is
simple.  I mean, even now you can do class.__dict__["as"].

I guess I'm -1 for full PL/1 craziness, but +1 for qualified keyword usage.
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread MRAB

Patrick Mullen wrote:

On Wed, Dec 10, 2008 at 6:57 AM, MRAB <[EMAIL PROTECTED]>
wrote:

Aaron Brady wrote:

On Dec 9, 12:40 pm, MRAB <[EMAIL PROTECTED]> wrote:

Aaron Brady wrote:
On Dec 9, 8:28 am, MRAB <[EMAIL PROTECTED]> wrote: 
snip

In some languages (I think Delphi is one of them - it's
been a while!) some words which would normally be
identifiers have a special meaning in certain contexts, but
the syntax precludes any ambiguity, and not in a difficult
way. "as" in Python was one of those. I certainly wouldn't
want something like PL/I, where "IF", "THEN" and "ELSE"
could be identifiers, so you could have code like: IF IF =
THEN THEN THEN = ELSE; ELSE ELSE = IF; 
Seehttp://en.wikipedia.org/wiki/PL/I_(programming_language).



snip That is, 'certainly' doesn't change the meaning of your
statement any.  You wouldn't want it, but King George III
didn't want the American Revolution.

It's called emphasis.

I just take you to have meant, then, +1 on excluding keywords
from identifiers.  You said it the long way though, so I thought
I missed something deeper, that didn't come across.


IIRC, most computer languages have an LL(1) grammar, which means
that when they are parsed you need to look at only the next word.
If you're about to parse a statement and the next word is "IF" then
you know it's an IF-statement, if it's an identifier then it's
either a call or an assignment statement (OK, you don't know
exactly what kind of statement it is at that point, but it works
out just fine!).

In the example from PL/I, "IF" could be the start of an
IF-statement "IF  THEN" or an assignment statement "IF =
". It's a bit more tricky for the parser as well as the
programmer.

Life is easier if words having special meanings are reserved.

However, that doesn't mean that all special words /must/ be
reserved (pragmatism beats purity). Sometimes the syntax makes it
clear and unambiguous, so you can get away with not making it a
reserved word. The word "as" in Python doesn't need to be reserved
because the syntax precludes ambiguity, but it's the only such word
in the language, so it's just tidier to make it reserved too.



I don't have a huge stake in this, but I wouldn't mind a change to 
allow anything proceeding a "." or preceeding a "(" to not be 
identified as a keyword.


Don't you mean 'following a "."'? IMHO if you forbid "bar = True" then
you should also forbid "foo.bar = True".

As for preceding a "(", what about the call "if(True)"? It looks like an
if-statement!


It is obvious to me a s a human reader that something.if is quite a
bit different than just a bare if.  And as far as parsing technology
goes, isn't it supposed to go for the biggest match first?  I would
not be for allowing bare keywords to be used in the situations
described above, but since we are so used to being able to being able
to have say, myclass.dir() or myclass.len() without them overwriting
the builtin functions, it makes sense to me to be able to define a
myclass.as() or myclass.with() without overwriting the keywords.
Though I know the semantics behind these two things are very
different, the rules I go through when reading the code are very 
similar.  The parser change might be a hassle, and it might not be 
worth it at all of course, but from a conceptual point of view it is 
simple.  I mean, even now you can do class.__dict__["as"].


I guess I'm -1 for full PL/1 craziness, but +1 for qualified keyword
usage.

Parsing isn't about the biggest match. Ideally you want something that's 
 simple without being simplistic. Python is a good example.

--
http://mail.python.org/mailman/listinfo/python-list


get todays files

2008-12-10 Thread Andrew D
I have a script that will login to my ftp server and download all the
backup files, but I want it to only download the files that were
created today, e.g. if I ran the script today I want it to only fetch
files created today.

I am really not sure about how to do this, but it is quite important
to me, so all help is highly appreciated!

Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Steve Holden
Andrew D wrote:
> I have a script that will login to my ftp server and download all the
> backup files, but I want it to only download the files that were
> created today, e.g. if I ran the script today I want it to only fetch
> files created today.
> 
> I am really not sure about how to do this, but it is quite important
> to me, so all help is highly appreciated!
> 
IIRC there's an "ftpmirror" script in the Tools directory (if you're on
Windows - Linux/Unix users have to download the source). I adapted it to
several different purposes.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--
http://mail.python.org/mailman/listinfo/python-list


Re: SequenceMatcher bug ?

2008-12-10 Thread Steve Holden
eliben wrote:
>>> My system is Gentoo, which installs python from source.  Maybe gentoo
>>> applies patches that the binary releases don't have.
>> I can't reproduce the problem. I got exactly the same results (0.999...)  
>> with all the releases I have at hand, ranging from 3.0 back to 2.1.3, all  
>> on Windows.
> 
>> Andhttp://try-python.mired.org/says the same thing.
>>
> 
> What ? This can't be.
> 
> 1. Go to http://try-python.mired.org/
> 2. Type
> import difflib
> 3. Type
> difflib.SequenceMatcher(None, [4] + [5] * 200, [5] * 200).ratio()
> 
> Don't you get 0 as the answer ?
> 
> The same with ActivePython on Windows ?
> 
> Here's a snapshot from my run on a Linux box:
> 
> Python 2.5.2 (r252:60911, Oct 20 2008, 09:11:31)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 import difflib

 difflib.SequenceMatcher(None, [4] + [5] * 200, [5] * 200).ratio()
> 0.0
> 
> Executing exactly the same steps, do you not get 0.0 ?
> 
I get 0.0 from everything I've tried it on so far: Cygwin 2.5.1, Windows
2.4.4, Windows 2.5.2, Windows 2.6, Ubuntu 2.5.2, Red Hat 2.4.3,
try-python. All my own machines are Intel architecture, if that makes
any difference. I'm not sure how gentoo would have patched their 2.5.2
when the bug, if 2.6 still contains it.

I find it strange that try-python gives one person a different result
from everyone else. What is this bizarre influence on web sites?

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Andrew D
On Dec 10, 5:55 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Andrew D wrote:
> > I have a script that will login to my ftp server and download all the
> > backup files, but I want it to only download the files that were
> > created today, e.g. if I ran the script today I want it to only fetch
> > files created today.
>
> > I am really not sure about how to do this, but it is quite important
> > to me, so all help is highly appreciated!
>
> IIRC there's an "ftpmirror" script in the Tools directory (if you're on
> Windows - Linux/Unix users have to download the source). I adapted it to
> several different purposes.
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/

Thanks Steve,

I don't want to sound rude here, but I really want some code to add to
my script so that it will only download todays files.

Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Jewel of the Week: Sterling Icon Collection just $39

2008-12-10 Thread JFMoreno
Add a touch of class to your projects with this beautiful icon
collection.

262 gorgeous icons for a total of 14934 files in +540mg that will make
all your projects shine (Application, Website, Gadget, Game, Desktop,
etc.).
The collection includes 9 sizes: 16x16, 24x24, 32x32, 48x48, 64x64,
72x72, 96x96, 128x128, and 256x256
Included as well 7 formats: Windows ICO, PSD, PNG, JPG, BMP, GIF and
Mac ICNS

Previously sold for$149, this week only you can get this jewel for
just $39

BUY NOW (secure): https://www.1stlogodesign.com/secure/orders/jeweloftheweek.htm

Preview the entire collection: 
http://www.1stlogodesign.com/core/docs/sterlingiconcollection.pdf

Download a sample: http://www.1stlogodesign.com/core/downloads/1stIDSterling.zip

Compare our collection to identical quality collections from other
vendors and you will find that you get:
•   More Icons – In some cases four times more icons.
•   More sizes – 9 different sizes from 16x16 to 256x256
•   More formats – Our collection includes, PNG,PSD, JPG, BMP, GIF, ICO
and ICNS formats
•   Better quality – Our icons are not cartoonish and therefore your
project will look more professional
•   More FREE updates – FREE for LIFE!

Would you like to receive notifications about our fantastic offers,
last minute low-price deals and new releases?  Join our newsletter:
https://www.1stlogodesign.com/forms/newsletter.htm
--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Steve Holden
Andrew D wrote:
> On Dec 10, 5:55 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>> Andrew D wrote:
>>> I have a script that will login to my ftp server and download all the
>>> backup files, but I want it to only download the files that were
>>> created today, e.g. if I ran the script today I want it to only fetch
>>> files created today.
>>> I am really not sure about how to do this, but it is quite important
>>> to me, so all help is highly appreciated!
>> IIRC there's an "ftpmirror" script in the Tools directory (if you're on
>> Windows - Linux/Unix users have to download the source). I adapted it to
>> several different purposes.
>>
> 
> Thanks Steve,
> 
> I don't want to sound rude here, but I really want some code to add to
> my script so that it will only download todays files.
> 
That's OK. Maybe somebody's already got that code ready to go. I don't ...

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Andrew D
On Dec 10, 6:13 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Andrew D wrote:
> > On Dec 10, 5:55 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> >> Andrew D wrote:
> >>> I have a script that will login to my ftp server and download all the
> >>> backup files, but I want it to only download the files that were
> >>> created today, e.g. if I ran the script today I want it to only fetch
> >>> files created today.
> >>> I am really not sure about how to do this, but it is quite important
> >>> to me, so all help is highly appreciated!
> >> IIRC there's an "ftpmirror" script in the Tools directory (if you're on
> >> Windows - Linux/Unix users have to download the source). I adapted it to
> >> several different purposes.
>
> > Thanks Steve,
>
> > I don't want to sound rude here, but I really want some code to add to
> > my script so that it will only download todays files.
>
> That's OK. Maybe somebody's already got that code ready to go. I don't ...
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/

Thank you anyway Steve!

Lets hope someone has the code ;)

Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Python is slow

2008-12-10 Thread cm_gui
http://blog.kowalczyk.info/blog/2008/07/05/why-google-should-sponsor-a-faster-python-vm.html

I fully agree with Krzysztof Kowalczyk .
Can't they build a faster VM for Python since they love the language
so much?

Python is SLOW.And I am not comparing it with compiled languages
like C.
Python is even slower than PHP!

Just go to any Python website and you will know.
An example is:
http://www2.ljworld.com/
And this site is created by the creators of Django!

And it is not just this Python site that is slow. There are many many
Python sites which are very slow. And please don’t say that it could
be the web hosting or the server which is slow — because when so many
Python sites are slower than PHP sites, it couldn’t be the web
hosting.   Also, Zope/Plone is even slower.

Python is slow. Very slow.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread Rhamphoryncus
On Dec 10, 7:49 am, Rasmus Fogh <[EMAIL PROTECTED]> wrote:
> Rhamphoryncus wrote:
> > You grossly overvalue using the "in" operator on lists.
>
> Maybe. But there is more to it than just 'in'. If you do:>>> c = 
> numpy.zeros((2,))
> >>> ll = [1, c, 3.]
>
> then the following all throw errors:
> 3 in ll, 3 not in ll, ll.index(3), ll.count(3), ll.remove(3)
> c in ll, c not in ll, ll.index(c), ll.count(c), ll.remove(c)
>
> Note how the presence of c in the list makes it behave wrong for 3 as
> well.

All of these are O(n).  Use a set or dict.  What is your use case
anyway?


> > It's far more
> > common to use a dict or set for containment tests, due to O(1)
> > performance rather than O(n).  I doubt the numpy array supports
> > hashing, so an error for misuse is all you should expect.
>
> Indeed it doees not. So there is not much to be gained from modifying
> equality comparison with sets/dicts.
>
> > In the rare case that you want to test for identity in a list, you can
> > easily write your own function to do it upfront:
> > def idcontains(seq, obj):
> >     for i in seq:
> >         if i is obj:
> >             return True
> >     return False
>
> Again, you can code around any particular case (though wrappers look like
> a more robust solution). Still, why not get rid of this wart, if we can
> find a way?

The wart is a feature.  I agree that it's confusing, but the cost of
adding a special case to work around it is far in excess of the
original problem.

Now if you phrased it as a hypothetical discussion for the purpose of
learning about language design, that'd be another matter.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread Terry Reedy

Rasmus Fogh wrote:

Rhamphoryncus wrote:

You grossly overvalue using the "in" operator on lists.


Maybe. But there is more to it than just 'in'. If you do:

c = numpy.zeros((2,))
ll = [1, c, 3.]

then the following all throw errors:
3 in ll, 3 not in ll, ll.index(3), ll.count(3), ll.remove(3)
c in ll, c not in ll, ll.index(c), ll.count(c), ll.remove(c)

Note how the presence of c in the list makes it behave wrong for 3 as
well.


So do not put numpy arrays into lists without wrapping them.  They were 
designed and semi-optimized, by a separate community, for a specific 
purpose -- numerical computation -- and not for 'playing nice' with 
other Python objects.


It is a design feature of Python that people can implement specialized 
objects with specialized behaviors for specialized purposes.


--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Tim Chase

I have a script that will login to my ftp server and download
all the backup files, but I want it to only download the files
that were created today, e.g. if I ran the script today I want
it to only fetch files created today.


Use Python's ftp module and send the MDTM command to get back the 
timestamp of the filename.  Insecurely, this would look something 
like


  from ftplib import FTP
  hostname = "ftp.mozilla.org"
  conn = FTP(hostname)
  user = "anonymous"
  password = "[EMAIL PROTECTED]"
  conn.login(user, password)
  filename = "pub/README"
  results = conn.sendcmd("MDTM %s" % filename)
  code, stamp = results.split(None, 1)
  assert code == "213", "Unexpected result"
  print "%s was modified on %s" % (filename, stamp)
  today = '20081210'
  if stamp[:8] == today:
process(filename)
  else:
print "ignoring", filename

The MDTM command is not part of the core RFC-959, but rather the 
RFC-3659[1] so you might run across some servers that don't 
support it.  You can read more about the Python ftplib module at 
[2] which would be where you want to read up on pulling back a 
listing of the directory of file-names to check.  There is a NLST 
command (I don't have a server handy that supports this command). 
 The LIST command returns pretty/readable information that's not 
quite so machine-parsing friendly (at least in a cross-FTP-server 
sort of way).  However, that part, I leave as an exercise for the 
reader along with the complications of the "today" bit.


Oh, SteveH, I checked your FTP-cloning source in my Python dir, 
and it doesn't look like it does anything regarding file-times in 
it, so that may have been a red-herring.  Unless you've added 
something since the ver. I've got here.


-tkc


[1]
http://en.wikipedia.org/wiki/List_of_FTP_commands

[2]
http://www.python.org/doc/2.5.2/lib/ftp-objects.html




--
http://mail.python.org/mailman/listinfo/python-list


Re: StringIO in 2.6 and beyond

2008-12-10 Thread Bill McClain
On 2008-12-10, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> I think this combination might do the trick (I don't have 2.6 to test
> it right now):

> from __future__ import print_function
> from __future__ import unicode_literals
> from functools import partial
> import io
> print = partial(print, sep=" ", end="\n")
> out = io.StringIO()
> print("hello", file=out)

The example works, but unicode_literals causes problems elsewhere, in optparse
for example. I didn't look into it too closely. I'll probably give up trying
to anticipate 3.0 with 2.6 too closely.

-Bill
-- 
Sattre Press  Tales of War
http://sattre-press.com/   by Lord Dunsany
[EMAIL PROTECTED] http://sattre-press.com/tow.html
--
http://mail.python.org/mailman/listinfo/python-list


Deeper tracebacks?

2008-12-10 Thread brooklineTom
I want my exception handler to report the method that originally
raised an exception, at the deepest level in the call-tree. Let give
an example.

import sys, traceback
class SomeClass:
def error(self):
"""Raises an AttributeError exception."""
int(3).zork()

def perform_(self, aSelector):
try:
aMethod = getattr(self, aSelector, None)
answer = apply(aMethod, [], {})
except: AttributeError, anAttributeErrorException:
aRawStack = traceback.extract_stack()
answer = None

When I call "perform_" (... SomeClass().perform_('error')), I want to
collect and report the location *within the method ("error") that
failed*. The above code reports the location of "perform_", and no
deeper in the call tree.

Anybody know how to accomplish this?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread Luis Zarrabeitia
On Wednesday 10 December 2008 10:50:57 am M.-A. Lemburg wrote:
> On 2008-12-10 16:40, Luis Zarrabeitia wrote:
> > Quoting Rasmus Fogh <[EMAIL PROTECTED]>:
> >> Rhamphoryncus wrote:
>
> Rich comparisons were added to Python at the request of the
> Numeric (now numpy) developers and they have been part of Python
> a Numeric for many many years.
>
> I don't think it's likely they'll change things back to the days
> of Python 1.5.2 ;-)

Please define "rich comparisons" for me. It seems that I do not understand the 
term - I was thinking it meant the ability to override the comparison 
operators, and specially, the ability to override them independently.

Even in statically typed languages, when you override the equality 
operator/function you can choose not to return a valid answer (raise an 
exception). And it would break all the cases mentioned above (element in 
list, etc). But that isn't the right thing to do. The language doesn't/can't 
prohibit you from breaking the equality test, but that shouldn't be 
considered a feature. (a==b).all() makes no sense. 

> > Even the transition itself could be done without breaking much code...
> > Make the == op return an object that wraps the array of bools (instead of
> > the array itself), give it the any() and all() methods, and make
> > __nonzero__/__bool__ equivalent to all().
>
> That would cause a lot of confusion on its own, since such an
> object wouldn't behave in the same way as say a regular Python
> list (bool([0]) == True).

I'm certain that something could be worked out. A quick paragraph that took me 
just a few minutes to type shouldn't be construed as a PEP that will solve 
all the problems :D.

-- 
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie
--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Andrew D
On Dec 10, 6:55 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I have a script that will login to my ftp server and download
> > all the backup files, but I want it to only download the files
> > that were created today, e.g. if I ran the script today I want
> > it to only fetch files created today.
>
> Use Python's ftp module and send the MDTM command to get back the
> timestamp of the filename.  Insecurely, this would look something
> like
>
>    from ftplib import FTP
>    hostname = "ftp.mozilla.org"
>    conn = FTP(hostname)
>    user = "anonymous"
>    password = "[EMAIL PROTECTED]"
>    conn.login(user, password)
>    filename = "pub/README"
>    results = conn.sendcmd("MDTM %s" % filename)
>    code, stamp = results.split(None, 1)
>    assert code == "213", "Unexpected result"
>    print "%s was modified on %s" % (filename, stamp)
>    today = '20081210'
>    if stamp[:8] == today:
>      process(filename)
>    else:
>      print "ignoring", filename
>
> The MDTM command is not part of the core RFC-959, but rather the
> RFC-3659[1] so you might run across some servers that don't
> support it.  You can read more about the Python ftplib module at
> [2] which would be where you want to read up on pulling back a
> listing of the directory of file-names to check.  There is a NLST
> command (I don't have a server handy that supports this command).
>   The LIST command returns pretty/readable information that's not
> quite so machine-parsing friendly (at least in a cross-FTP-server
> sort of way).  However, that part, I leave as an exercise for the
> reader along with the complications of the "today" bit.
>
> Oh, SteveH, I checked your FTP-cloning source in my Python dir,
> and it doesn't look like it does anything regarding file-times in
> it, so that may have been a red-herring.  Unless you've added
> something since the ver. I've got here.
>
> -tkc
>
> [1]http://en.wikipedia.org/wiki/List_of_FTP_commands
>
> [2]http://www.python.org/doc/2.5.2/lib/ftp-objects.html

This looks very good and I have tested successfully, but is there a
way I can set the today to automatically become todays date in that
format?

Thanks though, this is what I was looking for!

Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Paul McGuire
On Dec 10, 12:42 pm, cm_gui <[EMAIL PROTECTED]> wrote:
> Python is slow. Very slow.

And... ?   Was there a question or specific suggestion in there
somewhere?

Do you go to your mechanic and say "My car wont go as fast as the
other cars on the road!  They should make it faster!"?

Good luck to you in your futile, uh I meant, *future* endeavors.  (No
wait, I really meant "futile".)

-- Paul
--
http://mail.python.org/mailman/listinfo/python-list


conratulations.......

2008-12-10 Thread john adam
conratulatios..
Here's my dear friend largest mobile library programs
All you care programs :
Witness all the programs in the modern world Alkmiotr
Honored by your visit
You'll see in the blogger
1.If you are suffering from a virus protection programs most important
to you
 AVG Anti-Virus Free Edition  "avG"
http://mesotheliomame.blogspot.com/2008/11/pericardial-mesothelioma-and-modern.html
2.If you turn suffering from transmitting the files
LimeWire Pro 4.14.7
http://mesotheliomame.blogspot.com/2008/11/overview-of-mesothelioma-cancer.html
3.If you have files you spy on your computer solution
Ad-Aware 2008
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-lawsuits-faq.html
4.You stronger virus program Ante 2008
Avira AntiVir Personal - Free Antivirus
http://mesotheliomame.blogspot.com/2008/11/number-form-of-mesothelioma-pleural.html
5.Now a program of protection and anti-virus and anti-spy files
Avast Home Edition
http://mesotheliomame.blogspot.com/2008/11/what-to-look-for-in-california.html
6.If you are suffering from non-fast you download this program
FrostWire
http://mesotheliomame.blogspot.com/2008/11/if-you-are-diagnosed-with-mesothelioma_15.html
7.If you have difficulty loading of the Diaspora and Google
Orbit Downloader
http://mesotheliomame.blogspot.com/2008/11/if-you-are-diagnosed-with-mesothelioma.html
8.If you have difficulty difficult compression  "file"
winrar
http://mesotheliomame.blogspot.com/2008/11/contacting-mesothelioma-lawyer.html
9.If you are suffering from aAdware/Malware files you solution
Malwarebytes' Anti-Malware
http://mesotheliomame.blogspot.com/2008/11/scientists-conduct-clincial-trials-of.html
10.Now the most powerful video chat in the world
 Camfrog Video Chat
http://mesotheliomame.blogspot.com/2008/11/new-drug-study-for-abdominal.html
11.Program chat world is a lot
mIRC
http://mesotheliomame.blogspot.com/2008/11/ohio-mesothelioma-lawyer-help-you-get.html
12.If you have difficulty reading flv files
FLV Player
http://mesotheliomame.blogspot.com/2008/11/detailed-information-on-mesothelioma.html
13.If you have difficulty download from youtube
YouTube Downloader
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-lawyers-in-high-demand.html
14.If you are suffering from penetrating the strongest program you
repel breakthroughs in the world
 Spybot - Search & Destroy
http://mesotheliomame.blogspot.com/2008/11/chemotherapy-treatment-for-mesothelioma.html
15.If you have difficulty with the way they spread the images
IrfanView
http://mesotheliomame.blogspot.com/2008/11/california-mesothelioma-laws-and.html
16.Now have a major program of the torrent file and upload files
BitComet
http://mesotheliomame.blogspot.com/2008/11/facing-mesothelioma-without-california.html
17.The program is exclusive download from the Web at high speed
 Download Accelerator Plus
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-cancer-diagnoses-increase_15.html
18.If you are suffering from problems with the performance of the
solution you
Smart Defrag
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-cancer-diagnoses-increase.html
19.If you have difficulty in performing the solution you
Advanced WindowsCare Personal
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-is-deadly-cancer.html
20.If you have difficulty in operating the sound and video files you
solution
real player
http://mesotheliomame.blogspot.com/2008/11/facts-and-misconceptions-about.html
21.Here is the most important video player program in America
GOM Media Player
http://mesotheliomame.blogspot.com/2008/11/how-severe-is-mesothelioma-disease.html
22.If you have difficulty operating Flash Games
Flash Player
http://mesotheliomame.blogspot.com/2008/11/glimpse-at-mesothelioma-info-from-past.html
23.If you have difficulty in cleaning Riggstir professionally you the
best solution
http://mesotheliomame.blogspot.com/2008/11/detection-of-asbestos-mesothelioma.html
24.If you turn suffering from your computer and the difficulty you
download this program"System Mechanic"
http://mesotheliomame.blogspot.com/2008/11/brief-overview-of-malignant.html
25.If you are suffering from problems in the cleaning solution you
Riggstir
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-and-911.html
26.Use the latest hour computer in the world in the magnificence of
beauty
http://mesotheliomame.blogspot.com/2008/11/precise-idea-about-pericardial.html
27.If you have difficulty in maintaining from hard disk
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-at-glance.html
28.If you have difficulty in managing personal and protection of your
system you program
http://mesotheliomame.blogspot.com/2008/11/financial-burden-of-mesothelioma.html
29.If you have difficulty in recording data and operation of your
system
http://mesotheliomame.blogspot.com/2008/11/how-to-find-mesothelioma-lawyer.html
30.Here's this program that offers you much time
http://mesotheliomame.blogspot.com/2008/11/hurricane-victims-at-risk-for.html
31.If you have diffic

hi...hi.....hi

2008-12-10 Thread john adam
conratulatios..
Here's my dear friend largest mobile library programs
All you care programs :
Witness all the programs in the modern world Alkmiotr
Honored by your visit
You'll see in the blogger
1.If you are suffering from a virus protection programs most important
to you
 AVG Anti-Virus Free Edition  "avG"
http://mesotheliomame.blogspot.com/2008/11/pericardial-mesothelioma-and-modern.html
2.If you turn suffering from transmitting the files
LimeWire Pro 4.14.7
http://mesotheliomame.blogspot.com/2008/11/overview-of-mesothelioma-cancer.html
3.If you have files you spy on your computer solution
Ad-Aware 2008
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-lawsuits-faq.html
4.You stronger virus program Ante 2008
Avira AntiVir Personal - Free Antivirus
http://mesotheliomame.blogspot.com/2008/11/number-form-of-mesothelioma-pleural.html
5.Now a program of protection and anti-virus and anti-spy files
Avast Home Edition
http://mesotheliomame.blogspot.com/2008/11/what-to-look-for-in-california.html
6.If you are suffering from non-fast you download this program
FrostWire
http://mesotheliomame.blogspot.com/2008/11/if-you-are-diagnosed-with-mesothelioma_15.html
7.If you have difficulty loading of the Diaspora and Google
Orbit Downloader
http://mesotheliomame.blogspot.com/2008/11/if-you-are-diagnosed-with-mesothelioma.html
8.If you have difficulty difficult compression  "file"
winrar
http://mesotheliomame.blogspot.com/2008/11/contacting-mesothelioma-lawyer.html
9.If you are suffering from aAdware/Malware files you solution
Malwarebytes' Anti-Malware
http://mesotheliomame.blogspot.com/2008/11/scientists-conduct-clincial-trials-of.html
10.Now the most powerful video chat in the world
 Camfrog Video Chat
http://mesotheliomame.blogspot.com/2008/11/new-drug-study-for-abdominal.html
11.Program chat world is a lot
mIRC
http://mesotheliomame.blogspot.com/2008/11/ohio-mesothelioma-lawyer-help-you-get.html
12.If you have difficulty reading flv files
FLV Player
http://mesotheliomame.blogspot.com/2008/11/detailed-information-on-mesothelioma.html
13.If you have difficulty download from youtube
YouTube Downloader
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-lawyers-in-high-demand.html
14.If you are suffering from penetrating the strongest program you
repel breakthroughs in the world
 Spybot - Search & Destroy
http://mesotheliomame.blogspot.com/2008/11/chemotherapy-treatment-for-mesothelioma.html
15.If you have difficulty with the way they spread the images
IrfanView
http://mesotheliomame.blogspot.com/2008/11/california-mesothelioma-laws-and.html
16.Now have a major program of the torrent file and upload files
BitComet
http://mesotheliomame.blogspot.com/2008/11/facing-mesothelioma-without-california.html
17.The program is exclusive download from the Web at high speed
 Download Accelerator Plus
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-cancer-diagnoses-increase_15.html
18.If you are suffering from problems with the performance of the
solution you
Smart Defrag
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-cancer-diagnoses-increase.html
19.If you have difficulty in performing the solution you
Advanced WindowsCare Personal
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-is-deadly-cancer.html
20.If you have difficulty in operating the sound and video files you
solution
real player
http://mesotheliomame.blogspot.com/2008/11/facts-and-misconceptions-about.html
21.Here is the most important video player program in America
GOM Media Player
http://mesotheliomame.blogspot.com/2008/11/how-severe-is-mesothelioma-disease.html
22.If you have difficulty operating Flash Games
Flash Player
http://mesotheliomame.blogspot.com/2008/11/glimpse-at-mesothelioma-info-from-past.html
23.If you have difficulty in cleaning Riggstir professionally you the
best solution
http://mesotheliomame.blogspot.com/2008/11/detection-of-asbestos-mesothelioma.html
24.If you turn suffering from your computer and the difficulty you
download this program"System Mechanic"
http://mesotheliomame.blogspot.com/2008/11/brief-overview-of-malignant.html
25.If you are suffering from problems in the cleaning solution you
Riggstir
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-and-911.html
26.Use the latest hour computer in the world in the magnificence of
beauty
http://mesotheliomame.blogspot.com/2008/11/precise-idea-about-pericardial.html
27.If you have difficulty in maintaining from hard disk
http://mesotheliomame.blogspot.com/2008/11/mesothelioma-at-glance.html
28.If you have difficulty in managing personal and protection of your
system you program
http://mesotheliomame.blogspot.com/2008/11/financial-burden-of-mesothelioma.html
29.If you have difficulty in recording data and operation of your
system
http://mesotheliomame.blogspot.com/2008/11/how-to-find-mesothelioma-lawyer.html
30.Here's this program that offers you much time
http://mesotheliomame.blogspot.com/2008/11/hurricane-victims-at-risk-for.html
31.If you have diffic

Re: get todays files

2008-12-10 Thread Tim Chase

This looks very good and I have tested successfully, but is there a
way I can set the today to automatically become todays date in that
format?


Yes...see the python datetime module[1]...particularly the 
strftime() call on date/datetime objects.


-tkc

[1]
http://docs.python.org/library/datetime.html
--
http://mail.python.org/mailman/listinfo/python-list


Dabo 0.9.0 Released

2008-12-10 Thread Ed Leafe
We are proud (and relieved!) to finally release Dabo 0.9.0, the first  
official release of the framework in six months. We haven't been  
taking it easy during that period; rather, we made some changes that  
clean up some weak spots in the codebase, and as a result can offer a  
much more solid framework, and are on course for a 1.0 release in the  
near future.


To do this, we made some decisions that break backwards compatibility.  
We dropped support for Python versions earlier than 2.4, and wxPython  
versions below 2.8. Supporting everything is nice to aim for, but  
completely impractical.


There is also a major addition to the framework: the ability to deploy  
Dabo applications as true web apps. Imagine: being able to develop a  
rich internet app using nothing but Python on both the client and  
server! It's still early in the development process, so it's lacking a  
lot of the supporting tools, and almost no documentation has been  
created, but that will be coming in the next few weeks/months. When  
you deploy your app as a web app, all data access and business logic  
is on the server, and the framework automatically handles the  
communication between the client and server. The framework also  
automatically grabs file changes from the server, making UI updates  
seamless and quick. Lots more interesting stuff will be happening in  
this area in the near future, so stay tuned!


If you're not already familiar with Dabo, we're the premier open  
source framework for developing desktop (and now web!) applications in  
Python. We make the difficult stuff like binding databases to UI  
controls simple.


You can grab the latest version from http://dabodev.com/download

A fairly comprehensive list of the changes we've made since the last  
release can be found at http://svn.dabodev.com/dabo/tags/dabo-0.9.0/ChangeLog


And if you want to learn more, join our email list: 
http://leafe.com/mailman/listinfo/dabo-users


-- Ed Leafe



--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Benjamin Kaplan
On Wed, Dec 10, 2008 at 2:07 PM, Paul McGuire <[EMAIL PROTECTED]> wrote:

> On Dec 10, 12:42 pm, cm_gui <[EMAIL PROTECTED]> wrote:
> > Python is slow. Very slow.
>
> And... ?   Was there a question or specific suggestion in there
> somewhere?
>
> Do you go to your mechanic and say "My car wont go as fast as the
> other cars on the road!  They should make it faster!"?
>
> Good luck to you in your futile, uh I meant, *future* endeavors.  (No
> wait, I really meant "futile".)
>
> -- Paul
>

Don't bother arguing. It's just a pathetic attempt to start a flame war.

>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Tim Chase

[nibbling a little flame-bait]


Python is even slower than PHP!

Just go to any Python website and you will know.
An example is:
http://www2.ljworld.com/


I'm not sure I'm seeing what you're seeing -- the dynamic page 
loaded in under 2 seconds -- about on par with sun.com, 
python.org, php.net or msn.com all being pulled from non-cached 
servers.  You sure you're not mistaking your bandwidth and/or 
browser-rendering slowness for Python-as-a-web-server slowness?



Would it be nice if Python was faster?  Sure, why not?

Does it meet my needs speed-wise?  99% of the time, yes.  With 
Psyco, 99.9% of the time.  As has been shown repeatedly over the 
last couple months, algorithm-choice makes a far greater impact 
than some python tweaks.  Most of my time spent waiting is 
usually on I/O (disk, network, or user).  And those times I've 
experienced slowness where I'm not waiting on I/O, it's always 
been an algorithm aspect (an O(N**2) fuzzy comparison algorithm 
is my prime offender).  A faster Python might shave a 30-60 
seconds off a 10 minute run, but it's still a walk around the 
office either way.



Python is slow. Very slow.


However until you have a use-case that *you* have implemented 
with *real code*, publicly vetted the algorithm, and THEN find it 
slow as demonstrated by profiled timings, I'm afraid it's all 
just unsubstantiated hot air to say categorically that "python is 
slow".  It might be "too slow to do some particular CPU-intensive 
task", but it's repeatedly proven quite sufficient for a wide 
variety of development needs.


-tkc




--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Thorsten Kampe
* cm_gui (Wed, 10 Dec 2008 10:42:40 -0800 (PST))> 
> Python is SLOW.And I am not comparing it with compiled languages
> like C.
> Python is even slower than PHP!

Sure. But Perl is faster than Ruby (exactly 2.53 times as fast). And 
Python is 1.525 times faster than VisualBasic (or was it the other way 
round?).
 
> Just go to any Python website and you will know.
> An example is:
> http://www2.ljworld.com/
> And this site is created by the creators of Django!

Quite slow, indeed! Django is even slower than Python itself...
 
> And it is not just this Python site that is slow. There are many many
> Python sites which are very slow. And please don’t say that it could
> be the web hosting or the server which is slow — because when so many
> Python sites are slower than PHP sites, it couldn’t be the web
> hosting.   Also, Zope/Plone is even slower.

I hope this will awaken the community. I did a quick test and it seems 
that Zope is slower than Python but Python is faster than Plone and PHP 
is faster than even Perl and Python _together_...!

Thanks for the heads-up, cm_gui!

Thorsten
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Jason Scheirer
On Dec 10, 10:42 am, cm_gui <[EMAIL PROTECTED]> wrote:
> http://blog.kowalczyk.info/blog/2008/07/05/why-google-should-sponsor-...
>
> I fully agree with Krzysztof Kowalczyk .
> Can't they build a faster VM for Python since they love the language
> so much?
>
> Python is SLOW.    And I am not comparing it with compiled languages
> like C.
> Python is even slower than PHP!
>
> Just go to any Python website and you will know.
> An example is:http://www2.ljworld.com/
> And this site is created by the creators of Django!
>
> And it is not just this Python site that is slow. There are many many
> Python sites which are very slow. And please don’t say that it could
> be the web hosting or the server which is slow — because when so many
> Python sites are slower than PHP sites, it couldn’t be the web
> hosting.   Also, Zope/Plone is even slower.
>
> Python is slow. Very slow.

I have two responses, and could not decide which one to post. Then I
figured I could just do both.

--

Response 1:

You have stumbled on to our plot! We use Python because we hate
getting things done and love nothing more than waiting for things to
complete, because that means more time to drink coffee. Python is a
hoax pushed on the world by the Vast Conspiracy Of People Who Actually
Never Get Anything Done But Enjoy Watching Things Scroll By Very
Slowly While Drinking Coffee.

--

Response 2:

Are you new to Python and frustrated with it? Is that where this is
coming from? If so, I am sorry that Python is so hard.

You can use Jython and get the Java VM or IronPython and get the CLR
VM. There's an immediate fix there for your objections to the CPython
VM. You could investigate getting some higher performance code going
using Stackless. Or move to event-based coding in Twisted and avoid
lots of while loop spins and locking/threading mischief and the other
things that come with network-bound programming like web development.
The PyPy project is also writing a fast Python intepreter with
multiple code output options. Or you can also profile your existing
code and optimize. Or integrate NumPy and Psyco into your efforts. And
you have the advantage of writing C extensions where it makes sense if
you're using CPython -- it's relatively easy and has resulted in fewer
than a dozen fatalities over the course of its existence. There are
options galore here, and 'Python' is actually a large, diverse
ecosystem. Web development is one thing Python does, but is not its
specialized purpose. PHP is a collection of tragic mistakes that
masquerades as a scripting language for the web.

I'd like to see some data on the response times of sites running
various Python web frameworks against each other and versus sites in
other languages. I'm also curious about the perception of speed versus
actual speed here -- if a site pushes 125k of page data a second at a
constant rate or pushes it all in 125k chunks in one second intervals,
the first is going to 'feel' faster initially even though both will
finish transferring the data at the same time and have identical page
load times. And if you're dealing with massive amounts of static
content (javascript frameworks, css, etc) that only needs to go over
the wire one then yeah, the page is going to be slow ON FIRST LOAD but
from then on have 90% of what it needs in local cache, so subsequent
page loads will be smaller and faster. That appears to be the case
with ljworld, at least.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Comparisons Gotcha

2008-12-10 Thread M.-A. Lemburg
On 2008-12-10 20:01, Luis Zarrabeitia wrote:
> On Wednesday 10 December 2008 10:50:57 am M.-A. Lemburg wrote:
>> On 2008-12-10 16:40, Luis Zarrabeitia wrote:
>>> Quoting Rasmus Fogh <[EMAIL PROTECTED]>:
 Rhamphoryncus wrote:
>> Rich comparisons were added to Python at the request of the
>> Numeric (now numpy) developers and they have been part of Python
>> a Numeric for many many years.
>>
>> I don't think it's likely they'll change things back to the days
>> of Python 1.5.2 ;-)
> 
> Please define "rich comparisons" for me. It seems that I do not understand 
> the 
> term - I was thinking it meant the ability to override the comparison 
> operators, and specially, the ability to override them independently.

That's one of the features, rich comparisons added. Another is
the ability to return arbitrary objects instead of just booleans
or integers:

http://www.python.org/dev/peps/pep-0207/

David was a Numeric developer at the time (among other things).

> Even in statically typed languages, when you override the equality 
> operator/function you can choose not to return a valid answer (raise an 
> exception). And it would break all the cases mentioned above (element in 
> list, etc). But that isn't the right thing to do. The language doesn't/can't 
> prohibit you from breaking the equality test, but that shouldn't be 
> considered a feature. (a==b).all() makes no sense. 

Perhaps not in your application, but it does make sense in other
numeric applications, e.g. ones that work on vectors or matrixes.

I'd suggest you simply wrap the comparison in a function and then
have that apply the necessary conversion to a boolean.

>>> Even the transition itself could be done without breaking much code...
>>> Make the == op return an object that wraps the array of bools (instead of
>>> the array itself), give it the any() and all() methods, and make
>>> __nonzero__/__bool__ equivalent to all().
>> That would cause a lot of confusion on its own, since such an
>> object wouldn't behave in the same way as say a regular Python
>> list (bool([0]) == True).
> 
> I'm certain that something could be worked out. A quick paragraph that took 
> me 
> just a few minutes to type shouldn't be construed as a PEP that will solve 
> all the problems :D.

As always: the Devil is in the details :-)

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Dec 10 2008)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2008-12-02: Released mxODBC.Connect 1.0.0  http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Duncan Booth
Tim Chase <[EMAIL PROTECTED]> wrote:

> [nibbling a little flame-bait]
> 
>> Python is even slower than PHP!
>> 
>> Just go to any Python website and you will know.
>> An example is:
>> http://www2.ljworld.com/
> 
> I'm not sure I'm seeing what you're seeing -- the dynamic page 
> loaded in under 2 seconds -- about on par with sun.com, 
> python.org, php.net or msn.com all being pulled from non-cached 
> servers.  You sure you're not mistaking your bandwidth and/or 
> browser-rendering slowness for Python-as-a-web-server slowness?
> 
For another example try http://www.novell.com. That's a Plone site which 
gets a lot of visitors and isn't noticeably slow.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread George Sakkis
On Dec 10, 1:42 pm, cm_gui <[EMAIL PROTECTED]> wrote:

> http://blog.kowalczyk.info/blog/2008/07/05/why-google-should-sponsor-...
>
> I fully agree with Krzysztof Kowalczyk .
> Can't they build a faster VM for Python since they love the language
> so much?

WTF is Krzysztof Kowalczyk and why should we care ?

Thanks for playing, the exit for the trolls is right down the hall.
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread Benjamin Kaplan
On Wed, Dec 10, 2008 at 12:22 PM, Patrick Mullen <[EMAIL PROTECTED]>wrote:

> On Wed, Dec 10, 2008 at 6:57 AM, MRAB <[EMAIL PROTECTED]> wrote:
> > Aaron Brady wrote:
> >>
> >> On Dec 9, 12:40 pm, MRAB <[EMAIL PROTECTED]> wrote:
> >>>
> >>> Aaron Brady wrote:
> 
>  On Dec 9, 8:28 am, MRAB <[EMAIL PROTECTED]> wrote:
>  snip
> >
> > In some languages (I think Delphi is one of them - it's been a
> while!)
> > some words which would normally be identifiers have a special meaning
> > in
> > certain contexts, but the syntax precludes any ambiguity, and not in
> a
> > difficult way. "as" in Python was one of those.
> > I certainly wouldn't want something like PL/I, where "IF", "THEN" and
> > "ELSE" could be identifiers, so you could have code like:
> > IF IF = THEN THEN
> > THEN = ELSE;
> > ELSE
> > ELSE = IF;
> > Seehttp://en.wikipedia.org/wiki/PL/I_(programming_language)
> .
> 
>  snip
>  That is, 'certainly' doesn't change the meaning of your statement
>  any.  You wouldn't want it, but King George III didn't want the
>  American Revolution.
> >>>
> >>> It's called emphasis.
> >>
> >> I just take you to have meant, then, +1 on excluding keywords from
> >> identifiers.  You said it the long way though, so I thought I missed
> >> something deeper, that didn't come across.
> >>
> > IIRC, most computer languages have an LL(1) grammar, which means that
> when
> > they are parsed you need to look at only the next word. If you're about
> to
> > parse a statement and the next word is "IF" then you know it's an
> > IF-statement, if it's an identifier then it's either a call or an
> assignment
> > statement (OK, you don't know exactly what kind of statement it is at
> that
> > point, but it works out just fine!).
> >
> > In the example from PL/I, "IF" could be the start of an IF-statement "IF
> >  THEN" or an assignment statement "IF = ". It's a
> bit
> > more tricky for the parser as well as the programmer.
> >
> > Life is easier if words having special meanings are reserved.
> >
> > However, that doesn't mean that all special words /must/ be reserved
> > (pragmatism beats purity). Sometimes the syntax makes it clear and
> > unambiguous, so you can get away with not making it a reserved word. The
> > word "as" in Python doesn't need to be reserved because the syntax
> precludes
> > ambiguity, but it's the only such word in the language, so it's just
> tidier
> > to make it reserved too.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
> I don't have a huge stake in this, but I wouldn't mind a change to
> allow anything proceeding a "." or preceeding a "(" to not be
> identified as a keyword.  It is obvious to me a s a human reader that
> something.if is quite a bit different than just a bare if.  And as far
> as parsing technology goes, isn't it supposed to go for the biggest
> match first?  I would not be for allowing bare keywords to be used in
> the situations described above, but since we are so used to being able
> to being able to have say, myclass.dir() or myclass.len() without them
> overwriting the builtin functions, it makes sense to me to be able to
> define a myclass.as() or myclass.with() without overwriting the
> keywords.  Though I know the semantics behind these two things are
> very different, the rules I go through when reading the code are very
> similar.  The parser change might be a hassle, and it might not be
> worth it at all of course, but from a conceptual point of view it is
> simple.  I mean, even now you can do class.__dict__["as"].
>

so what happens here?

if(some_condition()) :
do_something(a)

Yes, I know you don't need the parenthesis there in Python, but you still
can use it.


> I guess I'm -1 for full PL/1 craziness, but +1 for qualified keyword usage.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Stef Mientki

cm_gui wrote:

http://blog.kowalczyk.info/blog/2008/07/05/why-google-should-sponsor-a-faster-python-vm.html

I fully agree with Krzysztof Kowalczyk .
Can't they build a faster VM for Python since they love the language
so much?

Python is SLOW.And I am not comparing it with compiled languages
like C.
Python is even slower than PHP!

Just go to any Python website and you will know.
An example is:
http://www2.ljworld.com/
And this site is created by the creators of Django!

And it is not just this Python site that is slow. There are many many
Python sites which are very slow. And please don’t say that it could
be the web hosting or the server which is slow — because when so many
Python sites are slower than PHP sites, it couldn’t be the web
hosting.   Also, Zope/Plone is even slower.

Python is slow. Very slow.

--
http://mail.python.org/mailman/listinfo/python-list
  

Put this guy in the junk filter,
in may of this year he (or it) started the same discussion.
Stef
--
http://mail.python.org/mailman/listinfo/python-list


Re: SequenceMatcher bug ?

2008-12-10 Thread Gabriel Genellina

En Wed, 10 Dec 2008 15:14:20 -0200, eliben <[EMAIL PROTECTED]> escribió:


> My system is Gentoo, which installs python from source.  Maybe gentoo
> applies patches that the binary releases don't have.

I can't reproduce the problem. I got exactly the same results  
(0.999...)  
with all the releases I have at hand, ranging from 3.0 back to 2.1.3,  
all  

on Windows.



Andhttp://try-python.mired.org/says the same thing.



What ? This can't be.

1. Go to http://try-python.mired.org/
2. Type
import difflib
3. Type
difflib.SequenceMatcher(None, [4] + [5] * 200, [5] * 200).ratio()

Don't you get 0 as the answer ?


Ah, but that isn't the same expression you posted originally:

SequenceMatcher(None, [4] + [10] * 500 + [5], [10] * 500 + [5]).ratio()

Using *that* expression I got near 1.0 always. But leaving out the [5] at  
the end, it's true, it gives the wrong answer. Old Python 2.1.3 didn't  
have this problem:


Python 2.1.3 (#35, Apr  8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.

import difflib
difflib.SequenceMatcher(None, [4] + [5] * 500, [5] * 500).ratio()

0.99900099900099903

difflib.SequenceMatcher(None, [4] + [5] * 200, [5] * 200).ratio()

0.99750623441396513

difflib.SequenceMatcher(None, [4] + [5] * 100, [5] * 100).ratio()

0.99502487562189057

I've updated the tracker item.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


How to pass out the result from iterated function

2008-12-10 Thread JD
I got a iterated function like this:

def iterSomething(list):
has_something = False
for cell in list:
if something in cell:
has_something = True
output = something
   if has_something:
   iterSomething(output)
   else:
   final_out = outupt

The problem is how can I read this final_out outside of the function.
I tried the global statement, it seems not work. Any idea?

JD
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread D'Arcy J.M. Cain
On Wed, 10 Dec 2008 21:04:12 +0100
Stef Mientki <[EMAIL PROTECTED]> wrote:
> cm_gui wrote:
> > [...]  
> Put this guy in the junk filter,

What's the point if people like you are just going to repost his entire
message like that?

-- 
D'Arcy J.M. Cain <[EMAIL PROTECTED]> |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-10 Thread Bruno Desthuilliers

cm_gui a écrit :

(snip FUD)

see also: 
http://groups.google.com/group/comp.lang.python/browse_frm/thread/5cea684680f63c82


by the same troll^M^M^M^M^Msmart guy.

--
http://mail.python.org/mailman/listinfo/python-list


Re: How to pass out the result from iterated function

2008-12-10 Thread Gary Herron
JD wrote:
> I got a iterated function like this:
>
> def iterSomething(list):
> has_something = False
> for cell in list:
> if something in cell:
> has_something = True
> output = something
>if has_something:
>iterSomething(output)
>else:
>final_out = outupt
>
> The problem is how can I read this final_out outside of the function.
> I tried the global statement, it seems not work. Any idea?
>   

Without examining the intent of your code, I'll suggest this:

   if has_something:
   return iterSomething(output)
   else:
   return output

So either way, *something* is returned, and in the case of the recursive call, 
the innermost result is returned back up through all levels of the recursion.

Is that what you wanted?

Gary Herron



--
http://mail.python.org/mailman/listinfo/python-list


Re: get todays files

2008-12-10 Thread Andrew Doades


Tim Chase wrote:

This looks very good and I have tested successfully, but is there a
way I can set the today to automatically become todays date in that
format?


Yes...see the python datetime module[1]...particularly the strftime() 
call on date/datetime objects.


-tkc

[1]
http://docs.python.org/library/datetime.html

Thanks Tim, I got it in there myself.

Thanks for all your help with this and the links proved very useful and 
interesting reads.


Andrew
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to pass out the result from iterated function

2008-12-10 Thread eric
On Dec 10, 9:16 pm, JD <[EMAIL PROTECTED]> wrote:
> I got a iterated function like this:
>
> def iterSomething(list):
>     has_something = False
>     for cell in list:
>         if something in cell:
>             has_something = True
>             output = something
>    if has_something:
>        iterSomething(output)
>    else:
>        final_out = outupt
>
> The problem is how can I read this final_out outside of the function.
> I tried the global statement, it seems not work. Any idea?
>
> JD

why don't you just return it ?


def iterSomething(list):
has_something = False
for cell in list:
if something in cell:
has_something = True
output = something
   if has_something:
   return iterSomething(output)
   else:
   return output

?
--
http://mail.python.org/mailman/listinfo/python-list


upgrading my SIMPL Programming with Python nofee online course need some volunteer testers

2008-12-10 Thread bobicanprogram
SIMPL is an open source project which has been around for almost 10
years.   It maintains a very compact interprocesss communication
library which gives Linux developers the Send/Receive/Reply messaging
paradigm first popularized by QNX almost 30 years ago.
(http://www.icanprogram.com/simpl).

SIMPL has had a Python shared library for almost 5 years now.  I
believe that the SIMPL-Python hooks are one of the underused gems in
the SIMPL project.

I also maintain a couple of nofee online courses including one whose
subject is this Python interface into the SIMPL world (although I'm
not the author of the lesson material).

http://www.icanprogram.com/06py/main.html

There is active work in the SIMPL project to bring two upgrades in the
Python area.

a) the ability to run Python code on Windows and seamlessly interface
with a SIMPL application running under Linux

b) the ability to interface to a SIMPL-Python application from a
simple browser interface

The plan is to enhance this course material with this new
functionality just as soon as it arrives. Meanwhile I've been
working to upgrade the course installation experience with a self
installing archive.

http://www.icanprogram.com/python.self.html

I'm exactly the wrong person to debug this stuff as I'm not a Python
programmer and I'm too close in to spot the obvious flaws.

I'm looking for Python/Linux volunteers to give this stuff a spin and
supply constructive criticism to help improve the student installation
experience.

Thanks in advance.

bob
SIMPL project coordinator
PS.
If anyone is interested in reading more about SIMPL and SIMPL-Python
I'm the co-author of a recent book on the subject. Google Books
has a free preview of many of the chapters.  (see
http://www.icanprogram.com/lulu.html).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Mathematica 7 compares to other languages

2008-12-10 Thread w_a_x_man
On Dec 5, 9:51 am, Xah Lee <[EMAIL PROTECTED]> wrote:
>
> For those of you who don't know linear algebra but knows coding, this
> means, we want a function whose input is a list of 3 elements say
> {x,y,z}, and output is also a list of 3 elements, say {a,b,c}, with
> the condition that
>
> a = x/Sqrt[x^2+y^2+z^2]
> b = y/Sqrt[x^2+y^2+z^2]
> c = z/Sqrt[x^2+y^2+z^2]

>
> In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
> you'll have 50 or hundreds lines.

Ruby:

def norm a
  s = Math.sqrt(a.map{|x|x*x}.inject{|x,y|x+y})
  a.map{|x| x/s}
end
--
http://mail.python.org/mailman/listinfo/python-list


getting back into programming

2008-12-10 Thread usawargamer
I used to program in C and Perl (up until 2001) (a little C++ and Java
too).  Since then I've been a Business Analyst and only coded in VBA/
Excel and written some SQL queries.  (we use Sybase)

I feel the need for other tools.
Primarily I want to write a bunch of small programs to query a
database and perform some calculations.   While I can do this inside a
Sybase stored procedure, its a bit messy trying to "reimplement" a set
of calculations from Excel into Sybase.

I would like to either:
- relearn Perl
or
- learn Python (I have heard its a nice language)

1. How good and easy to use is the Python database interface (to
Sybase)?

2. Can you suggest some good books, and/or links for learning Python,
as well as teh database interface?

3. How difficult is it to install Python vs Perl on PC/Windows
machines?
--
http://mail.python.org/mailman/listinfo/python-list


pydb 1.24

2008-12-10 Thread R. Bernstein
This release is to clear out some old issues. It contains some
bugfixes, document corrections, and enhancements. Tests were
revised for Python 2.6 and Python without readline installed. A bug
involving invoking from ipython was fixed. The "frame" command is a
little more like gdb's. Exceptions are now caught in runcall().

This is the last release contemplated before a major rewrite.

download:
https://sourceforge.net/project/showfiles.php?group_id=61395&package_id=175827

bug reports:
https://sourceforge.net/tracker/?group_id=61395&atid=497159
--
http://mail.python.org/mailman/listinfo/python-list


Re: Mathematica 7 compares to other languages

2008-12-10 Thread Dotan Cohen
2008/12/10  <[EMAIL PROTECTED]>:
> On Dec 5, 9:51 am, Xah Lee <[EMAIL PROTECTED]> wrote:
>>
>> For those of you who don't know linear algebra but knows coding, this
>> means, we want a function whose input is a list of 3 elements say
>> {x,y,z}, and output is also a list of 3 elements, say {a,b,c}, with
>> the condition that
>>
>> a = x/Sqrt[x^2+y^2+z^2]
>> b = y/Sqrt[x^2+y^2+z^2]
>> c = z/Sqrt[x^2+y^2+z^2]
>
>>
>> In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
>> you'll have 50 or hundreds lines.
>
> Ruby:
>
> def norm a
>  s = Math.sqrt(a.map{|x|x*x}.inject{|x,y|x+y})
>  a.map{|x| x/s}
> end

If someone doesn't counter with a Python one-liner then I'm going to
port that to brainfuck.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


looking up function's doc in emacs

2008-12-10 Thread Xah Lee
in programing elisp in emacs, i can press “Ctrl+h f” to lookup the doc
for the function under cursor.

is there such facility when coding in perl, python, php?

(i'm interested in particular python. In perl, i can work around with
“perldoc -f functionName”, and in php it's php.net/functionName. Both
of which i have a elisp command with a shortcut that let me jump to
the doc)

Thanks.

  Xah
∑ http://xahlee.org/

☄
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-10 Thread Patrick Mullen
On Wed, Dec 10, 2008 at 11:57 AM, Benjamin Kaplan
<[EMAIL PROTECTED]> wrote:
>
>
> On Wed, Dec 10, 2008 at 12:22 PM, Patrick Mullen <[EMAIL PROTECTED]>
> wrote:
>>
>> I don't have a huge stake in this, but I wouldn't mind a change to
>> allow anything proceeding a "." or preceeding a "(" to not be
>> identified as a keyword.  It is obvious to me a s a human reader that
>> something.if is quite a bit different than just a bare if.  And as far
>> as parsing technology goes, isn't it supposed to go for the biggest
>> match first?  I would not be for allowing bare keywords to be used in
>> the situations described above, but since we are so used to being able
>> to being able to have say, myclass.dir() or myclass.len() without them
>> overwriting the builtin functions, it makes sense to me to be able to
>> define a myclass.as() or myclass.with() without overwriting the
>> keywords.  Though I know the semantics behind these two things are
>> very different, the rules I go through when reading the code are very
>> similar.  The parser change might be a hassle, and it might not be
>> worth it at all of course, but from a conceptual point of view it is
>> simple.  I mean, even now you can do class.__dict__["as"].
>
> so what happens here?
>
> if(some_condition()) :
> do_something(a)
>
> Yes, I know you don't need the parenthesis there in Python, but you still
> can use it.
>
>>
>> I guess I'm -1 for full PL/1 craziness, but +1 for qualified keyword
>> usage.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
>

Right, I now see how this scenario is tricky.  It could maybe be in
the form of " " but that starts
getting pretty complicated.  Too tricky.

Following the period on the other hand still makes sense to me. It
makes sense in the nature of "I wouldn't mind seeing this added", but
I suppose it still might not make sense in the nature of "We should do
the work to make this a reality".
--
http://mail.python.org/mailman/listinfo/python-list


Re: getting back into programming

2008-12-10 Thread M.-A. Lemburg
On 2008-12-10 22:02, [EMAIL PROTECTED] wrote:
> I used to program in C and Perl (up until 2001) (a little C++ and Java
> too).  Since then I've been a Business Analyst and only coded in VBA/
> Excel and written some SQL queries.  (we use Sybase)
> 
> I feel the need for other tools.
> Primarily I want to write a bunch of small programs to query a
> database and perform some calculations.   While I can do this inside a
> Sybase stored procedure, its a bit messy trying to "reimplement" a set
> of calculations from Excel into Sybase.
> 
> I would like to either:
> - relearn Perl
> or
> - learn Python (I have heard its a nice language)
> 
> 1. How good and easy to use is the Python database interface (to
> Sybase)?

If you're looking for a reliable database interface to Sybase,
I'd suggest mxODBC:

http://www.egenix.com/products/python/mxODBC/

It's been used in production by many banks for years and so far
without problems.

> 2. Can you suggest some good books, and/or links for learning Python,
> as well as teh database interface?

One of the best books is "Learning Python":

http://oreilly.com/catalog/9781565924642/

> 3. How difficult is it to install Python vs Perl on PC/Windows
> machines?

There's an MSI installer, so it's basically just a few clicks
away:

http://www.python.org/download/

Hope that helps,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Dec 10 2008)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2008-12-02: Released mxODBC.Connect 1.0.0  http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
--
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Google Groups in bad odour

2008-12-10 Thread Arnaud Delobelle
Frank Millman <[EMAIL PROTECTED]> writes:

> Hi all
>
> I know there have been complaints about spam on Google Groups over the
> last few months, with some members rejecting all traffic from them.
>
> You might be interested in this comment I got in a reply from someone
> on comp.os.linux.setup -
>
> "If you want to be read by a wider audience, you really want to post
> from
> someplace other than Google Groups.  Many (most?) readers of the
> Linux
> lists kill everything from there automatically."
>
> Unfortunately it seems that their newsgroup does not have a mail
> gateway, so I cannot use gmane. (Please correct me if I am wrong). I
> will therefore have to find a suitable news client. Any
> recommendations?
>
> Frank Millman

I use Gnus, I don't kill posts from groups.google.com and I don't get a
lot of spam.  When I do I just press 'Laep'.

-- 
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >