Re: Getting values out of a CSV

2007-07-12 Thread Daniel
On Fri, 13 Jul 2007 08:51:25 +0300, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> data = [row for row in csv.reader(open('some.csv', 'rb')) > > Note that every time you see [x for x in ...] with no condition, you can > write list(...) instead - more clear, and faster. > > data = list(csv.read

Re: Fast powerset function

2007-07-12 Thread Evan Klitzke
On 7/12/07, Evan Klitzke <[EMAIL PROTECTED]> wrote: > On 7/12/07, Arash Arfaee <[EMAIL PROTECTED]> wrote: > > I need a powerset generator function. It's really slow with recursion. Does > > anybody have any idea or code(!!) to do it in an acceptable time? > > Thanks > > -Arash > > I thought that th

Re: bool behavior in Python 3000?

2007-07-12 Thread Miles
On Jul 12, 8:37 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > I do not like that bool(False-True) is True. I've never seen the "A-B" used to represent "A and not B", nor have I seen any other operator used for that purpose in boolean algebra, though my experience is limited. Where have you seen it

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-12 Thread Hendrik van Rooyen
"Donn Cave" <[EMAIL PROTECTED]> wrote: >In its day, goto was of course very well loved. Does anybody know for sure if it is in fact possible to design a language completely free from conditional jumps? At the lower level, I don't think you can get away with conditional calls - hence the "jumps w

Re: Understanding python functions - Instant Python tutorial

2007-07-12 Thread Ben Finney
Chris Carlen <[EMAIL PROTECTED]> writes: > I don't understand Hetland's terminology though, when he is speaking > of "binding" and "reference." Actually, Hetland's entire first > paragraph is unclear. > > Can anyone reword this in a way that is understandable? I've had some success with the foll

Re: MaildirMessage

2007-07-12 Thread Ben Finney
"Gabriel Genellina" <[EMAIL PROTECTED]> writes: > msg is an instance of MaildirMessage (subclass of Message) - it has > no specific iterator, so "for m in msg" tries to use the sequence > protocol, starting at 0; that is, tries to get msg[0]. Message > objects support the mapping protocol, and msg

Re: Fast powerset function

2007-07-12 Thread Evan Klitzke
On 7/12/07, Arash Arfaee <[EMAIL PROTECTED]> wrote: > I need a powerset generator function. It's really slow with recursion. Does > anybody have any idea or code(!!) to do it in an acceptable time? > Thanks > -Arash I thought that this was a really interesting question, so I wrote up a solution th

Assignments to __class_ broken in Python 2.5?

2007-07-12 Thread samwyse
On Jul 12, 11:48 am, samwyse <[EMAIL PROTECTED]> wrote: > On Jul 12, 6:31 am,samwyse<[EMAIL PROTECTED]> wrote: > > > On Jul 8, 8:50 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > > > > With Py 2.5 I get: > > > > new.__class__ = old.__class__ > > > TypeError: __class__ must be set to a cl

Re: Getting values out of a CSV

2007-07-12 Thread Gabriel Genellina
En Fri, 13 Jul 2007 02:10:17 -0300, Daniel <[EMAIL PROTECTED]> escribió: > data = [row for row in csv.reader(open('some.csv', 'rb')) Note that every time you see [x for x in ...] with no condition, you can write list(...) instead - more clear, and faster. data = list(csv.reader(open('some.csv'

Re: Re-raising exceptions with modified message

2007-07-12 Thread Christoph Zwerschke
samwyse wrote: > TypeError: __class__ must be set to a class > > Excpt ceratinly appears to be a class. Does anyone smarter than me > know what's going on here? Not that I want to appear smarter, but I think the problem here is that exceptions are new-style classes now, whereas Empty is an old-

Re: Fast powerset function

2007-07-12 Thread Carsten Haese
On Thu, 12 Jul 2007 21:33:11 -0700, Arash Arfaee wrote > I need a powerset generator function. It's really slow with recursion. Does anybody have any idea or code(!!) to do it in an acceptable time? 1) Don't use recursion. 2) Google is your friend. -Carsten -- http://mail.python.org/mailman/

Re: Screen Scraping Question

2007-07-12 Thread Raul Laansoo
Ühel kenal päeval, K, 2007-07-11 kell 12:45, kirjutas jeffbg123: > Hey, > > I am trying to make a bot for a flash game using python. However I am > having some trouble with a screen scraping strategy. Is there an > accepted way to compare a full screenshot with the image that I want > to locate? I

Re: Most efficient way to evaluate the contents of a variable.

2007-07-12 Thread Carsten Haese
On Fri, 13 Jul 2007 06:37:19 +0200, Stargaming wrote > bdude schrieb: > > Hey, I'm new to python and am looking for the most efficient way to > > see if the contents of a variable is equal to one of many options. > > > > Cheers, > > Bryce R > > > > if var in ('-h', '--hello', '-w', '--world'): >

Re: Getting values out of a CSV

2007-07-12 Thread Daniel
On Fri, 13 Jul 2007 05:59:53 +0300, <[EMAIL PROTECTED]> wrote: > > How do I access the value in the second row in the first position of a > CSV? Or the 3rd row, in the fifth position? > > a,b,c,d,e,f,g,h,i > j,k,l,m,n,o,p,q,r > r,s,t,v,w,x,y,z > > I'd want to get at "j" and "w". I know I can do >

Re: diferent answers with isalpha()

2007-07-12 Thread Jyotirmoy Bhattacharya
On Jul 13, 5:05 am, [EMAIL PROTECTED] wrote: > In Idle when I do print 'á'.isalpha() I get True. When I make and > execute a script file with the same code I get False. > > Why do I have diferent answers ? Non-ASCII characters in ordinary (8-bit) strings have all kinds of strangeness. First, the a

how to install pygame package?

2007-07-12 Thread zaperaj
Im working in red hat linux 9.0. I've downloaded the pygame package but i dont know how to install it. If anybody has the time to detail the steps sequentially... thanx! P.S. I've downloaded both the tar and the rpm packages... -- http://mail.python.org/mailman/listinfo/python-list

Re: Most efficient way to evaluate the contents of a variable.

2007-07-12 Thread Stargaming
bdude schrieb: > Hey, I'm new to python and am looking for the most efficient way to > see if the contents of a variable is equal to one of many options. > > Cheers, > Bryce R > if var in ('-h', '--hello', '-w', '--world'): pass Most maintenance-efficient, that is. -- http://mail.python.o

Fast powerset function

2007-07-12 Thread Arash Arfaee
I need a powerset generator function. It's really slow with recursion. Does anybody have any idea or code(!!) to do it in an acceptable time? Thanks -Arash -- http://mail.python.org/mailman/listinfo/python-list

Most efficient way to evaluate the contents of a variable.

2007-07-12 Thread bdude
Hey, I'm new to python and am looking for the most efficient way to see if the contents of a variable is equal to one of many options. Cheers, Bryce R -- http://mail.python.org/mailman/listinfo/python-list

Re: access to the namespace of a function from within its invocation

2007-07-12 Thread John Nagle
Poor Yorick wrote: > In the example below, the attribute "data" is added to a function > object. There are these things called "classes" which might be useful in this situation. Python has some gratitious semantics that come with implementations in which everything is a dictionary. Do

Re: Problem with Python's "robots.txt" file parser in module robotparser

2007-07-12 Thread John Nagle
Nikita the Spider wrote: > In article <[EMAIL PROTECTED]>, > John Nagle <[EMAIL PROTECTED]> wrote: > > >>Nikita the Spider wrote: >> >> >>>Hi John, >>>Are you sure you're not confusing your sites? The robots.txt file at >>>www.ibm.com contains the double slashed path. The robots.txt file at >>

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-12 Thread John Nagle
Chris Mellon wrote: > You can't prove a program to be correct, in the sense that it's proven > to do what it's supposed to do and only what it's supposed to do. Actually, you can prove quite a bit about programs with the right tools. For example, proving that a program cannot subscript out of

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-12 Thread John Nagle
Donn Cave wrote: > In its day, goto was of course very well loved. No, it wasn't. By 1966 or so, "GOTO" was starting to look like a bad idea. It was a huge hassle for debugging. It took another decade to get the iteration constructs approximately right (FORTRAN was too restrictive, AL

access to the namespace of a function from within its invocation

2007-07-12 Thread Poor Yorick
In the example below, the attribute "data" is added to a function object. "me" can be used to get the function when it is invoked using an identifier that matches the "co_name" attribute of function's code object. Can anyone conjure an example of accessing fun2.data from without prior knowled

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Paul Rubin
Godzilla <[EMAIL PROTECTED]> writes: > Regarding to the 32-bit number, the lenght is variable but it is > usually defined at design time... That you're trying to represent it as a list of bits at all is weird, and probably likely to slow the program down. You do know that python has arbitrary siz

Crunchy release 0.9.1

2007-07-12 Thread André
Crunchy 0.9.1 has been released. It is available at http://code.google.com/p/crunchy Note that, if you have downloaded version 0.9 or version 0.9.0.1 you likely will not need to download this latest version. What is new since version 0.9? * Possibility to log selectively part of a session (as i

Re: Client-side cookies on Python in Mac OSX

2007-07-12 Thread Adrian Petrescu
Oh, you're right! Silly me, I had always thought it was standard. Thanks for pointing this out! I went and downloaded ClientCookie and it works great on OS X. And since it is BSD-licensed, I can use it in my app without any fear. Perfect. Thank you, Graham! On Jul 12, 10:28 pm, Graham Dumpleton <

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Godzilla
On Jul 13, 11:13 am, bsneddon <[EMAIL PROTECTED]> wrote: > On Jul 12, 8:49 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > On Jul 13, 10:28 am, Paul Rubin wrote: > > > > Godzilla <[EMAIL PROTECTED]> writes: > > > > > num = 255 > > > > > numlist = [num >> i & 1 for i in r

Re: Circular import problem

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 23:36:16 -0300, bvdp <[EMAIL PROTECTED]> escribió: > I'm going quite nutty here with an import problem. I've got a fairly > complicated program (about 12,000 lines in 34 modules). I just made > some "improvements" and get the following error: > > bob$ mma > Traceback (most rece

Getting values out of a CSV

2007-07-12 Thread CarpeSkium
How do I access the value in the second row in the first position of a CSV? Or the 3rd row, in the fifth position? a,b,c,d,e,f,g,h,i j,k,l,m,n,o,p,q,r r,s,t,v,w,x,y,z I'd want to get at "j" and "w". I know I can do import csv reader = csv.reader(open("some.csv", "rb")) for row in reader: print r

Re: Understanding python functions - Instant Python tutorial

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 21:51:08 -0300, Chris Carlen <[EMAIL PROTECTED]> escribió: > Hi: > > I have begun learning Python by experimenting with the code snippets > here: > > http://hetland.org/writing/instant-python.html > > In the section on functions, Magnus Lie Hetland writes: > > -

Circular import problem

2007-07-12 Thread bvdp
I'm going quite nutty here with an import problem. I've got a fairly complicated program (about 12,000 lines in 34 modules). I just made some "improvements" and get the following error: bob$ mma Traceback (most recent call last): File "/usr/local/bin/mma", line 55, in import MMA.main Fil

Re: Client-side cookies on Python in Mac OSX

2007-07-12 Thread Graham Dumpleton
On Jul 13, 12:14 pm, Adrian Petrescu <[EMAIL PROTECTED]> wrote: > Hi, all. I'm writing an app for OS X; therefore I'd prefer to use only > the default python install that comes with Tiger. For the moment, > however, this means: > > NaviOSX:~ adrianpetrescu$ python -V > Python 2.3.5 > > Therefore, I

Re: diferent answers with isalpha()

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 21:05:42 -0300, <[EMAIL PROTECTED]> escribió: > Hi, > > I have python with sys.version_info = (2, 4, 4, 'final', 0) > > In Idle when I do print 'á'.isalpha() I get True. When I make and > execute a script file with the same code I get False. > > Why do I have diferent answers ?

Client-side cookies on Python in Mac OSX

2007-07-12 Thread Adrian Petrescu
Hi, all. I'm writing an app for OS X; therefore I'd prefer to use only the default python install that comes with Tiger. For the moment, however, this means: NaviOSX:~ adrianpetrescu$ python -V Python 2.3.5 Therefore, I was not surprised to find out that cookielib did not exist here, since I knew

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-07-12 Thread Twisted
On Jul 12, 7:10 pm, Miles Bader <[EMAIL PROTECTED]> wrote: > Twisted <[EMAIL PROTECTED]> writes: > > I won't dignify your insulting twaddle and random ad-hominem verbiage > > with any more responses after this one. Something with actual logical > > argumentation to rebut may be another matter of co

Re: inspite of proper package structure, no module named xyz error.

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 16:54:24 -0300, krishnakant Mane <[EMAIL PROTECTED]> escribió: > hello all, > can some one suggest me the best solution for a package? > I have a package folder called idm and there are the following files in > there. > __init__.py which is right now empty. > mainwindow.py

Re: storing pickles in sql data base

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 14:18:11 -0300, Chris Mellon <[EMAIL PROTECTED]> escribió: > On 12 Jul 2007 06:00:59 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> > wrote: >> On Wed, 11 Jul 2007 17:14:43 -0500, Chris Mellon wrote: >> >> > [pickle] >> > >> > Protocol 0 (the default) is a text protocol,

Re: MaildirMessage

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 21:46:32 -0300, Tzury <[EMAIL PROTECTED]> escribió: > I am getting the following error when trying to iterate in a message > in a Maildir directory. > please help. > from mailbox import Maildir, MaildirMessage mbox = Maildir('path/to/mailbox', create = False, factor

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread bsneddon
On Jul 12, 8:49 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 13, 10:28 am, Paul Rubin wrote: > > > Godzilla <[EMAIL PROTECTED]> writes: > > > > num = 255 > > > > numlist = [num >> i & 1 for i in range(8)] > > > > Thanks matimus! I will look into it... > > > numlist

Re: New guy help with setup

2007-07-12 Thread star . public
On Jul 12, 5:55 pm, meg99 <[EMAIL PROTECTED]> wrote: > got the >>> prompt Type fun things at the >>> prompt, such as: >>> print 'Some Obligatroy Greeting Like "Hello World."' or >>> [x*5 for x in [1,2,3,4,5]] or >>> import os >>> os.listdir('.') >>> [os.isdir(x) for x in os.listdir('.')] A

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Paul Rubin
John Machin <[EMAIL PROTECTED]> writes: > > numlist = lookup_table[num] > > where lookup_table is a precomputed list of lists. > Ummm ... didn't the OP say he had 32-bit numbers??? He asked about 8 bit numbers. I saw something about 32-bit numbers but figured those would be split into bytes or so

Re: wx.App console window [Windows]

2007-07-12 Thread kyosohma
On Jul 12, 5:55 pm, [EMAIL PROTECTED] wrote: > On 13 Lip, 00:28, [EMAIL PROTECTED] wrote: > > > > > On Jul 12, 3:44 pm, [EMAIL PROTECTED] wrote: > > > > Hi All, > > > > I'm looking for a way to hide console window created by wx.App class. > > > > examplary code below: > > > > import wx > > > > cla

Re: 2**2**2**2**2 wrong? Bug?

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 09:30:34 -0300, Ben Finney <[EMAIL PROTECTED]> escribió: > "Gabriel Genellina" <[EMAIL PROTECTED]> writes: > >> "Which is the largest number that can be written with only 3 >> digits?" Some people stop at 999, others try 99**9 and 9**99, and >> the winner is 9**9**9 > > Sinc

Understanding python functions - Instant Python tutorial

2007-07-12 Thread Chris Carlen
Hi: I have begun learning Python by experimenting with the code snippets here: http://hetland.org/writing/instant-python.html In the section on functions, Magnus Lie Hetland writes: For those of you who understand it: When you

Re: 2**2**2**2**2 wrong? Bug?

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 07:30:05 -0300, Nick Craig-Wood <[EMAIL PROTECTED]> escribió: > Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> En Wed, 11 Jul 2007 16:39:17 -0300, Paul McGuire <[EMAIL PROTECTED]> >> escribió: >> >> > As was >> > pointed out earlier, left-associativity with exponentiation

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread John Machin
On Jul 13, 10:28 am, Paul Rubin wrote: > Godzilla <[EMAIL PROTECTED]> writes: > > > num = 255 > > > numlist = [num >> i & 1 for i in range(8)] > > > Thanks matimus! I will look into it... > > numlist = lookup_table[num] > > where lookup_table is a precomputed list of list

MaildirMessage

2007-07-12 Thread Tzury
I am getting the following error when trying to iterate in a message in a Maildir directory. please help. >>> from mailbox import Maildir, MaildirMessage >>> mbox = Maildir('path/to/mailbox', create = False, factory = MaildirMessage) >>> for msg in mbox: ... for m in msg: ... print

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Alan Isaac
> On Jul 13, 9:54 am, Matimus <[EMAIL PROTECTED]> wrote: >>num = 255 >>numlist = [num >> i & 1 for i in range(8)] Godzilla wrote: > Thanks matimus! I will look into it... Watch out for the order, which might or might not match your intent. Cheers, Alan Isaac -- http://mail.python.org/mailma

Re: bool behavior in Python 3000?

2007-07-12 Thread Alan Isaac
> Alan Isaac skrev: >>http://www.python.org/dev/peps/pep-0285/ Nis Jørgensen wrote: > You forgot to quote this bit: [4)] Actually not. That is a different point. Ben seems bothered by this, but not me. I do not mind that True+1 is 2. I won't do it, but I do not object to it being possible. I

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Paul Rubin
Godzilla <[EMAIL PROTECTED]> writes: > > num = 255 > > numlist = [num >> i & 1 for i in range(8)] > > Thanks matimus! I will look into it... numlist = lookup_table[num] where lookup_table is a precomputed list of lists. -- http://mail.python.org/mailman/listinfo/python-list

Re: atexit, sys.exit, sys.exitfunc, reaching end of source code

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 06:30:45 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > I am getting quite confused with this SystemExit. > If I register a custom sys.excepthook then it is never invoked > when I do sys.exit(.) No, sys.excepthook won't be called for SystemExit: py> help(sys) Help

diferent answers with isalpha()

2007-07-12 Thread nuno
Hi, I have python with sys.version_info = (2, 4, 4, 'final', 0) In Idle when I do print 'á'.isalpha() I get True. When I make and execute a script file with the same code I get False. Why do I have diferent answers ? Thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Godzilla
On Jul 13, 9:54 am, Matimus <[EMAIL PROTECTED]> wrote: > On Jul 12, 3:34 pm, Godzilla <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I'm trying to find a way to convert an integer (8-bits long for > > starters) and converting them to a list, e.g.: > > > num = 255 > > numList = [1,1,1,1,1,1,1,1] > >

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Matimus
On Jul 12, 3:34 pm, Godzilla <[EMAIL PROTECTED]> wrote: > Hello, > > I'm trying to find a way to convert an integer (8-bits long for > starters) and converting them to a list, e.g.: > > num = 255 > numList = [1,1,1,1,1,1,1,1] > > with the first element of the list being the least significant, so >

Re: Where does str class represent its data?

2007-07-12 Thread James Stroud
[EMAIL PROTECTED] wrote: > I guess I don't understand what benefits come from using > UserString instead of just str. I hit send without remembering to include this kind of example: from UserString import UserString as UserString class MyString(UserString): def __init__(self, astr): UserS

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-07-12 Thread Miles Bader
Twisted <[EMAIL PROTECTED]> writes: > I won't dignify your insulting twaddle and random ad-hominem verbiage > with any more responses after this one. Something with actual logical > argumentation to rebut may be another matter of course. Er, why don't you just answer his question (what version)?

Re: [Fwd: RE: Lists in classes]

2007-07-12 Thread Wildemar Wildenburger
Adam Pletcher wrote: > I'm curious (and somewhat new to Python)... What's the benefit of > inheriting from 'object'? > > The docs aren't clear on that, nor is that used in the class examples > I've seen. > Thanks in advance. > Well, they are, but they are just not well integrated. Which they, t

Re: Where does str class represent its data?

2007-07-12 Thread James Stroud
[EMAIL PROTECTED] wrote: > On Jul 11, 9:49 pm, James Stroud <[EMAIL PROTECTED]> wrote: >>The "flat is better than nested" philosophy suggests that clean should >>be module level and you should initialize a MyString like such: >> >> m = MyString(clean(s)) >> >>Where clean is >> >> def clean(ast

Re: wx.App console window [Windows]

2007-07-12 Thread siwiak
On 13 Lip, 00:28, [EMAIL PROTECTED] wrote: > On Jul 12, 3:44 pm, [EMAIL PROTECTED] wrote: > > > > > Hi All, > > > I'm looking for a way to hide console window created by wx.App class. > > > examplary code below: > > > import wx > > > class Gui(wx.App): > > def __init__(self, *pargs, **kwar

Re: How to create new files?

2007-07-12 Thread Evan Klitzke
On 7/12/07, Larry Bates <[EMAIL PROTECTED]> wrote: > sizeof() in Python is len() No, sizeof in C/C++ is not like len (len is more like strlen). For example, on my computer compiling #include #include int main(int argc, char ** argv) { char * hello = "Hello World"; printf("sizeo

[Fwd: RE: Lists in classes]

2007-07-12 Thread Wildemar Wildenburger
Another one bitten by the 'missing' reply-to munging ;) You might want to ensure that you always reply to python-list@python.org intsead of the message author. Original Message Subject:RE: Lists in classes Date: Thu, 12 Jul 2007 16:58:50 -0500 From: Adam Pletcher <[E

Fastest way to convert a byte of integer into a list

2007-07-12 Thread Godzilla
Hello, I'm trying to find a way to convert an integer (8-bits long for starters) and converting them to a list, e.g.: num = 255 numList = [1,1,1,1,1,1,1,1] with the first element of the list being the least significant, so that i can keep appending to that list without having to worry about the

Re: wx.App console window [Windows]

2007-07-12 Thread kyosohma
On Jul 12, 3:44 pm, [EMAIL PROTECTED] wrote: > Hi All, > > I'm looking for a way to hide console window created by wx.App class. > > examplary code below: > > import wx > > class Gui(wx.App): > def __init__(self, *pargs, **kwargs): > wx.App.__init__(self, *pargs, **kwargs)

Re: Function parameter type safety?

2007-07-12 Thread Steven Bethard
Robert Dailey wrote: > Is there a way to force a specific parameter in a function to be a > specific type? For example, say the first parameter in a function of > mine is required to be a string. If the user passes in an integer, I > want to notify them that they should pass in a string, not an int

Re: Class decorators do not inherit properly

2007-07-12 Thread Lee Harr
> Traceback (most recent call last): > File "/Users/chris/Projects/CMR/closed.py", line 132, in > class M0(MetropolisHastings): > File "/Users/chris/Projects/CMR/closed.py", line 173, in M0 > @_add_to_post > NameError: name '_add_to_post' is not defined > > yet, when I look at the dict

Re: Function parameter type safety?

2007-07-12 Thread Larry Bates
Robert Dailey wrote: > Hi, > > Is there a way to force a specific parameter in a function to be a > specific type? For example, say the first parameter in a function of > mine is required to be a string. If the user passes in an integer, I > want to notify them that they should pass in a string, n

Re: How to create new files?

2007-07-12 Thread Lee Harr
> So far, I've found that unlike with the C++ version of fopen(), the > Python 'open()' call does not create the file for you when opened > using the mode 'w'. I get an exception saying that the file doesn't > exist. Works for me... :~$ mkdir foo :~$ cd foo :foo$ ls :foo$ python Python 2.4.4 (#2

Re: How to create new files?

2007-07-12 Thread Larry Bates
Robert Dailey wrote: > Hi, > > I'm trying to create a Python equivalent of the C++ "ifstream" class, > with slight behavior changes. > > Basically, I want to have a "filestream" object that will allow you to > overload the '<<' and '>>' operators to stream out and stream in data, > respectively.

Re: New guy help with setup

2007-07-12 Thread Paul McNett
meg99 wrote: > On Jul 12, 4:35 pm, Paul McNett <[EMAIL PROTECTED]> wrote: >> meg99 wrote: >>> On Jul 12, 4:24 pm, Paul McNett <[EMAIL PROTECTED]> wrote: meg99 wrote: > I just downloaded 2.5 and read the readme file. It says "Before you > can build Python, you must first confiigure it.

Re: New guy help with setup

2007-07-12 Thread meg99
On Jul 12, 4:35 pm, Paul McNett <[EMAIL PROTECTED]> wrote: > meg99 wrote: > > On Jul 12, 4:24 pm, Paul McNett <[EMAIL PROTECTED]> wrote: > >> meg99 wrote: > >>> I just downloaded 2.5 and read the readme file. It says "Before you > >>> can build Python, you must first confiigure itStart by runn

Function parameter type safety?

2007-07-12 Thread Robert Dailey
Hi, Is there a way to force a specific parameter in a function to be a specific type? For example, say the first parameter in a function of mine is required to be a string. If the user passes in an integer, I want to notify them that they should pass in a string, not an integer. -- http://mail.p

Re: Where does str class represent its data?

2007-07-12 Thread ChrisEdgemon
On Jul 11, 9:49 pm, James Stroud <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I'd like to implement a subclass of string that works like this: > > m = MyString('mail') > m == 'fail' > > > True > > m == 'mail' > > > False > > m in ['fail', hail'] > > > True > > > My best

Re: New guy help with setup

2007-07-12 Thread Paul McNett
meg99 wrote: > On Jul 12, 4:24 pm, Paul McNett <[EMAIL PROTECTED]> wrote: >> meg99 wrote: >>> I just downloaded 2.5 and read the readme file. It says "Before you >>> can build Python, you must first confiigure itStart by running the >>> script "./configure". >>> I can't find "./configure" >>>

Re: New guy help with setup

2007-07-12 Thread meg99
On Jul 12, 4:24 pm, Paul McNett <[EMAIL PROTECTED]> wrote: > meg99 wrote: > > I just downloaded 2.5 and read the readme file. It says "Before you > > can build Python, you must first confiigure itStart by running the > > script "./configure". > > > I can't find "./configure" > > > I am running

Re: New guy help with setup

2007-07-12 Thread Paul McNett
meg99 wrote: > I just downloaded 2.5 and read the readme file. It says "Before you > can build Python, you must first confiigure itStart by running the > script "./configure". > > I can't find "./configure" > > I am running Windows XP SP2 You downloaded the wrong file. You want the Windows

Re: bool behavior in Python 3000?

2007-07-12 Thread Alexander Schmolck
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Expressions like (i == j) used to return 0 and 1, and it was to avoid > breaking hacks like the above that bools were implemented as a subclass of > int, not because being able to write the above was a specific feature > requested. In the hypothetical

New guy help with setup

2007-07-12 Thread meg99
I just downloaded 2.5 and read the readme file. It says "Before you can build Python, you must first confiigure itStart by running the script "./configure". I can't find "./configure" I am running Windows XP SP2 btw Python.exe gives me a black window Pythonw.exe does nothing (I assume this

How to create new files?

2007-07-12 Thread Robert Dailey
Hi, I'm trying to create a Python equivalent of the C++ "ifstream" class, with slight behavior changes. Basically, I want to have a "filestream" object that will allow you to overload the '<<' and '>>' operators to stream out and stream in data, respectively. So far this is what I have: class fi

Re: os.wait() losing child?

2007-07-12 Thread Hrvoje Niksic
Nick Craig-Wood <[EMAIL PROTECTED]> writes: >> This can still be a problem for applications that call wait in a >> dedicated thread, but the program can always ignore the processes >> it doesn't know anything about. > > Ignoring them isn't good enough because it means that the bit of > code whi

Re: os.wait() losing child?

2007-07-12 Thread Jason Zheng
Nick Craig-Wood wrote: > Sure! > > You could get rid of this by sleeping until a SIGCHLD arrived maybe. Yah, I could also just dump Popen class and use fork(). But then what's the point of having an abstraction layer any more? >> This can still be a problem for applications that call wait in a

wx.App console window [Windows]

2007-07-12 Thread siwiak
Hi All, I'm looking for a way to hide console window created by wx.App class. examplary code below: import wx class Gui(wx.App): def __init__(self, *pargs, **kwargs): wx.App.__init__(self, *pargs, **kwargs) if __name__ == "__main__": app = Gui() app.MainLoop()

Re: bool behavior in Python 3000?

2007-07-12 Thread Bjoern Schliessmann
Steven D'Aprano wrote: > It seems to me that you deliberately misunderstood him. I know for sure I didn't. > Why else would you type-cast the integers 2 and 1 to bools to > supposedly demonstrate that there's nothing wrong with operations > between bools returning ints? Kindly excuse me bother

Re: bool behavior in Python 3000?

2007-07-12 Thread Bjoern Schliessmann
Alan Isaac wrote: > Bjoern Schliessmann wrote: >> Is there any type named "bool" in standard Python? type(True) > Thanks anyway, but I remembered it shortly after sending. Thus the cancel (seems to have failed a bit). Regards, Björn -- BOFH excuse #384: it's an ID-10-T error -- ht

Best way to add values from keys

2007-07-12 Thread robinsiebler
I have a data structure that looks like this: dates = {}; last_song = [] #; year = {}; week = {}; date = {}; artist = []; song = {} #dates = {'2007': {'25': {'06/23/07': {'aerosmith': [{'sweet emotion': 1}, {'dream on': 2}], # 'Metallica': [{'Fade t

DBXML and the Xerces DOM

2007-07-12 Thread nikki
I downloaded Berkeley DB XML and put together a test script to load a large 250mb XML file into the database. Storage and retrieval works great, but I need DOM access to the file without loading it all into a string and re-parsing it. In the c++ api (they used swig to expose c+ + to python) it sa

Re: bash-style pipes in python?

2007-07-12 Thread Dan Stromberg - Datallegro
On Wed, 11 Jul 2007 20:55:48 -0700, faulkner wrote: > On Jul 11, 8:56 pm, Dan Stromberg - Datallegro > <[EMAIL PROTECTED]> wrote: >> I'm constantly flipping back and forth between bash and python. >> >> Sometimes, I'll start a program in one, and end up recoding in the >> other, or including a bun

inspite of proper package structure, no module named xyz error.

2007-07-12 Thread krishnakant Mane
hello all, can some one suggest me the best solution for a package? I have a package folder called idm and there are the following files in there. __init__.py which is right now empty. mainwindow.py which has a single class called MainWindow which is an MDI Parent frame from wxpython. student.py wh

Re: web page text extractor

2007-07-12 Thread kublai
On Jul 13, 2:19 am, Stefan Behnel <[EMAIL PROTECTED]> wrote: > kublai wrote: > > For a project, I need to develop a corpus of online news stories. I'm > > looking for an application that, given the url of a web page, "copies" > > the rendered text of the web page (not the source HTNL text), opens

Re: os.wait() losing child?

2007-07-12 Thread Matthew Woodcraft
Jason Zheng <[EMAIL PROTECTED]> wrote: >Hrvoje Niksic wrote: >> Actually, it's not that bad. _cleanup only polls the instances that >> are no longer referenced by user code, but still running. If you hang >> on to Popen instances, they won't be added to _active, and __init__ >> won't reap them (

Re: profiling a C++ python extension

2007-07-12 Thread Matthew Woodcraft
rasmus <[EMAIL PROTECTED]> wrote: > I have used gprof to profile stand alone C++ programs. I am also > aware of pure python profilers. However, is there a way to get > profile information on my C++ functions when they are compiled in a > shared library (python extension module) and called from p

Class decorators do not inherit properly

2007-07-12 Thread Chris Fonnesbeck
I have a class that does MCMC sampling (Python 2.5) that uses decorators -- one in particular called _add_to_post that appends the output of the decorated method to a class attribute. However, when I subclass this base class, the decorator no longer works: Traceback (most recent call last): F

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-12 Thread Paul Rubin
"Chris Mellon" <[EMAIL PROTECTED]> writes: > You can't prove a program to be correct, in the sense that it's proven > to do what it's supposed to do and only what it's supposed to do. You > can prove type-correctness, and the debate is really over the extent > that a type-correct program is also be

Re: lists and dictionaries

2007-07-12 Thread Ladislav Andel
Thank you to all of you guys. It's exactly I was looking for. Lada Bart Ogryczak wrote: > On 12 jul, 04:49, anethema <[EMAIL PROTECTED]> wrote: > >>> li = [ {'index': 0, 'transport': 'udp', 'service_domain': >>> 'dp0.example.com'}, >>> {'index': 1, 'transport': 'udp', 'service_domain

Re: Lists in classes

2007-07-12 Thread Bruno Desthuilliers
Alex Popescu a écrit : (snip) > > You are defining the list in the class context and so it becomes a > class field/member. 'attribute' is the pythonic term. -- http://mail.python.org/mailman/listinfo/python-list

Re: lists and dictionaries

2007-07-12 Thread Ladislav Andel
Thank you to all of you guys. It's exactly I was looking for. > You provide scant information for this task. For example, is the > new list ordered or unordered? Can the list corresponding to the > 'transports' key contain duplicates? > unordered is fine.. I will be storing it in DB from that

Re: asyncore and OOB data

2007-07-12 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, billiejoex <[EMAIL PROTECTED]> writes: > Douglas Wells wrote: > > > Second, when I look at the FTP specification, I don't find the > > concept of OOB anywhere. So, it's not clear what OOB data would > > mean in terms of the defined FTP commands in any case. > > S

Re: asyncore and OOB data

2007-07-12 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> writes: > Douglas Wells wrote: > > > > Third, the TCP protocol, which you have selected via the SOCK_STREAM > > option doesn't support OOB at all, so there's no way that you can > > even send OOB data in the manner that you are expec

Re: Problem with Python's "robots.txt" file parser in module robotparser

2007-07-12 Thread Nikita the Spider
In article <[EMAIL PROTECTED]>, John Nagle <[EMAIL PROTECTED]> wrote: > Nikita the Spider wrote: > > > > > Hi John, > > Are you sure you're not confusing your sites? The robots.txt file at > > www.ibm.com contains the double slashed path. The robots.txt file at > > ibm.com is different and c

Re: os.wait() losing child?

2007-07-12 Thread Nick Craig-Wood
Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > >> I think your polling way works; it seems there no other way around this > >> problem other than polling or extending Popen class. > > > > I think polling is probably the right way of doing it... > >

  1   2   >