Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread John O'Hagan
On Tue, 14 Feb 2012 17:26:36 -0800 (PST)
Rick Johnson rantingrickjohn...@gmail.com wrote:

 On Feb 14, 6:44 pm, Chris Angelico ros...@gmail.com wrote:

 
 But WE are the fittest! Because we are INTELLIGENT!

And the whales say: But WE are the fittest! Because we are BIG!
And the rabbits say: But WE are the fittest! Because we are FERTILE!
And the snakes say: But WE are the fittest! Because we are VENOMOUS!

(Apologies to all animals mentioned for ascribing to them gratuitous
capitalisation and exclamation marks.)

Please read Darwin. He explicitly defined fittest, in the context of
evolutionary science, to mean sufficiently well-adapted to immediate local
conditions to be able to reproduce. There is nothing generalisable about this.
Intelligence is only useful in human ecological niches; and if the world were
underwater you would gladly swap it for gills.

But I don't think you'll read Darwin, or any real science on the subject.
You'll cling to your popular-science cartoon version of evolution because you
need it to support your false, odious worldview, which finally emerges from the
swamp: 

  Why were Negros treated as slaves in the US?
 
 Because they allowed themselves to be subjected. Sad, but true.
 
  Why were
  Australian Aboriginals treated like animals?
 
 Because they allowed them selves to be subjected. Sad, but true.
 
  And the one I hinted at
  above.
 
 Because the Jews allowed themselves to be subjected. Sad, but true.

You have just demonstrated that you are the worst kind of racist. Not only have
you blamed the victim on a truly monstrous scale, you have assigned blame not to
individuals, but to entire races. You are saying that something inherent in
each race caused them to allow their own subjugation. 

Calling it sad does not get you off the hook. Your cover was always
thin but now it's blown.



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


Re: Python vs. C++11

2012-02-15 Thread Henrik Faber
On 15.02.2012 08:18, Tim Roberts wrote:
 sturlamolden sturlamol...@yahoo.no wrote:

 There are bigsimilarities between Python and the new C++ standard. Now
 we can actually use our experience as Python programmers to write
 fantastic C++ :-)
 
 This is more true than you might think.  For quite a few years now, I've
 been able to do an almost line-for-line translation of my Python programs
 to C++ programs.  (Microsoft has had a for each extension for a while
 that made this easier.)

I disagree. Unicode support comes for free with Python3+ while C++ it
still is a piece of crap (or something that you'll have to pass to
external libraries). The C++ standard library is nowhere nearly as
densely packed with features than Python's. For every little thing you
need some external dependencies. Language semantics aren't enough to
translate one language into another.

Best regards,
Henrik
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Duncan Booth
Rick Johnson rantingrickjohn...@gmail.com wrote:

 On Feb 14, 5:31 am, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Rick Johnson rantingrickjohn...@gmail.com wrote:
  BS! With free healthcare, those who would have allowed their immune
  system fight off the flu, now take off from work, visit a local
  clinic, and get pumped full of antibiotics so they can create a new
  strain of antibiotic resistant flu virus! Thanks free healthcare!

 Anyone who can write 'antibiotic resistant flu virus' as though they
 believe it really needs to read some elementary books about disease.

 Here's a clue: No flu viruses are treatable with antibiotics. In some
 cas 
 es
 antibiotics may be useful for flu patients to treat secondary
 bacterial infections, but they are not effective against viruses.
 
 Duncan, your reading and comprehension skills are atrocious. Please
 re- read the paragraph you quoted, then spend some time
 comprehending it, then show me where i stated that antibiotics cure
 viral infections. psst: i NEVER said any such thing!

Rick, your reading and comprehension skills are atrocious. Please re-read 
the paragraph you quoted, then spend some time comprehending it, then 
show me where I stated that you '''stated that antibiotics cure viral 
infections'''. I never said any such thing.


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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Arnaud Delobelle
On 15 February 2012 09:47, Duncan Booth duncan.booth@invalid.invalid wrote:
 Rick Johnson rantingrickjohn...@gmail.com wrote:
[...]

Perhaps it's a bit presumptuous of me but...

It's tempting to react to his inflammatory posts, but after all Rick
is a troll and experience shows that trolls are best left alone.
Also, please spare a thought for all of us who have him in our
killfiles.

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


Re: Python usage numbers

2012-02-15 Thread Anssi Saari
Matej Cepl mc...@redhat.com writes:

 Slightly less flameish answer to the question “What should I do,
 really?” is a tough one: all these suggested answers are bad because
 they don’t deal with the fact, that your input data are obviously
 broken. The rest is just pure GIGO … 

Well, sure, but it happens that input data is broken and not fixable.
For example, I did a little program to display email headers like the
old frm that was bundled with elm, only with support for MIME decoding
of the headers. Obviously lots of email software is still completely
broken regarding MIME and also multi-line headers. However, something
useful can still be extracted from that broken data.

 BTW, can you display the following line?

 Příliš žluťoučký kůň úpěl ďábelské ódy.

Looks fine to me. You used an ellipsis too above. Well, I don't know
what it shold look like exactly. Lots of accents. Hmm, Google says it
means The quick brown fox cried too lazy? Seems appropriate :) BTW, I'm
sending this via Usenet, I wonder what happens in the mail-news gateway?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Duncan Booth
Arnaud Delobelle arno...@gmail.com wrote:

 On 15 February 2012 09:47, Duncan Booth duncan.booth@invalid.invalid
 wrote: 
 Rick Johnson rantingrickjohn...@gmail.com wrote:
 [...]
 
 Perhaps it's a bit presumptuous of me but...
 
 It's tempting to react to his inflammatory posts, but after all Rick
 is a troll and experience shows that trolls are best left alone.
 Also, please spare a thought for all of us who have him in our
 killfiles.
 
Yes, sorry about that.

Actually, I thought it was a bit weird that I saw ChrisA's comment but not 
the message he was commenting on until I went and looked for it. I read 
this group on a couple of machines and it looks like Rick's killfile entry 
had expired on the other but not this one. Next time I'm back on the other 
machine I'll try to remember to sort out the killfile.

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


Kill files [was Re: OT: Entitlements [was Re: Python usage numbers]]

2012-02-15 Thread Steven D'Aprano
On Wed, 15 Feb 2012 10:04:34 +, Duncan Booth wrote:

 Actually, I thought it was a bit weird that I saw ChrisA's comment but
 not the message he was commenting on until I went and looked for it. I
 read this group on a couple of machines and it looks like Rick's
 killfile entry had expired on the other but not this one. Next time I'm
 back on the other machine I'll try to remember to sort out the killfile.

Yes, I have this problem too. I'm reluctant to killfile people forever, 
call me a sucker if you like, but I'm willing to give people second 
chances (and apparently third and fourth and fifth chances). Methinks 
it's time for Monsieur Johnson to go back in the killfile.


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


atexit.register in case of errors

2012-02-15 Thread Andrea Crotti

I have the following very simplified situation

from atexit import register


def goodbye():
print(saying goodbye)


def main():
while True:
var = raw_input(read something)


if __name__ == '__main__':
register(goodbye)
main()


But in my case the goodbye function is deleting the logging file which 
was created

during the application execution.
Now the problem is that it *always* executes, even when the applications 
quits for

some bad errors.

Is there a way to have an exit hook, which doesn't execute in case of 
errors?
I've seen the code of atexit and it apparently doesn't know anything 
about the current

status and why the application is actually quitting, is that correct?
--
http://mail.python.org/mailman/listinfo/python-list


Re: atexit.register in case of errors

2012-02-15 Thread Mel Wilson
Andrea Crotti wrote:

 I have the following very simplified situation
 
 from atexit import register
 
 
 def goodbye():
  print(saying goodbye)
 
 
 def main():
  while True:
  var = raw_input(read something)
 
 
 if __name__ == '__main__':
  register(goodbye)
  main()
 
 
 But in my case the goodbye function is deleting the logging file which
 was created
 during the application execution.
 Now the problem is that it *always* executes, even when the applications
 quits for
 some bad errors.
 
 Is there a way to have an exit hook, which doesn't execute in case of
 errors?
 I've seen the code of atexit and it apparently doesn't know anything
 about the current
 status and why the application is actually quitting, is that correct?

That's sort of the point: to do things that simply *have* to happen, even if 
you've lost control of the program.

The usual way to do what you're asking is

if __name__ == '__main__':
main()
goodbye()

and write main so that it returns after it's done all the things it's 
supposed to do.  If you've sprinkled `sys.exit()` all over your code, then 
don't do that.  If you're forced to deal with a library that hides 
`sys.exit()` calls in the functions, then you have my sympathy.  Library 
authors should not do that, and there have been threads on c.l.p explaining 
why they shouldn't.

Mel.

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


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-15 Thread Devin Jeanpierre
On Tue, Feb 14, 2012 at 9:08 PM, MRAB pyt...@mrabarnett.plus.com wrote:
 There is one place in the re engine where it tries to avoid getting
 stuck in an infinite loop because of a zero-width match, but the fix
 inadvertently causes another bug. It's described in issue #1647489.

Just read the issue. Interesting, didn't know that was a bug rather
than deliberate behavior. The other behavior (only match empty space
once) makes more sense though. Thanks for linking.

Still, that's for avoiding infinite loops in finditer/findall, not
match/search :S

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


Re: atexit.register in case of errors

