Re: Rich __repr__

2005-10-30 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> wrote: > If I want to implement a __repr__ that's reasonably "nice" to the > programmer, what's the Right Way? Are there recipes I should look > at? As a (carefully selected) example from the code I'm writing: >>> import lib.attribute >>> m = lib.attribute.

Re: Scanning a file

2005-10-30 Thread David Rasmussen
No comments to this post? /David -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with py2exe

2005-10-30 Thread Miki Tebeka
Hello DDany, > copying D:\programs\python24\MSVCR71.dll -> D:\Applicazione\dist > error: could not delete 'C:\app\dist\MSVCR71.dll': Permission denied > > However folders build and dist are created: in particular into the > folder dist i have the w9xpopen.exe file, some *.pyd files and some > dl

Re: Scanning a file

2005-10-30 Thread Peter Otten
Bengt Richter wrote: > I still smelled a bug in the counting of substring in the overlap region, > and you motivated me to find it (obvious in hindsight, but aren't most ;-) > > A substring can get over-counted if the "overlap" region joins > infelicitously with the next input. E.g., try counting

Rich __repr__

2005-10-30 Thread Ben Finney
Howdy all, The builtin types have __repr__ attributes that return something nice, that looks like the syntax one would use to create that particular instance. The default __repr__ for custom classes show the fully-qualified class name, and the memory address of the instance. If I want to impleme

MacOS Extension Carbon.File.FSCatalogInfo file sizes should be UInt64?

2005-10-30 Thread donbro
If my read of the extension source (Mac/Modules/file/_Filemodule.c) is correct, the parameter sizes specified for data and resource file sizes are UInt32 where they should be UInt64. In both OS9 and OSX Carbon, the MacOS File Manager (Files.h) uses UInt64 values for data and resource filesizes.

Re: need start point for getting html info from web

2005-10-30 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hey there, > > i have a small app that i am going to need to get information from a > few tables on different websites. i have looked at urllib and httplib. > the sites i need to get data from mostly have this data in tables. So > that,

Re: Message about not deleted folders using Inno Setup

2005-10-30 Thread Peter Hansen
Martin wrote: >I would like to place a message in an uninstaller window which will > inform the user that some folders haven't been deleted. Is that possible > using > Inno Setup? Probably, but this newsgroup is for discussion of Python. Unless you have some kind of Python angle to your que

Re: putting a string in Mac Address form

2005-10-30 Thread Alex Martelli
kyle.tk <[EMAIL PROTECTED]> wrote: ... > new_mac = '' > c = 0 > while len(new_mac) < 16: > new_mac += mac[c:c+2] + ':' > c=c+2 > return new_mac[:-1].upper() ... > The part I think is bad is the while loop part. Could it be better? What abou

Re: need start point for getting html info from web

2005-10-30 Thread nephish
yeah, i know i am going to have to write a bunch of stuff because the values i want to get come from several different sites. ah-well, just wanting to know the easiest way to learn how to get started. i will check into beautiful soup, i think i have heard it referred to before. thanks shawn -- ht

Re: need start point for getting html info from web

2005-10-30 Thread Mike Meyer
[EMAIL PROTECTED] writes: > i have a small app that i am going to need to get information from a > few tables on different websites. i have looked at urllib and httplib. > the sites i need to get data from mostly have this data in tables. So > that, i think would make it easier. Anyone suggest a go

putting a string in Mac Address form

2005-10-30 Thread kyle.tk
I came up with this. Is there a better (more pythonic) way to do it? import string def mac_to_norm(mac): def bad_char(char): if char not in string.hexdigits: return False return True mac = filter(bad_char,mac) if len(m

Re: Scanning a file

2005-10-30 Thread Steven D'Aprano
Alex Martelli wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >... > >>>No. But if you get a totally unexpected exception, >> >>I'm more concerned about getting an expected exception -- or more >>accurately, *missing* an expected exception. Matching on Exception is too >>high. EOFError

Re: Controlling output using print with format string

2005-10-30 Thread Bengt Richter
On Sun, 30 Oct 2005 18:44:06 -0600, Paul Watson <[EMAIL PROTECTED]> wrote: >It is clear that just using 'print' with variable names is relatively >uncontrollable. However, I thought that using a format string would >reign the problem in and give the desired output. > >Must I resort to sys.stdou

Re: Pickling and unpickling inherited attributes

2005-10-30 Thread Steve Holden
Alex wrote: > I have a serious problem and I hope there is some solution. It is > easier to illustrate with a simple code: > > class Parent(object): > > __slots__=['A', 'B'] > def __init__(self, a, b): > self.A=a; self.B=b > def __getstate__(self): >

need start point for getting html info from web

2005-10-30 Thread nephish
hey there, i have a small app that i am going to need to get information from a few tables on different websites. i have looked at urllib and httplib. the sites i need to get data from mostly have this data in tables. So that, i think would make it easier. Anyone suggest a good starting point for

Re: Scanning a file

2005-10-30 Thread Paul Watson
Fredrik Lundh wrote: > Paul Watson wrote: > >>This is Cyngwin on Windows XP. > > using cygwin to analyze performance characteristics of portable API:s > is a really lousy idea. Ok. So, I agree. That is just what I had at hand. Here are some other numbers to which due diligence has also not b

Re: Scanning a file

2005-10-30 Thread Tony Nelson
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Steve Holden wrote: > > Indeed, but reading one byte at a time is about the slowest way to > > process a file, in Python or any other language, because it fails to > > amortize the overhead cost of function calls over many characters. > >

Re: Controlling output using print with format string

2005-10-30 Thread Mike Meyer
Paul Watson <[EMAIL PROTECTED]> writes: > It is clear that just using 'print' with variable names is relatively > uncontrollable. However, I thought that using a format string would > reign the problem in and give the desired output. > > Must I resort to sys.stdout.write() to control output? No.

Re: learning emacs lisp

2005-10-30 Thread Steve Holden
[To new readers: please ignore the rantings of this unbalanced person, who is well known for posing inappropriate and inflammatory material on news groups and mailing lists of all kinds.] Xah Lee wrote: > well, in the past couple of days i started my own: > http://xahlee.org/emacs/notes.html >

Re: Pickling and unpickling inherited attributes

2005-10-30 Thread Alex Martelli
Alex <[EMAIL PROTECTED]> wrote: > I have a serious problem and I hope there is some solution. It is > easier to illustrate with a simple code: > > >>> class Parent(object): > __slots__=['A', 'B'] > def __init__(self, a, b): > self.A=a; self.B=b > def __getstate__(s

Re: Scanning a file

2005-10-30 Thread Bengt Richter
On Sat, 29 Oct 2005 21:10:11 +0100, Steve Holden <[EMAIL PROTECTED]> wrote: >Peter Otten wrote: >> Bengt Richter wrote: >> >> >>>What struck me was >>> >>> >> gen = byblocks(StringIO.StringIO('no'),1024,len('end?')-1) >> [gen.next() for i in xrange(10)] >>> >>>['no', 'no', 'no', 'no', 'n

Re: Pickling and unpickling inherited attributes

2005-10-30 Thread Alex
Thanks so much! It makes perfect sense and I am sure it will work now. -- http://mail.python.org/mailman/listinfo/python-list

Re: Controlling output using print with format string

2005-10-30 Thread Alex Martelli
Paul Watson <[EMAIL PROTECTED]> wrote: > It is clear that just using 'print' with variable names is relatively > uncontrollable. However, I thought that using a format string would > reign the problem in and give the desired output. > > Must I resort to sys.stdout.write() to control output? In

Re: Scanning a file

2005-10-30 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > > No. But if you get a totally unexpected exception, > > I'm more concerned about getting an expected exception -- or more > accurately, *missing* an expected exception. Matching on Exception is too > high. EOFError will probably need to be han

Re: Scanning a file

2005-10-30 Thread Alex Martelli
John J. Lee <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: > [...] > > If you're trying to test your code to ensure it explicitly closes all > > files, you could (from within your tests) rebind built-ins 'file' and > > 'open' to be a class wrapping the real thing, and addin

Re: Pickling and unpickling inherited attributes

2005-10-30 Thread Sam Pointon
Of course, in __setstate__, there should be a tup = list(tup) as well - sheer forgetfulness and a confusing name in one. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickling and unpickling inherited attributes

2005-10-30 Thread Sam Pointon
The reason the state of obj.A and obj.B aren't preserved is because your __getstate__ and __setstate__ don't preserve them - they only save obj.C, and you don't make a call to the parent class's respective methods. Here's what I mean: >>> import pickle >>> class Child(Parent): __slots__=[

Controlling output using print with format string

2005-10-30 Thread Paul Watson
It is clear that just using 'print' with variable names is relatively uncontrollable. However, I thought that using a format string would reign the problem in and give the desired output. Must I resort to sys.stdout.write() to control output? $ python Python 2.4.1 (#1, Jul 19 2005, 14:16:43) [

Re: Automatically creating a HOME environ variable on Windows?

2005-10-30 Thread Jorgen Grahn
On Sat, 29 Oct 2005 18:43:44 +0200, Maciej Dziardziel <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >> Cool, even better. So what's best, having code to add HOME >> (=USERPROFILE) to os.environ, or change the various places that HOME is >> used to check for USERPROFILE? > > Best solution

Message about not deleted folders using Inno Setup

2005-10-30 Thread Martin
Hi I would like to place a message in an uninstaller window which will inform the user that some folders haven't been deleted. Is that possible using Inno Setup? -- Thanks in advance Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem With Insert with MySQLdb

2005-10-30 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Mitchell wrote: > Hello, > > I am a complete beginner with Python. I've managed to get mod_python up and > running with Apache2 and I'm trying to a simple insert into a table in a > MySQL database. > > I'm using the MySQLdb library for connect

Problem With Insert with MySQLdb

2005-10-30 Thread David Mitchell
Hello, I am a complete beginner with Python. I've managed to get mod_python up and running with Apache2 and I'm trying to a simple insert into a table in a MySQL database. I'm using the MySQLdb library for connectivity. I can read from the database no problem, but when I do an insert, the value

Re: How do I sort these?

2005-10-30 Thread Bengt Richter
On Sun, 30 Oct 2005 10:13:42 +0100, Peter Otten <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: > [...] >> Now select from the second list, by first-element position correspondence: >> >>> [second[t[1]] for t in sorted((f,i) for i,f in enumerate(first))] >> ['E', 'D', 'C', 'B', 'A', 'J', 'I', '

Re: parsing a tuple in embedded python

2005-10-30 Thread jenkins . justin
Thanks Fredrik. Yes, I see now how the function works. I'm new to Python and the book I'm studying out of wasn't too explicit in how to handle arrays. I've changed the code to what you suggested, but strangely enough nothing got read into my array. If I return a single integer from my Python method

Re: Pickling and unpickling inherited attributes

2005-10-30 Thread Alex
Sorry, I copied and pasted a wrong piece from shell at one part of the code: objct.Z=4 was in fact obj.Z=4 and it did refuse to accept Z (because it is not in __slots__). But the question remains: why the value of attribute A is not preserved during pickling and unpickling and what can be done ab

Pickling and unpickling inherited attributes

2005-10-30 Thread Alex
I have a serious problem and I hope there is some solution. It is easier to illustrate with a simple code: >>> class Parent(object): __slots__=['A', 'B'] def __init__(self, a, b): self.A=a; self.B=b def __getstate__(self): return self.A, self

Re: Examples of Python code compared to other languages

2005-10-30 Thread Nicolas Pernetty
On 29 Oct 2005 21:27:39 -0700, [EMAIL PROTECTED] wrote : > http://pleac.sourceforge.net/ probably is what you're looking for. It > shows how to to stuff from the perl cookbook in a plethora of other > languages, including Python. > > Kind regards Terji Petersen > Hello, As mentioned in the ori

Re: Using graphviz to visualize trace.py output, anybody?

2005-10-30 Thread Do Re Mi chel La Si Do
Hi! Under Windows, I call graphwiz from Python via COM, with win32all (PyWin). Sorry, I don't know the Mac. @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file

2005-10-30 Thread Steven D'Aprano
On Sun, 30 Oct 2005 08:35:12 -0700, Alex Martelli wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >... >> > Don't ever catch and ``handle'' exceptions in such ways. In particular, >> > each time you're thinking of writing a bare 'except:' clause, think >> > again, and you'll most likely f

Re: Using Python to add thumbnails to Explorer

2005-10-30 Thread John J. Lee
"Roger Upole" <[EMAIL PROTECTED]> writes: > "c d saunter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [...] > > Turns out I need to use a .dll shell extension as per > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ > > shellcc/platform/shell/programmersguide/she

Using graphviz to visualize trace.py output, anybody?

2005-10-30 Thread svenn . are
Hi, has anybody thought of / already used graphviz to convert the output of trace.py into a graph? I looked at PyUMLGraph, but 1. PyUMLGraph does not successfully create a dot file, and 2. I don't really want a UML representation but a compact representation of program execution. Maybe there is s

Re: Scanning a file

2005-10-30 Thread John J. Lee
[EMAIL PROTECTED] (Alex Martelli) writes: [...] > If you're trying to test your code to ensure it explicitly closes all > files, you could (from within your tests) rebind built-ins 'file' and > 'open' to be a class wrapping the real thing, and adding a flag to > remember if the file is open; at __d

Problem: Windows Command line Pipe to stdin

2005-10-30 Thread GerShar
Python 2.3 on Windows XP The following works when run from the command line. import sys text = sys.stdin.read() # do something on the text # ... sys.stdout.write(text) But if the above code is used as a filter program that gets another programs output as shown below, it fails as shown.

Re: Tk

2005-10-30 Thread Shi Mu
How can I make the main menu come first, and after clicking test/just try, "how are you" interface shows. Thanks a lot! from Tkinter import * from Tkinter import _cnfmerge class Dialog(Widget): def __init__(self, master=None, cnf={}, **kw): cnf = _cnfmerge((cnf, kw)) self.widgetName

Last.fm Python group

2005-10-30 Thread Jarek Zgoda
I was missing miscellaneous Python group on last.fm, so here it is: http://www.last.fm/group/PythonCode. Enjoy. -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list

Problem with py2exe

2005-10-30 Thread DDany
HI! I've a problem with py2exe: well, first of all I say that I use python 2.4.1 , py2exe 0.6.3 and distutils 1.0.2 on winxp. To use py2exe I wrote a file setup.py like this: from distutils.core import setup import py2exe setup( version = "0.1", description = "Py2Exe Script", name = "A

Re: XML Tree Discovery (script, tool, __?)

2005-10-30 Thread uche . ogbuji
"Neat, though non-trivial XSLT makes my head spin." Well, you don't have to know XSLT at all to use the Examplotron transform, although I can understand wanting to understand and hack what you're using. "Just for kicks, I rewrote in python Michael Kay's DTDGenerator (http://saxon.sourceforge.net/

MySQLdb and cgi

2005-10-30 Thread robert
 Dear group, I have a problem with importing MySQLdb in a cgi-script. The code fragment at the beginning:   1 #!/usr/bin/env python   2   3 print "Content-Type: text/html\n\n"   4   5 import re   6 import cgi   7 import MySQLdb 8 print "something" but the print statemen

Re: Understanding the arguments for SubElement factory in ElementTree

2005-10-30 Thread Giovanni Bajo
[EMAIL PROTECTED] wrote: > > xyz > > > rather than: > root = Element('root') > subroot = SubElement(root, 'subroot') > subroot.text = 'xyz' > > Was wondering whether this code accomplish that > root = Element('root') > subroot = SubElement(root, 'subroot', text='xyz') No, this creates:

Re: learning emacs lisp

2005-10-30 Thread Xah Lee
well, in the past couple of days i started my own: http://xahlee.org/emacs/notes.html but i'm sure something like it exists. Btw, the elisp intro by Robert J Chassell. At: http://www.gnu.org/software/emacs/emacs-lisp-intro/ is extremely well written. (and so is the elisp reference) Bravo to GNU

Re: popen2

2005-10-30 Thread Piet van Oostrum
> Piet van Oostrum <[EMAIL PROTECTED]> (PvO) wrote: >PvO> He didn't state that he has no control over that program. I.e. if it is a >PvO> program that he has source code of, he could change its behaviour to use a >PvO> named pipe. He could do the initial run of the program with stdin and stdo

Re: Recursive generators and backtracking search

2005-10-30 Thread Talin
Alex Martelli wrote: > for x in whatever_other_iterable: yield x > > into (say) > > yield from whatever_other_iterable > > is minute and not worth changing the syntax (even though something like > 'yield from' would mean no keywords would need to be added). I agree that the improvement is minor,

Re: Need Python Pro for Help!! Plzz

2005-10-30 Thread Lasse Vågsæther Karlsen
[EMAIL PROTECTED] wrote: > Need python Pro at [EMAIL PROTECTED] , if u wanna help, plz > reply to that address. We are python beginners. need a real good > Python Programmer for Help. TIA!! If you need help, post questions to the newsgroups. That way you might get help from several people inste

Re: process and spinning slash

2005-10-30 Thread Thomas Bellman
[EMAIL PROTECTED] (Alex Martelli) writes: > Have the spin function accept the pid argument and exit the loop if said > pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this > will raise an OSError if no process with that pid exists, so you can use > a try/except OSError: to catch

Re: process and spinning slash

2005-10-30 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > Have the spin function accept the pid argument and exit the loop if said > > pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this > > will raise an OSError if no process with that pid exists, so you can use >

Re: process and spinning slash

2005-10-30 Thread Fredrik Lundh
Alex Martelli wrote: > Have the spin function accept the pid argument and exit the loop if said > pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this > will raise an OSError if no process with that pid exists, so you can use > a try/except OSError: to catch that and break as app

Re: process and spinning slash

2005-10-30 Thread Alex Martelli
benz <[EMAIL PROTECTED]> wrote: ... > def spin(delay): > > pattern=['-','\\','|','/','-','\\','|'] > > while 1: > for i in pattern: > sys.stdout.write(i + " ") > sys.stdout.flush() > sys.stdout.write("\b\b") > time.sleep(delay) > > pid = os.fork() > > if pid =

process and spinning slash

2005-10-30 Thread benz
I am trying to fork and exec a child by python. Additionally, I am attempting to have a spinning slash while the child is running. My code is as below: import sys, os, time def spin(delay): pattern=['-','\\','|','/','-','\\','|'] while 1: for i in pattern: sys.stdout.write(i + "

Re: Automatic binding of **kwargs to variables

2005-10-30 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > I find this style of coding repulsive when compared to: > > > > def foo(arg1=None, arg2=None): > > print dict(arg1=arg1, arg2=arg2) > > > > I don't understand what added value all of those extra, contorted lines > > are

Re: Automatic binding of **kwargs to variables

2005-10-30 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Don't know about this particular case but sometimes, I don't want to > have a default argument value. That is, argument not there is different > from argument = None. Though in general, I prefer the None as special > meaning coding style. But even pyt

Re: Scanning a file

2005-10-30 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > > Don't ever catch and ``handle'' exceptions in such ways. In particular, > > each time you're thinking of writing a bare 'except:' clause, think > > again, and you'll most likely find a much better approach. > > What would you -- or anyone else

Re: popen2

2005-10-30 Thread Piet van Oostrum
> Grant Edwards <[EMAIL PROTECTED]> (GE) wrote: >GE> On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >GE> That would require that the application know about the named >GE> pipe and open it. I don't think there is any way to swap a >GE> pipe in for stdin/stdout once a process is run

Need Python Pro for Help!! Plzz

2005-10-30 Thread [EMAIL PROTECTED]
Need python Pro at [EMAIL PROTECTED] , if u wanna help, plz reply to that address. We are python beginners. need a real good Python Programmer for Help. TIA!! -- * Posted with NewsLeecher v3.0 Beta 7 * http://www.newsleecher.com/?usenet -- http://mail.python.org/mailman/listinfo/python-list

Re: parsing a tuple in embedded python

2005-10-30 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I am returning a tuple from my python method and am stuck trying to > figure out how to read it into a C array using PyArg_Parse. > My C Code: > int array[3]; > PyArg_Parse(return, "(iii)", &array); > > My Python Code: > mytuple = (1,2,3) > return mytuple > > That gives

Re: lambda functions within list comprehensions

2005-10-30 Thread Max Rybinsky
Valid link in my previews message is http://mail.python.org/pipermail/python-dev/2005-September/056669.html Sorry. -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda functions within list comprehensions

2005-10-30 Thread Max Rybinsky
OK. The thing i've got is an obscure semantic bug, occured because of my unawareness of the following Python "features": 1. (In major) http://mail.python.org/pipermail/python-dev/2005-September/056508.html 2. "late" bindings of the function's body Got to know! :) Thanks for your attention. -- h

Re: Problem with exe from py2exe

2005-10-30 Thread Andrea Gavana
Hello Martin, > My script runs fine with python, but the .exe produced with py2exe > crashes out with: > > Traceback (most recent call last): > File "App1.py", line 4, in ? > File "wx\__init__.pyc", line 42, in ? > File "wx\_core.pyc", line 3163, in ? > AttributeError: 'module' object has no

Re: Automatic binding of **kwargs to variables

2005-10-30 Thread Steven D'Aprano
On Fri, 28 Oct 2005 15:49:12 -0700, [EMAIL PROTECTED] wrote: > I have a very long list of parameters coming from a web form to my > method foo(self, **kwargs) > > I would like to avoid manually binding the variables to the values > coming through the **kwargs dictionary, That's easy: Just Don't

Re: Expanding Python as a macro language

2005-10-30 Thread has
Alex Martelli wrote: > Don't neglect MacOSX -- it's quite secure, there are many open and free > applications, AND it has a decent architecture for the kind of tasks you > want to do (mostly intended for Apple's own Applescript language, but > all the interfaces are open and easily available to Py

Re: Automatic binding of **kwargs to variables

2005-10-30 Thread Steven D'Aprano
On Sat, 29 Oct 2005 11:01:02 -0700, [EMAIL PROTECTED] wrote: > Mike Meyer wrote: > [snip] >>for name, value in kwargs.items(): >>if name in ('a', 'list', 'of', 'valid', 'keywords'): >> exec "%s = %s" % (name, value) >>else: >> raise ValueError, "Unrecognized

Re: query a port

2005-10-30 Thread Dan M
On Sat, 29 Oct 2005 23:21:16 -0700, eight02645999 wrote: > thanks alot! > that's all there is to it..so it's just a simple connect. If all you want to do is check that the given port is open on the given host, that's it. I tried it on my local box. When connecting to port 25, it made the connecti

parsing a tuple in embedded python

2005-10-30 Thread jenkins . justin
I am returning a tuple from my python method and am stuck trying to figure out how to read it into a C array using PyArg_Parse. My C Code: int array[3]; PyArg_Parse(return, "(iii)", &array); My Python Code: mytuple = (1,2,3) return mytuple That gives me a segmentation fault. What am I doing wrong

Re: dreaming in Python

2005-10-30 Thread Lasse Vågsæther Karlsen
The Eternal Squire wrote: > All, > > I have to tell all of you this, at least for some laughs. Honestly, I > had the silliest dream involving the language last night. I dreamt > that it was a decade into the future and that Grand Central Station in > NYC was installing a cement and steel "comput

Re: dreaming in Python

2005-10-30 Thread David Poundall
Sounds like someone may have the kernal of an idea for a book here ;-) -- http://mail.python.org/mailman/listinfo/python-list

Problem with exe from py2exe

2005-10-30 Thread Francach
Hi, I'm using python 2.4.1, wxPython 2.6.1.0 and py2exe 1.6.3 on Windows XP. My script runs fine with python, but the .exe produced with py2exe crashes out with: Traceback (most recent call last): File "App1.py", line 4, in ? File "wx\__init__.pyc", line 42, in ? File "wx\_core.pyc", line

Re: query a port

2005-10-30 Thread Lawrence Oluyede
Il 2005-10-30, [EMAIL PROTECTED] <[EMAIL PROTECTED]> ha scritto: > hi > in python, how do one query a port to see whether it's up or not? > thanks > Have a look at this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286240 -- Lawrence http://www.oluyede.org/blog -- http://mail.python

Re: How do I sort these?

2005-10-30 Thread bearophileHUGS
# This can be a solution: from operator import itemgetter seq1a = ([2] * 4) + ([1] * 4) seq2a = [complex(3-el,7-el) for el in range(1, 9)] assert len(seq1a) == len(seq2a) print seq1a, seq2a, "\n" mix = zip(seq1a, seq2a) # mix.sort() # Not possible mix.sort(key=itemgetter(0)) # If you need tuples

Re: How do I sort these?

2005-10-30 Thread Peter Otten
Bengt Richter wrote: > On Fri, 28 Oct 2005 20:00:42 +0100, Steve Holden <[EMAIL PROTECTED]> > wrote: > >>KraftDiner wrote: >>> I have two lists. >>> I want to sort by a value in the first list and have the second list >>> sorted as well... Any suggestions on how I should/could do this? >>> >> >>

Re: Recursive generators and backtracking search

2005-10-30 Thread Diez B. Roggisch
>>for pos in qsearch( pos ): >> yield pos > Um - do you really want to reuse the variable pos here? Yeah, it > works, but this strikes me as very confusing. I'm not sure that it > might not be implementation dependent. Certainly not. pos is - and that

Re: Scanning a file

2005-10-30 Thread Steven D'Aprano
On Sat, 29 Oct 2005 16:41:42 -0700, Alex Martelli wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >... >> I should also point out that for really serious work, the idiom: >> >> f = file("parrot") >> handle(f) >> f.close() >> >> is insufficiently robust for production level code. That was

Re: Scanning a file

2005-10-30 Thread Peter Otten
David Rasmussen wrote: > None of the solutions presented in this thread is nearly as fast as the > > print file("filename", "rb").read().count("\x00\x00\x01\x00") Have you already timed Scott David Daniels' approach with a /large/ blocksize? It looks promising. Peter -- http://mail.python.org

Re: Scanning a file

2005-10-30 Thread Fredrik Lundh
Paul Watson wrote: > This is Cyngwin on Windows XP. using cygwin to analyze performance characteristics of portable API:s is a really lousy idea. here are corresponding figures from a real operating system: using a 16 MB file: $ time python2.4 scanmap.py real0m0.080s user0m

Re: Scanning a file

2005-10-30 Thread Peter Otten
David Rasmussen wrote: > None of the solutions presented in this thread is nearly as fast as the > > print file("filename", "rb").read().count("\x00\x00\x01\x00") Have you already timed Scott David Daniel's approach with a /large/ blocksize? It looks promising. Peter -- http://mail.python.org