Re: is there any overheard with try/except statements?

2006-03-08 Thread Steve Holden
Delaney, Timothy (Tim) wrote: [...] > > Generally, you should always go for whatever is clearest/most easily > read (not just in Python, but in all languages). +1 QOTW regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Lo

Re: encoding problem

2006-03-08 Thread Yves Glodt
Sebastjan Trepca wrote: > I think you are trying to concatenate a unicode string with regular > one so when it tries to convert the regular string to unicode with > ASCII(default one) encoding it fails. First find out which of these > strings is regular and how it was encoded, then you can decode i

Re: a question about zip...

2006-03-08 Thread Steve Holden
KraftDiner wrote: > I had a structure that looked like this > ((0,1), (2, 3), (4, 5), (6,7) > > I changed my code slightly and now I do this: > odd = (1,3,5,7) > even = (0,2,4,6) > all = zip(even, odd) > > however the zip produces: > [(0, 1), (2, 3), (4, 5), (6, 7)] > > Which is a list of tuples

Re: advice on this little script

2006-03-08 Thread Steve Holden
Paul Rubin wrote: > John Salerno <[EMAIL PROTECTED]> writes: > >>>for x in range(minutes,0,-1): >>>sleep(60.0) >>>print minutes, 'minutes remaining' >>> >> >>Nice! Cross off another line! I feel like Hemingway. :) > > > Besides the bug mentioned, I don't think you should really do it th

Re: [wxpython] StaticBoxSizer problems

2006-03-08 Thread Steve Holden
Matthias Kluwe wrote: > Hi! > > I'd like to place several StaticBoxes in a frame, but I can't get it > right. > > Consider the following code: > > import wx > > app = wx.PySimpleApp() > frame = wx.Frame(parent=None, title="Test") > box = wx.BoxSizer(wx.VERTICAL) > frame.SetSizer(box) > upper_bo

Re: Type Hinting vs Type Checking and Preconditions

2006-03-08 Thread Alex Martelli
Jay Parlar <[EMAIL PROTECTED]> wrote: > class A(object): > def foo(self): > print "bar" > > class B(object): > def foo(self): > print "bar" > > def typedfunction(x : A): > x.foo() > > b = B() > typedfunction(b) #Your system would probably consider this an error

Re: Extending embedded Python: Adding single methods

2006-03-08 Thread Thomas Heller
Torsten Bronger wrote: > Hallöchen! > > Thomas Heller <[EMAIL PROTECTED]> writes: > >> Torsten Bronger wrote: >> >>> [...] However, is there a way to avoid this dummy "pp3" module >>> and add the C++ functions directy to the main namespace in the >>> Python script? >> Yes. You can import __buil

Re: Python advocacy in scientific computation

2006-03-08 Thread Michael McNeil Forbes
Robert Kern <[EMAIL PROTECTED]> writes: > sturlamolden wrote: ... > > 5. Versioning control? For each program there is only one > > developer and a single or a handful users. ... > This is one thing that a lot of people seem to get wrong: version > control is not a burden on software development. I

Re: is there any overheard with try/except statements?

2006-03-08 Thread Alex Martelli
John Salerno <[EMAIL PROTECTED]> wrote: > John Salerno wrote: > > One of the things I learned with C# is that it's always better to handle > > any errors that might occur within the codes itself (i.e. using if > > statements, etc. to catch potential out of range indexing) rather than > > use too

Re: PyGUI 1.6: A Note for MacOSX Users

2006-03-08 Thread Alex Martelli
Greg Ewing <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-pa > > ckages/GUI/Cocoa/Applications.py", line 184, in init_application_name > > ns_info['CFBundleName'] = GApplications.application_name > > TypeError: obj

Re: advice on this little script

2006-03-08 Thread Alex Martelli
John Salerno <[EMAIL PROTECTED]> wrote: ... > I think the 'from time import sleep' looks cleaner, because I'm only > taking what I need (is an import any more expensive than this from?), > but I also feel like the 'time.sleep' syntax is much more > self-describing and better to read than just

Re: advice on this little script

2006-03-08 Thread Alex Martelli
Grant Edwards <[EMAIL PROTECTED]> wrote: ... > > Nice! Cross off another line! I feel like Hemingway. :) > > Was he the one who once apologized to his editor for a story > being so long because he was in a hurry and didn't have time to > make it shorter? Nope, that immortal quote is by Blaise