2012-02-15 Thread Devin Jeanpierre
On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson mwil...@the-wire.com wrote:
 The usual way to do what you're asking is

 if __name__ == '__main__':
    main()
    goodbye()

 and write main so that it returns after it's done all the things it's
 supposed to do.  If you've sprinkled `sys.exit()` all over your code, then
 don't do that.  If you're forced to deal with a library that hides
 `sys.exit()` calls in the functions, then you have my sympathy.  Library
 authors should not do that, and there have been threads on c.l.p explaining
 why they shouldn't.

In such a case. one can do::

if __name__ == '__main__':
try:
main()
except SystemExit:
pass
goodbye()

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


[ANN]: Python module to distribute computations for parallel execution

2012-02-15 Thread Giridhar Pemmasani
Hello,

I would like to announce dispy (http://dispy.sourceforge.net), a
python framework for distributing computations for parallel execution
to processors/cores on single node to many nodes over the network. The
computations can be python functions or programs. If there are any
dependencies, such as other python functions, modules, classes,
objects or files, they are also distributed as well. The results of
each computation, output, error messages and exception trace, if any,
are made available to client program for further processing. Popular
map/reduce style programs can be easily developed and deployed with
dispy.

There is also an implementation of dispy, called discopy, that uses
asynchronous I/O and coroutines, so that discopy will scale
efficiently for large number of network connections (right now this is
a bit academic, until it has been tested with such setups). The
framework with asynchronous I/O and coroutines, called asyncoro, is
independent of dispy - discopy is an implementation of dispy using
asyncoro. Others may find asyncoro itself useful.

Salient features of dispy/discopy are:

  * Computations (python functions or standalone programs) and its
    dependencies (files, python functions, classes, modules) are
    distributed automatically.

  * Computation nodes can be anywhere on the network (local or
    remote). For security, either simple hash based authentication or
    SSL encryption can be used.

  * A computation may specify which nodes are allowed to execute it
    (for now, using simple patterns of IP addresses).

  * After each execution is finished, the results of execution,
    output, errors and exception trace are made available for further
    processing.

  * If callback function is provided, dispy executes that function
    when a job is finished; this feature is useful for further
    processing of job results.


  * Nodes may become available dynamically: dispy will schedule jobs
    whenever a node is available and computations can use that node.

  * Client-side and server-side fault recovery are supported:

    If user program (client) terminates unexpectedly (e.g., due to
    uncaught exception), the nodes continue to execute scheduled jobs.
    If client-side fault recover option is used when creating a cluster,
    the results of the scheduled (but unfinished at the time of crash)
    jobs for that cluster can be easily retrieved later.

    If a computation is marked re-entrant (with 'resubmit=True' option)
    when a cluster is created and a node (server) executing jobs for
    that computation fails, dispy automatically resubmits those jobs
    to other available nodes.

  * In optimization problems it is useful for computations to send
    (successive) provisional results back to the client, so it can,
    for example, terminate computations. If computations are python
    functions, they can use 'dispy_provisional_result' function for
    this purpose.

  * dispy can be used in a single process to use all the nodes
    exclusively (with JobCluster - simpler to use) or in multiple
    processes simultaneously sharing the nodes (with ShareJobCluster
    and dispyscheduler).

dispy works with python 2.7. It has been tested on Linux, Mac OS X and
known to work with Windows. discopy has been tested on Linux and Mac
OS X.

I am not subscribed to the list, so please Cc me if you have comments.

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


Re: atexit.register in case of errors

2012-02-15 Thread Andrea Crotti

On 02/15/2012 01:52 PM, Devin Jeanpierre wrote:

On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilsonmwil...@the-wire.com  wrote:

The usual way to do what you're asking is

if __name__ == '__main__':
main()
goodbye()

and write main so that it returns after it's done all the things it's
supposed to do.  If you've sprinkled `sys.exit()` all over your code, then
don't do that.  If you're forced to deal with a library that hides
`sys.exit()` calls in the functions, then you have my sympathy.  Library
authors should not do that, and there have been threads on c.l.p explaining
why they shouldn't.

In such a case. one can do::

 if __name__ == '__main__':
 try:
 main()
 except SystemExit:
 pass
 goodbye()

-- Devin


Makes perfect sense, I solved like this then, thanks
--
http://mail.python.org/mailman/listinfo/python-list


Re: Automatic Type Conversion to String

2012-02-15 Thread Bruce Eckel
 Could it be that you missed the fact that strings are immutable? That
 means that you can't change the content of the object once it is
 initialized. In particular, it means that you e.g. have to override
 __new__ instead of __init__, because the content is already fixed when
 the latter is called.

 Uli

Yes, that's what I missed, and it explains why I found examples of str
inheritance using __new__. I think this might end up being a puzzle I
poke at for awhile.

Also, I discovered that the attempt to create a Path class goes back
to 2006, where it created a lot of discussion and was finally shelved:
http://www.python.org/dev/peps/pep-0355/

A significant part of the problem seems to be that there was no
inheritance from str at the time, so maybe a lot of the issues they
ran into could be solved now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Rick Johnson
On Feb 15, 2:56 am, John O'Hagan resea...@johnohagan.com wrote:

 You have just demonstrated that you are the worst kind of racist. Not only 
 have
 you blamed the victim on a truly monstrous scale, you have assigned blame not 
 to
 individuals, but to entire races.

Your tabloid sensationalism is the worst i've seen. You'll jump at any
chance to tag someone a racist, homophobic, sexist, or any other kind
of hate group you can muster in a weak attempt to win an argument you
cannot win by spewing ad hominem attacks.

You cannot stay on subject because your argument is baseless and mine
is the backed by truth. Just in case you have forgotten, here is the
main point: degenerates are a drain on healthcare/society. Can you
counter that argument with a fact and prove they are not? The only
winning argument is that degenerates pay their own medical bills...
but as you and i know, most degenerates DON'T pay their own medical
bills. They expect US to pay them.

 You are saying that something inherent in
 each race caused them to allow their own subjugation.

I have PROVEN that when people FIGHT back, they will NOT be subjects
to tyranny; race has NOTHING to do with it. I gave one example in
history where people would rather die than be subjected to tyranny,
there are many more. GIVE ME FREEDOM FOR GIVE ME DEATH!

The world is full of evil people who seek to force their fellow man
into slavery. Those who refuse to fight for freedom will be victims,
on the other hand, those who are willing to sacrifice ALL in the name
of freedom will be free men.

300: Go now! Run along and tell your Xerxes he faces free men here,
not slaves! Do it quickly, before we decide to make our wall just a
little bit bigger.

John, I have grown weary of educating you. Go back to your day job
writing op-eds for the National Inquirer and News of the World; they
love this vile sensationalist crap! Goodnight John boy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Mark Lawrence

On 15/02/2012 15:04, Rick Johnson wrote:

On Feb 15, 2:56 am, John O'Haganresea...@johnohagan.com  wrote:



John, I have grown weary of educating you. Go back to your day job
writing op-eds for the National Inquirer and News of the World; they
love this vile sensationalist crap! Goodnight John boy.


The News of the Screws closed months ago.

As you didn't answer my question from some days back I'll ask it agin.

Please explain why previously healthy people get struck down with Common 
Fatigue Syndrome amongst other things.


--
Cheers.

Mark Lawrence.

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


Re: atexit.register in case of errors

2012-02-15 Thread Thomas Rachel

Am 15.02.2012 14:52 schrieb Devin Jeanpierre:

On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilsonmwil...@the-wire.com  wrote:

The usual way to do what you're asking is

if __name__ == '__main__':
main()
goodbye()

and write main so that it returns after it's done all the things it's
supposed to do.  If you've sprinkled `sys.exit()` all over your code, then
don't do that.  If you're forced to deal with a library that hides
`sys.exit()` calls in the functions, then you have my sympathy.  Library
authors should not do that, and there have been threads on c.l.p explaining
why they shouldn't.


In such a case. one can do::

 if __name__ == '__main__':
 try:
 main()
 except SystemExit:
 pass
 goodbye()

-- Devin


Wouldn't

if __name__ == '__main__':
try:
main()
finally:
goodbye()

be even better? Or doesn't it work well together with SystemExit?


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


Re: atexit.register in case of errors

2012-02-15 Thread Andrea Crotti

On 02/15/2012 03:18 PM, Thomas Rachel wrote:


Wouldn't

if __name__ == '__main__':
try:
main()
finally:
goodbye()

be even better? Or doesn't it work well together with SystemExit?


Thomas


Well in that case goodbye is always called, even if I have some other 
nasty exception,

which is not what I want.. (and is exactly what I had with atexit.register).
Isn't it?
--
http://mail.python.org/mailman/listinfo/python-list


Interactive keyword help

2012-02-15 Thread Mark Lawrence
I didn't realise that this was available until today.  It doesn't appear 
to be prominent in the official docs or have I missed something? 
Certainly I'd have thought a couple of sentences here 
http://www.python.org/about/help/ would be justified, what do y'all think?


--
Cheers.

Mark Lawrence.

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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Rick Johnson
On Feb 15, 9:18 am, Mark Lawrence breamore...@yahoo.co.uk wrote:
 As you didn't answer my question from some days back I'll ask it agin.
 Please explain why previously healthy people get struck down with Common
 Fatigue Syndrome amongst other things.

Why do you seek my counsel regarding medical ailments? Do you believe
i have special knowledge in the field? But more importantly: how is
your question germane to the destruction of healthcare and
expansion of tyranny by the degenerates of society; or by those who
support degeneracy by engaging in degenerate eugenics?

Was your question meant as rhetorical? Or merely yet ANOTHER crude
attempt to employ sophistry in hopes of coercing the less astute folks
among us to hop in your clown car of delirium and head-off down
ANOTHER path to that leads to logical fallacy?

Stay on subject!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Mark Lawrence

On 15/02/2012 16:27, Rick Johnson wrote:

On Feb 15, 9:18 am, Mark Lawrencebreamore...@yahoo.co.uk  wrote:

As you didn't answer my question from some days back I'll ask it agin.
Please explain why previously healthy people get struck down with Common
Fatigue Syndrome amongst other things.


Why do you seek my counsel regarding medical ailments? Do you believe
i have special knowledge in the field? But more importantly: how is
your question germane to the destruction of healthcare and
expansion of tyranny by the degenerates of society; or by those who
support degeneracy by engaging in degenerate eugenics?

Was your question meant as rhetorical? Or merely yet ANOTHER crude
attempt to employ sophistry in hopes of coercing the less astute folks
among us to hop in your clown car of delirium and head-off down
ANOTHER path to that leads to logical fallacy?

Stay on subject!


I don't seek your counsel on anything.  You set the ball rolling and I 
quote If you can't afford healthcare, then you die. and You want to 
solve the healthcare problem then STOP TREATING PEOPLE WHO

DON'T HAVE INSURANCE!

You later went on to say and I again quote
Healthy people do not need healthcare very often, and in the rare
cases when they do, they don't bog down the system because their
bodies are strong. Why are their bodies strong? Because healthy people
eat correctly, healthy people exercise, therefore, healthy people have
correctly functioning immune systems -- of course quality genes always
help!

The question was originally put in response to that, so you've resorted 
to your usual tactics of spewing ad hominem attacks on anybody who dares 
to challenge you in any way, shape or form.


If I were you I'd stick to things that you understand, like downloading 
workable help files.  But oh dear, you can't even manage that, you 
simply moan like hell because the help file you had didn't work 
correctly. Or IDLE is crap.  Or ...


--
Cheers.

Mark Lawrence.

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


Re: Interactive keyword help

2012-02-15 Thread Andrew Berg
On 2/15/2012 10:04 AM, Mark Lawrence wrote:
 I didn't realise that this was available until today.  It doesn't appear 
 to be prominent in the official docs or have I missed something? 
 Certainly I'd have thought a couple of sentences here 
 http://www.python.org/about/help/ would be justified, what do y'all think?
 
help() is a built-in function, not a keyword.
http://docs.python.org/library/functions.html#help
http://docs.python.org/py3k/library/functions.html#help

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interactive keyword help

2012-02-15 Thread Arnaud Delobelle
On 15 February 2012 17:23, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2/15/2012 10:04 AM, Mark Lawrence wrote:
 I didn't realise that this was available until today.  It doesn't appear
 to be prominent in the official docs or have I missed something?
 Certainly I'd have thought a couple of sentences here
 http://www.python.org/about/help/ would be justified, what do y'all think?

 help() is a built-in function, not a keyword.

I think he's referring to help *on* keywords, e.g.

 help('yield')

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


Re: Interactive keyword help

2012-02-15 Thread Mark Lawrence

On 15/02/2012 17:27, Arnaud Delobelle wrote:

On 15 February 2012 17:23, Andrew Bergbahamutzero8...@gmail.com  wrote:

On 2/15/2012 10:04 AM, Mark Lawrence wrote:

I didn't realise that this was available until today.  It doesn't appear
to be prominent in the official docs or have I missed something?
Certainly I'd have thought a couple of sentences here
http://www.python.org/about/help/ would be justified, what do y'all think?


help() is a built-in function, not a keyword.


I think he's referring to help *on* keywords, e.g.


help('yield')




Correct.

--
Cheers.

Mark Lawrence.

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


Re: Automatic Type Conversion to String

2012-02-15 Thread Ned Deily
In article 
dc097623-f377-4c7d-a065-13b58bf1c...@n12g2000yqb.googlegroups.com,
 Bruce Eckel lists.ec...@gmail.com wrote:
 Also, I discovered that the attempt to create a Path class goes back
 to 2006, where it created a lot of discussion and was finally shelved:
 http://www.python.org/dev/peps/pep-0355/
 
 A significant part of the problem seems to be that there was no
 inheritance from str at the time, so maybe a lot of the issues they
 ran into could be solved now.

You might want to take a look at pathlib, a current attempt at providing 
object-oriented paths, written by Antoine Pitrou, one of the Python core 
developers:

http://pypi.python.org/pypi/pathlib

-- 
 Ned Deily,
 n...@acm.org

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


Complexity question on Python 3 lists

2012-02-15 Thread Franck Ditter
What is the cost of calling primes(n) below ? I'm mainly interested in
knowing if the call to append is O(1), even amortized.
Do lists in Python 3 behave like ArrayList in Java (if the capacity
is full, then the array grows by more than 1 element) ?

def sdiv(n) : # n = 2
returns the smallest (prime) divisor of n
if n % 2 == 0 : return 2
for d in range(3,int(sqrt(n))+1,2) :
if n % d == 0 : return d
return n

def isPrime(n) :
Returns True iff n is prime
return n = 2 and n == sdiv(n)

def primes(n) :   # n = 2
Returns the list of primes in [2,n]
res = []
for k in range(2,n+1) :
if isPrime(k) : res.append(k)# cost O(1) ?
return res

Thanks,

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


Re: how to tell a method is classmethod or static method or instance method

2012-02-15 Thread Nathan Rice
 And I'll take this opportunity to plug my dualmethod descriptor:

 http://code.activestate.com/recipes/577030-dualmethod-descriptor/

I use an analogous pattern in SQL Alchemy all the time (it's called
hybridmethod/hybridproperty there).

+1 to dualmethod, that pattern is great when you want a method or
property that does something concrete when passed an instance, or
something abstract relating to all instances when passed a class.


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


Re: Complexity question on Python 3 lists

2012-02-15 Thread Chris Rebert
On Wed, Feb 15, 2012 at 10:20 AM, Franck Ditter fra...@ditter.org wrote:
 What is the cost of calling primes(n) below ? I'm mainly interested in
 knowing if the call to append is O(1), even amortized.
 Do lists in Python 3 behave like ArrayList in Java (if the capacity
 is full, then the array grows by more than 1 element) ?

Yes. Python lists aren't linked lists. list.append() resizes the
underlying array intelligently to give O(1) performance, although I
can't find any guarantee of this in the docs, but it is true in
practice for all major Python implementations.

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


Re: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-15 Thread Miki Tebeka
It depends on the overall runtime of the script vs start time of the vm. But 
yes in most benchmarks the script start time will bias against scripted 
languages.

On a site note: ALL CAPS is considered shouting, please don't use that in news 
groups.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: atexit.register in case of errors

2012-02-15 Thread Miki Tebeka
Another option is to use a global error flag and set it in sys.excepthook (see 
http://docs.python.org/library/sys.html#sys.excepthook).

goodbye will check the error flag and skip execution if error flag is set.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complexity question on Python 3 lists

2012-02-15 Thread Dave Angel

On 02/15/2012 01:20 PM, Franck Ditter wrote:

What is the cost of calling primes(n) below ? I'm mainly interested in
knowing if the call to append is O(1), even amortized.
Do lists in Python 3 behave like ArrayList in Java (if the capacity
is full, then the array grows by more than 1 element) ?

def sdiv(n) : # n= 2
 returns the smallest (prime) divisor of n
 if n % 2 == 0 : return 2
 for d in range(3,int(sqrt(n))+1,2) :
 if n % d == 0 : return d
 return n

def isPrime(n) :
 Returns True iff n is prime
 return n= 2 and n == sdiv(n)

def primes(n) :   # n= 2
 Returns the list of primes in [2,n]
 res = []
 for k in range(2,n+1) :
 if isPrime(k) : res.append(k)# cost O(1) ?
 return res

Thanks,

 franck
Yes, lists behave the way you'd expect (see vector in C++), where when 
they have to reallocate they do so exponentially.


However, realize that your algorithm is inefficient by a huge factor 
more than any time spent expanding lists.  The biggest single thing you 
need to do is to memoize -- store the list of known primes, and add to 
it as you encounter more.  Then use that list instead of range(3, xxx, 
2) for doing the trial divisions.




--

DaveA

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


Re: Complexity question on Python 3 lists

2012-02-15 Thread Ian Kelly
On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter fra...@ditter.org wrote:
 What is the cost of calling primes(n) below ? I'm mainly interested in
 knowing if the call to append is O(1), even amortized.

Yes, it's amortized O(1).  See:

http://wiki.python.org/moin/TimeComplexity

From a relatively shallow analysis, primes(n) appears to be O(n **
(3/2)), but it might be possible to tighten that up a bit with an
analysis of the distribution of primes and their smallest divisors.

 Do lists in Python 3 behave like ArrayList in Java (if the capacity
 is full, then the array grows by more than 1 element) ?

I believe the behavior in CPython is that if the array is full, the
capacity is doubled, but I'm not certain, and that would be an
implementation detail in any case.

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


Re: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-15 Thread Dave Angel

On 02/15/2012 01:36 PM, Miki Tebeka wrote:

It depends on the overall runtime of the script vs start time of the vm. But 
yes in most benchmarks the script start time will bias against scripted 
languages.

On a site note: ALL CAPS is considered shouting, please don't use that in news 
groups.
When you reply to a known bot, please include some indication of the 
fact, so we know your message can be ignored as well.






--

DaveA

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


Re: Complexity question on Python 3 lists

2012-02-15 Thread Stefan Behnel
Ian Kelly, 15.02.2012 19:43:
 On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote:
 Do lists in Python 3 behave like ArrayList in Java (if the capacity
 is full, then the array grows by more than 1 element) ?
 
 I believe the behavior in CPython is that if the array is full, the
 capacity is doubled

But only up to a certain limit. After that, it grows in constant steps.
Otherwise, your memory would be bound to explode on an append even though
your list uses only half of it (or one third, in case it needs to copy).


, but I'm not certain, and that would be an
 implementation detail in any case.

Absolutely.

Stefan

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


Re: Complexity question on Python 3 lists

2012-02-15 Thread Chris Rebert
On Wed, Feb 15, 2012 at 10:43 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter fra...@ditter.org wrote:
snip
 Do lists in Python 3 behave like ArrayList in Java (if the capacity
 is full, then the array grows by more than 1 element) ?

 I believe the behavior in CPython is that if the array is full, the
 capacity is doubled, but I'm not certain, and that would be an
 implementation detail in any case.

It's slightly more complex:
http://hg.python.org/cpython/file/096b31e0f8ea/Objects/listobject.c
The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, …
-- list_resize()

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


Python to Combine Multiple Excel Worksheets into One Worksheet

2012-02-15 Thread SMac2347
Hello,

I have one single Excel file with many separate worksheets, and for
work I need to combine all these separate worksheets into one single
worksheet (I am not worried about formatting, as the format is the
same in each sheet, nor am I worried about Excel's row limit).
Essentially, I am looking for a way to append the data in one sheet to
the bottom of the sheet that proceeds it.

What would be the best way to do this, and how would I go about doing
it? Can it be done simply with the xlwt, xlrd, and xutils modules, or
(as I was thinking) do I need to convert the sheets to separate csv
files, then append the separate csv files, and then write the
completed file back into .xls format? Or perhaps something else?

As I am really only a Python beginner, any and all help is very much
appreciated. Thank you in advance!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Kill files [was Re: OT: Entitlements [was Re: Python usage numbers]]

2012-02-15 Thread Ethan Furman

Steven D'Aprano wrote:

On Wed, 15 Feb 2012 10:04:34 +, Duncan Booth wrote:


Actually, I thought it was a bit weird that I saw ChrisA's comment but
not the message he was commenting on until I went and looked for it. I
read this group on a couple of machines and it looks like Rick's
killfile entry had expired on the other but not this one. Next time I'm
back on the other machine I'll try to remember to sort out the killfile.


Yes, I have this problem too. I'm reluctant to killfile people forever, 
call me a sucker if you like, but I'm willing to give people second 
chances (and apparently third and fourth and fifth chances). Methinks 
it's time for Monsieur Johnson to go back in the killfile.


Luckily for me there are enough folks that still reply to the trolls in 
my killfile that I can see if it's time to take them off or not.  ;)


(This one is a resounding NOT)

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


writing to a file from within nested loops

2012-02-15 Thread Rituparna Sengupta
Hi,

I'm working on this code and I keep getting an error. It might be some very 
basic thing but I was wondering if someone could help. Its a loop within a 
loop. The part outside the innermost loop gets printed fine, but the part 
within the innermost loop doesn't get printed. I get an error: 'str' has no 
attribute 'write'. Thanks in advance.

Ritu



.
.
.
i=0
 while im
 r=name[i]
 f=open('file'+'%s' %(r), a)
 f.write(whatever+r)    #part outside innermost loop gets printed
 j=0
  while jn
  f.write(output of loop)  #part within innermost loop doesn't get printed
  j=j+1
 f.close()
 i=i+1






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


Re: writing to a file from within nested loops

2012-02-15 Thread Ian Kelly
On Wed, Feb 15, 2012 at 1:12 PM, Rituparna Sengupta rsengu...@wisc.edu wrote:
 Hi,

 I'm working on this code and I keep getting an error. It might be some very 
 basic thing but I was wondering if someone could help. Its a loop within a 
 loop. The part outside the innermost loop gets printed fine, but the part 
 within the innermost loop doesn't get printed. I get an error: 'str' has no 
 attribute 'write'. Thanks in advance.

There's not enough to go on here.  Please post the actual code snippet
and the full traceback.  Don't summarize the error for us.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: writing to a file from within nested loops

2012-02-15 Thread Chris Rebert
On Wed, Feb 15, 2012 at 12:12 PM, Rituparna Sengupta rsengu...@wisc.edu wrote:
 Hi,

 I'm working on this code and I keep getting an error. It might be some very 
 basic thing but I was wondering if someone could help. Its a loop within a 
 loop. The part outside the innermost loop gets printed fine, but the part 
 within the innermost loop doesn't get printed. I get an error: 'str' has no 
 attribute 'write'. Thanks in advance.

Please post your exact actual code (which this isn't; it has clear
fatal syntax errors) and the full error message, including the stack
Traceback.

I would suspect there is some problematic assignment to `f` that you
excluded from the snippet you posted.

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


Re: writing to a file from within nested loops

2012-02-15 Thread Dave Angel

On 02/15/2012 03:12 PM, Rituparna Sengupta wrote:

Hi,

I'm working on this code and I keep getting an error. It might be some very 
basic thing but I was wondering if someone could help. Its a loop within a 
loop. The part outside the innermost loop gets printed fine, but the part 
within the innermost loop doesn't get printed. I get an error: 'str' has no 
attribute 'write'. Thanks in advance.

Ritu



.
.
.
i=0
  while im
  r=name[i]
  f=open('file'+'%s' %(r), a)
  f.write(whatever+r)#part outside innermost loop gets printed
  j=0
   while jn
   f.write(output of loop)  #part within innermost loop doesn't get printed
   j=j+1
  f.close()
  i=i+1



Welcome to the mailing list.

Some fundamentals, please:

1) give python version  os
2) copy/paste the code, don't retype it.  You have lots of typos which 
would cause syntax errors, not xxx has no attribute yyy.  And please 
don't use 1 column indents;  they're illegible.  4 spaces is a good 
number, recommended in a large number of places, including pep8.
3) copy/paste the whole error, including traceback.  Without it in this 
case, we're forced to guess where the problem might be, and that must be 
somewhere else in the program, since the only write() attribute you've 
quoted here are on f.write() calls, and f is only set to a file object, 
not a string object.  There are lots of ways in the code you don't show, 
where you might confuse the system, such as redefining open.


