Re: python3: help with subprocess

2010-07-14 Thread Ben Kaplan
On Jul 14, 2010, at 8:38 AM, Alan wrote: > Hi there, > > Module commands is gone in python3, so I am trying subprocess. So please I > would appreciate if someone can tell me how to do this better: > > before I had: > > cmd = 'uname -a' > out = commands.getoutput(cmd) > > 'Darwin amadeus.loca

RE: Python profiler usage with objects

2010-06-29 Thread Ben Kaplan
> -Original Message- > From: python-list-bounces+bsk16=case@python.org [mailto:python-list- > bounces+bsk16=case@python.org] On Behalf Of rik > Sent: Tuesday, June 29, 2010 10:52 PM > To: python-list@python.org > Subject: Re: Python profiler usage with objects > > harit gmail.co

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Ben Kaplan
On 1/6/10 10:12 AM, Phlip wrote: On Jan 5, 10:54 pm, Benjamin Kaplan wrote: {41: None}[41] ? In cases where None is a valid result, you can't use it to signal failure. Asked and answered. You change the "sentinel" in .fetch to something else. When did I specify a sentinel value

Re: AttributeError: 'module' object has no attribute 'pack'

2009-09-10 Thread Ben Kaplan
On Sep 10, 2009, at 4:21 PM, Sampsa Riikonen wrote: Hello, I already solved this.. I had to set PYTHONPATH= After that the error msg disappeared. Weird though.. I don't have any module called "subprocess" in my personal python modules directory. Anyway, thanks for the swift reply! Reg

Re: Question to python C API

2009-04-16 Thread Ben Kaplan
On Apr 16, 2009, at 1:53 AM, Andreas Otto wrote: Hi, I want to make a language binding for an existing C library http://libmsgque.sourceforge.net is this possible ? -- Not only is itpossible, it's pretty common. All of the major GUI toolkits do this. Look at www.swig.org if

Re: Framework installation of 2.6 on OS X, with specified prefix

2009-02-20 Thread Ben Kaplan
On Feb 20, 2009, at 9:30 AM, Evert Rol wrote: Hi, I'm trying to install Python 2.6 from source on Mac OS X.5, in its own directory using a framework install. That goes fine, up to the point where it wants to install the applications that come with it (eg, the Wish shell): it tries to

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Ben Kaplan
On Jan 14, 2009, at 9:44 AM, "Gary M. Josack" wrote: garywood wrote: def ask_ok(prompt, retries=4, complaint="Yes or no, please!"): while True: password = input("enter something") if password in ('y', 'ye', 'yes'): return True if password in ('n', 'no', 'nope'): retur

Re: Python's popularity

2008-12-22 Thread Ben Kaplan
On Dec 22, 2008, at 9:51 PM, r wrote: On Dec 22, 7:34 pm, Steven D'Aprano wrote: On Mon, 22 Dec 2008 10:01:21 -0800, r wrote: Walter, I just look at the stats for comp.lang.python, and i am 9th place for most post this month. And about 9,000th place for useful information. -- Steven

Re: Guido's new method definition idea

2008-12-08 Thread Ben Kaplan
On Dec 8, 2008, at 11:59 AM, [EMAIL PROTECTED] wrote: On Dec 6, 4:15 pm, Carl Banks <[EMAIL PROTECTED]> wrote: On Dec 6, 12:47 am, "Patrick Mullen" <[EMAIL PROTECTED]> wrote: Could I do something like this: def a.add(b): return a+b Outside of a class? Of course then that makes you thi

Re: Calling C# COM (.NET) from python

2008-12-08 Thread Ben Kaplan
On Dec 8, 2008, at 11:53 AM, Andrew Falanga <[EMAIL PROTECTED]> wrote: Hi, I've never programmed in python and only have a small understanding of what is wrapped up in the terms COM and .NET. Is there a way of using python to get a hold of objects written in C# as COM objects using python?

Re: Installed python 2.5 over 2.4 and lost installed packages

2008-04-27 Thread Ben Kaplan
I don't know what the best practice is, but just creating sym links into site-packages will work, and it saves the extra memory from cp'ing. - Original Message From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: python-list@python.org Sent: Sunday, April 27, 2008 9:15:06 AM Subject: Insta

Re: NameError: global name 'Response' is not defined

2008-04-24 Thread Ben Kaplan
Are you importing pylons? How are you doing it? If you are doing "from pylons import Response" or "from pylons import *", then you have another problem. If you are just doing "import pylons", then you need to do "return pylons.Response(...)" - Original Message From: Lalit <[EMAIL PROTE

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-23 Thread Ben Kaplan
I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. You might be able to use that to ensure that the terminal is installed, but you should probably look at a couple of other popular distros first to

Re: Importing My Own Script

2008-04-17 Thread Ben Kaplan
It might be something in mod python. Try asking on their mailing list. - Original Message From: Victor Subervi <[EMAIL PROTECTED]> To: Ben Kaplan <[EMAIL PROTECTED]> Cc: python-list@python.org Sent: Thursday, April 17, 2008 10:47:34 AM Subject: Re: Importing My Own Script On

Re: Importing My Own Script

2008-04-17 Thread Ben Kaplan
If x and y are in the same directory, just do "import x". If not, add the directory containing x to sys.path. Then, "import x" should work. - Original Message From: Victor Subervi <[EMAIL PROTECTED]> To: python-list@python.org Sent: Thursday, April 17, 2008 9:45:10 AM Subject: Importing M

Re: Calling Java Class from python

2008-04-17 Thread Ben Kaplan
If you need to explicitly call a method and get the results, AFAIK, the only way to do it is to use Jython, a version of Python written in java. If you can do everything you need from the command line, then you can just use subprocess.Popen to run it. Here is the article on how to run java files

Re: Logical Operator and code block not executing (newbie question)

2008-04-16 Thread Ben Kaplan
The problem is that your loop says "while guess != number". When guess is equal to the number, the code in the loop is not executed. Instead, do something like while guess != number and tries < total_attempts: if guess > number: ... elif guess < number: ... if guess == number :

Re: Java or C++?

2008-04-15 Thread Ben Kaplan
The fact that C# is a .NET language is also a major weakness, since you can only use it on Windows. - Original Message From: Michael Torrie <[EMAIL PROTECTED]> To: python-list@python.org Sent: Tuesday, April 15, 2008 1:19:31 PM Subject: Re: Java or C++? egbert wrote: > What is the role

Re: Module to read input from commandline

2008-04-13 Thread Ben Kaplan
Unless I misunderstand your needs, you could just use raw_input(prompt) to get your answers. - Original Message From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: python-list@python.org Sent: Sunday, April 13, 2008 11:12:06 AM Subject: Module to read input from commandline Hi all, I di

Re: How is GUI programming in Python?

2008-04-09 Thread Ben Kaplan
The pain level all depends on how you go about it. If you try to builda GUI from scratch, it will be very painful. If you use a toolkit, thenit's pretty close to working with Swing. WxPython is the only one I've used, so Ican't give you a "best one". I can say that going from Swing to wxPython w

TypeError with weakrefs

2008-04-01 Thread Ben Kaplan
I'm working with weakrefs, and I keep getting a type error The exact line I am getting is Exception exceptions.TypeError: '__call__() takes exactly 0 arguments (1 given)' in ignored The strange part is that I am not trying to call anything. From debugging, I found out that the message is pr