Running Python interpreter in Emacs

2005-06-23 Thread Rex Eastbourne
Hi,

I'm interested in running a Python interpreter in Emacs. I have Python
extensions for Emacs, and my python menu lists "C-c !" as the command
to run the interpreter. Yet when I run it I get the message "Spawning
Child Process: invalid argument." What do I need to do/download to fix
this?

I read in a post in this group from a while back where someone had the
following lines in his .emacs file:

 (setq interpreter-mode-alist
(cons '("python" . python-mode)
  interpreter-mode-alist))

Does that have something to do with it? Do I have to set my load-path
to my python interpreter?

Thanks, 

Rex

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


Re: Running Python interpreter in Emacs

2005-06-23 Thread Rex Eastbourne
Hi Skip and Philippe. I added the path for Python to PATH, but I still
get the same message (when I try executing the current buffer, I get
the message: "The system cannot find the path specified."

Philippe, I have the above lines of code in my .emacs file.

As for my environment, I'm running Emacs 21.4 on Windows XP.

Thanks a lot!

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


Re: Running Python interpreter in Emacs

2005-06-24 Thread Rex Eastbourne
I have the following in my .emacs:

(add-to-list 'load-path "C:\Program Files\Python24")

Is that enough? I didn't see anything similar to that in your .emacs
file, so I'm wondering if I'm supposed to add the path to my PATH
elsewhere.

Thanks,

Rex

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


Re: Running Python interpreter in Emacs

2005-06-26 Thread Rex Eastbourne
I went to My Computer | Properties | Advanced | Environment Variables
and added c:\program files\python24 to both the PYTHONPATH and Path
variables. Still no luck. I don't know whether the path I'm talking
about is the same as the $PATH you referred to, or whether I'm supposed
to put python.exe explicitly somewhere; could someone refer me to a
place where I can read about these things?

Thanks!

Rex

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


Debugger Confusion

2005-06-28 Thread Rex Eastbourne
I'm a little confused about which debugging utilities do what, and
which I should use for my Python code. I'd like to be able to step
through my code, insert breakpoints, etc. I haven't been able to do
this yet (I'm using Emacs on Windows). I have seen references to GDB,
GUD, PDB, and others. Which ones do I need?

Thanks,

Rex Eastbourne

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


Re: Debugger Confusion

2005-06-29 Thread Rex Eastbourne
Thanks!

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


Re: Debugger Confusion

2005-06-29 Thread Rex Eastbourne
One thing: is it possible to go through the code within emacs? Doing it
on the command line is useful, but it would be very helpful if I could
have a little marker within the emacs buffer that showed me where I am.

Rex

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


Re: Debugger Confusion

2005-06-29 Thread Rex Eastbourne
Also, when I try running pdb in my Emacs shell, I get very weird
behavior: for instance, I'll hit 'h' and enter twenty times with no
output. Then, all of a sudden, twenty output messages will pop up.

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


Re: Running Python interpreter in Emacs

2005-07-01 Thread Rex Eastbourne
Yes! Thank you so much! (For some reason, by the way, I had to copy
python.exe to my c:/ directory, since the computer could never find the
path in program files/python24. But when I did that, and used
setq-py-python-command, it worked. I now have python.exe in two
locations.)

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


Re: Running Python interpreter in Emacs

2005-07-02 Thread Rex Eastbourne
Yes, I knew that copying it to my root was a kludge. But between that
and not having it work, I chose the former. (As you might be able to
tell from my posts, I tried multiple things and was frustrated.) I
tried putting quotes around "c:\program files\python24". It still
didn't work.

I chose to install Python in Program Files. I didn't know it would
cause any problems; I just thought it was good to have all my programs
in the same place. I guess I was wrong.

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


Printing literal text of an argument

2005-08-11 Thread Rex Eastbourne
Hi all,

I've written the following simple macro called debug(aname, avalue)
that prints out the name of an expression and its value:

def debug(aname, avalue):
print aname, 'is':
pprint.pprint(avalue)

An example call is:

debug('compose(f1,f2)', compose(f1,f2))

Writing the exact same thing twice (one in quotes and the other not)
sets off an alarm in my head. Is there a way to make this function take
only one argument, and use both its value and its literal form? On a
slightly different topic, is it also possible to make the macro print
the line number where the function was first called?

Thanks,

Rex

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


Re: Printing literal text of an argument

2005-08-11 Thread Rex Eastbourne
Thanks. I adapted it a bit:

def debug(foo):
print foo, 'is:'
exec('pprint.pprint(' + foo + ')')

But I'm getting "NameError: name 'foo' is not defined," since foo is
not defined in this scope. (The function works beautifully when I'm
dealing with global variables, which is very rarely).

Any way around this?

Rex

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


Bicycle Repair Man usability

2005-08-30 Thread Rex Eastbourne
Are there any Bicycle Repair Man users here? I recently got PyDev for
Eclipse, which comes with BRM. I am disappointed with what I've seen,
although I'm not sure if I'm using its full functionality. According to
PyDev's documentation, this is what one can do:

-Rename a function/variable
-Block of code --> method and a method call
-Get rid of extra variables by shifting them inline (e.g.:
a=1;b=2;c=a+b --> c=1+2)

I'm not aware of anything else that can be done, as BRM's documentation
is extremely thin. Is anyone else aware of other uses?

It's a shame this project is not active; it seems like such a great
idea.

Rex

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


Bicycle Repair Man usability

2005-08-30 Thread Rex Eastbourne
Are there any Bicycle Repair Man users here? I recently got PyDev for
Eclipse, which comes with BRM. I am disappointed with what I've seen,
although I'm not sure if I'm using its full functionality. According to
PyDev's documentation, this is what one can do:

-Rename a function/variable
-Block of code --> method and a method call
-Get rid of extra variables by shifting them inline (e.g.:
a=1;b=2;c=a+b --> c=1+2)

I'm not aware of anything else that can be done, as BRM's documentation
is extremely thin. Is anyone else aware of other uses?

It's a shame this project is not active; it seems like such a great
idea.

Rex

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


Mysterious EOFError

2006-04-08 Thread Rex Eastbourne
Hi,

I'm executing a python script as a cron job. When I run it myself from
the command line it works, but when cron executes it I get an EOFError:

File "/home/rex/cronscript.py", line 6, in ?
level = int(raw_input("hello?"))
EOFError: EOF when reading a line

It's not the last line of the file.

When I run it as root from the command line I don't get any errors.

Any ideas?

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


Re: Mysterious EOFError

2006-04-09 Thread Rex Eastbourne
Thanks. Do you know of a solution to this? I tried the following, which
I found on this newsgroup:

#

lines = open(sys.argv[1]).readlines()

#

sys.stdin = open('/dev/tty')
a = raw_input('Prompt: ')

#

sys.stdin = os.fdopen(3)
a = raw_input('Prompt: ')

#

What I want to do is execute a scheduled task that prompts me for
something and allows me to enter it and have it stored somewhere. I'm
on Ubuntu Linux.

Thanks in advance!

Steven D'Aprano wrote:
> On Sat, 08 Apr 2006 23:07:54 -0700, Rex Eastbourne wrote:
>
> > Hi,
> >
> > I'm executing a python script as a cron job. When I run it myself from
> > the command line it works, but when cron executes it I get an EOFError:
> >
> > File "/home/rex/cronscript.py", line 6, in ?
> > level = int(raw_input("hello?"))
> > EOFError: EOF when reading a line
>
>
> Because raw_input is waiting for input from the user. I assume that when
> cron runs a Python script, and there is no actual human user to enter a
> string in response to raw_input, it raises a EOF error.
>
> Written in the docs:
>
> http://docs.python.org/lib/module-exceptions.html
>
>
> exception EOFError
> Raised when one of the built-in functions (input() or raw_input())
> hits an end-of-file condition (EOF) without reading any data. (N.B.:
> the read() and readline() methods of file objects return an empty
> string when they hit EOF.)
> 
> 
> -- 
> Steven.

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