Now to your questions:

A) Since you don't show n, it could very well be 0 or negative, in which 
case the inner loop would never execute.


B) Since you don't have correct indentation, it's possible the actual 
program closes the file inside the inner loop, in which case it might 
execute just once, then get an exception.  not the one you quote, but 
whatever.


C) Depending on how you run this program, perhaps the file isn't getting 
flushed when you get your error, so you just think the output didn't happen.


D) BTW, i don't see any prints, but perhaps that's a minor point.  You 
might think of file.write() as printing to a file.  Sort of.




--

DaveA

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


Re: writing to a file from within nested loops

2012-02-15 Thread Mark Lawrence

On 15/02/2012 20:12, Rituparna Sengupta wrote:

Hi,

I'm working on this code and I keep getting an error. It might be some very 
basic thing but I was wondering if someone could help. Its a loop within a 
loop. The part outside the innermost loop gets printed fine, but the part 
within the innermost loop doesn't get printed. I get an error: 'str' has no 
attribute 'write'. Thanks in advance.

Ritu

.
i=0
  while im
  r=name[i]
  f=open('file'+'%s' %(r), a)
  f.write(whatever+r)#part outside innermost loop gets printed
  j=0
   while jn
   f.write(output of loop)  #part within innermost loop doesn't get printed
   j=j+1
  f.close()
  i=i+1



