Re: "Python" is not a good name, should rename to "Athon"

2007-12-03 Thread Jim Hill
Michael Terry wrote:
>
>Folks admire Newton for some of his breathtaking insights, not because
>of his methods. The scientific method is a tool. 

As was Newton, according to many of his contemporaries.

> The results are far more important than the tool.

Yep.


Jim
-- 
"I loathe people who say, 'I always read the ending of the book first.'
That really irritates me.  It's like someone coming to dinner, just
opening the fridge and eating pudding, while you're standing there still
working on the starter. It's not on."  --  JK Rowling
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python books?

2007-03-14 Thread Jim Hill
wesley chun wrote:

>my book, Core Python Programming, is revised to 2.5, but focuses on
>teaching you the core part of the language, features, objects, memory
>management, development, good practices, some advanced topic coverage,
>and presents lots of exercises.  however, it is not an exhaustive
>guide to the standard library.

Sadly, the centerfolds were 'shopped and had bottle-bleached hair.

Wait, that was a different read.  CPP has been invaluable for me and I'd
recommend it for the OP even though it's not dedicated solely to the
PSL.  OK?


Jim
-- 

 It's not "pretexting", it's "lying."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding, "import site", PYTHONHOME, and an old, old issue

2007-02-12 Thread Jim Hill
Gabriel Genellina wrote:
>En Sat, 10 Feb 2007 03:57:05 -0300, Jim Hill <[EMAIL PROTECTED]> escribió:
>
>> int routine() {
>>   Py_Initialize();
>>   ...
>>   }
>
>(Why routine() and not main()? Unfortunately you can't repeteadly  
>initialize/finalize the interpreter, you must do that only once.)

This is a small routine tucked off to the side of a fairly large
mostly-FORTRAN-with-some-C program.  I need to parse a slash-delimited
input file from a different program and fill up some arrays with the
results.  Rather than wrestle with FORTRAN's wretched file I/O I thought
I'd do it this way.

>Try this:
>PyRun_SimpleString("import sys; print sys.path");
>to see where Python expects to find its library (or call the Py_GetPath  
>function).

It returned a list of paths nearly identical to what the interactive
interpreter does -- it's on a different machine and too long to retype
here -- the interactive sys.path has an empty string as item 0, while
the embedded sys.path returns the interactive[1:n].

>You may need to call Py_SetProgramName (before Py_Initialize) so it can  
>find where the standard library resides.

Didn't do anything, alas.

>At least for testing purposes, you can copy your executable into the same  
>directory where Python is installed.

No can do -- it's not my machine and I don't have appropriate
privileges.  Thanks for trying to help me out but I'm on a crash
deadline and it looks like I'll be doing some C parsing.  Blech.


Jim
-- 

 It's not "pretexting", it's "lying."
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Embedding, "import site", PYTHONHOME, and an old, old issue