Re: httplib raises ValueError reading chunked content

2006-03-08 Thread Philip Semanchuk
On Mar 8, 2006, at 8:32 PM, Etienne Desautels wrote: > > Hi Philip, > >> Hi all, >> Has anyone ever seen Python 2.4.1's httplib choke when reading chunked >> content? > > Yes, it's a know bug. See for yourself: > https://sourceforge.net/tracker/? > func=detail&atid=305470&aid=900744&group_id=547

Re: why no block comments in Python?

2006-03-08 Thread Paddy
I have found that some editors colourize text based on parsing a section of text around what is visible. Long, multi-line comments or strings might not then get colored correctly. Personally, I do use block comments in other languages but maybe they should not exist in finished code for reasons al

Re: Gathering screen output

2006-03-08 Thread Fredrik Lundh
Greg Lindstrom wrote: > I'm running Python 2.4 on windows xp "professional" and seem to recall there > is a way to kick off system command (or any external routine) and then > collect the screen output back into the calling python routine for > analysis. I've look and googled but have come up lac

Re: advice on this little script

2006-03-08 Thread Paul Rubin
John Salerno <[EMAIL PROTECTED]> writes: > > for x in range(minutes,0,-1): > > sleep(60.0) > > print minutes, 'minutes remaining' > > > Nice! Cross off another line! I feel like Hemingway. :) Besides the bug mentioned, I don't think you should really do it that way, since sleep(60.0) migh

Re: advice on this little script

2006-03-08 Thread John Salerno
James Stroud wrote: > John Salerno wrote: >> Grant Edwards wrote: >> >>> On 2006-03-09, John Salerno <[EMAIL PROTECTED]> wrote: >>> from time import sleep minutes = input('Enter the number of minutes to wait: ') for x in range(minutes): sleep(1.0) minutes

Re: advice on this little script

2006-03-08 Thread Benjamin Liebald
John Salerno wrote: >> for x in range(minutes,0,-1): >> sleep(60.0) >> print minutes, 'minutes remaining' >> > > I might be doing something wrong, but this just keeps printing out '10 > minutes remaining' each time. should be: for x in range(minutes,0,-1): sleep(60.0) print x,

Re: advice on this little script

2006-03-08 Thread James Stroud
John Salerno wrote: > Grant Edwards wrote: > >> On 2006-03-09, John Salerno <[EMAIL PROTECTED]> wrote: >> >>> from time import sleep >>> >>> minutes = input('Enter the number of minutes to wait: ') >>> >>> for x in range(minutes): >>> sleep(1.0) >>> minutes -= 1 >>> print minutes, 'min

Re: advice on this little script

2006-03-08 Thread John Salerno
Ben Cartwright wrote: > BartlebyScrivener wrote: >> What about a console beep? How do you add that? >> >> rpd > > Just use ASCII code 007 (BEL/BEEP): > > >>> import sys > >>> sys.stdout.write('\007') > > Or if you're on Windows, use the winsound standard module. > > --Ben > I'd prefer to

Re: grayscale pixel based graphics with pygame

2006-03-08 Thread Kamilche
import pygame def main(): SIZE = (300, 200) WHITE = (255, 255, 255) pygame.init() # Create a new grayscale surface pic = pygame.Surface(SIZE, 0, 8) palette = tuple([(i, i, i) for i in range(256)]) pic.set_palette(palette) # Fill it with a gradient array = pyga

Re: grayscale pixel based graphics with pygame

2006-03-08 Thread Terry Reedy
"Brian L. Troutwine" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I've recently begun to teach myself pygame by making a bunch of small > toys. My current toy is cellular automata displayer and I've gotten a > bit stuck on the displaying bit. (If automata isn't the plural of > au

Re: advice on this little script

2006-03-08 Thread John Salerno
Grant Edwards wrote: > On 2006-03-09, John Salerno <[EMAIL PROTECTED]> wrote: > >> from time import sleep >> >> minutes = input('Enter the number of minutes to wait: ') >> >> for x in range(minutes): >> sleep(1.0) >> minutes -= 1 >> print minutes, 'minutes remaining.' > > for x in

Re: question about slicing with a step length

2006-03-08 Thread Terry Reedy
> John Salerno wrote: >> Given: > > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > can someone explain to me why > > numbers[10:0:-2] results in [10, 8, 6, 4, 2]? It appears that s[i:j:-1] is s[(j+1):(i+1)] .reverse()'ed. For 'numbers', this is 10, 9, 8, 7, 6, 5, 4, 3, 2]. Then take every other i

Re: advice on this little script

2006-03-08 Thread John Salerno
Grant Edwards wrote: > Was he the one who once apologized to his editor for a story > being so long because he was in a hurry and didn't have time to > make it shorter? Hmm, not sure. He doesn't seem like the type to apologize, or even have long stories. :) He was ruthless with his edits, that'