The above isn't Python so please post all of your code or a 
representative snippet that can show the problem, with the complete 
traceback and not simply the last line.  Having said that I'm guessing 
that you're reassigning f somewhere to be a string, hence the error. 
Also why not write Python loops like:-

for r in name:
etc.

--
Cheers.

Mark Lawrence.

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


[semi OT]: Smartphones and Python?

2012-02-15 Thread Martin Schöön
First of all: I don't have any first hand experience of smartphones
but now that my trusted old GSM phone is getting old I decided I am
in for an up-grade. It struck me it might be nice to get something
for which I could write Python programs.

A very quick internet search indicated that this should be no big
deal if I go for an Android-based phone. What about the alterna-
tives?

It struck me this must be the best place to ask.

What else? I don't know if it matters but my home PC OS is Linux.
And I am not much of a Python programmer but I enjoy learning it
and I have reached a level that has turned out to be useful at work.

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


Numerical Linear Algebra in arbitrary precision

2012-02-15 Thread Ken
Brand new Python user and a bit overwhelmed with the variety of
packages available.  Any recommendation for performing numerical
linear algebra (specifically least squares and generalized least
squares using QR or SVD) in arbitrary precision?  I've been looking at
mpmath but can't seem to find much info on built in functions except
for LU decomposition/solve.

Appreciate any comments.

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


Re: Looking for PyPi 2.0...

2012-02-15 Thread John Nagle

On 2/8/2012 9:47 AM, Chris Rebert wrote:

On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice
nathan.alexander.r...@gmail.com  wrote:

As a user:
* Finding the right module in PyPi is a pain because there is limited,
low quality semantic information, and there is no code indexing.


   CPAN does it right.  They host the code.  (PyPi is just a
collection of links).  They have packaging standards (PyPi
does not.)  CPAN tends not to be full of low-quality modules
that do roughly the same thing.

   If you want to find a Python module, Google is more useful
than PyPi.

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


Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-15 Thread John Nagle

