[Ann] Celery 2.2 released!

2011-02-01 Thread Ask Solem Hoel
==
 Celery 2.2 is now available!
==

We're happy to announce the release of Celery 2.2.

Thanks to all contributors, testers and users, which without
this release would not have been possible.

What is it?
===

Celery is an asynchronous task queue/job queue based on distributed message
passing. It is focused on real-time operation, but supports scheduling as well.

The execution units, called tasks, are executed concurrently on a single or
more worker nodes using multiprocessing, Eventlet, or gevent. Tasks can
execute asynchronously (in the background) or synchronously (wait until ready).

Celery is used in production systems to process millions of tasks a day.

Celery is written in Python, but the protocol can be implemented in any
language. It can also operate with other languages using webhooks.

The recommended message broker is RabbitMQ, but limited support for Redis,
Beanstalk, MongoDB, CouchDB, and databases (using SQLAlchemy or the Django ORM)
is also available.

Celery is easy to integrate with Django, Pylons and Flask, using the
django-celery, celery-pylons and Flask-Celery add-on packages.

Going to PyCon US 2011?
===

Then don't forget to attend Ryan Petrello's talk,
Distributed Tasks with Celery: http://us.pycon.org/2011/schedule/sessions/1/

What's new?
===

* Eventlet and gevent support.

  Worker nodes can now use Eventlet/gevent as an alternative to
  multiprocessing.  You could run several nodes running different
  pool implementations and route tasks to the best tool for the job.

* Jython support!

* This is the last version supporting Python 2.4.