Re: advice on this little script

2006-03-08 Thread Grant Edwards
On 2006-03-09, John Salerno <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: >> On 2006-03-09, John Salerno <[EMAIL PROTECTED]> wrote: >> >>> from time import sleep >>> >>> minutes = input('Enter the number of minutes to wait: ') >>> >>> for x in range(minutes): >>> sleep(1.0) >>> minutes

Re: advice on this little script

2006-03-08 Thread Ben Cartwright
BartlebyScrivener wrote: > What about a console beep? How do you add that? > > rpd Just use ASCII code 007 (BEL/BEEP): >>> import sys >>> sys.stdout.write('\007') Or if you're on Windows, use the winsound standard module. --Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: advice on this little script

2006-03-08 Thread John Salerno
John Salerno wrote: > from time import sleep ... > sleep(1.0) Very picky point, but I'd like to know what others think of this. Should I import as above, or should I do this: import time time.sleep(60.0) ??? I think the 'from time import sleep' looks cleaner, because I'm only tak

Re: advice on this little script

2006-03-08 Thread John Salerno
Grant Edwards wrote: > On 2006-03-09, John Salerno <[EMAIL PROTECTED]> wrote: > >> from time import sleep >> >> minutes = input('Enter the number of minutes to wait: ') >> >> for x in range(minutes): >> sleep(1.0) >> minutes -= 1 >> print minutes, 'minutes remaining.' > > for x in

Re: advice on this little script

2006-03-08 Thread John Salerno
BartlebyScrivener wrote: > What about a console beep? How do you add that? > > rpd > Ooh, good point! I forgot about the most important part, otherwise I'd never know it was done and someone would steal my clothes! :) Time to do some library reference research -- http://mail.python.org/m

Re: advice on this little script

2006-03-08 Thread John Salerno
James Stroud wrote: > Very nice, but maybe > > ... >sleep(60.0) > > This corrects for the number of seconds in a minute. > > James > Thanks! And yeah, I fixed that little issue. If only laundry could be done that fast. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: advice on this little script