On 2/4/2012 12:43 PM, Chris Angelico wrote:

On Sun, Feb 5, 2012 at 3:32 AM, Andrew Bergbahamutzero8...@gmail.com  wrote:

On 2/3/2012 9:15 PM, Chris Angelico wrote:

Do you call on potentially-buggy external modules?

It imports one module that does little more than define a few simple
functions. There's certainly no (intentional) interpreter hackery at work.


   Are you doing a conditional import, one that takes place after load
time?  If you do an import within a function or class, it is executed
when the code around it executes.  If you import a file with a
syntax error during execution, you could get the error message you're
getting.

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


Re: Looking for PyPi 2.0...

2012-02-15 Thread Donald Stufft
On Wednesday, February 15, 2012 at 4:24 PM, John Nagle wrote:
 On 2/8/2012 9:47 AM, Chris Rebert wrote:
  On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice
  nathan.alexander.r...@gmail.com (mailto:nathan.alexander.r...@gmail.com) 
  wrote:
   As a user:
   * Finding the right module in PyPi is a pain because there is limited,
   low quality semantic information, and there is no code indexing.
   
  
  
 
 
 CPAN does it right. They host the code. (PyPi is just a
 collection of links). They have packaging standards (PyPi
 does not.) CPAN tends not to be full of low-quality modules
 that do roughly the same thing.
 
 If you want to find a Python module, Google is more useful
 than PyPi.
 
 

Hopefully soon crate.io will be useful for finding modules ;) I have plans for 
it to try and, encourage people to host their code and encourage following 
packaging standards. I'm currently focused mostly on the backend stability 
(e.g. getting it stable) but emphasizing things that are generally good for the 
packaging ecosystem is something I hope to do. 
 
 John Nagle
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 
 

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


Re: atexit.register in case of errors

2012-02-15 Thread Terry Reedy

On 2/15/2012 8:12 AM, Andrea Crotti wrote:

I have the following very simplified situation

from atexit import register

def goodbye(): print(saying goodbye)

def main():

   while True: var = raw_input(read something)


if __name__ == '__main__':

   register(goodbye)
   main()


But in my case the goodbye function is deleting the logging file
which was created during the application execution. Now the problem
is that it *always* executes, even when the applications quits for
some bad errors.

Is there a way to have an exit hook, which doesn't execute in case of
errors?


Have a single no-error normal exit point.

if __name__ == '__main__':
   main()
   cleanup()

if you really want to exit by exceptions rather than by returns,

if __name__ == '__main__':
   try: main()
   except SystemExit: normal_exit_cleanup()

--
Terry Jan Reedy

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


Re: Complexity question on Python 3 lists

2012-02-15 Thread Terry Reedy

On 2/15/2012 2:11 PM, Chris Rebert wrote:


It's slightly more complex:
http://hg.python.org/cpython/file/096b31e0f8ea/Objects/listobject.c
The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, …
 -- list_resize()


This has apparently changed from time to time.

--
Terry Jan Reedy


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


Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-15 Thread Andrew Berg
On 2/15/2012 3:28 PM, John Nagle wrote:
 Are you doing a conditional import, one that takes place after load
 time?  If you do an import within a function or class, it is executed
 when the code around it executes.  If you import a file with a
 syntax error during execution, you could get the error message you're
 getting.
It does have conditional imports, but the tracebacks don't occur while
that function is running (it's executed once, and this happens well after).

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Is this the right list?

2012-02-15 Thread Alan McKay
Hey folks,

I looked all through the list of mailing lists on the
mail.python.orgserver and this seems to be the only one that might
apply to me other than
maybe the German list which did not seem to have any specific python issue
associated with it other than that you should write German on it.

I am having a problem moving an application from RHEL 5.7 to Ubuntu 11.11,
and the problem is around .py program.

It is a web based program, and seems to use a strange combination of
mod_python and python CGI as best I can tell.

Would this be the right list to ask?

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


Re: Looking for PyPi 2.0...

2012-02-15 Thread Nathan Rice
 Hopefully soon crate.io will be useful for finding modules ;) I have plans
 for it to try and, encourage people to host their code and encourage
 following packaging standards. I'm currently focused mostly on the backend
 stability (e.g. getting it stable) but emphasizing things that are generally
 good for the packaging ecosystem is something I hope to do.

I think providing commit hooks for version control ala read the docs
is the #1 thing you could do in the short term to add a lot of value.
That would be enough for me to adopt the service :)

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


Re: Is this the right list?

2012-02-15 Thread Terry Reedy

On 2/15/2012 4:51 PM, Alan McKay wrote:


I am having a problem moving an application from RHEL 5.7 to Ubuntu
11.11, and the problem is around .py program.

It is a web based program, and seems to use a strange combination of
mod_python and python CGI as best I can tell.

Would this be the right list to ask?


Go ahead. If the question is too specialized for readers here, you might 
get a suggestion where else to look. Include python versions on both 
systems and any tracebacks from executing the program.


--
Terry Jan Reedy

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


Re: Is this the right list?

2012-02-15 Thread Mark Lawrence

On 15/02/2012 21:51, Alan McKay wrote:

Hey folks,

I looked all through the list of mailing lists on the
mail.python.orgserver and this seems to be the only one that might
apply to me other than
maybe the German list which did not seem to have any specific python issue
associated with it other than that you should write German on it.

I am having a problem moving an application from RHEL 5.7 to Ubuntu 11.11,
and the problem is around .py program.

It is a web based program, and seems to use a strange combination of
mod_python and python CGI as best I can tell.

Would this be the right list to ask?

thanks,
-Alan






Welcome.

Put (a snippet of) code here that's causing the problem together with a 
full traceback and you'll soon find out :)  If it is the right place 
you'll get answers, if not you'll certainly be pointed in the right 
direction.


--
Cheers.

Mark Lawrence.

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


Stand-Alone Python Executable Skeletons

2012-02-15 Thread Calvin Spealman
I've recently been looking into different options to package python
code into stand-alone executables, with tools like Py2EXE and
PyInstaller, but I'm left feeling a little lost. Documentation seems
sparse on all of them, the setups a little unusual to me. It feels
like they could be a lot simpler, or that I could put in some
preliminary work to make it easier for my needs in the long run. I'm
hoping someone can help me pick the best option.

What I would love to do (or know if it is possible) is have a set of
executables, for Linux, Windows, and OS X, with a Zip archive appended
to the end of them. I know the zip archive at the end of an executable
works with EXE and ELF binaries, but does it work for whatever OSX
uses (I have no mac machines, currently)? I'd like to build these
three empty stand-alone python executables, setup such that they'll
run any main.py sitting at the top level of the archive. After this,
building for all three platforms would just be a matter of copying the
empty versions and dumping the project into it.

I'm leaning on doing this with PyInstaller being the easiest. Am I
headed in the right direction? Ideally, these empty stand-alones could
be distributed for use by others without any tools required to use
them other than a zip utility.

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complexity question on Python 3 lists

2012-02-15 Thread Ian Kelly
On Wed, Feb 15, 2012 at 1:28 PM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 On Wed, 15 Feb 2012 11:11:27 -0800, Chris Rebert c...@rebertia.com
 wrote:


The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, …
    -- list_resize()

        Rather perverse, is it not? The first set is plain doubling, but
 then you get a series of increases by:

        ... 9, 10, 11, 12, 14, 16, 16,...

 or

        100%, 100%, 100%, 56%, 40%, 34%, 30%, 27%, 22%,...

        Big jump form 100% to 56%...

Based on the formula in the code, it would seem to asymptotically
approach 12.5%.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Stand-Alone Python Executable Skeletons

2012-02-15 Thread Chris Rebert
On Wed, Feb 15, 2012 at 2:43 PM, Calvin Spealman ironfro...@gmail.com wrote:
 I've recently been looking into different options to package python
 code into stand-alone executables, with tools like Py2EXE and
 PyInstaller, but I'm left feeling a little lost. Documentation seems
 sparse on all of them, the setups a little unusual to me. It feels
 like they could be a lot simpler, or that I could put in some
 preliminary work to make it easier for my needs in the long run. I'm
 hoping someone can help me pick the best option.

 What I would love to do (or know if it is possible) is have a set of
 executables, for Linux, Windows, and OS X, with a Zip archive appended
 to the end of them. I know the zip archive at the end of an executable
 works with EXE and ELF binaries, but does it work for whatever OSX
 uses (I have no mac machines, currently)?

OS X has application bundles:
http://en.wikipedia.org/wiki/Application_bundle

py2app can generate them:
http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html

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


Re: [semi OT]: Smartphones and Python?

2012-02-15 Thread MRAB

On 15/02/2012 20:58, Martin Schöön wrote:

First of all: I don't have any first hand experience of smartphones
but now that my trusted old GSM phone is getting old I decided I am
in for an up-grade. It struck me it might be nice to get something
for which I could write Python programs.

A very quick internet search indicated that this should be no big
deal if I go for an Android-based phone. What about the alterna-
tives?

It struck me this must be the best place to ask.

What else? I don't know if it matters but my home PC OS is Linux.
And I am not much of a Python programmer but I enjoy learning it
and I have reached a level that has turned out to be useful at work.


Python has been ported to iOS, if you're thinking of going the Apple
route:

http://ipython.hozbox.com
--
http://mail.python.org/mailman/listinfo/python-list


Wanted: Criticism of code for a Python module, plus a Mac tester

2012-02-15 Thread HoneyMonster
I am quite new to Python (running Python 2.7 on Linux).

