Opening an editor for interactive use

2006-06-16 Thread Webb
Hi all,

(I am sure there is a recipe somewhere, but I can't find it.)  How does
one open an editor while in the middle of an interactive program, let
the user do some editing and closing, and then capture the text that
was edited?  I am reminded of subversion or CVS when they open an
$EDITOR session for the check-in log entry.

I tried os.popen, but it fired off vim in the background--not useful.
Then I tried os.system, but that only returns the return code (126 in
my case) after you close the editor.  Perhaps I need to write to a file
and read it--shouldn't there be a cleaner way?

Thanks
W

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


git_revision issues with scipy/numpy/matplotlib

2012-07-06 Thread Stephen Webb
I installed py27-numpy / scipy / matplotlib using macports, and it ran without 
failing.

When I run Python I get the following error:

$>> which python

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

$>> python

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py",
 line 128, in 
from version import git_revision as __git_revision__
ImportError: cannot import name git_revision

I get the same error for all three packages. Is this a MacPorts issue or a 
different issue?

I am running OS X 10.6 with the Intel Core i5 architecture. At one point I 
thought this was a 64-bit versus 32-bit issue, viz.:

>>> import platform
>>> platform.architecture()
('64bit', '')

but I would have thought the MacPorts install would have resolved that.

Any help would be appreciated.

Thanks!

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


Re: git_revision issues with scipy/numpy/matplotlib

2012-07-07 Thread Stephen Webb
I think the easiest thing to do would be to remove the python.org Python 
entirely, kill it from the path (which I've already done), and install directly 
a MacPorts version of Python.

Any caveats or warnings about getting rid of the /Library/Frameworks/Python 
directory?

On Jul 7, 2012, at Jul 7 8:40 AM, Hans Mulder wrote:

> On 7/07/12 14:09:56, Ousmane Wilane wrote:
>>> "H" == Hans Mulder  writes:
>> 
>>H> Or you can explicitly type the full path of the python you want.
>> 
>>H> Or you can define aliases, for example:
>> 
>>H> alias apple_python=/usr/bin/python alias
>>H> macport_python=/opt/local/bin/python
>> 
>>H> lfpv=/Library/Frameworks/Python.framework/Versions alias
>>H> python_org_python=$lfpv/2.7/bin/python
>> 
>> 
>> Or alternatively use `port select --set' to make one of the MacPort version 
>> the
>> default:
>> 
>> imac:~ wilane$ port select --list python
>> Available versions for python:
>>  none
>>  python25-apple
>>  python26
>>  python26-apple
>>  python27 (active)
>>  python27-apple
>>  python32
> 
> That would work if the OP had /opt/local/bin early in his searcht path.
> However, the OP has installed Python27 from python.org, and that has
> prepended /Library/Frameworks/Python.framework/Versions/2.7/bin to
> his PATH, overriding anything he does with "port select".
> 
> He could, of course, change his PATH and move /opt/local/bin to the
> front and then use "port select".
> 
> -- HansM
> -- 
> http://mail.python.org/mailman/listinfo/python-list

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


Re: Academic citation of Python

2012-06-16 Thread Rich Webb
On Sat, 16 Jun 2012 14:01:12 +0100, Mark Lawrence
 wrote:

>On 16/06/2012 04:24, Mark Livingstone wrote:
>> Hello!
>>
>> I wish to properly cite Python in an academic paper I am writing.
>>
>> Is there a preferred document etc to cite?
>>
>> Thanks in advance,
>>
>> MArkL
>
>The main website www.python.org and possibly the sites for Jython, 
>IronPython and PyPY?

He's probably looking for an IEC or ANSI standard, like "Information
technology — Programming languages — C  INCITS/ISO/IEC 9899-2011[2012]
(ISO/IEC 9899-2011, IDT)". I don't think URLs qualify as standards
documents.

-- 
Rich Webb Norfolk, VA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BUSTED!!! 100% VIDEO EVIDENCE that WTC7 was controlled demolition!! NEW FOOTAGE!!! Ask yourself WHY havn't I seen this footage before?

2007-05-03 Thread Peter Webb
> Ask yourself WHY havn't I seen this footage before?
> 
> 

OK, why haven't you seen this footage before?


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


Strange set of errors

2007-08-03 Thread Stephen Webb
Greetings all,

I've recently begun using Python to do scientific computation, and I wrote
the following script to find approximate eigenvalues for a semi-infinite
matrix:


from pylab import *
from numpy import *
from scipy import *

def bandstructure(N,s):

b = s/4.0

jmax = 10 + N**2

spectrum1 = [0]*2*N
spectrum2 = [0]*2*N
spectrum3 = [0]*2*N


for k in arange(1, 2*N+1, 1):

A = zeros( (jmax,jmax) )

i = 0
while i <= jmax-1:
if i <= jmax-2:
A[i,i+1] = b
A[i+1,i] = b
A[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1
else:
A[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1

#This portion of the code builds a matrix twice as large to check
against

B = zeros( (2*jmax,2*jmax) )

i = 0
while i <= 2*jmax-1:
if i <= 2*jmax-2:
B[i,i+1] = b
B[i+1,i] = b
B[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1
else:
B[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1

x = linalg.eigvals(A)
y = linalg.eigvals(B)

j = 1
while j<=3:
if abs(y[j]-x[j]) <= 10.0**(-5):
j = j + 1
else:
print 'jmax not large enough to obtain accurate results'

spectrum1[k-1] = x[0] + 0.5*s
spectrum2[k-1] = x[1] + 0.5*s
spectrum3[k-1] = x[2] + 0.5*s

plot (k, spectrum1, k, spectrum2, k, spectrum3)

xlabel('k (energy level)')
ylabel('E/E_r')
title('Finite Size Band Structure, N = %d, s = %f' % (N, s))
grid(true)


When I run this script, I get the following message, which I can't figure
out:

Traceback (most recent call last):
  File "", line 1, in 
  File "bandstruc.py", line 61, in bandstructure
plot (k, spectrum1, k, spectrum2, k, spectrum3)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pylab.py",
line 2028, in plot
ret =  gca().plot(*args, **kwargs)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 2535, in plot
for line in self._get_lines(*args, **kwargs):
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 437, in _grab_next_args
for seg in self._plot_2_args(remaining[:2], **kwargs):
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 337, in _plot_2_args
x, y, multicol = self._xy_from_xy(x, y)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 266, in _xy_from_xy
nrx, ncx = x.shape
ValueError: need more than 0 values to unpack

Also, I've been having trouble with the plot function in matplotlib. For
example, I enter the following in the terminal:

>>> from pylab import *
>>> plot([1,2,3])
[]

I'm reasonably sure that the issue in the first big error message is just an
indexing error on my part, but I have no idea what the second thing means.
Every time I run the plot([1,2,3]) I get a different ending number that
seems to vary randomly.

Could anybody please help me out with these problems?

Thanks,

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

Re: what is the difference between st_ctime and st_mtime one is the time of last change and the other is the time of last modification, but i can not understand what is the difference between 'change'

2012-09-28 Thread Kristen J. Webb

The Windows stat() call treats things differently,

FROM: http://msdn.microsoft.com/en-us/library/14h5k7ff%28v=vs.80%29.aspx

 st_ctime

Time of creation of file. Valid on NTFS but not on FAT formatted disk 
drives.

I don't think that Windows has a concept of a "change time" for meta data
(though that would be nice).  How's that for compatibility ;)

NOTE: I am a C programmer and new to python, so can anyone comment
on what the st_ctime value is when os.stat() is called on Windows?

Kris
On 9/28/12 9:25 AM, Chris Angelico wrote:

On Sat, Sep 29, 2012 at 1:18 AM, Christian Heimes  wrote:

Am 28.09.2012 17:07, schrieb Chris Angelico:
In the future please read the manual before replying! ;) You are wrong,
ctime is *not* the creation time. It's the change time of the inode.
It's updated whenever the inode is modified, e.g. metadata modifications
like permission changes, link/unlink of hard links etc.


Whoops, my bad! Sorry. I was remembering some other APIs with similar
terminology.

Lesson: Check the docs, they're more reliable.

ChrisA



--
This message is NOT encrypted
----
Mr. Kristen J. Webb
Chief Technology Officer
Teradactyl LLC.
2301 Yale Blvd. SE.
Suite C7
Albuquerque, NM 87106
Phone: 1-505-338-6000
Email: kw...@teradactyl.com
Web: http://www.teradactyl.com

Home of the

 True incremental Backup System

NOTICE TO RECIPIENTS: Any information contained in or attached to this message 
is intended solely for the use of the intended recipient(s). If you are not the 
intended recipient of this transmittal, you are hereby notified that you 
received this transmittal in error, and we request that you please delete and 
destroy all copies and attachments in your possession, notify the sender that 
you have received this communication in error, and note that any review or 
dissemination of, or the taking of any action in reliance on, this communication 
is expressly prohibited.



Regular internet e-mail transmission cannot be guaranteed to be secure or 
error-free. Therefore, we do not represent that this information is complete or 
accurate, and it should not be relied upon as such. If you prefer to communicate 
with Teradactyl LLC. using secure (i.e., encrypted and/or digitally signed) 
e-mail transmission, please notify the sender. Otherwise, you will be deemed to 
have consented to communicate with Teradactyl via regular internet e-mail 
transmission. Please note that Teradactyl reserves the right to intercept, 
monitor, and retain all e-mail messages (including secure e-mail messages) sent 
to or from its systems as permitted by applicable law.




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


Re: Aggressive language on python-list

2012-10-16 Thread Kristen J. Webb
 a forum faster than
trolls and dicks feeding off each other, until there is nothing left but
trolls and dicks. A single troll doesn't do much harm -- few of them have
the energy to spam a news group for long periods, drowning out useful
posts.



But even if you had a more rational response


*raises eyebrow*


and saved that reaction for
actual trolling and not someone who simply disagreed with you, I ask
again, what makes you think your response will change that troll's
behavior, when in actuality, your kind of response is exactly what most
trolls hope to elicit?  Did it help in the case I mentioned?


As I said, I do not believe that Dwight Hutto is a troll. I believe he is
merely badly behaved. And yes, I do believe that confronting him has
changed his behaviour, at least for now.

Not immediately, of course. His immediate response was to retaliate and
defend himself. Naturally -- very few people are self-honest enough to
admit, even to themselves, when they are behaving badly.

But in the intervening weeks, we, this community, has done anything but
ignore him. We're still talking about him *right now*. We're just not
necessarily talking *to* him. And the few times that people do respond
directly to Dwight, they make it very clear that their response is
guarded and on sufferance.

And there have been no further outbursts from Dwight, at least not so
far. So, yes, I think we've gotten the message across.



How will others know that I do not agree with your advice?


Why is it so important to you that I and others know what you think?
Since you are (usually) a reasonable person I don't need to read your
explicit pronouncement to assume that you disagree with some repugnant
post.


You are assuming we all agree on what is repugnant. That pretty much
demonstrates that you have missed my point. Without drawing explicit
boundaries, how do people know what we consider beyond the boundary of
acceptable behaviour?

The people in this forum come from all over the world. We're not all
white, middle-class[2], Australian, educated, progressive/liberals like
me. We're black, Chinese, German, conservative, Muslim, Christian,
atheist, socialist, anarchist, fascist, etc. We come from all sorts of
cultures, where families are run like democracies, or where they are run
like dictatorships where the father is the head of the household even of
his adult children; cultures that consider euthanasia beyond the pale and
those that believe that there are fates worse than death; cultures where
smacking children is an abomination and cultures where it is simply
common sense; cultures that condone honour-killings and those that don't;
cultures where blowing yourself up to kill the enemy is thought to be an
act of bravery, and cultures where pushing a button to kill strangers a
thousand miles away is thought to be an honourable act of military
service.

What on earth makes you think we would possibly agree on what posts are
repugnant without talking about it?

I'm sure that there are some people here -- and you might be one of them
-- that consider my use of the word "dick" unacceptable. And others who
consider dick a mild word and far less offensive than the euphemisms
others might prefer.

Your opinion that we should all, somehow, agree on acceptable behaviour
is culturally self-centred and rather naive. I'm far more offended by
Dwight's habit of posting incoherently while pissed[3] than I am by his
possibly-or-possibly-not racist punning. But I don't expect everyone to
agree with me.




[1] However, we can both be wrong. There's no reason to think that there
is *any* strategy to respond to bad behaviour that will work all the
time, against all people.

[2] Nearly everybody thinks they're middle-class, except the filthy rich
and the filthy poor.

[3] I don't give a damn what mind-altering chemicals Dwight wishes to
indulge in, so long as he does it in private.


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


Bravo!...Encore, Encore!!!




--
This message is NOT encrypted

Mr. Kristen J. Webb
Chief Technology Officer
Teradactyl LLC.
2301 Yale Blvd. SE.
Suite C7
Albuquerque, NM 87106
Phone: 1-505-338-6000
Email: kw...@teradactyl.com
Web: http://www.teradactyl.com

Home of the

 True incremental Backup System

NOTICE TO RECIPIENTS: Any information contained in or attached to this message 
is intended solely for the use of the intended recipient(s). If you are not the 
intended recipient of this transmittal, you are hereby notified that you 
received this transmittal in error, and we request that you please delete and 
destroy all copies and attachments in your possession, notify the sender that 
you have received this communication in error, and note that any review or 
dissemination of, or the taking of any action in reliance on, this communication 
is 

shipping python

2011-10-11 Thread Kristen J. Webb

I am new to python coming from the C/shell side.
We have been experimenting with some code
samples and now I'm looking at some command line
argument processing.  I find

getopt older
optparse new in 2.3
argparse new in 2.7

I search around on some of my client systems and
find lots of people in the 2.4 - 2.6 range.

After some more digging I see that I can
easy_install argparse on my development system.

My question is will I be able to ship this
to a customer?  Can I create .pyc files so
that the customer does not have to install the argparse
module?

If not, and I want to go back into the 2.3+ range,
should I just use optparse?

I guess what I am asking here is are there any
guidelines/recommendations for shipping python
programs to customers?

Thanks in advance,
Kris
--
Mr. Kristen J. Webb
Teradactyl LLC.

PHONE: 1-505-242-1091
EMAIL: kw...@teradactyl.com
VISIT: http://www.teradactyl.com

Home of the

 True incremental Backup System
--
http://mail.python.org/mailman/listinfo/python-list


Re: shipping python

2011-10-12 Thread Kristen J. Webb

I tried experimenting with .pyc files only to end up at:

RuntimeError: Bad magic number in .pyc file

can't run 2.5 pyc files on 2.6 :(

My main motivation to use .pyc is to keep end users from changing scripts,
breaking things, and then calling us.  Tamper proofing may be an
alternative approach if anyone has suggestions.

Otherwise, trying to summarize my goals:

1. Distribute python (and other stuff) across many platforms
(Linux, UNIXes, OSX, Windows)

2. Support the current 2.X version of python installed on the system

3. Take advantage of python modules that use shared OS libraries
(e.g. libssl.so.whatever)

4. For linux especially, support many distributions/versions
(getting openssl to work right, for example, is a tricky problem)

5. Take advantage of the latest python modules whenever possible
(hence the argparse testing).  I realize that I may be able
to go back so far for this to make sense...

6. Provide additional product functionality through our own
shared libraries (c code).

I'm assuming that the customer system has python 2.X installed, otherwise they
can use their favorite OS method to get it in the standard way.

Looking at methods that try to package and run without python installed at
all do not look appealing, anywhere from does it work, to export issues,
to needing a C compiler on the client system.

Shipping .py files and support for modules like argparse for
backward compatibility is what I've come up with so far.
Then they have everything I need to create and install a .pyc file.
(The can modify the installer .py files, but I expect this to be
less of an issue and may be able to make my own simple tamper detecting
for this).

Can anyone suggest better strategies, or point out where this just won't work?

Is distutils a good starting point?

Many thanks!

Kris

On 10/11/11 7:31 PM, Steven D'Aprano wrote:

On Tue, 11 Oct 2011 17:04:45 -0600, Kristen J. Webb wrote:


After some more digging I see that I can easy_install argparse on my
development system.

My question is will I be able to ship this to a customer?  Can I create
.pyc files so that the customer does not have to install the argparse
module?


Yes, and yes. The licence of argparse is a very liberal licence, so you
can just include it in your application. There's no need for the user to
install it separately.

You could include just the .pyc file if you insist, but I personally
don't like or recommend .pyc only installations.



If not, and I want to go back into the 2.3+ range, should I just use
optparse?


That depends on how complex your command line arguments are.




--
Mr. Kristen J. Webb
Teradactyl LLC.

PHONE: 1-505-242-1091
EMAIL: kw...@teradactyl.com
VISIT: http://www.teradactyl.com

Home of the

 True incremental Backup System
--
http://mail.python.org/mailman/listinfo/python-list


Re: shipping python

2011-10-12 Thread Kristen J. Webb



On 10/12/11 6:02 PM, Andrea Crotti wrote:



Why do you want to use the system python and system libraries?

It is a standard, just like glibc on linux, I'd like my code should work
on the OS with minimal intrusion.

If you want to avoid too much troubles and compatibility hell maybe
give PyInstaller a try, you ship just one big executable and you're done.
But apart from that setuptools is very good to know.

What about Solaris, NetBSD, FreeBSD, etc, etc.
If the executable includes bits from the openssl library, what about export
restrictions?
I'll take a look at setuptools, thanks.


And also the world is a funny place, but does it really happen that
a customer changes the code in your python scripts, and the *complain*
if it doens't work anymore??


Yes, support costs with very knowledgeable clients is a very important factor.

Thank you for the feedback!
K
--
Mr. Kristen J. Webb
Teradactyl LLC.

PHONE: 1-505-242-1091
EMAIL: kw...@teradactyl.com
VISIT: http://www.teradactyl.com

Home of the

 True incremental Backup System
--
http://mail.python.org/mailman/listinfo/python-list


Re: shipping python

2011-10-12 Thread Kristen J. Webb



On 10/12/11 3:26 PM, Chris Angelico wrote:

On Thu, Oct 13, 2011 at 8:10 AM, Kristen J. Webb  wrote:

My main motivation to use .pyc is to keep end users from changing scripts,
breaking things, and then calling us.  Tamper proofing may be an
alternative approach if anyone has suggestions.



I wouldn't bother; if you're worried about that, try a tamper-evident
system rather than tamper-proof - for instance, MD5 checksums of
everything:

$ md5sum *>checksum.txt
$ md5sum checksum.txt
123412341234123412341234 md5sum

Save that meta-checksum and have an easy way to read it back - that
way, you can be sure they haven't just rebuilt the checksum file. If
that one checksum has changed, you know something else has; to find
out which:

$ md5sum -c --quiet checksum.txt

No need to restrict what you send out that way, and you can still get
a guarantee that they haven't fiddled with anything.

ChrisA

So you could think of the meta-checksum as a script wide version control
of what is installed.  Then, at key entry points, take the hit
and re-generate the meta-checksum and compare.  If bad, you
have a major version control error, do not process further.

Makes sense, so long as the user does not bother to regenerate
the meta-checksum as well.

Would be more extensible if in debugging, users can disable
this feature. or have a tool that updates the meta-checksum
so that they can run one-off code to fix problems.  Oddly,
this feature would make it easier to change code and still
keep things running.  But we could use the value in the support
chain to say, "something changed, what's going on?".

Thoughts?
K
--
Mr. Kristen J. Webb
Teradactyl LLC.

PHONE: 1-505-242-1091
EMAIL: kw...@teradactyl.com
VISIT: http://www.teradactyl.com

Home of the

 True incremental Backup System
--
http://mail.python.org/mailman/listinfo/python-list


ssl module with C

2011-10-18 Thread Kristen J. Webb

Hi All,
I'm hoping that the answer to this question
will shed light on the Python/C interface
and make me a much better python programer.

I have a test TLS connection program in
python (very breif)

import socket, ssl
news=socket.socket()
news.connect()
new_ssl=ssl.wrap_socket()
new_ssl.read()/new_ssl.write()

I'd like to pass my new_ssl to a C .so
library so that I can SSL_read()/SSL_write.

Why?  Using the python/ssl interface
gets me around so many issues with
varies Linux distros as libssl.so
is so unstandard.  My idea is that
using the installed python helps
me to separte my own work-horse C
code from the native openssl library.

Can this be done?  If not, the why should
make me a better python programer!

Many thanks in advance!
Kris
--
Mr. Kristen J. Webb
Teradactyl LLC.

PHONE: 1-505-242-1091
EMAIL: kw...@teradactyl.com
VISIT: http://www.teradactyl.com

Home of the

 True incremental Backup System
--
http://mail.python.org/mailman/listinfo/python-list