2006-03-08 Thread Grant Edwards
On 2006-03-09, John Salerno <[EMAIL PROTECTED]> wrote: > from time import sleep > > minutes = input('Enter the number of minutes to wait: ') > > for x in range(minutes): > sleep(1.0) > minutes -= 1 > print minutes, 'minutes remaining.' for x in range(minutes,0,-1): sleep(60.

Re: Removing .DS_Store files from mac folders

2006-03-08 Thread Greg Ewing
David Pratt wrote: > Hi Ben. I hadn't realize that walk was just giving the file name so the > join did the job just great. I don't think that deleting the .DS_Store files is the right approach to this, for various reasons: * You're messing with MacOSX's metadata, which is not a nice thing t

Re: advice on this little script

2006-03-08 Thread BartlebyScrivener
What about a console beep? How do you add that? rpd -- http://mail.python.org/mailman/listinfo/python-list

Re: generators shared among threads

2006-03-08 Thread jess . austin
I just noticed, if you don't define maxsize in _init(), you need to override _full() as well: def _full(self): return False cheers, Jess -- http://mail.python.org/mailman/listinfo/python-list

Re: advice on this little script

2006-03-08 Thread James Stroud
John Salerno wrote: > My first project when I started learning C# was to make a little timer > to tell me when my laundry was done :) and I thought it would be fun to > convert this to Python. Here's what I came up with after much struggling > with the Timer class from the threading module -- as

Re: advice on this little script

2006-03-08 Thread John Salerno
John Salerno wrote: > sleep(1.0) Heh heh, that was for testing. Obviously it should read 60.0 (is a float necessary at all?). -- http://mail.python.org/mailman/listinfo/python-list

advice on this little script

2006-03-08 Thread John Salerno
My first project when I started learning C# was to make a little timer to tell me when my laundry was done :) and I thought it would be fun to convert this to Python. Here's what I came up with after much struggling with the Timer class from the threading module -- as you can see, I abandoned i

Re: question about slicing with a step length

2006-03-08 Thread John Salerno
André wrote: > An extended slice of list x of length n in the form x[j:k:i] selects > every i-th element starting with and including the element at index j This makes it sound like the index of 10 should be inclusive. > When either index is missing or lies outside of the > list bounds, the mini

Re: PyGUI 1.6: A Note for MacOSX Users

2006-03-08 Thread Greg Ewing
Alex Martelli wrote: > "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-pa > ckages/GUI/Cocoa/Applications.py", line 184, in init_application_name > ns_info['CFBundleName'] = GApplications.application_name > TypeError: object does not support item assignment You need to r

Re: Python advocacy in scientific computation

2006-03-08 Thread Greg Ewing
Peter Maas wrote: > This is hard to understand for an outsider. If you pass an int, a float, > a string or any other "atomic" object to a function you have "pass by > value" semantics. If you put a compound object like a list or a dictionary > or any other object that acts as an editable data cont

Re: Python advocacy in scientific computation

2006-03-08 Thread Greg Ewing
Andy Salnikov wrote: > Actually os.system() is rather poor replacement for the shell's > capabilities, and it's _very_ low level, it's really a C-level code > wrapped in Python syntax. Since os.system() spawns a shell to execute the command, it's theoretically capable of anything that the shell c

Re: reading float from binary data file

2006-03-08 Thread Peter Hansen
cesco wrote: > I have a binary file containing 1000 floating point numbers. I want to > load that file into an array. A way to do it could be the following: > import array data = array.array('f') f = open('FileName.bin', 'rb') data.fromfile(f, 1000) > > Now I have the following pr

Re: Python advocacy in scientific computation

2006-03-08 Thread Greg Ewing
Andy Salnikov wrote: > I saw lots of awk or sed "code" embedded in scripts In my experience, embedding any of make/sh/awk/sed in any of the others is a nightmare of singlequote/ doublequote/backslash juggling that makes a few tab/space problems in Python pale by comparison. -- Greg Ewing, Comput

Re: Send email notification

2006-03-08 Thread Peter Hansen
Dennis Lee Bieber wrote: > On Wed, 08 Mar 2006 06:20:42 +, Steve Holden <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >>Hang around here long and you'll see a bunch of people waiting on >>replies to questions Google could have given them far quicker. If we >>weren't pa

Gathering screen output

2006-03-08 Thread Greg Lindstrom
Hello- I'm running Python 2.4 on windows xp "professional" and seem to recall there is a way to kick off system command (or any external routine) and then collect the screen output back into the calling python routine for analysis.  I've look and googled but have come up lacking.  Please tell me t

grayscale pixel based graphics with pygame

2006-03-08 Thread Brian L. Troutwine
I've recently begun to teach myself pygame by making a bunch of small toys. My current toy is cellular automata displayer and I've gotten a bit stuck on the displaying bit. (If automata isn't the plural of automaton please forgive me.) The current automata are only binary and are calculated using 2

Re: question about slicing with a step length

2006-03-08 Thread André
Steven D'Aprano wrote: > John Salerno wrote: > > > Given: > > > > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > > > can someone explain to me why > > > > numbers[10:0:-2] results in [10, 8, 6, 4, 2]? > > I think the documentation is misleading/incomplete when > it comes to negative strides for ext

Re: question about slicing with a step length

2006-03-08 Thread James Stroud
John Salerno wrote: > James Stroud wrote: > >> John Salerno wrote: >> >>> Given: >>> >>> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> >>> can someone explain to me why >>> >>> numbers[10:0:-2] results in [10, 8, 6, 4, 2]? >>> >>> I thought the first index, whether going forward or backward, was

Re: question about slicing with a step length

2006-03-08 Thread Steven D'Aprano
John Salerno wrote: > Given: > > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > can someone explain to me why > > numbers[10:0:-2] results in [10, 8, 6, 4, 2]? I think the documentation is misleading/incomplete when it comes to negative strides for extended slices. The relevent sections are h

Re: httplib raises ValueError reading chunked content

2006-03-08 Thread Etienne Desautels
Hi Philip, > Hi all, > Has anyone ever seen Python 2.4.1's httplib choke when reading chunked > content? Yes, it's a know bug. See for yourself: https://sourceforge.net/tracker/? func=detail&atid=305470&aid=900744&group_id=5470 Etienne > I'm using it via urrlib2, and I ran into a particular s

Re: is there any overheard with try/except statements?

2006-03-08 Thread John Salerno
John Salerno wrote: > One of the things I learned with C# is that it's always better to handle > any errors that might occur within the codes itself (i.e. using if > statements, etc. to catch potential out of range indexing) rather than > use too many try/catch statements, because there is some

Re: question about slicing with a step length

2006-03-08 Thread John Salerno
James Stroud wrote: > John Salerno wrote: >> Given: >> >> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >> >> can someone explain to me why >> >> numbers[10:0:-2] results in [10, 8, 6, 4, 2]? >> >> I thought the first index, whether going forward or backward, was >> inclusive. And there is no index of

Re: question about slicing with a step length

2006-03-08 Thread Steven Bethard
John Salerno wrote: > Given: > > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > can someone explain to me why > > numbers[10:0:-2] results in [10, 8, 6, 4, 2]? I always have trouble with these. Given the docs[1]: """ The slice of s from i to j with step k is defined as the sequence of items w

Re: question about slicing with a step length

2006-03-08 Thread James Stroud
John Salerno wrote: > Given: > > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > can someone explain to me why > > numbers[10:0:-2] results in [10, 8, 6, 4, 2]? > > I thought the first index, whether going forward or backward, was > inclusive. And there is no index of 10 in this list, so what is

RE: is there any overheard with try/except statements?

2006-03-08 Thread Delaney, Timothy (Tim)
Steven D'Aprano wrote: > The classic example of the "look before you leap" and > "just do it" idioms involves looking up a key in a > dictionary: > > # method one > if some_dict.has_key(key): > do_something_with(some_dict[key]) > else: > do_something_else() FWIW, in recent Python versi

Re: why no block comments in Python?

2006-03-08 Thread Terry Hancock
On Wednesday 08 March 2006 12:42 pm, Warby wrote: > The danger with block comments is that there is no way to tell that the > code you're looking at has been commented out unless you can see the > start or end of the comment block. If you have a modern editor, it > probably changes the color of al

Re: Problem Solving Skills for Engineers

2006-03-08 Thread Paul Rubin
[EMAIL PROTECTED] writes: > I have been a software developer for the past 10 years now. I get job > descriptions that requires problem-solving skills as one of the most > desirable skills in a candidate. But there are not many resources that > is devoted to this topic. > > So, I have created a web

Problem Solving Skills for Engineers

2006-03-08 Thread bparanj
Hello, I have been a software developer for the past 10 years now. I get job descriptions that requires problem-solving skills as one of the most desirable skills in a candidate. But there are not many resources that is devoted to this topic. So, I have created a website for problem solving skill

Re: Interfacing with the command line

2006-03-08 Thread Terry Hancock
On Wednesday 08 March 2006 09:35 am, Byte wrote: > I know its possible to acsess Python via the command line, but can I do > the opposite and acsess the command line via Python? For example, can I > write a script that will enter > > $ firefox > > on the command line, opening Firefox for me? You

Re: is there any overheard with try/except statements?

2006-03-08 Thread Steven D'Aprano
John Salerno wrote: > One of the things I learned with C# is that it's always better to handle > any errors that might occur within the codes itself (i.e. using if > statements, etc. to catch potential out of range indexing) rather than > use too many try/catch statements, because there is some

Re: is there any overheard with try/except statements?

2006-03-08 Thread Roy Smith
In article <[EMAIL PROTECTED]>, John Salerno <[EMAIL PROTECTED]> wrote: > One of the things I learned with C# is that it's always better to handle > any errors that might occur within the codes itself (i.e. using if > statements, etc. to catch potential out of range indexing) rather than > use

Re: is there any overheard with try/except statements?

2006-03-08 Thread Paul McNett
John Salerno wrote: > One of the things I learned with C# is that it's always better to handle > any errors that might occur within the codes itself (i.e. using if > statements, etc. to catch potential out of range indexing) rather than > use too many try/catch statements, because there is some

is there any overheard with try/except statements?

2006-03-08 Thread John Salerno
One of the things I learned with C# is that it's always better to handle any errors that might occur within the codes itself (i.e. using if statements, etc. to catch potential out of range indexing) rather than use too many try/catch statements, because there is some overhead every time the pro

question about slicing with a step length

2006-03-08 Thread John Salerno
Given: numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] can someone explain to me why numbers[10:0:-2] results in [10, 8, 6, 4, 2]? I thought the first index, whether going forward or backward, was inclusive. And there is no index of 10 in this list, so what is it referring to? Thanks. -- http://m

Re: a question about zip...

2006-03-08 Thread Steven D'Aprano
KraftDiner wrote: > I had a structure that looked like this > ((0,1), (2, 3), (4, 5), (6,7) > > I changed my code slightly and now I do this: > odd = (1,3,5,7) > even = (0,2,4,6) > all = zip(even, odd) > > however the zip produces: > [(0, 1), (2, 3), (4, 5), (6, 7)] > > Which is a list of tuple

Re: help

2006-03-08 Thread Steven D'Aprano
Steve Holden wrote: > Alexander wrote: > >> hi, my name is alexander. i'm from indonesia >> i wanna ask, is there Pygoogle with GUI? because i've got assignment >> from my teacher to make an user interface for Pygoogle. if there's a >> Pygoogle with GUI, can u tell me where to find it. >> > So "m

Re: Checking function calls

2006-03-08 Thread James Stroud
Fredrik Tolf wrote: > On Mon, 2006-03-06 at 20:25 -0800, James Stroud wrote: > >>Fredrik Tolf wrote: >> >>>If I have a variable which points to a function, can I check if certain >>>argument list matches what the function wants before or when calling it? >>> >>>Currently, I'm trying to catch a Typ

httplib raises ValueError reading chunked content

2006-03-08 Thread philip20060308
Hi all, Has anyone ever seen Python 2.4.1's httplib choke when reading chunked content? I'm using it via urrlib2, and I ran into a particular server that returns something that httplib doesn't expect. Specifically, in the code below where the error occurs, line == ''. Python 2.4.1 (#2, Oct 12 2005

RE: Simple questions on use of objects (probably faq)

2006-03-08 Thread Delaney, Timothy (Tim)
Max M wrote: > decorated = [(obj.x, obj) for obj in objects] > max_decorated = max(decorated) > max_obj = max_decorated[-1] Python 2.5 will make this even easier - max() and min() aquire a `key` keyword parameter much like list.sort()/sorted(). max_obj = max(objects, key=operator.attrgetter(

Re: python debugging question

2006-03-08 Thread P Boy
Install active python from http://activestate.com/Products/ActivePython/?mp=1 Run PythonWin for: coding, interactive commands, and debugging. Good luck. -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking function calls

2006-03-08 Thread James Stroud
Fredrik Tolf wrote: > On Mon, 2006-03-06 at 20:25 -0800, James Stroud wrote: > >>Fredrik Tolf wrote: >> >>>If I have a variable which points to a function, can I check if certain >>>argument list matches what the function wants before or when calling it? >>> >>>Currently, I'm trying to catch a Typ

Re: Python advocacy in scientific computation

2006-03-08 Thread Andy Salnikov
"Michael Tobis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I think I agree with Steve here. > > I suspect you should either have sufficiently trained your users in > Python, or have limited them to one-line statements which you could > then strip of leading whitespace before pas

Re: Extending embedded Python: Adding single methods

2006-03-08 Thread Torsten Bronger
Hallöchen! Thomas Heller <[EMAIL PROTECTED]> writes: > Torsten Bronger wrote: > >> [...] However, is there a way to avoid this dummy "pp3" module >> and add the C++ functions directy to the main namespace in the >> Python script? > > Yes. You can import __builtin__, and add methods to it. This

Re: reading float from binary data file

2006-03-08 Thread Diez B. Roggisch
cesco schrieb: > Hi, > > I have a binary file containing 1000 floating point numbers. I want to > load that file into an array. A way to do it could be the following: > import array data = array.array('f') f = open('FileName.bin', 'rb') data.fromfile(f, 1000) > > Now I have t

Re: Python advocacy in scientific computation

2006-03-08 Thread Andy Salnikov
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Andy Salnikov wrote: >> "Michael Tobis" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >>> >>>When you say "all kinds" of inlined code, do you have any other >>>examples besides HTML? >>> >> >> Make

Re: RAD tutorials and tools for GUI development with Python?

2006-03-08 Thread Ravi Teja
Jarek Zgoda wrote: > Michael Ekstrand napisa³(a): > > > Glade + PyGTK + libglade does the trick. libglade (exposed as gtk.glade > > in Python) allows you to load Glade interface files (the raw XML Glade > > saves your interfaces as) and then connect to various signals, access > > the widgets, etc.

reading float from binary data file

2006-03-08 Thread cesco
Hi, I have a binary file containing 1000 floating point numbers. I want to load that file into an array. A way to do it could be the following: >>> import array >>> data = array.array('f') >>> f = open('FileName.bin', 'rb') >>> data.fromfile(f, 1000) Now I have the following problem: if I don't

Re: New python.org website

2006-03-08 Thread Kay Schluehr
Michael Tobis wrote: > > No one > > of the complainers and negativists do claim that they could do it much > > better. > > Indeed, I do not have to be able to write a particular program to > notice it has bugs. > > On the other hand, (since I think the design, while not brilliant, is > good) fixin

Re: %r

2006-03-08 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Blackbird wrote: > By "cargo cult programming", do you mean actually *running* the code? http://www.catb.org/~esr/jargon/html/C/cargo-cult-programming.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-08 Thread Ralf Muschall
Douglas Alan wrote: > Experienced Lisp programmers use indentation to visually parse the > program structure, just like Python programmers do for Python. > Experienced Lisp programmers learn to not see the parentheses when > they don't need to. True, and this is IMHO an advantage of lisp to pytho

Re: Bidirectional communication over unix socket (named pipe)

2006-03-08 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "J Rice" <[EMAIL PROTECTED]> wrote: > Hi Donn, > Not sure I fully understand your suggestion. bind() only works once -- > I can't bind again in the client. Same thing with connect() -- once I > issue a connect in the server, it rejects it in the client. > > Doin

Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-08 Thread Douglas Alan
"Carl Banks" <[EMAIL PROTECTED]> writes: > Douglas Alan wrote: > >> For instance, if Python were to have been designed so that you would >> write: >> >>let myVeryLongVariableName = 3 >> >> I would have preferred this over >> >>myVeryLongVariableName = 3 >> >> With the latter, I have to sca

Re: cgi problem

2006-03-08 Thread Paul Rubin
Thomas Guettler <[EMAIL PROTECTED]> writes: > > back to the originating url, i.e. I want the cgi to send a 302 redirect. > > I have this setup for a small script (for bigger things I use quixote)... Thanks. It looks like you've written your cgi completely from scratch. I was hoping to use the cg

Re: help

2006-03-08 Thread Jordan Greenberg
I see no problem with finding existing code on the Internet and used to learn a subject, so long as it isn't just stolen and handed in as is. I guess I still believe people are good, no matter how hard Usenet and IRC tries to convince me otherwise. -- http://mail.python.org/mailman/listinfo/pyth

Re: using PyShell, or other shells?

2006-03-08 Thread André
John Salerno wrote: > I'm interested in trying out shells other than IDLE, and I found > PyShell, but I'm not sure how to get it exactly. Is there a way to get > it without installing wxPython, or is it a part of it? I can't find much > reference to it in any of the manuals at wxpython.org (except

Re: python debugging question

2006-03-08 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > I am a python newbie. I have writen some 500 lines of code. There are 4 > classes and in all 5 files. > > Now, I am trying to run the program. I am getting wrong values for the > simulation results. > Is there any debugging facilities in python which would let me go step

Re: python debugging question

2006-03-08 Thread Thomas G. Willis
On 8 Mar 2006 13:23:44 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I am a python newbie. I have writen some 500 lines of code. There are 4classes and in all 5 files. Now, I am trying to run the program. I am getting wrong values for thesimulation results.Is there any debugging facilities in

python debugging question

2006-03-08 Thread diffuser78
I am a python newbie. I have writen some 500 lines of code. There are 4 classes and in all 5 files. Now, I am trying to run the program. I am getting wrong values for the simulation results. Is there any debugging facilities in python which would let me go step by step and check the values of the

Re: Learning different languages

2006-03-08 Thread Harry George
"gene tani" <[EMAIL PROTECTED]> writes: > Rich wrote: > > Hi, > > > > (this is a probably a bit OT here, but comp.lang seems rather > > desolated, so I'm not sure I would get an answer there. And right now > > I'm in the middle of learning Python anyway so...) > > > > Anyway, my question is: what

Re: sending a text message via webpage button

2006-03-08 Thread Larry Bates
John wrote: > Can anyone help me in coding a script that can send a text message > typed to > the script like. > > sendmessage 6318019564 "test message" > > What I want to do is fill up this information on this webpage > > http://www.cingularme.com/do/public/send;jsessionid=aKDwXM1S0Reh > > and

Re: RAD tutorials and tools for GUI development with Python?

2006-03-08 Thread Jarek Zgoda
Michael Ekstrand napisał(a): > Glade + PyGTK + libglade does the trick. libglade (exposed as gtk.glade > in Python) allows you to load Glade interface files (the raw XML Glade > saves your interfaces as) and then connect to various signals, access > the widgets, etc. > > About as fast as anything

Re: Checking function calls

2006-03-08 Thread Peter Otten
Fredrik Tolf wrote: > # ... > if callable(f): > try: > f(*cv[1:]) > except TypeError: > self.reply("err", "argno") > # ... > > However, this results in bugs in the server code that would cause > TypeError to reply to the client that it had the wrong number of args, > and I

Re: a question about zip...

2006-03-08 Thread Diez B. Roggisch
KraftDiner schrieb: > I had a structure that looked like this > ((0,1), (2, 3), (4, 5), (6,7) > > I changed my code slightly and now I do this: > odd = (1,3,5,7) > even = (0,2,4,6) > all = zip(even, odd) > > however the zip produces: > [(0, 1), (2, 3), (4, 5), (6, 7)] > > Which is a list of tupl

RE: a question about zip...

2006-03-08 Thread Jeff Elmore
Just do: tuple(zip(even,odd)) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of KraftDiner Sent: Wednesday, March 08, 2006 3:22 PM To: python-list@python.org Subject: a question about zip... I had a structure that looked like this ((0,1), (2, 3), (4, 5), (

Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-08 Thread Carl Banks
Douglas Alan wrote: > For instance, if Python were to have been designed so that you would > write: > >let myVeryLongVariableName = 3 > > I would have preferred this over > >myVeryLongVariableName = 3 > > With the latter, I have to scan down the line to see that this line is > in an assign

Re: a question about zip...

2006-03-08 Thread Xavier Morel
KraftDiner wrote: > I had a structure that looked like this > ((0,1), (2, 3), (4, 5), (6,7) > > I changed my code slightly and now I do this: > odd = (1,3,5,7) > even = (0,2,4,6) > all = zip(even, odd) > > however the zip produces: > [(0, 1), (2, 3), (4, 5), (6, 7)] > > Which is a list of tuples

Re: Simple questions on use of objects (probably faq)

2006-03-08 Thread James Stroud
Brian Elmegaard wrote: > "Matt Hammond" <[EMAIL PROTECTED]> writes: > > >>y_max = max([e.x for e in y]) > > > Would there be a way to refer back to the e with maximum x, or how > could I find other attributes of it? > You should look into __cmp__ and other magic methods. This is probably the

Re: Need recs on the best graphing interface

2006-03-08 Thread Robert Kern
Mudcat wrote: > Hi, > > I have looked through the previous suggestions on graphing modules and > have been able to find some good suggestions. However I was wondering > about something more specific. I am going to write a program that > tracks stock prices and other financial related charts, so I

Re: reshape an array?

2006-03-08 Thread Michael Spencer
KraftDiner wrote: > I have a 2D array. Say it is 10x10 and I want a 1D Array of 100 > elements... > What is the syntax? > > oneD = reshape(twoD, (100,1)) > or > oneD = reshape(twoD, (1,100)) > > One I guess is the transpose of the other but both seem to be > arrays of arrays... > > help?! > Us

  1   2   3   >