Re: Resticted mode still active (error?)

2005-04-06 Thread Jeff Epler
Is there a script that causes this problem, without using mod_python or jepp? If so, please attach it to the sourceforge bug. http://sourceforge.net/tracker/index.php?func=detail&aid=1163563&group_id=5470&atid=105470 pgpiWdvwwFmcD.pgp Description: PGP signature -- http://mail.python.org/mailman

Re: Read 16 bit integer complex data

2005-04-07 Thread Jeff Epler
You may want to use the 'numeric' or 'numarray' extensions for this. The page on numarray is here: http://www.stsci.edu/resources/software_hardware/numarray numarray doesn't support "complex 16-bit integer" as a type, but you can get a complex, floating-point valued array from your integer val

Re: curious problem with large numbers

2005-04-07 Thread Jeff Epler
You may want to read http://www.python.org/peps/pep-0754.html Part of the text reads The IEEE 754 standard defines a set of binary representations and algorithmic rules for floating point arithmetic. Included in the standard is a set of constants for representing special values, in

Re: help: loading binary image data into memory

2005-04-11 Thread Jeff Epler
probably something like this: (untested) def make_ftplib_callback(f): def callback(block): f.write(block) return callback img = cStringIO.StringIO() retrbinary( "get ???", make_ftplib_callback(img)) Jeff pgpaecaxnsqYB.pgp Description: PGP signature -- http://mail.pyt

Why won't someone step up and make use of the Free tools (was Re: Python 2.4 killing commercial Windows Python development ?)

2005-04-12 Thread Jeff Epler
I'm sorry that this is going to come out sounding like a flame, but it seems to me that there today only a few technical problems remaining with Python when built with mingw32. If one of the people who has expressed such deep concern about this "msvcr71.dll" problem would simply install the Free t

Re: Tkinter "withdraw" and "askstring" problem