I have written a very small and simple dealing module for the game of 
Bridge. For those unfamiliar with the game, the idea is to deal each of 4 
players a hand of 13 cards from a pack of 52, and to display it thus (use 
a fixed pitch font):

Board 1
Neither vulnerable
Dealer North

K98432   
T7   
2
AQT2 

T   AQJ  
KJ854   9632 
KQ973   T854 
85  74   

765  
AQ   
AJ6  
KJ963


Firstly, is there anyone here who uses Python on a Mac and would be 
prepared to test it? I have tested it on Linux and Windows, but don't 
have access to a Mac.

Secondly, as a more general point I would welcome comments on code 
quality, adherence to standards and so forth. The code is at:

http://dl.dropbox.com/u/6106778/bridgedeal.py

Thanks.

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


Re: [semi OT]: Smartphones and Python?

2012-02-15 Thread Paul Rubin
Martin Schöön martin.sch...@gmail.com writes:
 A very quick internet search indicated that this should be no big
 deal if I go for an Android-based phone. What about the alternatives?

It works pretty well with Maemo, though phones with that are not so easy
to find.  My ex-officemate wrote some SL4A (Android) apps in Python and
said it was pretty easy to use, though some features were missing.  I
know that one missing feature was tkinter.


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


Re: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-15 Thread Chris Angelico
On Thu, Feb 16, 2012 at 5:48 AM, Dave Angel d...@davea.name wrote:
 When you reply to a known bot, please include some indication of the fact,
 so we know your message can be ignored as well.

Sometimes I wonder about 8. Is there a real person there, as well
as the bot? A lot of his/its posts look too intelligent to be
computer-generated - or maybe I'm underestimating the quality of AI.

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


Re: Interactive keyword help

2012-02-15 Thread Steven D'Aprano
On Wed, 15 Feb 2012 11:23:20 -0600, Andrew Berg wrote:

 help() is a built-in function, not a keyword.
 http://docs.python.org/library/functions.html#help
 http://docs.python.org/py3k/library/functions.html#help

Technically, it's not actually built-in, it is added to the built-ins by 
site.py.


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


Re: Wanted: Criticism of code for a Python module, plus a Mac tester

2012-02-15 Thread Ian Kelly
On Wed, Feb 15, 2012 at 4:33 PM, HoneyMonster someone@someplace.invalid wrote:
 Secondly, as a more general point I would welcome comments on code
 quality, adherence to standards and so forth. The code is at:

Looks pretty nice overall.  To reduce repetition, I would have
constructed the CONDITIONS list by iteration like you did the DECK
list, something like:

DEALERS = [Dealer North, Dealer East, Dealer South, Dealer West]
VULNERABILITIES = [
Neither vulnerable, North-South vulnerable,
East-West vulnerable, Both vulnerable,
]
CONDITIONS = [(d, v) for d in DEALERS for v in VULNERABILITIES]

You could also eliminate some repetition in the deal method by putting
the suit lists in a local dict:

suits = {'S': self.spades, 'H': self.hearts,
 'D': self.diamonds, 'C': self.clubs}
for card in cards:
suits[DECK[card][SUIT]].append(DECK[card][RANK])

Another comment I had at first was that instead of creating the pack
list, which is just a list of indexes into DECK, you could shuffle and
deal the DECK list directly.  But then I realized that the indirection
allows you to easily sort the cards in the desired order, so that
should be left alone.

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


format a measurement result and its error in scientific way

2012-02-15 Thread Daniel Fetchinson
Hi folks, often times in science one expresses a value (say
1.03789291) and its error (say 0.00089) in a short way by parentheses
like so: 1.0379(9)

One can vary things a bit, but let's take the simplest case when we
only keep 1 digit of the error (and round it of course) and round the
value correspondingly. I've been searching around for a simple
function that would take 2 float arguments and would return a string
but didn't find anything although something tells me it's been done a
gazillion times.

What would be the simplest such function?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complexity question on Python 3 lists

2012-02-15 Thread Steven D'Aprano
On Wed, 15 Feb 2012 19:20:21 +0100, Franck Ditter wrote:

 What is the cost of calling primes(n) below ? I'm mainly interested in
 knowing if the call to append is O(1)

Your primes() function appears to be a variation on trial division, which 
is asymptotically O(n*sqrt(n)/(log n)**2). Regardless of the exact Big Oh 
behaviour, it is going to be SLOW for large values of n.

The behaviour of append is the least of your concerns.



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


Re: Wanted: Criticism of code for a Python module, plus a Mac tester

2012-02-15 Thread Tim Chase

On 02/15/12 17:33, HoneyMonster wrote:

Firstly, is there anyone here who uses Python on a Mac and
would be prepared to test it? I have tested it on Linux and
Windows, but don't have access to a Mac.