2007-02-09 Thread Jim Hill
Jim Hill (that'd be me) wrote:

I forgot one more key thing: the compiled code is being run via mpirun
(LAM/MPI).  Might that have something to do with my pain and heartache?


Jim

(original post reproduced below in shocking breach of etiquette on the
off chance someone's interested in this post and didn't bother reading
the first.)


>Well, I've found about a hundred thousand web pages where people have
>had the same problem I have but nary a page with a solution that works
>for me.
>
>I want to do a simple embed, so I've followed the example in the
>Extending and Embedding documentation:
>
>In the .c file, 
>
>#include 
>
>int routine() {
>  Py_Initialize();
>  PyRun_SimpleString("from time import time,ctime\n"
> "print 'Today is',ctime(time())\n");
>  Py_Finalize();
>  return 0;
>  }
>
>The code compiles just fine, but when I execute it the call to
>Py_Initialize() comes back with:
>
>'import site' failed; use -v for traceback
>Traceback (most recent call last):
>  File "", line 1, in 
>ImportError: No module named time
>
>
>
>I found a lot of websites that say to set PYTHONHOME to the the path to
>the directory where site.py lives.  I did that but I get the same error.
>
>Here are a few bits o' additional information:
>
>'python -v' tells me it was built with gcc 3.4.4 (and has no trouble at
>all finding site.py whether PYTHONHOME is defined or not).  The
>following code snippet:
>
>  >>> import distutils.sysconfig
>  >>> distutils.sysconfig.get_config_var('LINKFORSHARED')
>
>comes back with '-Xlinker -export-dynamic'.
>
>My own code needs to use Portland Group's pgi.  I did some googling for
>various permutations of nouns from the preceding few paragraphs and
>found Pythonic mention of using "-Wl,-export-dynamic" as a flag for the
>PG linker.  OK, try that, builds fine, same error.
>
>I cannot recompile Python on this machine and I don't really understand
>exactly what is happening with the Py_* function calls in the C snippet
>above, or whether I can get more detailed traceback info.  This is the
>first time I've tried embedding and it's rather obvious that I've run
>into a problem that everyone but Messrs. van Rossum and Lundh has hit.
>Somebody, somewhere must have an honest-to-glub solution.  If you are
>that somebody, please let me know what to do because I'm about to throw
>in the towel and embed That Other Language.
>
>Oh, one more thing: if I launch python from the shell and type in the
>strings from the C snippet it works fine.
-- 

 It's not "pretexting", it's "lying."
-- 
http://mail.python.org/mailman/listinfo/python-list


Embedding, "import site", PYTHONHOME, and an old, old issue

2007-02-09 Thread Jim Hill
Well, I've found about a hundred thousand web pages where people have
had the same problem I have but nary a page with a solution that works
for me.

I want to do a simple embed, so I've followed the example in the
Extending and Embedding documentation:

In the .c file, 

#include 

int routine() {
  Py_Initialize();
  PyRun_SimpleString("from time import time,ctime\n"
 "print 'Today is',ctime(time())\n");
  Py_Finalize();
  return 0;
  }

The code compiles just fine, but when I execute it the call to
Py_Initialize() comes back with:

'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named time



I found a lot of websites that say to set PYTHONHOME to the the path to
the directory where site.py lives.  I did that but I get the same error.

Here are a few bits o' additional information:

'python -v' tells me it was built with gcc 3.4.4 (and has no trouble at
all finding site.py whether PYTHONHOME is defined or not).  The
following code snippet:

  >>> import distutils.sysconfig
  >>> distutils.sysconfig.get_config_var('LINKFORSHARED')

comes back with '-Xlinker -export-dynamic'.

My own code needs to use Portland Group's pgi.  I did some googling for
various permutations of nouns from the preceding few paragraphs and
found Pythonic mention of using "-Wl,-export-dynamic" as a flag for the
PG linker.  OK, try that, builds fine, same error.

I cannot recompile Python on this machine and I don't really understand
exactly what is happening with the Py_* function calls in the C snippet
above, or whether I can get more detailed traceback info.  This is the
first time I've tried embedding and it's rather obvious that I've run
into a problem that everyone but Messrs. van Rossum and Lundh has hit.
Somebody, somewhere must have an honest-to-glub solution.  If you are
that somebody, please let me know what to do because I'm about to throw
in the towel and embed That Other Language.

Oh, one more thing: if I launch python from the shell and type in the
strings from the C snippet it works fine.

Thanks,


Jim
-- 

 It's not "pretexting", it's "lying."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Easy "here documents" ??

2004-12-22 Thread Jim Hill
Fredrik Lundh wrote:
>Jim Hill wrote:
>
>> I'm trying to write a script that writes a script for a rather specialized
>> task.  I know that seems weird, but the original version was written in
>> Korn shell and most of my team are familiar with the way it does things
>> even though they don't read Korn.
>
>so why didn't you tell us? ;-)

I was afraid there'd be mockery involved and not originating on my end.


Jim, delicately sensitive to mockery despite burly masculinity
-- 
"I regard NASCAR the same way I regard gay porn: I know it exists and I
know some guys like it; I just don't want to see it."  --  Z. B. Goode
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
John Roth wrote:

[Here docs]
>I'm not sure why you'd want to do this, though.
>It seems like it would be mostly useful in a style
>of programming that's quite foreign to the way
>Python wants to be programmed.

I'm going to try some of the suggestions that others have floated but I
think you've really tumbled to the core of my situation: Trying to take
a Korn shell script and convert it as closely to line-for-line into
Python as possible is Just Dumb.


Jim
-- 
"I regard NASCAR the same way I regard gay porn: I know it exists and I
know some guys like it; I just don't want to see it."  --  Z. B. Goode
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
Keith Dart  wrote:
>Jim Hill wrote:
>> Is there a way to produce a very long multiline string of output with
>> variables' values inserted without having to resort to this wacky
>
>I was thinking about this. But I can't think of any reason why you would 
>want to do this in Python. What's wrong with a regular parameterized 
>function?

I'm trying to write a script that writes a script for a rather specialized 
task.  I know that seems weird, but the original version was written in
Korn shell and most of my team are familiar with the way it does things
even though they don't read Korn.  (The original author has since
decamped for greener pastures.)  Since we're trying to standardize all
our scripts on Python I got the task of rewriting.  Once I have the
simple port done I'll see if I can't figure out A Better Way.