2005-04-12 Thread Jeff Epler
The answer has to do with a concept Tk calls "transient". wm transient window ?master? If master is specified, then the window manager is informed that window is a transient window (e.g. pull-down menu) working on behalf of master (where master is the path name for

Re: Why won't someone step up and make use of the Free tools (was Re: Python 2.4 killing commercial Windows Python development ?)

2005-04-12 Thread Jeff Epler
On Tue, Apr 12, 2005 at 08:25:58PM +, Bengt Richter wrote: > But credit where due. Someone has stepped up to a large chunk of the problem: > >http://jove.prohosting.com/iwave/ipython/pyMinGW.html Yay. I'm glad somebody *is* doing this. Maybe all that is needed is to "get the word out".

Re: Get the entire file in a variable - error

2005-04-14 Thread Jeff Epler
It's not clear to me what you mean by "the first line" (gzip does not output a file composed of lines, its output is byte-oriented). Printing tst.getvalue() is probably not a very useful thing to do, since it won't do anything useful when the output is a terminal, and it will add an extra newline

Re: New Python regex Doc (was: Python documentation moronicities)

2005-04-18 Thread Jeff Epler
On Mon, Apr 18, 2005 at 01:40:43PM -0700, Xah Lee wrote: > i have rewrote the Python's re module documentation. > See it here for table of content page: > http://xahlee.org/perl-python/python_re-write/lib/module-re.html For those who have long ago consigned Mr. Lee to a killfile, it looks like he'

Re: fpectl

2005-04-18 Thread Jeff Epler
It looks like the automatic build of the 'fpectl' module was broken somewhere along the line, perhaps when the transition from Modules/Setup to setup.py took place. Once I made the change below and rebuilt, I got the fpectl module. Furthermore, it appeared to "do something" on my Linux/x86 system:

Re: Tkinter Event Types

2005-04-18 Thread Jeff Epler
The "type" field is related to the definition of different events in X11. In Xlib, the event structure is a "C" union with the first (common) field giving the type of the event so that the event-dependant fields can be accessed through the proper union member. Generally, you won't use this field

Re: fpectl

2005-04-19 Thread Jeff Epler
On Tue, Apr 19, 2005 at 02:05:11AM -0700, Sébastien Boisgérault wrote: > Thanks for this answer. > > Did you forward this info to python-dev ? I created a patch on the sf tracker. It's been responded to by several developers. You can read what they said there. http://python.org/sf/1185529 Jef

Re: Writing to stdout and a log file

2005-04-19 Thread Jeff Epler
This variation works: # class Tee: def __init__(self, *args): self.files = args def write(self, data): for f in self.files: result = f.write(data) return result def writelines(s

Re: Writing to stdout and a log file

2005-04-19 Thread Jeff Epler
In that case, it looks like you won't be able to get what you want without modifying CPython. PRINT_ITEM calls PyFile_SoftSpace, PyFile_WriteString, and PyFile_WriteObject, which all use PyFile_Check(). It might be as simple as changing these to PyFile_CheckExact() calls in PyFile_WriteString / P

Re: Why is Python not supporting full derivation of built-in file class?

2005-04-24 Thread Jeff Epler
This issue was discussed in another recent python-list thread, called "Writing to stdout and a log file". My second post includes a patch to Python's "fileobject.c" that made the code that started that thread work, but for reasons I mentioned in that post I didn't want to push for inclusion of my

Re: python equivalent of php implode

2005-04-26 Thread Jeff Epler
It looks like php's implode(sep, seq) is like sep.join(seq) in Python. But this is a lousy way to write database queries. You should use the Python's DB-API interface's execute(statement, parameters) instead. Assuming that paramstyle is 'qmark', I think it ends up looking something like this:

Re: python equivalent of php implode

2005-04-27 Thread Jeff Epler
On Tue, Apr 26, 2005 at 09:59:29PM -0500, Mike Meyer wrote: > Jeff Epler <[EMAIL PROTECTED]> writes: > > > items = query_param.items() > > keys = [item[0] for item in items] > > values = [item[1] for item in items] > > Is there some reason not to

Re: tkinter OptionMenu column break

2005-04-30 Thread Jeff Epler
I don't think that Tk's menus ever use more than one column. They certainly don't on Unix. Jeff pgpsVnvjgm3Qy.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: How to track down all required shared libraries?

2005-04-30 Thread Jeff Epler
One poster suggests 'ldd' for executables. You can also use this on shared libraries: $ ldd /usr/lib/python2.3/lib-dynload/_tkinter.so libtix8.1.8.4.so => /usr/lib/libtix8.1.8.4.so (0x009b6000) libtk8.4.so => /usr/lib/libtk8.4.so (0x00111000) libtcl8.4.so => /usr/lib/libtc

Re: cgi "print statement" in multithreaded enviroment?

2005-05-02 Thread Jeff Epler
You could write something like class ThreadSpecificFile: def set_stdout(f): self.files[thread_id] = f def write(data): self.files[thread_id].write(data) sys.stdout = ThreadSpecificFile() where you'll have to fill out a few more things like thread_id,

Re: How to read an integer value from a binary file?

2005-05-03 Thread Jeff Epler
As your 'for' loop shows, the number of items in the slice [2:5] is only 3, not 4. Maybe you want the slice [2:6] instead. >>> x = "xx\xb6/\0\0" >>> struct.unpack('i', x[2:6]) (12214,) Jeff pgprzSG2OzoK4.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: A faster method to generate a nested list from a template?

2005-05-04 Thread Jeff Epler
Are there only a few, unchanging templates? If so, (dynamiclly) create a function for each template. This will be nearly the fastest you can go in Python, excluding the time to create and byte-compile the nesting function. # This code is in the public domain def make_nesting_expression(l, s):

Re: descriptor dilemma

2005-05-04 Thread Jeff Epler
On Wed, May 04, 2005 at 09:14:18AM -0700, Sébastien Boisgérault wrote: > > Yup ?!? Weird ... especially as: > > >>> id(c.f) == id(C.__dict__['f'].__get__(c,C)) > True Here, c.f is discarded by the time the right-hand-side of == is executed. So the object whose id() is being calculated on the ri

Re: Best way to convert a list into function call arguments?

2005-05-05 Thread Jeff Epler
Your question is answered in the tutorial: http://docs.python.org/tut/node6.html#SECTION00674 4.7.4 Unpacking Argument Lists The reverse situation occurs when the arguments are already in a list or tuple but need to be unpacked for a function call requiring separate positional arg

Re: New Python regex Doc (was: Python documentation moronicities)

2005-05-06 Thread Jeff Epler
To add to what others have said: * Typos and lack of spell-checking, such as "occurances" vs "occurrences" * Poor grammar, such as "Other characters that has special meaning includes:" * You dropped version-related notes like "New in version 2.4" * You seem to love the use of s, while docs.py

Re: [HELP] Tkinter Application Minimized to System Tray :)