* Celery is now a class that can be instantiated, and the configuration is no
  longer global (see http://bit.ly/i6s3qK)

* Built-in support for virtual transports (ghettoq queues)

Virtual transports for Redis, Beanstalk, CouchDB, MongoDB,
SQLAlchemy and the Django ORM are now available by default,
and the implementations have been drastically improved.

* Now using Kombu instead of Carrot.

Kombu is the next generation messaging framework for Python.
See http://packages.python.org/kombu

* Multiple instances of event monitors can now run simultaneously (celeryev,
  celerymon, djcelerymon)

* Redis transport can now do remote control commands.

* Autoscaling of worker processes.

* Magic keyword arguments pending deprecation.

The magic keyword arguments will be completely removed in version 3.0.
It is important that you read the full changelog for more details.


And *lots* more!  The Changelog contains a detailed
list of all improvements and fixes:

http://celeryproject.org/docs/changelog.html#version-2-2-0

Be sure to read this before you upgrade!

Upgrading
=

To upgrade using pip::

$ pip install -U celery

If you're using Django, then django-celery will automatically
upgrade Celery as well::

$ pip install -U django-celery

Resources
=

:Homepage: http://celeryproject.org

:Download: http://pypi.python.org/pypi/celery

:Community Links: http://celeryq.org/community.html

:Documentation: http://celeryproject.org/docs/

:Code: http://github.com/ask/celery/

:FAQ: http://ask.github.com/celery/faq.html

:Mailing list: http://groups.google.com/group/celery-users

:IRC: #celery at irc.freenode.net.


-- 
{Ask Solem | twitter.com/asksol }.

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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


ANN: mpmath 0.17 (Python 3 support and more)

2011-02-01 Thread Fredrik Johansson
Hi all,

Version 0.17 of mpmath is now available on the project website:
http://code.google.com/p/mpmath/

It can also be downloaded from the Python Package Index:
http://pypi.python.org/pypi/mpmath/0.17

Mpmath is a pure-Python library for arbitrary-precision floating-point
arithmetic that implements an extensive set of mathematical functions. It
can be used as a standalone library or via SymPy
(http://code.google.com/p/sympy/), and is also available as a standard
component of Sage (http://sagemath.org/).

The major news in 0.17 is that mpmath now works with Python 3. To
support both Python 2.x and 3.x with the same codebase, compatibility with
Python 2.4 has been dropped (mpmath now requires 2.5 or higher). New
functionality in mpmath 0.17 includes an implementation of the Lerch
transcendent, Riemann zeta zero counting, and improved support for
evaluating derivatives of the Hurwitz zeta function and related functions.

Many thanks to Juan Arias de Reyna and Case Vanhorsen who contributed
to this version.

For more details, see the changelog:
http://mpmath.googlecode.com/svn/tags/0.17/CHANGES

Extensive documentation is available at:
http://mpmath.googlecode.com/svn/trunk/doc/build/index.html or
http://mpmath.googlecode.com/svn/tags/0.17/doc/build/index.html

Bug reports and other comments are welcome on the issue tracker at
http://code.google.com/p/mpmath/issues/list or the mpmath mailing list:
http://groups.google.com/group/mpmath

Enjoy,
Fredrik Johansson
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Reassign or discard Popen().stdout from a server process

2011-02-01 Thread John O'Hagan
I'm starting a server process as a subprocess. Startup is slow and 
unpredictable (around 3-10 sec), so I'm reading from its stdout until I get a 
line that tells me it's ready before proceeding, in simplified form:

import subprocess
proc = subprocess.Popen(['server', 'args'], stdout=subprocess.PIPE)
while proc.stdout.readline() != Ready.\n:
pass

Now I can start communicating with the server, but I eventually realised that 
as I'm no longer reading stdout, the pipe buffer will fill up with output from 
the server and before long it blocks and the server stops working. 

I can't keep reading because that will block - there won't be any more output 
until I send some input, and I don't want it in any case.

To try to fix this I added:

proc.stdout = os.path.devnull

which has the effect of stopping the server from failing, but I'm not convinced 
it's doing what I think it is. If I replace devnull in the above line with a 
real file, it stays empty although I know there is more output, which makes me 
think it hasn't really worked. 

Simply closing stdout also seems to stop the crashes, but doesn't that mean 
it's still being written to, but the writes are just silently failing? In 
either case I'm wary of more elusive bugs arising from misdirected stdout.

Is it possible to re-assign the stdout of a subprocess after it has started? 
Or just close it? What's the right way to read stdout up to a given line, then 
discard the rest?

Thanks,

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


Re: Reassign or discard Popen().stdout from a server process

2011-02-01 Thread Chris Rebert
On Tue, Feb 1, 2011 at 12:30 AM, John O'Hagan m...@johnohagan.com wrote:
 I'm starting a server process as a subprocess. Startup is slow and
 unpredictable (around 3-10 sec), so I'm reading from its stdout until I get a
 line that tells me it's ready before proceeding, in simplified form:

 import subprocess
 proc = subprocess.Popen(['server', 'args'], stdout=subprocess.PIPE)
 while proc.stdout.readline() != Ready.\n:
    pass

 Now I can start communicating with the server, but I eventually realised that
 as I'm no longer reading stdout, the pipe buffer will fill up with output from
 the server and before long it blocks and the server stops working.

 I can't keep reading because that will block - there won't be any more output
 until I send some input, and I don't want it in any case.

 To try to fix this I added:

 proc.stdout = os.path.devnull

 which has the effect of stopping the server from failing, but I'm not 
 convinced
 it's doing what I think it is. If I replace devnull in the above line with a
 real file, it stays empty although I know there is more output, which makes me
 think it hasn't really worked.

Indeed. proc.stdout is a file, whereas os.devnull is merely a path
string; the assignment is nonsensical type-wise.

 Simply closing stdout also seems to stop the crashes, but doesn't that mean
 it's still being written to, but the writes are just silently failing? In

Based on some quick experimentation, yes, more or less.

 either case I'm wary of more elusive bugs arising from misdirected stdout.

 Is it possible to re-assign the stdout of a subprocess after it has started?

I think that's impossible. (Most of Popen's attributes probably should
be read-only properties to clarify that such actions are don't have
the intended effect.)

 What's the right way to read stdout up to a given line, then
 discard the rest?

I would think calling Popen.communicate() after you've reached the
given line should do the trick.
http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate
Just ignore its return value. However, that does require sending the
input all at once in a single chunk, which it sounds like may not be
feasible in your case; if so, I have no idea how to do it cleanly.

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread flebber
On Feb 1, 4:39 am, rantingrick rantingr...@gmail.com wrote:
 IDLE: A cornicopia of mediocrity and obfuscation.
 -- by Rick Johnson

 IDLE --which is the Python Integrated Development and Learning
 Environment-- was once the apple of Guido's eye but has since
 degenerated into madness many years ago and remains now as the shining
 jewel show piece on the proverbial python wall of shame. A once
 mighty dream of programming for everyone that is now nothing more
 than an example of how NOT to program.

 IDLE contains some of the worst code this community has created. Bad
 design patterns, tacked on functionality, blasphemous styling, and
 piss poor packaging. There seems to be no guiding goals or game-plan.
 And year after year if IDLE *does* get any attention it's just more
 haphazard code thrown into the mix by someone who has gone blind from
 reading the source. However we cannot blame the current maintainer (if
 any such even exists!) because NOBODY can maintains such a spaghetti
 mess that this package has become!

 If we would have had a proper game plan from day one i believe we
 could have avoided this catastrophe. Follows is an outline of the
 wrongs with some suggestions to right them...

  * First of all the main two modules PyShell and EditorWindow are
 laid out in such a non sequential way that it is virtually impossible
 to follow along. We should have had a proper app instance from which
 all widgets where combined. The main app should have followed a
 common sense sequential mentality of...

  * subclassing the tk.Toplevel
  * initializing instance variables
  * creating the main menu
  * creating the sub widgets
  * declaring internal methods
  * declaring event handlers
  * then interface/generic methods.

  This is the recipe for order AND NOT CHAOS! What we have now is utter
 chaos! When we have order we can read source code in a sequential
 fashion. When we have order we can comprehend what we read. And when
 we have order we can maintain a library/package with ease. However
 sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS!

 * The underlying sub widgets should have started with their own proper
 order of declared initialization. And all events should be handled
 in the widget at hand NOT outsourced to some other class!

  * One of the biggest design flaws is the fact that outside modules
 manipulate the main editor/pyshells events. This is a terrible way to
 code. For example the AutoCompleteWindow takes over the tab event

   #-- Puesdo Code --#
   # in editor window __init__
   self.autocomplete = AutoComplete(blah)
   # in editor window onKeyPress(blah)
   if key == 'Tab' and blah:
       self.autocomplete.show_tip(blah)
   elif key == 'Escape' and acw.is_visibe():
       self.autocomplete.hide()

  This is a bad design! The main editor window should handle all its
 own events AND THEN call outside class methods when needed. We don't
 want Mommy classes telling the kids what to do, when to eat, when to
 sleep, and when to excrete! We should create our objects with the
 virtue of self reliance and responsibility!. The Colorizer,
 ParenMatch, textView, TreeWidget, CallTips, and many other modules are
 guilty of event stealing also. Event functionality must be handled
 in the widget itself, NOT stolen and handled in an outside class. When
 we split up sequential code we get CHAOS!

  * Another bad choice was creating custom reusable widgets
 (Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in
 idlelib. These should have been moved into the lib-tk module where
 they would be more visible to python programmers AND we could reduce
 the cruft in the idlelib! Remember, when we create more files,
 folders, and objects we create CHAOS. And nobody can learn from CHAOS!

  * Another blasphemy is the fact that every module should include some
 sort of test to display its usage. If the module is a GUI widget then
 you MUST show how to use the widget in a window. Sadly like all
 everything else, idlelib is devoid of examples and testing. And the
 very few tests that DO exists just blow chunks!

  * Last but not least idlelib does not follow PEP8 or ANY convention.
 So much so that it seems the developers snubbed their nose at such
 conventions! We are missing doc strings and comments. We have built-
 ins being re-bound! Just code horror after code horror.

 These are just the top of the list. The peak of a huge iceberg that
 threatens to sink the community in the arms of chaos never to return.
 I am beginning to believe that this community is either made of
 amateurs due to this lackluster code in the stdlib. However it could
 be that the folks are really professional and refuse to work on such a
 horrible code base (which i understand). I am going with the latter.

 When are we going to demand that these abominations be rectified? How
 much longer must we wait? A year? Ten years?... i don't think Python
 will survive another ten years with this attitude of 

Re: multiple values for keyword argument

2011-02-01 Thread Jean-Michel Pichavant

Patty wrote:



pa...@cruzio.com wrote:

  I have been avoiding understanding this 'self',
[snip]
Regards,

Patty
  
What is to be understood ?? self references the instance. Did I miss 
something ?


JM





Yes, there was more.  And it's been fully explained at this point.

Patty



Hmm... I re-read the thread just in case ... Anyway.
I'd like to read suggestions for self replacements...
Currently 'yo' have been proposed.

I'm just curious, I promise I won't make any comment :D

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


Installing Suds for Python 2.6.1 on Mac OS X

2011-02-01 Thread Darkside Android
I'd like to test my SOAP-based web service from Textmate (PyMate)
however I'm running into some trouble trying to get suds configured on
my Mac. I was able to install it from Terminal however I'm getting the
message each time I run the script:

ImportError: No module named suds

What do you recommend I do? I think it might have something to do with
the PYTHONPATH but I have no idea where this is?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Suds for Python 2.6.1 on Mac OS X

2011-02-01 Thread Chris Rebert
On Tue, Feb 1, 2011 at 2:43 AM, Darkside Android
darksideandr...@gmail.com wrote:
 I'd like to test my SOAP-based web service from Textmate (PyMate)
 however I'm running into some trouble trying to get suds configured on
 my Mac. I was able to install it from Terminal however I'm getting the
 message each time I run the script:

Can you successfully import it when running Python in Terminal?

 ImportError: No module named suds

 What do you recommend I do? I think it might have something to do with
 the PYTHONPATH but I have no idea where this is?

Have you set the TM_PYTHON Shell Variable appropriately in TextMate's
Preferences (Advanced section)?

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 4:20 am, flebber flebber.c...@gmail.com wrote:

 Sorry Rick too boringtrying to get bored people to bite at your
 ultra lame post yawn...

Well reality and truth both has a tendency to be boring. Why? Well
because we bathe in them daily. We have come accustomed, acclimated,
and sadly complacent of the ill state of our stdlib. Yes, boring.
However we must be aware of these things.
-- 
http://mail.python.org/mailman/listinfo/python-list


argparse: combine current option value with positional argument

2011-02-01 Thread Peter Otten
I'd like to capture the current value of an option --prefix=whatever along 
with a positional value as it is seen by argparse.

Example:
python script.py -p1 alpha beta -p2 gamma -p3

should result in a list

[(1, alpha), (1, beta), (2, gamma)]

Here's a working script that uses --name=some-value instead of of just 
some-value:

$ cat tmp.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(-p, --prefix)
parser.add_argument(-n, --name)

class Namespace(object):
def __init__(self):
self.pairs = []
self.prefix = None
def set_name(self, value):
if value is not None:
self.pairs.append((self.prefix, value))
name = property(None, set_name)

ns = Namespace()
parser.parse_args(namespace=ns)
print ns.pairs
$ python tmp.py -p1 -nalpha -nbeta -p2 -ngamma
[('1', 'alpha'), ('1', 'beta'), ('2', 'gamma')]

However, modifying the --name option to a positional with

parser.add_argument(name, nargs=*)

results in an error:

$ python tmp2.py -p1 alpha beta -p2 gamma
usage: tmp2.py [-h] [-p PREFIX] [name [name ...]]
tmp2.py: error: unrecognized arguments: gamma

Am I missing a simple way to avoid that?

Peter

PS: I've not yet used the source ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Adam Tauno Williams
On Tue, 2011-02-01 at 04:38 -0800, rantingrick wrote: 
 On Feb 1, 4:20 am, flebber flebber.c...@gmail.com wrote:
  Sorry Rick too boringtrying to get bored people to bite at your
  ultra lame post yawn...
 Well reality and truth both has a tendency to be boring.

Even more true of pointless and drawn-out pontificating.

If you despise IDLE so much - use one of the many other IDE's that
support Python;  move on.

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 6:53 am, Adam Tauno Williams awill...@whitemice.org wrote:

 If you despise IDLE so much - use one of the many other IDE's that
 support Python;  move on.

Not exactly. Can we continue to ignore such lackluster and shabby code
in OUR stdlib. Remember the code reflects on all of us!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread André
On Tuesday, February 1, 2011 9:38:26 AM UTC-4, Richard quot;rantingrickquot; 
Johnson wrote:
 On Feb 1, 6:53 am, Adam Tauno Williams awil...@whitemice.org wrote:
 
  If you despise IDLE so much - use one of the many other IDE's that
  support Python;  move on.
 
 Not exactly. Can we continue to ignore such lackluster and shabby code
 in OUR stdlib. Remember the code reflects on all of us!

Could you enlighten us and tell us what code YOU contributed to the stdlib?  

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Jean-Michel Pichavant

rantingrick wrote:

On Feb 1, 6:53 am, Adam Tauno Williams awill...@whitemice.org wrote:

  

If you despise IDLE so much - use one of the many other IDE's that
support Python;  move on.



Not exactly. Can we continue to ignore such lackluster and shabby code
in OUR stdlib. Remember the code reflects on all of us!
  
Can we continue to ignore such lackluster and shabby trolls in OUR 
mailing list ? Fortunately, the behavior of one does not reflect the 
behavior of us all.


In a more serious way, just count the people who second your 
prosposition. It's around 0. It is usually a good sign that you're 
wrong. This rule kinda applies to anyone, don't take it personnaly.


... or maybe you're just trolling, in which case you can thank me for 
feeding.


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Westley Martínez
Man you're a real comedian. This is a hilarious thread. Keep up the good
work!

On Tue, 2011-02-01 at 05:38 -0800, rantingrick wrote:

 On Feb 1, 6:53 am, Adam Tauno Williams awill...@whitemice.org wrote:
 
  If you despise IDLE so much - use one of the many other IDE's that
  support Python;  move on.
 
 Not exactly. Can we continue to ignore such lackluster and shabby code
 in OUR stdlib. Remember the code reflects on all of us!


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


Re: Installing Suds for Python 2.6.1 on Mac OS X

2011-02-01 Thread Darkside Android
On Feb 1, 4:30 am, Chris Rebert c...@rebertia.com wrote:
 On Tue, Feb 1, 2011 at 2:43 AM, Darkside Android

 darksideandr...@gmail.com wrote:
  I'd like to test my SOAP-based web service from Textmate (PyMate)
  however I'm running into some trouble trying to get suds configured on
  my Mac. I was able to install it from Terminal however I'm getting the
  message each time I run the script:

 Can you successfully import it when running Python in Terminal?

  ImportError: No module named suds

  What do you recommend I do? I think it might have something to do with
  the PYTHONPATH but I have no idea where this is?

 Have you set the TM_PYTHON Shell Variable appropriately in TextMate's
 Preferences (Advanced section)?

 Cheers,
 Chris
 --http://blog.rebertia.com

Thanks for the feedback Chris. I was able to figure it out this
morning.

I needed to run 'sudo easy_install -z suds' from Terminal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 8:27 am, Jean-Michel Pichavant jeanmic...@sequans.com
wrote:

 In a more serious way, just count the people who second your
 prosposition. It's around 0. It is usually a good sign that you're
 wrong. This rule kinda applies to anyone, don't take it personnaly.

Well your statment completely ignores the silent majority. Are you
telling me that this sloth of trolls, minions, and flamers that have
so far replied are represetative of this fine community. Gawd i hope
NOT!. Here is a list of the compiled personalities...


#-- Embedded Trolls and Minions --#
Steven D'Aprano(smart and witty (annoying) troll)
Stephan Hansen (controversy troll)
Ben Finny (haughty troll)
alex23(angry/dangerous troll)
Tyler Littlefeild(confused troll)
Bryan ? (annoying troll)
Corey Richarson
Nicholas Devenish
Alexander Kapps
rusi ?
Andre ?
Geremy Condra (troll-wagoneer)
Ethan Furman
Noah Hall
Adam Skutt
Arndt Rodger Schnieder
Mark Roseman (Tkinter's minion)


#-- Occasonal Flamers --#
Micheal Torrie
Grant Edwards
MRAB
Thomas L Shinnink
Peter Otten
Giampaolo Rodola
Giacomo Boffi
malcom ?
Zeissmann
Mel
Owen Jacobson
Robert ?

#-- Complete Nobodys --#
Bill Felton
flebber

#-- MIA --#
GvR
Steve Holden

#-- Moderates --#
Richard Johnson
Terry Reedy
Kevin Walzer
Octavian Rasnita
Robert Kern
Brenden Simon
Tommy Grav
Martin V Leowis
Ian ?
Tim Chase
CM
Bob Martin
Neil Hodgenson
Robin Dunn
Benjamin Kaplan
Jerry Hill
Patty ?
Martin Gregorie
Albert van der Horst
Martin P Hellwig
jmfauth
Steven Howe
Antoine Pitrou
Hank Fay
Katie T
Gerry Reno
Stefen Behnel

26 moderates
31 trolls, minions, sockpuppets, and or flamers
2 missing in action

= This community needs serious help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Noah Hall
On Tue, Feb 1, 2011 at 3:14 PM, rantingrick rantingr...@gmail.com wrote:
 #-- Embedded Trolls and Minions --#
 Steven D'Aprano(smart and witty (annoying) troll)
 Stephan Hansen (controversy troll)
 Ben Finny (haughty troll)
 alex23(angry/dangerous troll)
 Tyler Littlefeild(confused troll)
 Bryan ? (annoying troll)
 Corey Richarson
 Nicholas Devenish
 Alexander Kapps
 rusi ?
 Andre ?
 Geremy Condra (troll-wagoneer)
 Ethan Furman
 Noah Hall
 Adam Skutt
 Arndt Rodger Schnieder
 Mark Roseman (Tkinter's minion)

These people, including myself, aren't trolls nor minions. They just
don't agree with you.

And on the topic of IDLE, I agree the coding's not great, but I
disagree with it being a problem for the Python community. I've never,
ever seen a thread saying OMG, WHAT DOES THIS IDLE SOURCE CODE
EXTRACT MEAN? PLEASE HELP, I CAN'T UNDERSTAND IDLE, THEREFORE I CAN
NOT USE Tkinter! I'm leaving Python, Visual Basic's for me from now
on! NO DAMN IDLE TO MESS UP EVERYTHING, YOU SEE?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reassign or discard Popen().stdout from a server process

2011-02-01 Thread John O'Hagan
On Tue, 1 Feb 2011, Chris Rebert wrote:
 On Tue, Feb 1, 2011 at 12:30 AM, John O'Hagan m...@johnohagan.com wrote:
  I'm starting a server process as a subprocess. Startup is slow and
  unpredictable (around 3-10 sec), so I'm reading from its stdout until I
  get a line that tells me it's ready before proceeding, in simplified
  form:
  
  import subprocess
  proc = subprocess.Popen(['server', 'args'], stdout=subprocess.PIPE)
  while proc.stdout.readline() != Ready.\n:
 pass
  
  Now I can start communicating with the server, but I eventually realised
  that as I'm no longer reading stdout, the pipe buffer will fill up with
  output from the server and before long it blocks and the server stops
  working.
  
  I can't keep reading because that will block - there won't be any more
  output until I send some input, and I don't want it in any case.
  
  To try to fix this I added:
  
  proc.stdout = os.path.devnull
  
  which has the effect of stopping the server from failing, but I'm not
  convinced it's doing what I think it is. If I replace devnull in the
  above line with a real file, it stays empty although I know there is
  more output, which makes me think it hasn't really worked.
 
 Indeed. proc.stdout is a file, whereas os.devnull is merely a path
 string; the assignment is nonsensical type-wise.

My mistake, of course I meant open(os.path.devnull).

  Simply closing stdout also seems to stop the crashes, but doesn't that
  mean it's still being written to, but the writes are just silently
  failing? In
 
 Based on some quick experimentation, yes, more or less.
 
  either case I'm wary of more elusive bugs arising from misdirected
  stdout.
  
  Is it possible to re-assign the stdout of a subprocess after it has
  started?
 
 I think that's impossible. (Most of Popen's attributes probably should
 be read-only properties to clarify that such actions are don't have
 the intended effect.)

I don't doubt what you say, but attempting to assign it does seem to do 
something, as it consistently stops the crashes which occur otherwise. What it 
does, I have no idea.

  What's the right way to read stdout up to a given line, then
  discard the rest?
 
 I would think calling Popen.communicate() after you've reached the
 given line should do the trick.
 http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate
 Just ignore its return value. However, that does require sending the
 input all at once in a single chunk, which it sounds like may not be
 feasible in your case; if so, I have no idea how to do it cleanly.

Yes, unfortunately I need to send a lot of precisely-timed short strings, and 
communicate() blocks after the first call. I tried calling stdout.readline() 
the right number of times after each input, but that seems fiddly and fragile - 
for example the number of lines of output is not guaranteed and may vary in 
the case of errors, and also the extra reads had a noticeable effect on 
latency, which is important in this case. 

So far my best bet seems to be closing stdin, which doesn't seem very clean, 
but it does what I want and seems to be just as fast as using 
stdin=open(os.devnull) in the Popen call in the first place.

Thanks,

John

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


How can I tell if I am inside a context manager?

2011-02-01 Thread Gerald Britton
I'd like to know how (perhaps with the inspect module) I can tell if I
am running in a context manager.

e.g.

class f():
def __init__(s): pass
def __enter__(s): return s
def __exit__(s,a,b,c): return None

def g():
x = f()
# insert code here to return False, since I am not in a context
manager on f:
with h as f():
# insert code here to return True, since I am in a context manager on f:

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


Re: Looking for Remote Python Project

2011-02-01 Thread Subhabrata
On Feb 1, 8:45 am, Alan Meyer amey...@yahoo.com wrote:
 On 01/29/2011 04:19 PM,joy99wrote:

  Dear Room,

  I am a Python Programmer from India(New Delhi Region), and I worked
  for quite a long time in Bangalore. I have been working in Python for
  the last 4 years or so. I have successfully built around 15 projects
  in Python. I am looking for some remote Python Projects, which can be
  done from home.

  If any one knows of anything, I may be helpful enough.

  Best Regards,
  Subhabrata.

 Subharata,

 Would you be willing to tell us what a programmer with your level of
 experience typically charges per hour for his services?

 I'm not in a position to hire anyone, I'm just a programmer myself.  But
 I'm curious about rates in India vs. the U.S., where I live and work.

 Thanks and good luck with your efforts to get work.

      Alan

Alan,
Usually if any one pays USD 1 per hr in India it is good, USD 2 per
hour is handsome,
very rare people pay USD 3 to 4 per hour, but I know some people in
India charge USD 20/25 per line I do not know their hourly rate but as
I know they just run some consultancy and do not do any job.
The people who give in range of USD 1-4/hr also gives some perks like
performance related bonus, housing, medical, etc.
But again rate varies. Delhi/Gurgaon gives highest pay, followed by
Bangalore/Hyderabad, then comes Chennai, Mumbai gives moderate,
Kolkata/Mysore/Bhubaneswar are casual players, they neither have
serious places of work nor any good environment.
In India, lots of development goes on in the government sector but
right now they are paying very high, generally they pay 20-30% lower
than private sector, but job security is there.

Hope this information helps.
Best Regards,
Subhabrata.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Terry Reedy

On 2/1/2011 12:13 AM, rantingrick wrote:

On Jan 31, 4:17 pm, Kevin Walzerk...@codebykevin.com  wrote:

Rick,



Yes. IDLE is first and foremost a tool to get work done. However we
should not ignore the fact that IDLE could also be a great learning
resource for Tkinter GUI's and other subjects. Why not clean up the
code base? We could start small. First, move the custom widgets like
textView, Tabbedpages, FindDialog, ReplaceDialog, and TreeWidget into
the lib-tk for others to use more freely. Then we can modify the
event robbers CallTips, ParenMatch, and ColorDelegator.


Perhaps, after the repository moves from svn to hg, some 'we' will. 
Maybe by then, you will have had your fun and be ready to work. Maybe 
Kevin would help a bit.


Such a project would be carried out on the tracker and idle-sig mailing 
list. Normal decorum would be required -- no ranting or insulting. The 
first thing to do, in my opinion, is to review existing patches on the 
tracker.



Well some changes and improvements can be made to the UI as well.


There is patch on the tracker, by G. Polo, as I remember, to replace tk 
widgets with the newer themed ttk widgets. It needs to be reviewed and 
tested. To make a big change (or proceed with any refactoring) better 
automated testing would be very useful.


--
Terry Jan Reedy

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


Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Wolfgang Rohdewald
On Dienstag 01 Februar 2011, Gerald Britton wrote:
 I'd like to know how (perhaps with the inspect module) I can
 tell if I am running in a context manager.

class f(object):
def __init__(self): 
self.inContext = False
def __enter__(self): 
self.inContext = True
return self
def __exit__(self,a,b,c):
self.inContext = False
return None

x = f()
print 'not within:', x.inContext
with f() as h:
print 'within:', h.inContext

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 9:26 am, Noah Hall enali...@gmail.com wrote:
 On Tue, Feb 1, 2011 at 3:14 PM, rantingrick rantingr...@gmail.com wrote:
  #-- Embedded Trolls and Minions --#
  Steven D'Aprano(smart and witty (annoying) troll)
  Stephan Hansen (controversy troll)
  Ben Finny (haughty troll)
  alex23(angry/dangerous troll)
  Tyler Littlefeild(confused troll)
  Bryan ? (annoying troll)
  Corey Richarson
  Nicholas Devenish
  Alexander Kapps
  rusi ?
  Andre ?
  Geremy Condra (troll-wagoneer)
  Ethan Furman
  Noah Hall
  Adam Skutt
  Arndt Rodger Schnieder
  Mark Roseman (Tkinter's minion)

 These people, including myself, aren't trolls nor minions. They just
 don't agree with you.

No they are trolls and they have demonstrated trollish behavior on
many occasions. Some have even threatened to kill me. Can you believe
that? If you will look over my moderate list you will see that many do
not agree with me completely however they express their disagreement
in a moderate way. On the other hand the trolls and flamers just hurl
insults and inflammatory speech. The trolls and flamers don't offer
any argument to back up their statements. They only hurl more
emotional bile.

 And on the topic of IDLE, I agree the coding's not great,

See now you are offering truth in your argument! Keep this up and i'll
move you over to the occasional flamers group. Then over time, if you
can demonstrate an ability to engage in lively discussion based on
facts and not emotion, i *may* even move you into the moderates group.
I believe in every troll there is a rational person just waiting to
break free.

 but I
 disagree with it being a problem for the Python community. I've never,
 ever seen a thread saying OMG, WHAT DOES THIS IDLE SOURCE CODE
 EXTRACT MEAN? PLEASE HELP,

Thats because even the maintainers of IDLE don't understand completely
how it works. It is a true nightmare of code horror --  of *epic*
proportions!

 I CAN'T UNDERSTAND IDLE, THEREFORE I CAN
 NOT USE Tkinter! I'm leaving Python, Visual Basic's for me from now
 on! NO DAMN IDLE TO MESS UP EVERYTHING, YOU SEE?

Well this would be expected of an emotionally driven creature. One who
cannot wield the tools of reason and logic. I pity these poor souls
just as i pity the trolls in the troll group. But like they say: When
your at the bottom there is only one direction to go... Strait up!
Sadly some of these folks may be suffering from gimbal lock with their
up vector pointing strait down.


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Kevin Walzer

On 2/1/11 10:54 AM, Terry Reedy wrote:

Maybe Kevin would help a bit.


Probably not--IDLE is good enough for my needs. I've submitted some 
(rather extensive) patches for things that annoyed me and got in my way, 
and they eventually made it in. (The classic open source 
pathway--scratching my own itch.) Beyond that, though, hacking on IDLE 
isn't a project I have time for.


--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 9:54 am, Terry Reedy tjre...@udel.edu wrote:
 On 2/1/2011 12:13 AM, rantingrick wrote:

  On Jan 31, 4:17 pm, Kevin Walzerk...@codebykevin.com  wrote:
  Rick,
  Yes. IDLE is first and foremost a tool to get work done. However we
  should not ignore the fact that IDLE could also be a great learning
  resource for Tkinter GUI's and other subjects. Why not clean up the
  code base? We could start small. First, move the custom widgets like
  textView, Tabbedpages, FindDialog, ReplaceDialog, and TreeWidget into
  the lib-tk for others to use more freely. Then we can modify the
  event robbers CallTips, ParenMatch, and ColorDelegator.

 Perhaps, after the repository moves from svn to hg, some 'we' will.

Well the best attribute of IDLE is backward compatibility -- there is
none to worry about. IDLE is not a module with an interface, it's just
a tool. So we could change anything we want without worry of causing
code breakage. There is not good reason NOT to fix IDLE.

 Maybe Kevin would help a bit.

I was hoping he would get involved however his last post proved
otherwise. I know he has his own projects however he would have been a
valuable asset for the ttk theming stuff.

 Such a project would be carried out on the tracker and idle-sig mailing
 list. Normal decorum would be required -- no ranting or insulting. The
 first thing to do, in my opinion, is to review existing patches on the
 tracker.

Agreed. Terry (or anyone) can you give some link to info on hg so i
can study up on this topic? Thanks

  Well some changes and improvements can be made to the UI as well.

 There is patch on the tracker, by G. Polo, as I remember, to replace tk
 widgets with the newer themed ttk widgets. It needs to be reviewed and
 tested. To make a big change (or proceed with any refactoring) better
 automated testing would be very useful.

Yes turning on the themes would be a huge improvement. I also wished
IDLE would look better.

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


Re: argparse: combine current option value with positional argument

2011-02-01 Thread rantingrick
On Feb 1, 6:59 am, Peter Otten __pete...@web.de wrote:
 I'd like to capture the current value of an option --prefix=whatever along
 with a positional value as it is seen by argparse.


Have you seen the handy optphart module yet? I believe its in alpha2
currently but very stable.

http://tinyurl.com/optphart
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Littlefield, Tyler

See now you are offering truth in your argument! Keep this up and i'll
move you over to the occasional flamers group. Then over time, if you
can demonstrate an ability to engage in lively discussion based on
facts and not emotion, i *may* even move you into the moderates group.
O no, whatever shall I do. I apparently have no hope of being moved into 
the moderates group because I don't agree with him. I hope everyone will 
excuse me now, I must dash off to slit  my wrists in a tub of warm water 
and listen to Free Bird, while morning over the fact that I may *never* 
get moved into RR's moderate's group. Tisk tisk.


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


How can I tell if I am inside a context manager?

2011-02-01 Thread Gerald Britton
On Dienstag 01 Februar 2011, Gerald Britton wrote:
 I'd like to know how (perhaps with the inspect module) I can
 tell if I am running in a context manager.

class f(object):
   def __init__(self):
   self.inContext = False
def __enter__(self):
self.inContext = True
return self
def __exit__(self,a,b,c):
self.inContext = False
return None

 x = f()
 print 'not within:', x.inContext
 with f() as h:
print 'within:', h.inContext

yes, of course, but in this case I may not modify the class.  try it with open:

x = open('somefile')
# return false since not in a context
with open('somefile') as x
# return true since in a context.


-- 
Wolfgang

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 10:29 am, Littlefield, Tyler ty...@tysdomain.com wrote:

 I hope everyone will
 excuse me now, I must dash off to slit  my wrists in a tub of warm water
 and listen to Free Bird,

Free Bird! hmm, I would have chosen Chopin's nocturne 48-1 or 72-1 if
i was feeling rather melancholy at the moment. Then there is always
the funeral march if you really want to lay it on thick. However the
march does have a rather lengthy hopeful section that may make you
give second thoughts. Or perhaps the Berceuse in D-flat Major as a
final glorious celebration of life as one journeys beyond the edge of
transcendence. If there is a heaven it must sound like this...

   http://il.youtube.com/watch?v=8TQ-AXJZqtg

...only a man who suffered so greatly can know what true beauty is.
RIP Chopin.

If you're going to met your end it should be at least to a piece that
is truly timeless -- not some reefer+jack induced rockabilly ballad!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Red John
On Feb 1, 10:26 am, rantingrick rantingr...@gmail.com wrote:
 On Feb 1, 10:29 am, Littlefield, Tyler ty...@tysdomain.com wrote:

  I hope everyone will
  excuse me now, I must dash off to slit  my wrists in a tub of warm water
  and listen to Free Bird,

 Free Bird! hmm, I would have chosen Chopin's nocturne 48-1 or 72-1 if
 i was feeling rather melancholy at the moment. Then there is always
 the funeral march if you really want to lay it on thick. However the
 march does have a rather lengthy hopeful section that may make you
 give second thoughts. Or perhaps the Berceuse in D-flat Major as a
 final glorious celebration of life as one journeys beyond the edge of
 transcendence. If there is a heaven it must sound like this...

    http://il.youtube.com/watch?v=8TQ-AXJZqtg

 ...only a man who suffered so greatly can know what true beauty is.
 RIP Chopin.

 If you're going to met your end it should be at least to a piece that
 is truly timeless -- not some reefer+jack induced rockabilly ballad!

Go away. You are easily one of the worst (and definitely most
annoying) person I've encountered in person or online, which is saying
something because I used to frequent 4chan.

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


Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Jerry Hill
On Tue, Feb 1, 2011 at 11:34 AM, Gerald Britton gerald.brit...@gmail.comwrote:

 x = open('somefile')
 # return false since not in a context
 with open('somefile') as x
 # return true since in a context.


Perhaps something like this:

x = open('somefile')
if hasattr(x, '__enter__'):
return false
with open('somefile') as x:
do_something()

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Robert

On 2011-02-01 00:13:06 -0500, rantingrick said:


On Jan 31, 4:17 pm, Kevin Walzer k...@codebykevin.com wrote:

Yes. IDLE is first and foremost a tool to get work done. However we
should not ignore the fact that IDLE could also be a great learning
resource for Tkinter GUI's and other subjects. Why not clean up the
code base? We could start small. First, move the custom widgets like
textView, Tabbedpages, FindDialog, ReplaceDialog, and TreeWidget into
the lib-tk for others to use more freely. Then we can modify the
event robbers CallTips, ParenMatch, and ColorDelegator. Just small
steps Kevin. It all starts with babysteps. At least we would be doing
something. Currently we are sitting around waiting for a miracle to
happen, and problems are solved by methods, not miracles!

Well some changes and improvements can be made to the UI as well.


Fork it and do it!

--
Robert


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 11:52 am, Red John redjohn...@gmail.com wrote:

 Go away. You are easily one of the worst (and definitely most
 annoying) person I've encountered in person or online, which is saying
 something because I used to frequent 4chan.

Hmm, that coming from someone who has two posts in this group. And the
last he posted was a year ago! Alright, let me add you to the proper
category...

py troll_group.append(Red John)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Gerald Britton
Perhaps something like this:

x = open('somefile')
if hasattr(x, '__enter__'):
return false
with open('somefile') as x:
do_something()

 class f():
def __init__(s): pass
def __enter__(s): return s
def __exit__(s,a,b,c): return None

 x = f()
 hasattr(x, '__enter__')
True
 with f() as x:
hasattr(x,'__enter__')


True


As you can see, the object has a '__enter__' method regardless of how
it was created.  Whatever the test, it needs to return False in the
first case and True in the second case, without modifying the class
definition.


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Cousin Stanley
rantingrick wrote:

 Terry (or anyone) can you give some link to info on hg 
 so i can study up on this topic ?

  http://mercurial.selenic.com/


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: multiple values for keyword argument

2011-02-01 Thread Patty


- Original Message - 
From: Jean-Michel Pichavant jeanmic...@sequans.com

To: Patty pa...@cruzio.com
Cc: python-list@python.org
Sent: Tuesday, February 01, 2011 2:27 AM
Subject: Re: multiple values for keyword argument



Patty wrote:



pa...@cruzio.com wrote:

  I have been avoiding understanding this 'self',
[snip]
Regards,

Patty

What is to be understood ?? self references the instance. Did I miss 
something ?


JM





Yes, there was more.  And it's been fully explained at this point.

Patty



Hmm... I re-read the thread just in case ... Anyway.
I'd like to read suggestions for self replacements...
Currently 'yo' have been proposed.

I'm just curious, I promise I won't make any comment :D

JM




Hi Jean-Michel -

I'm sorry.  I was getting sensitive about being criticized (or trying to 
re-explain what I learned and getting it terribly mangled).  As it turns 
out - Westley Martinez pointed out the link about the usage of 'self' : 
http://en.wikipedia.org/wiki/Self_(computer_science)and these specific 
two lines showed me why I had been thinking I (we) could replace the word 
'self' with any descriptive word (variable) I want.  I was thinking of 
'self' as a variable and not In Python, there is no keyword for this, but 
it exists as the name of the obligatory first argument of all member 
functions. Conventionally, the name self is used.


And since I come from a C background, I thought I could do the following 
(which the wiki page mentions)  :} ) , thus I wanted to use an invented 
variable name that makes sense to me and helped me as programmer remember 
where I was in my program when I went and tried to reassign new values, 
basically override my object at will.  But this is what I did not realize:


the assignment does not modify the original object, only changing which 
object that the rest of the code in the method refers to 


Some languages, such as Objective-C, allow assignment to self, although it 
is deprecated.


And then after the thread ended - I read this in the wiki page which totally 
explains everything -- Early versions of C++ would let the this pointer be 
changed; by doing so a programmer could change which object a method was 
working on  and I learned C++ from an early version so this is Precisely 
what I thought I could do -- I was envisioning having my object (member 
function) and then as my program forked different paths, well I thought I 
could do this very program design.  Hopefully that makes more sense as to 
why I would change the 'name of the obligatory first argument of all member 
functions'.


As other people pointed out, you _can_ make up your own name, 'yo' or 
anything else, it is by _convention_ to use 'self' and by doing your own 
thing, could develop a bad habit.


Regards,

Patty 


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread David Hutto
In the grand scope of things...you're all boring.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Terry Reedy

On 2/1/2011 11:18 AM, rantingrick wrote:


Well the best attribute of IDLE is backward compatibility -- there is
none to worry about. IDLE is not a module with an interface, it's just
a tool. So we could change anything we want without worry of causing
code breakage. There is not good reason NOT to fix IDLE.


That is similar to my view. Of course, there will be an tracker issue 
and list discussion for any major change. I have even thought it should 
perhaps be moved to the Tools/ directory, but installation of that is 
optional. Google codesearch can be used to see what, if anything, anyone 
imports from idlelib.



Agreed. Terry (or anyone) can you give some link to info on hg so i
can study up on this topic? Thanks


Joel Spolsky's tutorial is highly regarded as an easier intro than the 
reference manual. I am about to reread it myself.

http://hginit.com/

--
Terry Jan Reedy

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


Re: Use the Source Luke

2011-02-01 Thread OKB (not okblacke)
Tim Wintle wrote:

 However I think the biggest changes that have probably happened
 with python itself are:
 
  (1) More users for whom this is their first language.
  (2) CS courses / training not teaching C (or pointer-based
  languages). 
 
 (2) is especially important IMO - under half of the python
 developers I have regularly worked with would feel comfortable
 reading C - so for the other half reading C source code probably
 isn't going to help them understand exactly what's going on
 (although in the long run it might help them a lot)

I'd just like to note that (2) applies to me in spades.  I'm not 
sure how many other people are in my position, but I use Python because 
I like how it works, and I do not want to use C because I find it 
insufferable.  I quite frequently look at the source of Python modules, 
although more often third-party modules than the standard lib, but if I 
have to look at the C source of something I basically stop and find 
another solution (possibly abandoning Python altogether for that usage).

I think, in general, the less anyone needs to know C even exists, 
the better for Python; likewise, the more that people have to mention 
the existence of C in a Python context, the worse for Python.  This may 
be a somewhat extreme viewpoint, but that's my position.

-- 
--OKB (not okblacke)
Brendan Barnwell
Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail.
--author unknown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Jerry Hill
On Tue, Feb 1, 2011 at 1:38 PM, Gerald Britton gerald.brit...@gmail.comwrote:

 As you can see, the object has a '__enter__' method regardless of how
 it was created.  Whatever the test, it needs to return False in the
 first case and True in the second case, without modifying the class
 definition.


I'm sorry, I completely misunderstood your question.  I thought you were
asking how you could tell if something provided a context manager.  Based on
the PEP[1], I don't see any generic way to tell if you are within a context
manager.

1: http://www.python.org/dev/peps/pep-0343/

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread John Nagle

On 1/31/2011 2:17 PM, Kevin Walzer wrote:


It certainly would be interesting to see a fresh approach to IDLE...


The future of playing with Python is probably Python in a browser
window, of which there are several implementations.  If you're doing
anything serious, you're using a programmer's editor or an IDE.
IDLE lives in a narrowing niche between those two points. Maybe
it should be killed off.

John Nagle

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


Re: multiple values for keyword argument

2011-02-01 Thread Patty
stuff snipped

Here is a list of the compiled personalities...

stuff snipped


#-- Moderates --#

stuff snipped


Patty ?

stuff snipped

26 moderates
31 trolls, minions, sockpuppets, and or flamers
2 missing in action

= This community needs serious help!
-- 
http://mail.python.org/mailman/listinfo/python-list


 
How Embarrassing!!  This caused great blushing!!  Being categorized on a big 
email list...also not sure why I am not on the #-- Complete Nobodys --# list.
You hit me right in my shy streak.  I am really capable of a lot of 
participation on email lists and considering attending one of the BayPiggies 
in-person meetings
and getting more involved.  But I need to get smarter about Python programming 
first.  This might _make_ me go MIAyikes!

Patty

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


Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Ethan Furman

Gerald Britton wrote:

I'd like to know how (perhaps with the inspect module) I can tell if I
am running in a context manager.


What's your use-case?

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread rantingrick
On Feb 1, 1:35 pm, John Nagle na...@animats.com wrote:
 On 1/31/2011 2:17 PM, Kevin Walzer wrote:

  It certainly would be interesting to see a fresh approach to IDLE...

 The future of playing with Python is probably Python in a browser
 window, of which there are several implementations.

Hello John,

I found skulpt which looks rather interesting.

  http://www.skulpt.org/

Why do we not have a version of this at python.org so people can get a
feel for python right away. Ruby has that Learn Ruby in 20 Minutes
thing and so should we.

Do you have any links to projects such as this one that you like to
share, John?

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Corey Richardson
On 02/01/2011 03:05 PM, rantingrick wrote:
 On Feb 1, 1:35 pm, John Nagle na...@animats.com wrote:
 On 1/31/2011 2:17 PM, Kevin Walzer wrote:

 It certainly would be interesting to see a fresh approach to IDLE...

 The future of playing with Python is probably Python in a browser
 window, of which there are several implementations.
 
 Hello John,
 
 I found skulpt which looks rather interesting.
 
   http://www.skulpt.org/
 
 Why do we not have a version of this at python.org so people can get a
 feel for python right away. Ruby has that Learn Ruby in 20 Minutes
 thing and so should we.
 
 Do you have any links to projects such as this one that you like to
 share, John?
 

http://people.csail.mit.edu/pgbovine/python/

Not quite an interpreter, and certainly has its limits, for example, it
will only let you run so many steps before not letting you go on. I
think it's a decent learning tool, but the visualisation is what makes
it shine, IMO. That version uses python 2.5, there is also a version
that uses python 3.1:

http://netserv.ict.ru.ac.za/python3_viz/


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


how to get and search a html file from a website

2011-02-01 Thread Tracubik
Hi all!
i'm writing a notification program and i'm quite new to python.
The program have to check every 5 minutes a particular website and alert 
me when a particular sentence (user online) is in the html.
i've thinked to use a text browser (lynx) to retrieve the html and parse 
the output in python as a normal text file.
Do you have any better idea?

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


Re: how to get and search a html file from a website

2011-02-01 Thread Paul Anton Letnes

Den 01.02.11 22.20, skrev Tracubik:

Hi all!
i'm writing a notification program and i'm quite new to python.
The program have to check every 5 minutes a particular website and alert
me when a particular sentence (user online) is in the html.
i've thinked to use a text browser (lynx) to retrieve the html and parse
the output in python as a normal text file.
Do you have any better idea?

thanks
Medeo


Of course there is a pythonic way :-)

 import urllib
 urllib.urlretrieve('http://docs.python.org/tutorial/index.html', 
'tut.html')


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


XEmacs output from Python

2011-02-01 Thread Beliavsky
The script

name = raw_input(What is your name? )
print Hello, ,name

runs fine from the Windows prompt (cmd.exe), but when I run it in a
shell buffer under XEmacs, I only see the text What is your name? 
AFTER I enter some text, so a run looks like this:

H:\pythonpython xinput.py
x
What is your name? Hello,  x

Is there a workaround? Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to get and search a html file from a website

2011-02-01 Thread James Mills
On Wed, Feb 2, 2011 at 7:20 AM, Tracubik affdfsdfds...@b.com wrote:
 Hi all!
 i'm writing a notification program and i'm quite new to python.
 The program have to check every 5 minutes a particular website and alert
 me when a particular sentence (user online) is in the html.
 i've thinked to use a text browser (lynx) to retrieve the html and parse
 the output in python as a normal text file.
 Do you have any better idea?

Assuming the website in question does not provide
any useful APIs (sad), then a better approach is to
use the urllib library in conjunction with lxml to
parse the html in a sensible way (instead of just
doing: if foo in s)

cheers
James

-- 
-- James Mills
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to get and search a html file from a website

2011-02-01 Thread Corey Richardson
On 02/01/2011 04:20 PM, Tracubik wrote:
 Hi all!
 i'm writing a notification program and i'm quite new to python.
 The program have to check every 5 minutes a particular website and alert 
 me when a particular sentence (user online) is in the html.
 i've thinked to use a text browser (lynx) to retrieve the html and parse 
 the output in python as a normal text file.
 Do you have any better idea?
 
 thanks
 Medeo

urllib2

http://docs.python.org/howto/urllib2.html

If you need fancy-shmancy parsing, look into:

 http://docs.python.org/library/htmlparser.html

Or you can treat the returned site as a string and just search for that
sentence.
-- 
http://mail.python.org/mailman/listinfo/python-list


test: please ignore

2011-02-01 Thread Gelonida
Somehow I can't post anymore to gmane.

Would like to know why.

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


How to create an entry in the Program menu of Windows?

2011-02-01 Thread Diesel

Hi,

I'd like to add menu entry in the Program Menu as part of the
installation of an application. Is it possible to do that from Python? 

Any examples or link? I have not been able to find anything with
google...

thanks in advance
s/

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


DRY and static attribute for multiple classes.

2011-02-01 Thread Marc Aymerich
Hi all,
I want to provide an encapsulated static attribute called _registry
for several classes.

I try to use inheritance in order to make it DRY: all classes inherit
from a BaseClass that implements the _registry encapsulation. But with
inheritance it doesn't work how I want, because a single instance of
the _registry is shared between all of the inherited classes, and I
want to have an independent _registry for every class.

How can I do that without coping all the code in every class?

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


Re: simplest way to create simple standalone wsgi server without import wsgi_lib.server

2011-02-01 Thread Gelonida
On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote:
 On Jan 31, 5:28 pm, Gelonida gelon...@gmail.com wrote:
 Hi,

 Normally I use following code snippet to quickly test a wsgi module
 without a web server.

 import wsgi_lib.server
 wsgi_lib.server.run(application, port=port)

 However Now I'd like to test a small wsgi module on a rather old host
 ( Python 2.4.3 ) where I don't have means to update python.

 Is there any quick and easy code snippet / module, performing the same
 task as my above mentioned lines?

 Thanks in advance for any hints
 
 You didn't mention why you can't update Python, or if that means you
 can't install new libraries either.  However, if you have Twisted 8.2
 or newer, you can replace your snippet with this shell command:
 
 twistd -n web --port port --wsgi application

Thanks Jean-Paul

The problem is rather simple. The host in question is not 100% under my
control. I can request to have packages installed if they're in the list
of available packages.

python 2.4 is part of it. twisted is not

In the worst case I could request the installation of python virtualenv,
the entire gcc tool chain and try to compile twisted,
or wsgilib, but I wondered whether there isn't a simple pure python way
of starting a wsgi server for test purposes.


 
 application is the fully-qualified Python name of your application
 object.  So, for example if you have a module named foo that defines
 an application name, you would pass foo.application.
 
 Jean-Paul


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


Re: How to create an entry in the Program menu of Windows?

2011-02-01 Thread rantingrick
On Feb 1, 3:43 pm, Diesel die...@e-den.it wrote:

 I'd like to add menu entry in the Program Menu as part of the
 installation of an application. Is it possible to do that from Python?

Diesel your description is ambiguous at best, might we inquire that
you elaborate a wee bit more? Is this application something that YOU
created? If so what GUI library did you use? Can you show us some code
or a small example?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: test: please ignore

2011-02-01 Thread Gelonida
On 02/01/2011 10:44 PM, Gelonida wrote:
 Somehow I can't post anymore to gmane.
 
 Would like to know why.
 
Now this message arrived.
So it seems to work again, though with quite some heavy delay.

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread AD.
On Feb 2, 4:14 am, rantingrick rantingr...@gmail.com wrote:
 On Feb 1, 8:27 am, Jean-Michel Pichavant jeanmic...@sequans.com
 wrote:

  In a more serious way, just count the people who second your
  prosposition. It's around 0. It is usually a good sign that you're
  wrong. This rule kinda applies to anyone, don't take it personnaly.

 Well your statment completely ignores the silent majority. Are you
 telling me that this sloth of trolls, minions, and flamers that have
 so far replied are represetative of this fine community.

As a member of this silent majority - we care less about IDLEs code
quality than all the others that did actually care enough to even
reply to you.

Now stop your annoying trolling and either start working on your IDLE
fork or shut up. Nobody else who agrees with you (there might be
someone out there) has been ever been motivated enough to initiate
this work by themselves, so unless YOU start it - it probably is never
going to happen.

Once it is underway you might attract some other people interested in
helping to refactor or recode IDLE - but you won't know that unless
you start work on it.

But I think we all know exactly what you are actually going to keep
doing though.

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


Re: simplest way to create simple standalone wsgi server without import wsgi_lib.server

2011-02-01 Thread Jean-Paul Calderone
On Feb 1, 2:01 pm, Gelonida gelon...@gmail.com wrote:
 On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote:



  On Jan 31, 5:28 pm, Gelonida gelon...@gmail.com wrote:
  Hi,

  Normally I use following code snippet to quickly test a wsgi module
  without a web server.

  import wsgi_lib.server
  wsgi_lib.server.run(application, port=port)

  However Now I'd like to test a small wsgi module on a rather old host
  ( Python 2.4.3 ) where I don't have means to update python.

  Is there any quick and easy code snippet / module, performing the same
  task as my above mentioned lines?

  Thanks in advance for any hints

  You didn't mention why you can't update Python, or if that means you
  can't install new libraries either.  However, if you have Twisted 8.2
  or newer, you can replace your snippet with this shell command:

      twistd -n web --port port --wsgi application

 Thanks Jean-Paul

 The problem is rather simple. The host in question is not 100% under my
 control. I can request to have packages installed if they're in the list
 of available packages.

 python 2.4 is part of it. twisted is not

 In the worst case I could request the installation of python virtualenv,
 the entire gcc tool chain and try to compile twisted,
 or wsgilib, but I wondered whether there isn't a simple pure python way
 of starting a wsgi server for test purposes.


You may be able to install Twisted (or even wsgilib) in your home
directory.  For example, the command:

python setup.py --prefix ~/.local

will install Twisted (or maybe wsgilib) in ~/.local/lib/python2.4/site-
packages/.  Add that to your PYTHONPATH (eg in your .bashrc) and
you're basically all set.  Also, though Twisted has some extension
modules, they're optional.  So you should be fine without a compiler,
*except* that distutils doesn't cope so well with certain cases.  If
you find setup.py install fails for some reason, you can also just
add the unpacked source directory to PYTHONPATH and run it in-place
without installation.

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


Re: DRY and static attribute for multiple classes.

2011-02-01 Thread Peter Otten
Marc Aymerich wrote:

 Hi all,
 I want to provide an encapsulated static attribute called _registry
 for several classes.
 
 I try to use inheritance in order to make it DRY: all classes inherit
 from a BaseClass that implements the _registry encapsulation. But with
 inheritance it doesn't work how I want, because a single instance of
 the _registry is shared between all of the inherited classes, and I
 want to have an independent _registry for every class.
 
 How can I do that without coping all the code in every class?

If you want to go fancy use a metaclass:

 class Base(object):
... class __metaclass__(type):
... def __init__(self, *args):
... type.__init__(self, *args)
... self.per_class = []
...
 class A(Base): pass
...
 A().per_class is A().per_class
True
 class B(Base): pass
...
 B().per_class is B().per_class
True
 A().per_class is B().per_class
False

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


Re: simplest way to create simple standalone wsgi server without import wsgi_lib.server

2011-02-01 Thread Gelonida
On 02/01/2011 11:36 PM, Jean-Paul Calderone wrote:

 twistd -n web --port port --wsgi application


 The problem is rather simple. The host in question is not 100% under my
 control. I can request to have packages installed if they're in the list
 of available packages.

 python 2.4 is part of it. twisted is not

 
 You may be able to install Twisted (or even wsgilib) in your home
 directory.  For example, the command:
 
 python setup.py --prefix ~/.local
 
 will install Twisted (or maybe wsgilib) in ~/.local/lib/python2.4/site-
 packages/.  Add that to your PYTHONPATH (eg in your .bashrc) and
 you're basically all set.  Also, though Twisted has some extension
 modules, they're optional.  So you should be fine without a compiler,
 *except* that distutils doesn't cope so well with certain cases.  If
 you find setup.py install fails for some reason, you can also just
 add the unpacked source directory to PYTHONPATH and run it in-place
 without installation.
 

Thanks a lot you gave me some new ideas.

I made first attempts with virtualenv
and easy_install

no module with C-code can be installed (some issue with tool chain)

- wsgilib installation failed therefore
- twisted installation failed therefore

I untarred twisted and tried to run twistd.

it complains about missing zope.interface
installing of zope.interface fails also with gcc error.

It seems I am currently stuck until I find a simplistic python only
solution for quick standalone wsgi_module tests.





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


PyQT: QWebView with custom QNetworkAccessManager

2011-02-01 Thread Gelonida
Hi,

I would like to subclass QNetworkAccessManager and
create a subclass of QWebView, that will use the subclassed
QNetworkAccessManager for all accesses.

Is this possible?
I have really no idea when and how I could achieve this.

Thanks in advance for any suggestions / pointers

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


Re: How to create an entry in the Program menu of Windows?

2011-02-01 Thread Michael Torrie
On 02/01/2011 02:43 PM, Diesel wrote:
 I'd like to add menu entry in the Program Menu as part of the
 installation of an application. Is it possible to do that from Python? 
 
 Any examples or link? I have not been able to find anything with
 google...

Use an installer program like nsis to create an installer package from
your python app.  It can do all those kinds of things, and clean up
after the program is uninstalled.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create an entry in the Program menu of Windows?

2011-02-01 Thread Alexander Kapps

On 01.02.2011 22:43, Diesel wrote:


Hi,

I'd like to add menu entry in the Program Menu as part of the
installation of an application. Is it possible to do that from Python?

Any examples or link? I have not been able to find anything with
google...

thanks in advance
s/



AFAIK, the startmenu entries are just .lnk files, placed either in 
the All Users or Some Specific User Startmenu directory. I only 
have a German XP and can't boot it to test at the moment, so I can't 
give more details, but there are surely registry entries to find the 
Startmenu location for the current user or for All Users.


See http://codesnippets.joyent.com/posts/show/529 for an example how 
to place .lnk files. However, for real deployment, you probably want 
to use a real installer framework like NSIS for example.


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


Print docstrings to shell

2011-02-01 Thread Gnarlodious
Can I run a script in bash and print out its docstrings to the bash
shell? I tried this at the end:

print(help(__file__))

Runnig the script:
python ~/Sites/Sectrum/Harmonics.py

but all it spit out was:

no Python documentation found for '~/Sites/Sectrum/Harmonics.py'

However in the interactive shell it prints out the class structure
nicely. What I really want to see is this output in the bash window.

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Michael Torrie
On 02/01/2011 08:26 AM, Noah Hall wrote:
 On Tue, Feb 1, 2011 at 3:14 PM, rantingrick rantingr...@gmail.com wrote:
 #-- Embedded Trolls and Minions --#
 These people, including myself, aren't trolls nor minions. They just
 don't agree with you.

I strongly disagree with rr and find him to be an egotistical troll who
likes to hear the sound of his own, er, typing.  Hence I'm disappointed
that I'm not on his list.

His posts really cause me to be conflicted.  On the one hand they are
fascinating in the train-wreck sense, on the other hand my replying to
this perpetuates his ranting.  Sigh.  Consider yourself fed, rr.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create an entry in the Program menu of Windows?

2011-02-01 Thread Westley Martínez
distutils can do this with a post-install script. See the distutils
documentation.
This is a script I wrote that did this (and other stuff):
import sys
import os

if sys.argv[1] == '-install':
# Append .py to scripts
os.rename(os.path.join(sys.prefix, 'Scripts', 'anikom15'),
  os.path.join(sys.prefix, 'Scripts', 'anikom15.py'))
file_created(os.path.join(sys.prefix, 'Scripts', 'anikom15.py'))
# Create desktop and start menu shortcuts
desktop = get_special_folder_path(CSIDL_COMMON_DESKTOPDIRECTORY)
startmenu = get_special_folder_path(CSIDL_COMMON_STARTMENU)
create_shortcut(os.path.join(sys.prefix, 'Scripts', 'anikom15.py'),
Launch Anikom15's Computer Game,
os.path.join(desktop, 'Anikom15.lnk'),
'', '',
os.path.join(sys.prefix, 'Icons', 'anikom15.ico'))
file_created(os.path.join(desktop, 'Anikom15.lnk'))
create_shortcut(os.path.join(sys.prefix, 'Scripts', 'anikom15.py'),
Anikom15's Computer Game,
os.path.join(startmenu, 'Anikom15.lnk'),
'', '',
os.path.join(sys.prefix, 'Icons', 'anikom15.ico'))
file_created(os.path.join(startmenu, 'Anikom15.lnk'))
elif sys.argv[1] == '-remove':
pass

On Tue, 2011-02-01 at 21:43 +, Diesel wrote:

 Hi,
 
 I'd like to add menu entry in the Program Menu as part of the
 installation of an application. Is it possible to do that from Python? 
 
 Any examples or link? I have not been able to find anything with
 google...
 
 thanks in advance
 s/
 


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


Re: Print docstrings to shell

2011-02-01 Thread André Roberge
On Tuesday, February 1, 2011 8:11:51 PM UTC-4, Gnarlodious wrote:
 Can I run a script in bash and print out its docstrings to the bash
 shell? I tried this at the end:
 
 print(help(__file__))
 
 Runnig the script:
 python ~/Sites/Sectrum/Harmonics.py
 
 but all it spit out was:
 
 no Python documentation found for '~/Sites/Sectrum/Harmonics.py'
 
 However in the interactive shell it prints out the class structure
 nicely. What I really want to see is this output in the bash window.
 
 -- Gnarlie

Try the following:

test.py==
import pydoc

'''this is a test'''

class A(object):
'''docstring'''
pass

print(pydoc.help(__file__[:-3]))
=

python test.py

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Robert

On 2011-02-01 10:54:26 -0500, Terry Reedy said:


On 2/1/2011 12:13 AM, rantingrick wrote:

On Jan 31, 4:17 pm, Kevin Walzerk...@codebykevin.com  wrote:

Rick,



Yes. IDLE is first and foremost a tool to get work done. However we
should not ignore the fact that IDLE could also be a great learning
resource for Tkinter GUI's and other subjects. Why not clean up the
code base? We could start small. First, move the custom widgets like
textView, Tabbedpages, FindDialog, ReplaceDialog, and TreeWidget into
the lib-tk for others to use more freely. Then we can modify the
event robbers CallTips, ParenMatch, and ColorDelegator.


Perhaps, after the repository moves from svn to hg, some 'we' will.
Maybe by then, you will have had your fun and be ready to work. Maybe
Kevin would help a bit.


If he does not, I think I might. Is there a timeline for the move?



Such a project would be carried out on the tracker and idle-sig mailing
list. Normal decorum would be required -- no ranting or insulting. The
first thing to do, in my opinion, is to review existing patches on the
tracker.


Well some changes and improvements can be made to the UI as well.


There is patch on the tracker, by G. Polo, as I remember, to replace tk
widgets with the newer themed ttk widgets. It needs to be reviewed and
tested. To make a big change (or proceed with any refactoring) better
automated testing would be very useful.


+1 for the UI update
+1 for more tests

--
Robert


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Corey Richardson
On 02/01/2011 07:42 PM, Robert wrote:
 On 2011-02-01 10:54:26 -0500, Terry Reedy said:
 
 On 2/1/2011 12:13 AM, rantingrick wrote:
 On Jan 31, 4:17 pm, Kevin Walzerk...@codebykevin.com  wrote:
 Rick,

 Yes. IDLE is first and foremost a tool to get work done. However we
 should not ignore the fact that IDLE could also be a great learning
 resource for Tkinter GUI's and other subjects. Why not clean up the
 code base? We could start small. First, move the custom widgets like
 textView, Tabbedpages, FindDialog, ReplaceDialog, and TreeWidget into
 the lib-tk for others to use more freely. Then we can modify the
 event robbers CallTips, ParenMatch, and ColorDelegator.

 Perhaps, after the repository moves from svn to hg, some 'we' will.
 Maybe by then, you will have had your fun and be ready to work. Maybe
 Kevin would help a bit.
 
 If he does not, I think I might. Is there a timeline for the move?
 

I would help with such a project as well, given the opportunity.

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


Re: Print docstrings to shell

2011-02-01 Thread Gnarlodious
On Feb 1, 5:30 pm, André Roberge andre.robe...@gmail.com wrote:

 test.py==
 import pydoc

 '''this is a test'''

 class A(object):
         '''docstring'''
         pass

 print(pydoc.help(__file__[:-3]))
 =

 python test.py


OK that works, but only if I cd into the folder of the script. If I
run it from ~ I get the same error. How to get around that prob?

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


Re: Print docstrings to shell

2011-02-01 Thread André Roberge
On Tuesday, February 1, 2011 9:05:28 PM UTC-4, Gnarlodious wrote:
 On Feb 1, 5:30 pm, André Roberge andre@gmail.com wrote:
 
  test.py==
  import pydoc
 
  '''this is a test'''
 
  class A(object):
          '''docstring'''
          pass
 
  print(pydoc.help(__file__[:-3]))
  =
 
  python test.py
 
 
 OK that works, but only if I cd into the folder of the script. If I
 run it from ~ I get the same error. How to get around that prob?
 
 -- Gnarlie

===
import pydoc
import os
import sys

'''this is a test'''

class A(object):
'''docstring'''
pass

_path, _file_name = os.path.split(__file__)
_module_name = _file_name[:-3]
sys.path.append(_path)
pydoc.help(_module_name)
=

Note: I've included an underscore in variables names so that they would not 
appear.
Note 2: for some reason, which I do not understand, it shows the help twice 
(i.e. I have to hit q twice to make it go away).  Sorry that I can not help 
with this.

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


Re: PyQT: QWebView with custom QNetworkAccessManager

2011-02-01 Thread Gelonida
On 02/02/2011 12:31 AM, Gelonida wrote:
 Hi,
 
 I would like to subclass QNetworkAccessManager and
 create a subclass of QWebView, that will use the subclassed
 QNetworkAccessManager for all accesses.
 
 Is this possible?
 I have really no idea when and how I could achieve this.
 
 Thanks in advance for any suggestions / pointers
 


Well I answer my own question.

In fact my first experiments failed horribly due to a tiny PyQt detail.

I expected that, the variable new_manager does not have to be persistent.

I naively assumed, that a call to setNetworkAccessManager() would keep a
reference to new_manager and thus avoid its destruction this does not
seem to be the case.

Below an example of how to create a QQWebview with a custom
NetworkAccessManager

import sys
import PyQt4.QtGui as QtGui
import PyQt4.QtCore as QtCore
import PyQt4.QtWebKit as QtWebKit
from PyQt4.QtNetwork import QNetworkAccessManager

class MyNetworkAccessManager(QNetworkAccessManager):
def __init__(self, old_manager):
QNetworkAccessManager.__init__(self)
self.setCache(old_manager.cache())
self.setCookieJar(old_manager.cookieJar())
self.setProxy(old_manager.proxy())
self.setProxyFactory(old_manager.proxyFactory())

def createRequest(self, operation, request, data):
print mymanager handles , request.url()
return QNetworkAccessManager.createRequest(
self, operation, request, data)


def set_new_manager(web):
global new_manager # if this line is commented I will se
old_manager = web.page().networkAccessManager()
new_manager = MyNetworkAccessManager(old_manager)
web.page().setNetworkAccessManager(new_manager)

app = QtGui.QApplication(sys.argv)
web = QtWebKit.QWebView()
set_new_manager()
web.setUrl( QtCore.QUrl(http://www.google.com;) )
web.show()

sys.exit(app.exec_())





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


Re: Print docstrings to shell

2011-02-01 Thread André Roberge
On Tuesday, February 1, 2011 9:21:48 PM UTC-4, André Roberge wrote:
SNIP
 
 ===
 import pydoc
 import os
 import sys
 
 '''this is a test'''
 
 class A(object):
   '''docstring'''
   pass
 
 _path, _file_name = os.path.split(__file__)
 _module_name = _file_name[:-3]
 sys.path.append(_path)
 pydoc.help(_module_name)
 =
 

Actually, one does not need to import pydoc; using help() without importing 
seems to work just as well (or as badly, as it displays it twice...)
André


 Note: I've included an underscore in variables names so that they would not 
 appear.
 Note 2: for some reason, which I do not understand, it shows the help twice 
 (i.e. I have to hit q twice to make it go away).  Sorry that I can not help 
 with this.
 
 André

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


Re: Reassign or discard Popen().stdout from a server process

2011-02-01 Thread John O'Hagan
On Tue, 1 Feb 2011, John O'Hagan wrote:

 
 So far my best bet seems to be closing stdin, which doesn't seem very
 clean, but it does what I want and seems to be just as fast as using
 stdin=open(os.devnull) in the Popen call in the first place.

...and both references to stdin above should have been to stdout (I really 
shouldn't post last thing at night).

 Thanks,
 
 John

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


Re: Print docstrings to shell

2011-02-01 Thread Carl Banks
On Feb 1, 4:11 pm, Gnarlodious gnarlodi...@gmail.com wrote:
 Can I run a script in bash and print out its docstrings to the bash
 shell? I tried this at the end:

 print(help(__file__))

 Runnig the script:
 python ~/Sites/Sectrum/Harmonics.py

 but all it spit out was:

 no Python documentation found for '~/Sites/Sectrum/Harmonics.py'

 However in the interactive shell it prints out the class structure
 nicely. What I really want to see is this output in the bash window.

The help() function prints the documentation itself itself (piping it
to a pager if possible).  It doesn't return the help text.

If that's what you want, then probably the most foolproof way is:

help(sys.modules[__name__])

This'll work whether it's a module or script.  If you just want to
print the documentation and bypass the pager, then I think something
like this will do it:

import pydoc
print pydoc.render_doc(sys.modules[__name__])


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Raymond Hettinger
On Jan 31, 9:39 am, rantingrick rantingr...@gmail.com wrote:
 IDLE: cornucopia
 ...
 These are just the top of the list. The peak of a huge iceberg that
 threatens to sink the community in the arms of chaos never to return.

That being said, I've taught a lot of people Python using IDLE.
It's a surprisingly productive environment and has a near-zero
learning curve.

 I am beginning to believe that this community is either made of
 amateurs due to this lackluster code in the stdlib. However it could
 be that the folks are really professional and refuse to work on such a
 horrible code base (which i understand). I am going with the latter.

Patches are welcome :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Westley Martínez
http://www.youtube.com/watch?v=z5jKMEB4hHE

 On Tue, 2011-02-01 at 10:23 -0800, rantingrick wrote:

 On Feb 1, 11:52 am, Red John redjohn...@gmail.com wrote:
 
  Go away. You are easily one of the worst (and definitely most
  annoying) person I've encountered in person or online, which is saying
  something because I used to frequent 4chan.
 
 Hmm, that coming from someone who has two posts in this group. And the
 last he posted was a year ago! Alright, let me add you to the proper
 category...
 
 py troll_group.append(Red John)


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


Re: Print docstrings to shell

2011-02-01 Thread Gnarlodious
Thank you for the help, I learned a few things. The André solution
renders the colors but needs q-q to quit. The Carl solution 1 prints
colors and requires q to quit. The Carl solution 2 prints colorlessly,
it looks good for exporting to a file. Everything I need.

-- Gnarlie
http://Gnarlodious.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Adding Asian text error with IIS

2011-02-01 Thread Panupat Chongstitwattana
I created a very simple script, testing it out with web browser.

# -*- coding: utf-8 -*-
import sys
sys.getdefaultencoding()

f = '?'
print Content-Type: text/plain;charset=utf-8
print f

 The moment I have an Asian text in my file (without doing anything to it at
all) I always get a 502 error - web server received an invalid response. The
script prints out just fine if I use python own IDLE however.

The file was utf-8 encoded and setdefaultencoding is also utf-8. Testing out
on windows server 2008 R2 IIS 7.5.

Any help greatly appreciate!
-- 
http://mail.python.org/mailman/listinfo/python-list


Perl Hacker, Python Initiate

2011-02-01 Thread Gary Chambers

All,

Given the following Perl script:

#!/usr/bin/perl

%dig = (
solaris = /usr/sbin/dig,
linux   = /usr/bin/dig,
darwin  = /usr/bin/dig
);

$DIG = $dig{$^O};
$DOMAIN = example.com;
$DNS = ns.example.com;
$DIGCMD = qq/$DIG \@$DNS $DOMAIN axfr/;

open DIG, $DIGCMD| or die $DIG: $!\n;
while (DIG) {
next if (/^;/); # Skip any comments
# If we match a CNAME record, we have an alias to something.
# $1 = alias (CNAME), $2 = canonical hostname
if (/^(\S+)\.${DOMAIN}\.\s+\d+\s+IN\s*CNAME\s+(\S+)\.${DOMAIN}\.$/) {
# Push an alias (CNAME) onto an array indexed on canonical hostname
push(@{$cnames{$2}}, $1);
}
# Here's a standard A (canonical hostname) record
# $1 = canonical hostname, $2 = IPv4 address
if (/^(\S+)\.${DOMAIN}\.\s+\d+\s+IN\s*A\s+(\S+)$/) {
$ip{$1} = $2;
}
}
close DIG;

# Format and display it like niscat hosts:
# canonicalHostname alias1 [alias2 aliasN] ipAddress
for $host (sort keys %ip) {
print $host ;
if (defined(@{$cnames{$host}})) {
print join(' ', @{$cnames{$host}});
print  ;
}
print $ip{$host}\n;
}
exit 0;

Will someone please provide some insight on how to accomplish that task in
Python?  I am unable to continually (i.e. it stops after displaying a single
line) loop through the output while testing for the matches on the two
regular expressions.  Thank you.

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


Re: Perl Hacker, Python Initiate

2011-02-01 Thread Chris Rebert
On Tue, Feb 1, 2011 at 8:36 PM, Gary Chambers gwch...@gwcmail.com wrote:
 All,

 Given the following Perl script:
snip
 Will someone please provide some insight on how to accomplish that task in
 Python?  I am unable to continually (i.e. it stops after displaying a single
 line) loop through the output while testing for the matches on the two
 regular expressions.  Thank you.

What's your Python translation attempt look like?

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


Re: Perl Hacker, Python Initiate

2011-02-01 Thread Ben Finney
Gary Chambers gwch...@gwcmail.com writes:

 Given the following Perl script:
[…]

 Will someone please provide some insight on how to accomplish that
 task in Python? I am unable to continually (i.e. it stops after
 displaying a single line) loop through the output while testing for
 the matches on the two regular expressions. Thank you.

Insight will be easier to provide once we see your Python code.

-- 
 \  “In the long run, the utility of all non-Free software |
  `\  approaches zero. All non-Free software is a dead end.” —Mark |
_o__)Pilgrim, 2006 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


wxPython's Print Help

2011-02-01 Thread Akand Islam
I can print whatever I want (definitely texts) by using following
Printer class. However, it prints only in Black and White mode
regardless original color of texts. Is there any way I can print color
texts?

=
#License: MIT
import wx
from wx import Printout, PrintData, PAPER_LETTER, PrintDialogData
from wx import Printer as wxPrinter, MessageBox, PrintPreview,
PrintDialog

def GetErrorText():
Put your error text logic here.  See Python Cookbook for a useful
example of error text.
return Some error occurred.

class Printer(Printout):
def __init__(self, frame):
Prepares the Printing object.  Note: change current_y for 1,
1.5, 2 spacing for lines.
Printout.__init__(self)
self.printer_config = PrintData()
self.printer_config.SetPaperId(PAPER_LETTER)
self.frame = frame
self.doc_text = ''
self.doc_name = ''
self.current_y = 50  #y should be either (15, 22, 30)
if self.current_y == 15:
self.num_lines_per_page = 50
elif self.current_y == 22:
self.num_lines_per_page = 35
else:
self.num_lines_per_page = 60


def Print(self, text, doc_name):
Prints the given text.  Currently doc_name logic doesn't
exist.  E.g. might be useful for a footer..
self.doc_text = text
self.doc_name = doc_name
pdd = PrintDialogData()
pdd.SetPrintData(self.printer_config)
printer = wxPrinter(pdd)
if not printer.Print(self.frame,self):
MessageBox(Unable to print the document.)
else:
self.printer_config =
PrintData(printer.GetPrintDialogData().GetPrintData())

def PreviewText(self, text, doc_name):
This function displays the preview window for the text with
the given header.
try:
self.doc_name = doc_name
self.doc_text = text

#Destructor fix by Peter Milliken --
print1 = Printer(self.frame, text = self.doc_text)
print2 = Printer(self.frame, text = self.doc_text)
preview = PrintPreview(print1, print2,
self.printer_config)
#preview = PrintPreview(self,self,self.printer_config)
if not preview.Ok():
MessageBox(Unable to display preview of document.)
return

preview_window = PreviewFrame(preview, self.frame, \
Print Preview - %s %
doc_name)
preview_window.Initialize()
preview_window.SetPosition(self.frame.GetPosition())
preview_window.SetSize(self.frame.GetSize())
preview_window.MakeModal(True)
preview_window.Show(True)
except:
MessageBox(GetErrorText())

def PageSetup(self):

This function handles displaying the Page Setup window and
retrieving the user selected options.

It's been updated to use the new style Windows, which allow
more options to be configured.

config_dialog = wxPageSetupDialog(self.frame)
config_dialog.GetPageSetupData()
config_dialog.ShowModal()
self.printer_config = config_dialog.GetPageSetupData()
config_dialog.Destroy()

def OnBeginDocument(self,start,end):
Do any end of document logic here.
self.base_OnBeginDocument(start,end)

def OnEndDocument(self):
Do any end of document logic here.
self.base_OnEndDocument()

def OnBeginPrinting(self):
Do printing initialization logic here.
self.base_OnBeginPrinting()

def OnEndPrinting(self):
Do any post printing logic here.
self.base_OnEndPrinting()

def OnPreparePrinting(self):
Do any logic to prepare for printing here.
self.base_OnPreparePrinting()

def HasPage(self, page_num):
This function is called to determine if the specified page
exists.
return len(self.GetPageText(page_num))  0

def GetPageInfo(self):

This returns the page information: what is the page range
available, and what is the selected page range.
Currently the selected page range is always the available page
range.  This logic should be changed if you need
greater flexibility.


minPage = 1
maxPage = int(len(self.doc_text.split('\n'))/
self.num_lines_per_page) + 1
fromPage, toPage = minPage, maxPage
return (minPage,maxPage,fromPage,toPage)

def OnPrintPage(self, page_num):
This function / event is executed for each page that needs to
be printed.
dc = self.GetDC()
x,y = 25, self.current_y
if not self.IsPreview():
y *=4
line_count = 1
for line in self.GetPageText(page_num):
dc.DrawText(line, x, y*line_count)
line_count += 1

return True

def GetPageText(self, 

Classic asp registered with python in IIS 7

2011-02-01 Thread Ansuman Bebarta
I had a website which used IIS 6 to call classic asp pages. The asp
pages called python script and the python pages was doing all the
operations. Now I am using IIS7 in windows7 and while running my
websites I am getting HTTP/1.1 500 Server Error.

I have done following steps but no luck.
I have installed asp in IIS7 and I have registered asp with python by
running pyscript.py (using python 2.7).

Let me tell you that I wrote a simple classic asp code and it worked
in IIS7.The asp code was

- %response.write(Hello World)%

I wrote a cgi with python and it worked with IIS7.The python script
for cgi was

- print Content-Type: text/plain;charset=utf-8
- print Hello World!

But when I wrote another classic asp containing python code it didnt
worked and I got same HTTP/1.1 500 Server Error. The code for asp with
python was

-%@Language=Python%
-%
-x=Hello
-response.write(x)
-%
-- 
http://mail.python.org/mailman/listinfo/python-list


Help with python-twain module

2011-02-01 Thread Sandy Oz

Hello everyone,


Really need help with the python-twain module. I installed 
the module for python 2.6 on a win-xp 32bit machine.


I ran the demo app and got a python core crash when calling 
SourceManager.OpenSource().


I've managed to run the scanner I'm using on a Linux machine 
with python-imaging-sane module, but ran into problems when


switching to windows.


Any help will be greatly appreciated,

Thanks,

Sandy

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


Re: Perl Hacker, Python Initiate

2011-02-01 Thread Carl Banks
On Feb 1, 8:36 pm, Gary Chambers gwch...@gwcmail.com wrote:

 open DIG, $DIGCMD| or die $DIG: $!\n;
 while (DIG) {


 Will someone please provide some insight on how to accomplish that task in
 Python?  I am unable to continually (i.e. it stops after displaying a single
 line) loop through the output while testing for the matches on the two
 regular expressions.  Thank you.

You may have called read() instead of readlines().


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


[issue11075] Turtle crash with IDLE on Mac OS X 10.6

2011-02-01 Thread Alex McNerney

Alex McNerney amcnerne...@yahoo.com added the comment:

Sorry to keep bothering, but running Python 2.7.1:88286 (maintenance) on 
ActiveState Tcl/Tk 8.5.9 causes the idle to hang when a simple script like:

x = raw_input(x: )
print x

is run. Is this a bug in Tcl/Tk? Looking in the logs I see several instances of 
setCanCycle: is deprecated.  Please use setCollectionBehavior instead Does 
this have any relevancy?

Relating to this, I don't know if it is proper to ask here, but is it possible 
to link Python to a specific Tcl/Tk when compiling from the source?

Note: When running Python 2.7.1 (32-bit from installer) with Tcl/Tk 8.4, the 
above problem is not there.

--

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



[issue4735] An error occurred during the installation of assembly

2011-02-01 Thread Mads Darø Kristensen

Mads Darø Kristensen mad...@gmail.com added the comment:

I have this problem using Python 2.7.1 on a 32-bit Windows 7 PC.

--
nosy: +madsdk
versions: +Python 2.7

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



[issue11084] Serialization of decimal.Decimal to XML-RPC

2011-02-01 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

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



[issue11085] expose _abcoll as collections.abc

2011-02-01 Thread Daniel Urban

Changes by Daniel Urban urban.dani...@gmail.com:


--
nosy: +durban

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



[issue8998] add crypto routines to stdlib

2011-02-01 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
nosy: +ncoghlan

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



[issue11075] Using Turtle with IDLE on Mac OS X

2011-02-01 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

Now that I looked at the documentation 
(http://docs.python.org/library/turtle.html), I see that it is clear that 
Turtle is designed to work from IDLE *but*, as is noted, when using the module 
from within IDLE run with the -n switch, which means run IDLE without a 
subprocess.  What may not be so obvious is how to do that on Mac OS X.  
Double-clicking on IDLE.app launches it with default values including a 
subprocess and there is no straightforward to override those.  From a terminal 
shell, it is easy to start bin/idle:

   $ idle2.7 -n

although that has a few cosmetic disadvantages with bin/idle over IDLE.app (for 
example, the application name displayed is Python not IDLE).  It has aways 
been possible to launch an OS X GUI app from a shell command line using the 
open(1) command; as of OS X 10.6 it is now also possible to pass regular 
command line arguments to the application.  So the following would work in 10.6 
and probably be preferable:

   $ open -a /Applications/Python 2.7/IDLE.app --args -n

If you want to have a double-clickable application, a simple approach is to 
create a launcher application with AppleScript:

   $ osacompile -o 'IDLE-n.app' EOF
do shell script open -a '/Applications/Python 2.7/IDLE.app' --args -n
EOF

As someone not used to using Turtle and given the intended user base for 
Turtle, I wonder whether the current Turtle module documentation is sufficient 
on this point.  Two possible actions I could see are: (1) expanding the 
documentation to include a suggestion like the above to allow for an OS X 
clickable app; and/or (2) actually supplying such a simple no-subprocess app 
with the standard python.org installer distribution (or some other solution).  
How is this issue handled on Windows?  Is there a need to expand the 
documentation in general?
(adding Raymond to the nosy list)

--
nosy: +rhettinger
title: Turtle crash with IDLE on Mac OS X 10.6 - Using Turtle with IDLE on Mac 
OS X
versions: +Python 3.2

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



[issue7330] PyUnicode_FromFormat segfault

2011-02-01 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

I opened other tickets related to PyUnicode_FromFormatV:

 * #10833 :Replace %.100s by %s in PyErr_Format(): the arbitrary limit of 500 
bytes is outdated
 * #10831: PyUnicode_FromFormatV() doesn't support %li, %lli, %zi
 * #10830: PyUnicode_FromFormatV(%c) doesn't support non-BMP characters on 
narrow build
 * #10829: PyUnicode_FromFormatV() bugs with % and %% format strings

(see also #10832: Add support of bytes objects in PyBytes_FromFormatV())

PyUnicode_FromFormatV() has now tests in test_unicode: issue_7330.diff should 
add new tests, at least to check that %20R doesn't crash.

--

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



[issue11088] IDLE on OS X with Cocoa Tk 8.5 can hang waiting on input / raw_input

2011-02-01 Thread Ned Deily

New submission from Ned Deily n...@acm.org:

As reported by Alex McNerney in Issue11075 msg127687:

... running Python 2.7.1:88286 (maintenance) [built from source] on 
ActiveState Tcl/Tk 8.5.9 causes the idle to hang when a simple script like:

x = raw_input(x: )
print x

is run. Is this a bug in Tcl/Tk? Looking in the logs I see several instances of 
setCanCycle: is deprecated.  Please use setCollectionBehavior instead Does 
this have any relevancy?

I can reproduce the problem using input with Cocoa Tk 8.5 and Python 3.2rc2 or 
raw_input with Python 2.7.1+.  It does not seem to happen with Carbon Tk 8.4.  
This may be related to Issue10940.  Investigating further for impact on 3.2.

--
assignee: ned.deily
components: IDLE, Macintosh
messages: 127691
nosy: amcnerney13, ned.deily
priority: critical
severity: normal
status: open
title: IDLE on OS X with Cocoa Tk 8.5 can hang waiting on input / raw_input
type: behavior
versions: Python 2.7, Python 3.2

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



[issue11075] Using Turtle with IDLE on Mac OS X

2011-02-01 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

[Please don't add new topics to the same tracker issue.  As David mentioned, it 
would be better to ask for help on one of the user lists to be sure before 
opening an issue.  Besides the general python-list, there is an active OS X 
users list (pythonmac-sig) where you will find users of IDLE;  see 
http://www.python.org/community/sigs/

That said, to address your most recent message, that appears to indeed be a 
problem.  I've opened Issue11088 for it.  The setCanCycle: is deprecated 
messages are a harmless artifact; they should disappear in an upcoming 
maintenance release of ActiveState Tcl 8.5.]

--

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



[issue11022] locale.setlocale() doesn't change I/O codec, os.environ does

2011-02-01 Thread Steffen Daode Nurpmeso

Steffen Daode Nurpmeso sdao...@googlemail.com added the comment:

Most of this is much too loud for a newbie who is about to read PEP 7 anyway.  
And if this community has chosen to try (?!?) not to break compatibility with 
code which does not have a notion of a locale setting (i.e. naively uses other 
code in that spirit), you know, then this is simply the way it is.  Thus: 
you're right.  I do agree with what you say, we here have a (8-bit) C++ library 
which does this in it's setup():

// Initialize those Locale variables we're responsible for
Locale::_ctype_cclass = Locale::_posix_cclass;
Locale::_ctype_ccase = Locale::_posix_ccase;

(Like i said: we here went completely grazy and avoid system libraries whenever 
possible and at least directly, doing the stuff ourselfs and only with 
syscalls.)

Besides that i would agree with me that unthreaded init, optional embeddor 
locale argument, cleanup of .getprefer...() and other drops of setlocale() 
are/would be good design decisions.  And of course: keeping the thing simple 
and understandable is a thing to keep in mind in respect to a normal user.

After the end (i have to excuse myself once again for a book):
I, f.e., opened an issue 11059 on saturday because the HG repo was (2.7 may 
still be) not cloneable, and i did so at selenic, too.  Notes on that:
- pitrou closed it because this tracker is of course for Python bugs.   (I 
asked him to decide - thanks.)
- The selenic people told me that i added my trace to a completely wrong issue. 
 (Just searched - that's more than shown in trace dump.)
- I've found out that many, *many* issues seem to have been created due to this 
repo failure at python.org (at selenic), and i've added a note that they 
possibly should include a prominent notice that people should look for most 
recent call last before creating a new one.  (I guess that most of these 
people are programmers - who else uses HG?)
- Conclusion: maybe even os.environ[]= == locale.setlocale() is not simple 
minded enough.

--

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



[issue11079] Make OS X entry in Applications like that in Windows

2011-02-01 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

I agree that adding a link to the installed documentation set would be an 
improvement.  Currently, the only easy way to find it is within IDLE:  Help - 
Python Docs (or F1).  I'll propose an installer patch for that for 3.2.

-0.5 for removing the Extras directory.  Prior to Python 3.2, it contained the 
contents of the Demo directory.  For 3.2, the Demo directory was pruned and 
relocated to Tools, which had not previously been installed anywhere by OS X 
installers.  Also, there has been at least one request to make some of the 
contents of Tools available on OS X, i.e. unittestgui.  For those reasons, I 
added Tools under Extras for 3.2.  I agree that much of the contents is not 
particularly useful from, say, IDLE.  But the Python Launcher will run them 
under a command line and users can easily drag/drop any of onto a python 
command line in a terminal shell or just cd there and can also use the Finder's 
Get Info to change the application associated with them.  That said, the 
launching of Python scripts in OS X is currently is currently somewhat fragile 
and unintuitive (in the presence of multiple Python versions) and in need of 
some work post-3.2; see, for instance, Issue5262.  Due to OS X's multipl
 e personalities and interaction styles (Classic Mac, command line UNIX, 
X-based apps, etc), it's also difficult to assess exactly how the python.org 
installed Pythons are being used on OS X. My guess, though, is that a majority 
of our users these days primarily or exclusively use Python from a command line 
so it would be good to not neglect their needs.

The issue of uninstalling has come up before, most recently (IIRC) in 
Issue7107.  Unfortunately, the Mac/README file updated there is not installed.  
I would be +0.5 at looking into it further as time permits while recognizing 
that there would need to be caveats like potentially wiping out installed 
system-wide site-packages.

--

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



[issue10227] Improve performance of MemoryView slicing

2011-02-01 Thread Stefan Behnel

Stefan Behnel sco...@users.sourceforge.net added the comment:

I've extracted and fixed the part of this patch that implements the slice 
object cache. In particular, PySlice_Fini() was incorrectly implemented. This 
patch applies cleanly for me against the latest py3k branch.

--
Added file: http://bugs.python.org/file20639/slice-object-cache.patch

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



[issue11075] Using Turtle with IDLE on Mac OS X

2011-02-01 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Ned: I read the bits in the turtle docs about -n as meaning *if* you use -n 
*then* you should set this profile option (but if you don't, things should 
work).  I didn't go over the docs in detail, though, so maybe I'm misreading.  
Since you and I clearly don't know what we are talking about in detail, I'm 
adding Gregor and Alexander (the latter since he's clearly been using it) to 
nosy.

--
assignee: ned.deily - 
nosy: +belopolsky, gregorlingl

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



  1   2   >