Jim
-- 
"I regard NASCAR the same way I regard gay porn: I know it exists and I
know some guys like it; I just don't want to see it."  --  Z. B. Goode
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
Fredrik Lundh wrote:
>Scott David Daniels wrote:
>
>> And if you enjoy building insecure stuff, try:
>>
>> def fix(text, globals_=None, locals=None, quote='"'):
>> d = (globals_ or locals or globals()).copy()
>> source = text.split(quote)
>> source[1::2] = (str(eval(expr, d, locals or d))
>> for expr in source[1::2])
>> return ''.join(source)
>>
>And if you prefer not to type so much:
>
>def I(*args): return "".join(map(str, args))
>def F(v, fmt): return ("%" + fmt) % v

Not that I don't appreciate the suggestions from masters of the Python
universe, but the reason I'm switching to Python from Perl is for the
readability.  What you fells are suggesting might as well be riddled
with dollar signs and semicolons...  .


Jim
-- 
"I regard NASCAR the same way I regard gay porn: I know it exists and I
know some guys like it; I just don't want to see it."  --  Z. B. Goode
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
Nick Craig-Wood  wrote:

>Jim Hill <[EMAIL PROTECTED]> wrote:
>>  Is there a way to produce a very long multiline string of output with
>>  variables' values inserted without having to resort to this wacky
>>  """v = %s"""%(variable)

>I prefer this
>
>   ... I'll have %(amount)s %(what)s
>   ... for $%(cost)s please""" % locals()

Looks pretty slick.  This might just be what I need.

>Its almost as neat as perl / shell here documents and emacs parses """
>strings properly too ;-)

Mmm...emacs...

Thanks for the tip.


Jim
-- 
"I regard NASCAR the same way I regard gay porn: I know it exists and I
know some guys like it; I just don't want to see it."  --  Z. B. Goode
-- 
http://mail.python.org/mailman/listinfo/python-list


Easy "here documents" ??

2004-12-18 Thread Jim Hill
I've done some Googling around on this and it seems like creating a here
document is a bit tricky with Python.  Trivial via triple-quoted strings
if there's no need for variable interpolation but requiring a long, long
formatted arglist via (%s,%s,%s,ad infinitum) if there is.  So my
question is:

Is there a way to produce a very long multiline string of output with
variables' values inserted without having to resort to this wacky

"""v = %s"""%(variable)

business?

Thanks,


Jim, Python no0b
-- 
"I regard NASCAR the same way I regard gay porn: I know it exists and I
know some guys like it; I just don't want to see it."  --  Z. B. Goode
-- 
http://mail.python.org/mailman/listinfo/python-list