2005-05-06 Thread Jeff Epler
Tk, the library that Tkinter wraps, does not offer a way to "minimize to the taskbar". Jeff pgp3ATXnxg0dO.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Using TCL files in Python ?

2005-05-11 Thread Jeff Epler
While I've never used it, there *is* a Tix module in Python which appears to wrap the widgets provided by Tix. In Fedora Core 2, Python doesn't seem to be configured to use Tix OOTB but a one-liner (that should be harmless elsewhere) does make it work. These classes are defined in the Tix module:

Re: How "return" no return ?

2005-05-13 Thread Jeff Epler
At the interactive prompt, a result is printed when both these things are true: * The entered code is an expression, not any other kind of statement * The result of the expression is not 'None' If an expression occurs, information about it will be printed instead. So the interpreter won't

Re: Precision?

2005-05-15 Thread Jeff Epler
If you want to do decimal arithmetic, use the decimal module which is new in Python 2.4. Python 2.4 (#1, Jan 22 2005, 20:45:18) [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from decimal import Decimal as D >>> D(

Re: Recommended version of gcc for Python?

2005-05-16 Thread Jeff Epler
Most versions of gcc should be just fine to compile Python. Python is targeted at ANSI/ISO C compilers, but does not yet use any C99 features. I don't think there was ever such a thing as "gcc 3.5"; http://gcc.gnu.org/ lists 4.0 as the "current release series" and 3.4.3 as the "previous release s

Re: Interaction between TclTk editor with Python code

2005-05-17 Thread Jeff Epler
One way to get a handle on some Tcl variables from Python is to create Tkinter.Variable instances with the names of the existing Tcl variables (normally, the variable names are chosen arbitrarily). Once you've done this, you can do things like add variable traces (the trace_variable method) on the

Re: iso_8859_1 mystery/tkinter

2005-05-18 Thread Jeff Epler
this isn't about the "sign bit", it's about assumed encodings for byte strings.. In iso_8859_1 and unicode, the character with value 0xb0 is DEGREE SIGN. In other character sets, that may not be true---For instance, in the Windows "code page 437", it is u'\u2591' aka LIGHT SHADE (a half-tone patte

Re: Byte-operations.

2005-05-19 Thread Jeff Epler
In Python, "chr" gives a 1-byte string from a small integer, "ord" does the reverse. Strings are concatenated with "+" and substrings are taken with the slice operator, s[pos1:pos2]. I'm not a visual basic expert, but it looks like these are the operations the code below performs. Jeff pgpWpqb

Re: Tkinter special math chars

2005-05-19 Thread Jeff Epler
I wrote the following code: import Tkinter t = Tkinter.Label() t.configure( text=u"As the function approaches \N{INFINITY}, \N{HORIZONTAL ELLIPSIS}") t.pack() t.mainloop() It worked for me on Windows NT 4.0 with Python 2.4, and on RedHat 9 with a self-compiled Python 2.

Re: Tkinter special math chars

2005-05-19 Thread Jeff Epler
On Thu, May 19, 2005 at 12:56:12PM -0500, phil wrote: > Why is it so slow? (RH Linux, 2.4.20, 1.6Ghz AMD) > 3/4 second slower to display widget w/unicode, > even if I encode u'\u221e' u'\u221e' vs u'\N{INFINITY}' should make no noticible run-time difference--they both specify exactly the same stri

Re: Shift-JIS to UTF-8 conversion

2005-05-19 Thread Jeff Epler
I think you do something like this (untested): import codecs def transcode(infile, outfile, incoding="shift-jis", outcoding="utf-8"): f = codecs.open(infile, "rb", incoding) g = codecs.open(outfile, "wb", outcoding) g.write(f.read()) # If the file is so large that it can't be

Re: Shift-JIS to UTF-8 conversion

2005-05-23 Thread Jeff Epler
On Fri, May 20, 2005 at 12:16:15AM -0700, [EMAIL PROTECTED] wrote: > Hello, I think the answer is basically correct but shift-jis is not a > standard part of Python 2.3. Ah, I was fooled --- I tested on Python 2.3, but my packager must have included the codecs you went on to mention. Jeff pgp4q

Re: Strange behaviour of floating point constants in imported modules

2005-05-23 Thread Jeff Epler
This may be relevant to the problems you're seeing: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=774665&group_id=5470 The short story, as the tracker item paints it, is that setting LC_NUMERIC to anything other than 'C' can give results like the ones you describe---Python itse

Re: exit after process exit

2005-05-31 Thread Jeff Epler
You might want os.spawnv(os.P_WAIT, "a.exe", ["a.exe"]) os.system("a.exe") Jeff pgpp3Fxdo0nYA.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: scripting browsers from Python

2005-06-01 Thread Jeff Epler
I wanted to have a Python program make my browser do a POST. I am using Firefox on Linux. Here's what I did: * Prepare a HTML page on the local disk that looks like this: http://www.example.com/cgi-bin/example.cgi";> Submitting form.

Re: Unicode string in exec

2005-06-02 Thread Jeff Epler
First off, I just have to correct your terminology. "exec" is a statement, and doesn't require parentheses, so talking about "exec()" invites confusion. I'll answer your question in terms of eval(), which takes a string representing a Python expression, interprets it, and returns the result. In

Re: TkInter Listbox Widget Formatting

2005-06-02 Thread Jeff Epler
This isn't an option in the stock Tk listbox or any of the alternatives I know of offhand (bwidget ListBox, TixTList). The TkTable widget, which can also display multiple columns, can select different justifications, either for the whole table, or for single cells. I've never used TkTable with Pyt

Re: Easy way to detect hard drives and partitions in Linux

2005-06-02 Thread Jeff Epler
You're not going to find a single portable "unix" way of doing this. The format of /etc/fstab and /etc/mtab are pretty portable, but they only list mountable/mounted partitions, not all partitions. In addition to the linux possibilities mentioned in another reply, there is also /proc/partitions.

Re: thread vs GC

2005-06-02 Thread Jeff Epler
I suspect that getting the threads to die will be tricky, and as written the thread holds a reference to the 'primegen' instance (this part can be cured, but it still doesn't ever make the thread exit). Instead of figuring out how to get this to clean itself up, why not make sure you only make one

Re: method = Klass.othermethod considered PITA

2005-06-04 Thread Jeff Epler
On Sat, Jun 04, 2005 at 10:43:39PM +, John J. Lee wrote: > 1. In derived classes, inheritance doesn't work right: Did you expect it to print 'moo'? I'd have been surprised, and expected the behavior you got. > 2. At least in 2.3 (and 2.4, AFAIK), you can't pickle classes that do >this.

Re: Socket Speed

2005-06-05 Thread Jeff Epler
300KB/s sounds dreadfully low. I simply ran "python /usr/lib/python2.3/SimpleHTTPServer.py &", then "wget -O /dev/null http://0.0.0.0:8000/70megfile";. On the best of 4 runs (when the file was cached) wget measured 225.20MB/s. The hardware is a Pentium-M laptop with 768MB RAM runnng at 1.5GHz.

Re: GUI builders considered harmful (Was: anygui, anydb, any opinions?)

2005-06-05 Thread Jeff Epler
On Sun, Jun 05, 2005 at 02:38:16PM -0500, Mike Meyer wrote: [...] > The first, and most obvious, thing that GUI builders do is force the > developer to specify an exact position - if not size - for the > graphical elements of the UI. [...] Certainly some---or even most---builders work like this.

Re: PyArg_ParseTuple and dict

2005-06-05 Thread Jeff Epler
I tried to recreate the problem based on what you described in your message. I was unable to recreate the problem. I wrote the following file "sjh.c": #include PyObject *f(PyObject *self, PyObject *args) { PyObject *ob = NULL; if(!PyArg_ParseTuple(args, "O", &ob)) return NULL; Py_I

Re: Socket Speed

2005-06-06 Thread Jeff Epler
The machines with the 100mbps ethernet link are slightly different---Pentium 4, 2.8GHz, Python 2.2, RedHat 9. File size: 87490278 Best of 4 runs: 7.50 MB/s reported by "wget". There was other network activity and system load at the time. Jeff pgpNVPeW3ghJL.pgp Description: PGP signature -- h

Re: Hiding X windows

2005-06-11 Thread Jeff Epler
You may want to use a standalone program to do this. "xwit" has the ability to iconify a window which can be selected in a variety of ways. http://hpux.connect.org.uk/hppd/hpux/X11/Misc/xwit-1.0/man.html There's a direct Python interface to the X protocol in python-xlib. You could re-write t

Re: TKinter -- '' event executing more than once?

2005-06-12 Thread Jeff Epler
For me, an 'is' test works to find out what widget the event is taking place on. # import Tkinter def display_event(e): print "event received", e.widget, e.widget is t t = Tkinter.Tk() t.bind("", display_event) w = Tkint

Re: count string replace occurances

2005-06-12 Thread Jeff Epler
On Sun, Jun 12, 2005 at 04:55:38PM -0700, Xah Lee wrote: > if i have > mytext.replace(a,b) > how to find out many many occurances has been replaced? The count isn't returned by the replace method. You'll have to count and then replace. def count_replace(a, b, c): count = a.count(b) retur

Re: Get drives and partitions list (Linux)

2005-06-12 Thread Jeff Epler
Using /proc/partitions is probably preferable because any user can read it, not just people who can be trusted with read access to drives, and because the format of /proc/partitions is probably simpler and more stable over time. That said, what you do is import commands fdisk_output = comm

Re: [Python-Dev] A bug in pyconfig.h under Linux?

2005-06-14 Thread Jeff Epler
[sent to python-list and poster] Did you follow the direction that Python.h be included before any system header? This is mentioned at least in http://docs.python.org/ext/simpleExample.html It's a crummy thing for Python to insist on, but if you can re-organize your headers to do this it sho

Re: Strange socket problem

2005-06-15 Thread Jeff Epler
When using os.system(), files that are open in the parent are available in the child, as you can see here in Linux' listing of the files open by the child program: [EMAIL PROTECTED] jepler]$ python -c 'f = open("/tmp/test", "w"); print f.fileno(); import os; os.system("ls -l /proc/self/fd")' 3 to

Re: Programmatic links in a TKinter TextBox

2005-06-15 Thread Jeff Epler
Based on the location where the user clicked, you can find the associated tags. Then you must loop through them to find the one that gives the "href" value. Jeff :r /tmp/link.py import Tkinter app = Tkinter.Tk() text = Tkinter.Text(app) text.pack() def click(event): #this doesn't work

Re: log in to a website

2005-06-16 Thread Jeff Epler
You may find the third-party modules "ClientForm" and "ClientCookie" to be useful. Using ClientForm, the following code uploads a file to a particular web form: forms = ClientForm.ParseResponse(urllib2.urlopen(url)) f = forms[0] f.add_file(open(local, "rb"), filename=remote, name="file

<    1   2