It works from my quick test of it on my Mac.  The class 
Player(): and the .format() calls choke on 2.4 (if perhaps for 
some reason you're running it on earlier versions), but 
otherwise, it should be good if you're running 2.7 everywhere.



Secondly, as a more general point I would welcome comments on
code quality, adherence to standards and so forth. The code is
at:



All the .append()s seem a little unpythonic to me.  I'd just set 
it up with


  CONDITIONS = [
[...],
...
]

And since you're not modifying it, I'd even use tuples (or named 
tuples):


  CONDITIONS = (
(Dealer North, Neither vulnerable),
...
)

I'd also take advantage of iterable-unpacking to do something 
like the following in your Player.deal() method:


  for card in cards:
suit, rank = DECK[card]
{
 'S': self.spades,
 'D': self.diamonds,
 'C': self.clubs,
 'H': self.hearts,
}[suit].append(rank)

(that fixed dictionary might even be hoisted out for reuse 
elsewhere).


Additionally, if you import this as a module rather than running 
it directly, there's no north, south, ... in your module 
namespace (they're only defined in the if __name__ ... section) 
so it will fail.


There are some other structural decisions that I might reconsider 
too:


- just shuffling the deck, rather than shuffling indexes into 
that deck


- there seems to be a lot of redundancy in the drawing code, but 
I'm not sure how I'd reduce that


- assigning to internal rank-named lists seems a little redundant 
to me.  In my (non-bridge) card-playing history, and tinkering 
with small programs like this to simulate card-games, I usually 
just give a player the cards and then leave the sifting/sorting 
to the display algorithm


- I see Ian's email came in as I was typing this and agree with 
his method of defining CONDITIONS with the caveat that it doesn't 
keep the same order as yours (I seem to recall bridge had some 
odd rules about that order)



-tkc




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


Re: Wanted: Criticism of code for a Python module, plus a Mac tester

2012-02-15 Thread HoneyMonster
On Wed, 15 Feb 2012 17:07:48 -0700, Ian Kelly wrote:

 On Wed, Feb 15, 2012 at 4:33 PM, HoneyMonster
 someone@someplace.invalid wrote:
 Secondly, as a more general point I would welcome comments on code
 quality, adherence to standards and so forth. The code is at:
 
 Looks pretty nice overall.  To reduce repetition, I would have
 constructed the CONDITIONS list by iteration like you did the DECK list,
 something like:
 
 DEALERS = [Dealer North, Dealer East, Dealer South, Dealer West]
 VULNERABILITIES = [
 Neither vulnerable, North-South vulnerable,
 East-West vulnerable, Both vulnerable,
 ]
 CONDITIONS = [(d, v) for d in DEALERS for v in VULNERABILITIES]
 
 You could also eliminate some repetition in the deal method by putting
 the suit lists in a local dict:
 
 suits = {'S': self.spades, 'H': self.hearts,
  'D': self.diamonds, 'C': self.clubs}
 for card in cards:
 suits[DECK[card][SUIT]].append(DECK[card][RANK])
 
 Another comment I had at first was that instead of creating the pack
 list, which is just a list of indexes into DECK, you could shuffle and
 deal the DECK list directly.  But then I realized that the indirection
 allows you to easily sort the cards in the desired order, so that should
 be left alone.

Thank you very much indeed, Ian.

Your second suggestion has opened my eyes; it had not even occurred to me 
that the value element of a dictionary entry could be a list. Just 
shows me how much I have to learn! Isn't Python great?

As to your first suggestion though, I am having some difficulty. Note 
that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as 
CONDITIONS[0].
Is there a better way of doing it than a simple list.append()?

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


Re: format a measurement result and its error in scientific way

2012-02-15 Thread Ian Kelly
On Wed, Feb 15, 2012 at 5:18 PM, Daniel Fetchinson
fetchin...@googlemail.com wrote:
 Hi folks, often times in science one expresses a value (say
 1.03789291) and its error (say 0.00089) in a short way by parentheses
 like so: 1.0379(9)

 One can vary things a bit, but let's take the simplest case when we
 only keep 1 digit of the error (and round it of course) and round the
 value correspondingly. I've been searching around for a simple
 function that would take 2 float arguments and would return a string
 but didn't find anything although something tells me it's been done a
 gazillion times.

 What would be the simplest such function?

Well, this basically works:

 def format_error(value, error):
... precision = int(math.floor(math.log(error, 10)))
... format = %%.%df(%%d) % max(-precision, 0)
... return format % (round(value, -precision),
...  int(round(error / 10 ** precision)))
...
 format_error(1.03789291, 0.00089)
'1.0379(9)'

Note that math.floor(math.log(error, 10)) may return the wrong
decimal precision due to binary floating point rounding error, which
could produce some strange results:

 format_error(10378929, 1000)
'10378900(10)'

So you'll probably want to use decimals instead:

def format_error(value, error):
value = decimal.Decimal(value)
error = decimal.Decimal(error)
value_scale = value.log10().to_integral(decimal.ROUND_FLOOR)
error_scale = error.log10().to_integral(decimal.ROUND_FLOOR)
precision = value_scale - error_scale
if error_scale  0:
format = %%.%dE % max(precision, 0)
else:
format = %%.%dG % (max(precision, 0) + 1)
value_str = format % value.quantize(decimal.Decimal(10) ** error_scale)
error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
if 'E' in value_str:
index = value_str.index('E')
return value_str[:index] + error_str + value_str[index:]
else:
return value_str + error_str

 format_error(1.03789291, 0.00089)
'1.0379(9)'
 format_error(103789291, 1000)
'1.03789(1)E+08'

I haven't tested this thoroughly, so use at your own risk. :-)

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


Re: [semi OT]: Smartphones and Python?

2012-02-15 Thread geremy condra
On Wed, Feb 15, 2012 at 12:58 PM, Martin Schöön martin.sch...@gmail.com wrote:
 First of all: I don't have any first hand experience of smartphones
 but now that my trusted old GSM phone is getting old I decided I am
 in for an up-grade. It struck me it might be nice to get something
 for which I could write Python programs.

 A very quick internet search indicated that this should be no big
 deal if I go for an Android-based phone. What about the alterna-
 tives?

 It struck me this must be the best place to ask.

 What else? I don't know if it matters but my home PC OS is Linux.
 And I am not much of a Python programmer but I enjoy learning it
 and I have reached a level that has turned out to be useful at work.

Please note that while SL4A is a pretty good mobile python environment
it doesn't support all of the Android API, which means it generally
isn't an easy way to develop fully-fledged Android apps.

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


Re: [semi OT]: Smartphones and Python?

2012-02-15 Thread 88888 Dihedral
在 2012年2月16日星期四UTC+8上午10时19分15秒,geremy condra写道:
 On Wed, Feb 15, 2012 at 12:58 PM, Martin Schöön martin.sch...@gmail.com 
 wrote:
  First of all: I don't have any first hand experience of smartphones
  but now that my trusted old GSM phone is getting old I decided I am
  in for an up-grade. It struck me it might be nice to get something
  for which I could write Python programs.
 
  A very quick internet search indicated that this should be no big
  deal if I go for an Android-based phone. What about the alterna-
  tives?
 
  It struck me this must be the best place to ask.
 
  What else? I don't know if it matters but my home PC OS is Linux.
  And I am not much of a Python programmer but I enjoy learning it
  and I have reached a level that has turned out to be useful at work.
 
 Please note that while SL4A is a pretty good mobile python environment
 it doesn't support all of the Android API, which means it generally
 isn't an easy way to develop fully-fledged Android apps.
 
 Geremy Condra
In the 4 G space of SW AP in Adndroid phones,
check Jython. But I think a better data compression 
modules  is more helpful. 

Patterns about arithmetic compressions and LZW are expired, but not  those in 
mp4 for the commercial use.

Thus, the time to install a complete OS on a tablet 
or mobile phone with LTE on the way.

We need smaller HD or flashes in these small devices.

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


Re: [semi OT]: Smartphones and Python?

2012-02-15 Thread Michael Torrie
On 02/15/2012 07:38 PM, 8 Dihedral wrote:
 In the 4 G space of SW AP in Adndroid phones,
 check Jython. But I think a better data compression 
 modules  is more helpful. 

Jython, though a very cool and useful implementation, relies on the Java
virtual machine to run.  It does not yet run on Dalvik, nor is it clear
that it ever will.  The project to port jython to Dalvik, but it died
and the authors said, just use Android scripting.  lame.
-- 
http://mail.python.org/mailman/listinfo/python-list


Web browser Python programming in NCLab

2012-02-15 Thread Pavel Solin
Hello,
  the NCLab development team would like to invite everybody
to try out Python programming in the web browser at www.nclab.com.
Using NCLab is free for personal, non-commercial purposes.
If you'd like to give us feedback how we are doing, please use
the mailing list nclab-u...@googlegroups.com. We hope to
hear from you!

Best,

Pavel

-- 
Pavel Solin
University of Nevada, Reno
http://hpfem. http://hpfem.math.unr.edu/people/pavel/org/~pavel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wanted: Criticism of code for a Python module, plus a Mac tester

2012-02-15 Thread Ian Kelly
On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster someone@someplace.invalid wrote:
 As to your first suggestion though, I am having some difficulty. Note
 that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as
 CONDITIONS[0].
 Is there a better way of doing it than a simple list.append()?

Ah, it's more complicated than I realized.  I believe this generates
the correct result, although adding None to the dealers list is
somewhat unsatisfactory:

DEALERS = [Dealer North, Dealer East, Dealer South, Dealer West, None]
VULNERABILITIES = [
   Neither vulnerable, North-South vulnerable,
   East-West vulnerable, Both vulnerable,
]
CONDITIONS = [(d, v) for (d, v) in zip(DEALERS * 4, VULNERABILITIES * 5) if d]

I might be tempted to write a custom iterator for it, something like this:

def rotating(iterable):
cache = collections.deque()
for value in iterable:
yield value
cache.append(value)
while True:
cache.rotate(-1)
for value in cache:
yield value

# Using the original 4-length DEALERS list
CONDITIONS = list(itertools.islice(itertools.izip(itertools.cycle(DEALERS),
rotating(VULNERABILITIES)), 16))

But I don't know that it's really worth the added complexity.

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


Re: XSLT to Python script conversion?

2012-02-15 Thread Tim Arnold

On 2/13/2012 6:20 AM, Matej Cepl wrote:

Hi,

I am getting more and more discouraged from using XSLT for a
transformation from one XML scheme to another one. Does anybody could
share any experience with porting moderately complicated XSLT stylesheet
(https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl)
into a Python script using ElementTree's interparse or perhaps xml.sax?

Any tools for this? Speed differences (currently I am using xsltproc)?
Any thoughts?

Thank you,

Matěj


Just a note to encourage you to stick with XSLT. I also use lxml for 
creating and postprocessing my DocBook documents and it is great.  But I 
use the DocBook XSL stylesheets to convert to html; if you're like me, 
you got discouraged at the strangeness of the XSLT language.


I'm no expert with it by any means, but I'm amazed at some of the things 
it does. It is a great tool to add to your programming toolbox.


Also, I used xsltproc for a while but bogged down in processing time. 
Now I use SAXON which is much faster for my documents.


Good luck,
--Tim


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


[issue14019] Unify tests for str.format and string.Formatter

2012-02-15 Thread Nick Coghlan

New submission from Nick Coghlan ncogh...@gmail.com:

A couple of issues have arisen where features were added to str.format without 
similarly being added to string.Formatter.

This is only possible because the test cases for the two are currently almost 
entirely separate.

A common set of tests defined as (fmt, args, kwargs, output) tuples would help 
ensure that the implementations remained consistent in the future.

--
components: Tests
messages: 153392
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Unify tests for str.format and string.Formatter
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14019
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13579] string.Formatter doesn't understand the !a conversion specifier

2012-02-15 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

Agreed that this is a bug in string.Formatter rather than a new feature.

There's already a separate bug for the autonumbering problem: 
http://bugs.python.org/issue13598

And I created a new issue about unifying some of the tests: 
http://bugs.python.org/issue14019

%-style string formatting is its own thing - it doesn't share semantics or code 
with str.format or string.Formatter.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13579
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10112] Use -Wl, --dynamic-list=x.list, not -Xlinker -export-dynamic

2012-02-15 Thread Jan Kratochvil

Jan Kratochvil jan.kratoch...@redhat.com added the comment:

What more can be done to get it fixed?  I do not mind Python but GDB linking is 
broken due to it.  And while I can workaround it in GDB I am not used for 
workarounding one Free package in another Free package.  Free software has the 
advantage problems can be fixed at the right place.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10112
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13703] Hash collision security issue

2012-02-15 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Frankly, other short strings may give away even more, because you can
 put several into the same dict.

Please don't make such claims without some reasonable security analysis:
how *exactly* would you derive the hash seed when you have the hash
values of all 256 one-byte strings (or all 2**20 one-char Unicode
strings)?

 I would prefer that the randomization not kick in until strings are at
 least 8 characters, but I think excluding length 1 is a pretty obvious
 win.

-1. It is very easy to create a good number of hash collisions already
with 6-character strings. You are opening the security hole again that
we are attempting to close.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13703
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-15 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

As a security issue, it applies to 2.6 and 3.1 as well.

--
versions: +Python 2.6, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13598] string.Formatter doesn't support empty curly braces {}

2012-02-15 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

One potential problem with the simple approach to fixing this is that up until 
now, string.Formatter has been thread safe. Because all the formatting state 
was held in local variables and passed around as method arguments, there was no 
state on the instance object to protect.

Now, this only applies if you start using the new feature, but it should be 
noted in the documentation and What's New that you need to limit yourself to 
accessing each formatter instance from a single thread.

It's also enough for me to say no, not in a maintenance release.

Adding two attributes also seems unnecessary, and the pre-increment looks 
strange. Why not:

In __init__:
auto_field_count = 0

Then as the auto numbering checking, something like:

auto_field_count = self.auto_field_count
if field_name:
if auto_field_count  0:
   # Can't switch auto - manual
auto_field_count = -1
elif auto_field_count  0:
   # Can't switch manual - auto
else:
field_name = str(auto_field_count)
self.auto_field_count += 1

(Alternatively, I'd ask the question: why do we prevent mixing manual numbering 
and explicit numbering anyway? It's not like it's ambiguous at all)

