Re: Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Edward C. Jones
On 06/19/2012 12:41 PM, Hemanth H.M wrote: >>> float.hex(x) '0x1.5p+3' Some days I don't ask the brightest questions. Suppose x was a numpy floating scalar (types numpy.float16, numpy.float32, numpy.float64, or numpy.float128). Is there an easy way to write x in binary or hex?

Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Edward C. Jones
Consider the following line in C: printf('%a\n', x); where x is a float or double. This outputs a hexadecimal representation of x. Can I do this in Python? -- http://mail.python.org/mailman/listinfo/python-list

Hashable object with self references OR how to create a tuple that refers to itself

2012-06-15 Thread Edward C. Jones
I am trying to create a collection of hashable objects, where each object contains references to other objects in the collection. The references may be circular. To simplify, one can define x= list() x.append(x) which satisfies x == [x]. Can I create a similar object for tuples which sa

Re: Using modules from Debian "python3-..." packages with locally compiled Python 3.3

2012-05-08 Thread Edward C. Jones
Terry Reedy said: > Question 1: if you use the .pth method, do you get the same result? (I expect you will, but good to > check.) Recompiled Pyhton 3.3 without the SITEPATH change. Same result: > python3.3 Python 3.3.0a3 (default, May 8 2012, 19:57:45) [GCC 4.6.3] on linux Type "help", "cop

Using modules from Debian "python3-..." packages with locally compiled Python 3.3

2012-05-08 Thread Edward C. Jones
I use up-to-date Debian testing (wheezy), amd64 architecture. I downloaded, compiled and installed Python 3.3.0 alpha 3 (from python.org) using "altinstall". Debian wheezy comes with python3.2 (and 2.6 and 2.7). I installed the Debian package "python3-bs4" (BeautifulSoup4 for Python3). Note: De

Modifying a variable in a non-global outer scope?

2006-05-19 Thread Edward C. Jones
#! /usr/bin/env python """ When I run the following program I get the error message: UnboundLocalError: local variable 'x' referenced before assignment Can "inner" change the value of a variable defined in "outer"? Where is this explained in the docs? """ def outer(): def inner(): x

Widget that displays a directory tree?

2006-01-12 Thread Edward C. Jones
Do any of the Python GUIs have a super-high-level widget that displays a directory tree? Most file managers or editors have this type of window. -- http://mail.python.org/mailman/listinfo/python-list

Announcement: mrquery finds duplicate images

2005-12-19 Thread Edward C. Jones
I have uploaded "mrquery.05.12.19.tgz"' to my web page "http://members.tripod.com/~edcjones/pycode.html";. "mrquery" finds the duplicate images in a collection of images. It implements a variant of the algorithm in "Fast Multiresolution Image Querying" by Charles E. Jacobs, Adam Finkelstein and Da

Problem with __str__ if baseclass is list

2005-11-12 Thread Edward C. Jones
#! /usr/bin/env python class A(list): def __init__(self, alist, n): list.__init__(self, alist) self.n = n def __str__(self): return 'AS(%s, %i)' % (list.__str__(self), self.n) def __repr__(self): return 'AR(%s, %i)' % (list.__repr__(self), self.

__new__, __init__ and pickle

2005-06-29 Thread Edward C. Jones
Suppose I want to define the class MyClass so I can create an instance by MyClass(arg0, arg1, kwarg0=None, kwarg1=0, reuse=None, save=None) If reuse is not None, it is the name of a pickle file. Unpickle the file to get the instance. If save is not None, it is a file name. Pickle the instanc

Lexicographical sort for numarray

2005-04-26 Thread Edward C. Jones
Suppose arr is a two dimensional numarray array. Suppose we do the following: def rowsort(arr): a = arr.tolist() a.sort() return numarray.array(a) Can this sort be done efficiently in numarray? This function is called "rowsort" in MatLab. -- http://mail.python.org/mailman/listinfo/py

Does numarray search for blas and lapack during installation?

2005-04-23 Thread Edward C. Jones
I have a PC with Debian sid installed. I install all my Python stuff in /usr/local. I just installed numarray 1.3.1. Blaslite and lapacklite were compiled. Did the installation process search for blas and lapack? -- http://mail.python.org/mailman/listinfo/python-list

Re: numarray.array can be VERY slow

2005-04-10 Thread Edward C. Jones
Steven Bethard wrote: > As mentioned, this has nothing to do with numarray, and everything to > do with your inexplicable use of lists. Why don't you just write this > as: > > arr = numarray.ones((8, 8, 256, 256), Float64) The code I posted was simplified from a larger program which I have now re

numarray.array can be VERY slow

2005-04-10 Thread Edward C. Jones
#! /usr/bin/env python """Should this program take 4.3 seconds to run? I have a Linux PC with an AMD Athlon XP 2000+ chip (1.7Gh). I use Python 2.4.1 and numarray 1.2.3, both compliled from source.""" import time, numarray from numarray.numerictypes import * nested = [] for i in range(8):

Module subprocess: How to "communicate" more than once?

2005-04-01 Thread Edward C. Jones
I have a program named "octave" (a Matlab clone). It runs in a terminal, types a prompt and waits for the user to type something. If I try # Run octave. oct = subprocess.Popen("octave", stdin=subprocess.PIPE) # Run an octave called "startup". oct.communicate("startup") # Change directory inside o

Re: Python 3.0

2004-12-14 Thread Edward C. Jones
Chris wrote: Okay, color me stupid, but what is everyone referencing when they mention Python 3.0? I didn't see any mention of it on the Python site. http://www.python.org/peps/pep-3000.html (which happens to be the first hit if you search for "python 3.0" in the search box on python.org...) Oka