--
nosy: +ncoghlan
versions:  -Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13598
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13987] Handling of broken markup in HTMLParser on 2.7

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 11a31eb5da93 by Ezio Melotti in branch '2.7':
#13987: HTMLParser is now able to handle EOFs in the middle of a construct.
http://hg.python.org/cpython/rev/11a31eb5da93

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13987
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13987] Handling of broken markup in HTMLParser on 2.7

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 3d7904e3f4b9 by Ezio Melotti in branch '2.7':
#13987: HTMLParser is now able to handle malformed start tags.
http://hg.python.org/cpython/rev/3d7904e3f4b9

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13987
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14019] Unify tests for str.format and string.Formatter

2012-02-15 Thread Eric V. Smith

Changes by Eric V. Smith e...@trueblade.com:


--
nosy: +eric.smith

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14019
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13987] Handling of broken markup in HTMLParser on 2.7

2012-02-15 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

This should be fixed now.
The first two chunks of the attached patch have been committed in the two 
changesets linked in the previous messages.  The third chunk about the end tag 
has been fixed as part of #13933.  The error previously raised by unknown_decl 
has been removed in 4743a3a1e669.  More fixes have been backported as part of 
#13960.
2.7 should now behave like 3.2 non-strict.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13987
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14020] Improve HTMLParser doc

2012-02-15 Thread Ezio Melotti

New submission from Ezio Melotti ezio.melo...@gmail.com:

Attached patch reworks a bit the HTMLParser doc:
 - moved the basic example on the top and showed the output;
 - added a more complete parser with other examples;
 - fixed some factual errors;
 - added additional information for some methods;
 - added a couple of headers to divide the sections;
 - rephrased the text a bit to be more coherent and clear;
 - fixed a few links, typos, and terms;

I think the note about IE condcoms could be removed by the handle_comment doc, 
since it's already in the examples at the bottom.  A note in handle_data about 
the behavior with buffered input might be added in addition to the example at 
the bottom.

--
assignee: ezio.melotti
components: Documentation
files: issue14020.diff
keywords: patch
messages: 153401
nosy: eli.bendersky, eric.araujo, ezio.melotti, terry.reedy
priority: normal
severity: normal
stage: commit review
status: open
title: Improve HTMLParser doc
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file24523/issue14020.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14020
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7644] bug in nntplib.body() method with possible fix

2012-02-15 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

I have also added a test for NTTP.head(), enjoy.

--
keywords: +patch
Added file: http://bugs.python.org/file24524/nntp-file-test.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7644
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14015] surrogateescape largely missing from documentation

2012-02-15 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
versions:  -Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14015
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14004] Distutils filelist selects too many files on Windows

2012-02-15 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

It's not that I forgot to set DISTUTILS_DEBUG, I simply did not set it. If the 
bug were still present, I would have seen a line indicating that 
.hg/last-message.txt was being copied.

For completeness, here's the output with the DEBUG setting:

PS C:\Users\jaraco\projects\public\keyring $env:DISTUTILS_DEBUG=1
PS C:\Users\jaraco\projects\public\keyring 
..\cpython\PCbuild\amd64\python.exe setup.py sdist 2 NULL | findstr hg
 adding .hg\last-message.txt
exclude_pattern: applying regex 
r'(^|/|\\)(RCS|CVS|\.svn|\.hg|\.git|\.bzr|_darcs)(/|\\).*'
 removing .hg\last-message.txt

--
Added file: http://bugs.python.org/file24525/smime.p7s

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14004
___

smime.p7s
Description: S/MIME cryptographic signature
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14004] Distutils filelist selects too many files on Windows

2012-02-15 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

So it looks like that even if the exclusion of .hg removes 
.hg/last-message.txt, it should not have been added in the first place, as the 
command was include and not recursive-include.

At first glance, Nadeem’s proposed fix is not right: paths in MANIFEST.in use 
'/', but then filelist produces paths using os.sep, so that the MANIFEST file 
and other operations done by the sdist command use native paths.  So even 
though the currently supported OSes all accept '/', I think the right thing is 
to use os.sep.

(About posixpath: It is always available and can be used e.g. to manipulate URI 
paths.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14004
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12297] Clarifications to atexit.register and unregister doc

2012-02-15 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks.  I’ve also realized that the doc does not mention that any callable can 
be used; I don’t know if we should say it explicitly (I think I did a change 
like that recently in another file), or if we expect people to just know it 
from experience, or if we should add an entry for “function” in the glossary.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12297
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14020] Improve HTMLParser doc

2012-02-15 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Didn’t review in detail but the plan LGTM.

In a subsequent commit, you could update the markup to use nested class/method 
directives.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14020
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12297] Clarifications to atexit.register and unregister doc

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 55fc092dad72 by Éric Araujo in branch '3.2':
Improve doc for atexit.register and unregister (#12297)
http://hg.python.org/cpython/rev/55fc092dad72

New changeset f7163afecb97 by Éric Araujo in branch 'default':
Merge fixes for #1326113 and #12297 from 3.2
http://hg.python.org/cpython/rev/f7163afecb97

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12297
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1326113] Letting build_ext --libraries take more than one lib

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 53df93a9c002 by Éric Araujo in branch '3.2':
Fix parsing of build_ext --libraries option (#1326113)
http://hg.python.org/cpython/rev/53df93a9c002

New changeset f7163afecb97 by Éric Araujo in branch 'default':
Merge fixes for #1326113 and #12297 from 3.2
http://hg.python.org/cpython/rev/f7163afecb97

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1326113
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1326113] Letting build_ext --libraries take more than one lib

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 96f5718bf005 by Éric Araujo in branch '2.7':
Fix parsing of build_ext --libraries option (#1326113)
http://hg.python.org/cpython/rev/96f5718bf005

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1326113
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12297] Clarifications to atexit.register and unregister doc

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset a99632426af5 by Éric Araujo in branch '2.7':
Improve doc for atexit.register (#12297)
http://hg.python.org/cpython/rev/a99632426af5

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12297
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1326113] Letting build_ext --libraries take more than one lib

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 4ba43318e56b by Éric Araujo in branch 'default':
Fix parsing of packaging’s build_ext --libraries option (#1326113)
http://hg.python.org/cpython/rev/4ba43318e56b

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1326113
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1326113] Letting build_ext --libraries take more than one lib

2012-02-15 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 60dd0041c9bc by Éric Araujo in branch 'default':
Fix parsing of build_ext --libraries option (#1326113)
http://hg.python.org/distutils2/rev/60dd0041c9bc

New changeset 158697fd8fa1 by Éric Araujo in branch 'python3':
Merge #1326113 fix from default
http://hg.python.org/distutils2/rev/158697fd8fa1

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1326113
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1326113] Letting build_ext --libraries take more than one lib

2012-02-15 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Here you are!  Thanks for the testing.

--
resolution:  - fixed
stage: test needed - committed/rejected
status: open - closed
versions: +Python 3.3 -Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1326113
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12297] Clarifications to atexit.register and unregister doc

2012-02-15 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Closing as fixed, but if you have any feedback on my function vs. callable 
question, please share.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12297
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14021] Write pkg_info with local encoding(GBK) will be a problem.

2012-02-15 Thread 勇刚 罗

New submission from 勇刚 罗 luoyongg...@gmail.com:

D:\CI\bld\vcs\pygit2python setup.py install
Find C:\Python32\python.exe
Using C:\Python32\python.exe
running install
running bdist_egg
running egg_info
writing pygit2.egg-info\PKG-INFO
Traceback (most recent call last):
  File setup.py, line 106, in module
**kwargs)
  File C:\Python32\lib\distutils\core.py, line 148, in setup
dist.run_commands()
  File C:\Python32\lib\distutils\dist.py, line 917, in run_commands
self.run_command(cmd)
  File C:\Python32\lib\distutils\dist.py, line 936, in run_command
cmd_obj.run()
  File 
C:\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\install.py,
 line 73, in run
self.do_egg_install()
  File 
C:\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\install.py,
 line 93, in do_egg_install
self.run_command('bdist_egg')
  File C:\Python32\lib\distutils\cmd.py, line 313, in run_command
self.distribution.run_command(command)
  File C:\Python32\lib\distutils\dist.py, line 936, in run_command
cmd_obj.run()
  File 
C:\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\bdist_egg.py,
 line 172, in run
self.run_command(egg_info)
  File C:\Python32\lib\distutils\cmd.py, line 313, in run_command
self.distribution.run_command(command)
  File C:\Python32\lib\distutils\dist.py, line 936, in run_command
cmd_obj.run()
  File 
C:\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\egg_info.py,
 line 172, in run
writer(self, ep.name, os.path.join(self.egg_info,ep.name))
  File 
C:\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg\setuptools\command\egg_info.py,
 line 384, in write_pkg_info
metadata.write_pkg_info(cmd.egg_info)
  File C:\Python32\lib\distutils\dist.py, line 1015, in write_pkg_info
self.write_pkg_file(pkg_info)
  File C:\Python32\lib\distutils\dist.py, line 1031, in write_pkg_file
file.write('Author: %s\n' % self.get_contact() )
UnicodeEncodeError: 'gbk' codec can't encode character '\xf1' in position 20: 
illegal multibyte sequence

D:\CI\bld\vcs\pygit2
It's better to use utf8 instead.

--
assignee: tarek
components: Distutils
messages: 153415
nosy: eric.araujo, tarek, 勇刚.罗
priority: normal
severity: normal
status: open
title: Write pkg_info with local encoding(GBK) will be a problem.
type: crash
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14021
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >