Dr. Dobb's Python-URL! - weekly Python news and links (Jun 26)

2006-06-26 Thread Cameron Laird
QOTW: In short, it's never what you think it is ;-) - timbot, probably on the subject of performance Real efficiency comes from elegant solutions, not optimized programs. Optimization is always just a few correctness-preserving transformations away. - Jonathan Sobel

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread John Thingstad
On Sun, 25 Jun 2006 20:11:22 +0200, Anton van Straaten [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: In this context, the term latently-typed language refers to the language that a programmer experiences, not to the subset of that language which is all that we're typically able to

list problem 4 newbie

2006-06-26 Thread manstey
I can't figure out why my code is not working. I thought I had the list copied correctly: Here is my code: a=[[u'HF', []], [u')F', [u'75']], [u'RE', []], [u'C', []]] b=a[:] for index in reversed(range(0,len(a)-1)): if '75' in b[index][1]: b[index][1].remove('75')

Re: Python sub-interpreter, security

2006-06-26 Thread faulkner
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496746 [EMAIL PROTECTED] wrote: Hello, I am writing a pure-Python game engine that interprets the code of game objects within the same process with the exec statement. My main goal is to make as much power available as possible and exec

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Anton van Straaten
Chris Smith wrote: What makes static type systems interesting is not the fact that these logical processes of reasoning exist; it is the fact that they are formalized with definite axioms and rules of inference, performed entirely on the program before execution, and designed to be entirely

Re: Python sub-interpreter, security

2006-06-26 Thread jvvhie
faulkner wrote: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496746 Thanks! I was searching everywhere but couldn't find the right terms, I guess. -- http://mail.python.org/mailman/listinfo/python-list

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Anton van Straaten
John Thingstad wrote: On Sun, 25 Jun 2006 20:11:22 +0200, Anton van Straaten [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: ... \sarcasm One step further, and somebody starts calling C a latently memory-safe language, because a real programmer knows that his code is in a safe

Re: list problem 4 newbie

2006-06-26 Thread vaibhav
Hi, if u check the id's of a and b lists and also its elements, you will obeserve that the id's of a and b have changed but id's of their elements have not changed. If you make a deep copy of the list a and then make your changes in that list, it shud work. this can be done using the copy

Re: Interactive debugging

2006-06-26 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Hi, is there a way in python to place some sort of keyboard() type statement which stops the script and puts you back at the console? see the third example on this page: http://effbot.org/librarybook/code.htm /F --

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Anton van Straaten
Joachim Durchholz wrote: Anton van Straaten schrieb: Marshall wrote: Can you be more explicit about what latent types means? Sorry, that was a huge omission. (What I get for posting at 3:30am.) The short answer is that I'm most directly referring to the types in the programmer's

Re: Python database access

2006-06-26 Thread Dave Cook
On 2006-06-26, Serge Orlov [EMAIL PROTECTED] wrote: On 25 Jun 2006 21:19:18 -0700, arvind [EMAIL PROTECTED] wrote: I am going to work on Python 2.4.3 and MSSQL database server on Windows platform. The module you're looking for is the first result if you search python mysql on google or if

Re: Python taught in schools?

2006-06-26 Thread Lawrence D'Oliveiro
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: ... let's try some google searches and see the number of million hits...: But how reliable are those estimates of numbers of hits, anyway? More than once I've got a page showing something like Results 1 - 10 of about 36

Re: Python taught in schools?

2006-06-26 Thread Lawrence D'Oliveiro
In article [EMAIL PROTECTED], Mirco Wahab [EMAIL PROTECTED] wrote: C++ programming requires you to massively invest your thinking first into the setup of your build environment ... I don't understand why. It's easy enough to build small programs with a single g++ command. --

Re: Duplex communication with pipes - is possible ?

2006-06-26 Thread Dara Durum
Hi ! See this shortened, simplified example. It is not working, but I don't understand why... # Client Process import os, sys from subprocess import Popen, PIPE from time import sleep, time from cPickle import loads, dumps from binascii import hexlify, unhexlify from base64 import

Re: What technologies should I use for my application manager?

2006-06-26 Thread Adam Jones
MrBlueSky wrote: Hello! I've just finished working on my first Python app (a Tkinter-based program that displays the content of our application log files in graphical format). It was a great experience that's had a very positive response from my colleagues. So I'd like to try something

Re: list problem 4 newbie

2006-06-26 Thread Duncan Booth
manstey wrote: for index in reversed(range(0,len(a)-1)): if '75' in b[index][1]: b[index][1].remove('75') b[index][1].append('99') What on earth is all that messing around in the for loop intended to do? If you want a range from len(a)-2 to 0 inclusive then just do it in

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Ketil Malde
Rob Thorpe [EMAIL PROTECTED] writes: I think statements like this are confusing, because there are different interpretations of what a value is. But I mean the value as the semantics of the program itself sees it. Which mostly means the datum in memory. I don't agree with that. Generally,

Re: Pygame.draw challenge is over!

2006-06-26 Thread Duncan Booth
Richard Jones wrote: spiffy wrote: Congrats to Seth Yastrov for 'gravity.py' ... THE ONLY ONE THAT WORKED! I did test that they all worked on my machine before putting them online... What issues are you having? What OS? The only issue I found is that goop dies with IndexError: list

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Chris Smith
Anton van Straaten [EMAIL PROTECTED] wrote: I'm not trying to call programmer reasoning in general a type system. I'd certainly agree that a programmer muddling his way through the development of a program, perhaps using a debugger to find all his problems empirically, may not be reasoning

Re: Kamaelia 0.4.0 RELEASED - Faster! More Tools! More Examples! More Docs! ; -)

2006-06-26 Thread Matt Hammond
This allows somethings to run eg AxonVisualiser.py --navelgaze but I'm not sure if the results are really unaffected by not having a real yielder. The diagram appears, but doesn't seem to settle down. I don't think the AxonVisualiser would be particularly affected by this - any wobbling

Re: Python taught in schools?

2006-06-26 Thread Duncan Booth
Lawrence D'Oliveiro wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: ... let's try some google searches and see the number of million hits...: But how reliable are those estimates of numbers of hits, anyway? More than once I've got a page showing something

Re: Interactive debugging

2006-06-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: Hi, is there a way in python to place some sort of keyboard() type statement which stops the script and puts you back at the console? I'm looking for something like in matlab, where you place a keyboard() command (I think), then you're in debug mode in the console,

Re: Mix-In Class Methods At Run-Time

2006-06-26 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: (snip) Two additional questions though: 1) is there a way for a function to get a reference to its caller automatically (as in, without the caller having to pass it in)? It's possible with sys._getframe() and a decorator - but consider it a hack. and 2) what's the

Re: error with string (beginner)

2006-06-26 Thread Bruno Desthuilliers
Jason wrote: I believe what you are trying to do is something like the following. [code] def isIntLike(x): try:int(x) except: return False *Never* ever use a bare except clause. *Always* specify wich exceptions you are expecting. (NB : here, TypeError and ValueError). (NB

style question

2006-06-26 Thread Hari Sekhon
Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Since the first method does not follow python's clean and easy looking indentation structure but the second just

Re: Python question

2006-06-26 Thread Bruno Desthuilliers
Harry wrote: Hi All, (snip) I have the following object which is like a list of tuples row= [('name', 'x1'), ('min', 15.449041129349528), ('max', 991.6337818245629), ('range', 976.18474069521335), ('mean', 496.82174193958127), ('stddev', 304.78275004920454), ('variance',

Re: style question

2006-06-26 Thread MTD
Hari Sekhon wrote: Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Is there any reason you can't do it in one line? message = This is line1.\nThis is

Re: style question

2006-06-26 Thread Hari Sekhon
MTD wrote: Hari Sekhon wrote: Is it better to do: message = """This is line1. This is line2 This is line3\n""" or message = "This is line1.\n message = message + "This is line2\n" message = message + "This is line3\n" Is there any reason you can't do it in one line?

Re: Mix-In Class Methods At Run-Time

2006-06-26 Thread bearophileHUGS
I can't give much answers, I am not that expert yet. Bruno Desthuilliers: newstyle classes can do whatever oldstyle classes did, *and much more* (descriptors and usable metaclasses) - and they are somewhat faster too. In the past I have done few tests, and it seemed that new style classes are

Re: style question

2006-06-26 Thread Frank Millman
Hari Sekhon wrote: Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Since the first method does not follow python's clean and easy looking indentation

Re: style question

2006-06-26 Thread Frank Millman
Frank Millman wrote: How about message = (This is line1. This is line2 This is line3\n) The brackets mean that the lines are automatically treated as continuous, without the need for the ugly '\' continuation character. The opening/closing

Re: style question

2006-06-26 Thread Laurent Rahuel
Hari Sekhon wrote: Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Since the first method does not follow python's clean and easy looking

Re: style question

2006-06-26 Thread Fredrik Lundh
Frank Millman wrote: How about message = (This is line1. This is line2 This is line3\n) The brackets mean that the lines are automatically treated as continuous, without the need for the ugly '\' continuation character. The opening/closing

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Ketil Malde
Chris Smith [EMAIL PROTECTED] writes: I've since abandoned any attempt to be picky about use of the word type. That was a mistake on my part. I still think it's legitimate to object to statements of the form statically typed languages X, but dynamically typed languages Y, in which it is

Re: style question

2006-06-26 Thread Frank Millman
Fredrik Lundh wrote: Frank Millman wrote: How about message = (This is line1. This is line2 This is line3\n) The brackets mean that the lines are automatically treated as continuous, without the need for the ugly '\' continuation

Re: Python taught in schools?

2006-06-26 Thread Mirco Wahab
Thus spoke Lawrence D'Oliveiro (on 2006-06-26 09:21): In article [EMAIL PROTECTED], Mirco Wahab [EMAIL PROTECTED] wrote: C++ programming requires you to massively invest your thinking first into the setup of your build environment ... I don't understand why. It's easy enough to build

Re: style question

2006-06-26 Thread Duncan Booth
Hari Sekhon wrote: Since the first method does not follow python's clean and easy looking indentation structure but the second just looks crude and ugly anyway. If you want indented and pretty is important to you: from textwrap import dedent as D message = D(\ This is line1.

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Ketil Malde
Chris Smith [EMAIL PROTECTED] writes: Joachim Durchholz [EMAIL PROTECTED] wrote: Assume a language that a) defines that a program is type-correct iff HM inference establishes that there are no type errors b) compiles a type-incorrect program anyway, with an establishes rigorous semantics

Re: pypy-0.9.0: stackless, new extension compiler

2006-06-26 Thread cfbolz
Hi all! Michael Hudson wrote: The PyPy development team has been busy working and we've now packaged our latest improvements, completed work and new experiments as version 0.9.0, our fourth public release. Unfortunately the download links for the release tarballs did not work until very

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Ketil Malde
Anton van Straaten [EMAIL PROTECTED] writes: But a program as seen by the programmer has types: the programmer performs (static) type inference when reasoning about the program, and debugs those inferences when debugging the program, finally ending up with a program which has a perfectly good

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Andreas Rossberg
Gabriel Dos Reis wrote: [EMAIL PROTECTED] writes: | think that it is too relevant for the discussion at hand. Moreover, | Harper talks about a relative concept of C-safety. Then, I believe you missed the entire point. I think the part of my reply you snipped addressed it well enough.

About python 2.5 and its try statement.

2006-06-26 Thread defcon8
I can't remember the proposal number, but many of you reading will have probably read the features that will be added to python 2.5. The actual part I wanted to talk about was the finally part of try. Isn't it totally defeating a compiler's job by executing the finally part even if there is an

Re: Python database access

2006-06-26 Thread defcon8
arvind wrote: Hi all, I am going to work on Python 2.4.3 and MSSQL database server on Windows platform. But I don't know how to make the connectivity or rather which module to import. I searched for the modules in the Python library, but I couldn't find which module to go for. Please

Re: About python 2.5 and its try statement.

2006-06-26 Thread Tim N. van der Leeuw
Hi, defcon8 wrote: I can't remember the proposal number, but many of you reading will have probably read the features that will be added to python 2.5. The actual part I wanted to talk about was the finally part of try. Isn't it totally defeating a compiler's job by executing the finally

RE: SWIG problems with gcc and Cygwin?

2006-06-26 Thread Michael Yanowitz
No response yet. The SWIG test works fine in Linux no problems. However, I still have the problem in Cygwin. Also, not sure if related but I do have a win32 Python 2.4.3 and Cygwin Python 2.4.1. Not sure if there are any conflicts. Any advice in making these two co-exist? The only C/C++

Help with conversion VB script to Python : COM objects

2006-06-26 Thread mitsura
Hi, I need to re-write a VB script into Python (because I really don't like VB). The VB script is used to create a Windows COM object. (I am more of Unix guy, so COM objects are a little bit alien for me). At a certain point in the VB script, I have the following line: objPolTypes =

Re: About python 2.5 and its try statement.

2006-06-26 Thread Bruno Desthuilliers
defcon8 wrote: I can't remember the proposal number, http://docs.python.org/dev/whatsnew/pep-341.html but many of you reading will have probably read the features that will be added to python 2.5. The actual part I wanted to talk about was the finally part of try. It has been here from the

automatic debugger?

2006-06-26 Thread micklee74
hi is there something like an automatic debugger module available in python? Say if i enable this auto debugger, it is able to run thru the whole python program, print variable values at each point, or print calls to functions..etc...just like the pdb module, but now it's automatic. thanks --

Re: About python 2.5 and its try statement.

2006-06-26 Thread Fredrik Lundh
defcon8 wrote: I can't remember the proposal number, but many of you reading will have probably read the features that will be added to python 2.5. The actual part I wanted to talk about was the finally part of try. Isn't it totally defeating a compiler's job by executing the finally part even

Re: SWIG problems with gcc and Cygwin?

2006-06-26 Thread Istvan Albert
Michael Yanowitz wrote: Also, not sure if related but I do have a win32 Python 2.4.3 and Cygwin Python 2.4.1. Not sure if there are any conflicts. Any advice in making these two co-exist? SWIG will work with the windows and cygwin python, just make sure you don't mix the various platforms.

Re: String negative indices?

2006-06-26 Thread Antoon Pardon
On 2006-06-23, Filip Wasilewski [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Logically, I should be able to enter x[-2:-0] to get the last and next to last characters. However, since Python doesn't distinguish between positive and negative zero, this doesn't work. Instead, I have to

Re: automatic debugger?

2006-06-26 Thread Paul Rubin
[EMAIL PROTECTED] writes: is there something like an automatic debugger module available in python? Say if i enable this auto debugger, it is able to run thru the whole python program, print variable values at each point, or print calls to functions..etc...just like the pdb module, but now

Re: Mix-In Class Methods At Run-Time

2006-06-26 Thread digitalorganics
Bruno Desthuilliers wrote: [EMAIL PROTECTED] wrote: (snip) Two additional questions though: 1) is there a way for a function to get a reference to its caller automatically (as in, without the caller having to pass it in)? It's possible with sys._getframe() and a decorator - but

DictProxy? What is this?

2006-06-26 Thread digitalorganics
When I tried to update a class's __dict__, I got an error saying that there is no 'update' attribute for dictproxy object. What is a dictproxy object? I thought that __dict__ is always suppose to be a, no kidding, dictionary? Hence there should indeed be an update method. What's this proxy

Re: DictProxy? What is this?

2006-06-26 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: When I tried to update a class's __dict__, I got an error saying that there is no 'update' attribute for dictproxy object. What is a dictproxy object? a CPython implementation detail, used to protect an internal data structure used by new-style objects from unexpected

Re: DictProxy? What is this?

2006-06-26 Thread digitalorganics
Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: When I tried to update a class's __dict__, I got an error saying that there is no 'update' attribute for dictproxy object. What is a dictproxy object? a CPython implementation detail, used to protect an internal data structure used by

A game idea.

2006-06-26 Thread defcon8
I have had what I think is quite a nice game idea, but I don't really have the experience or knowledge to go about it. Would anyone be willing to start a game project? The game I am thinking about is a virtual IRC stock exchange. There will be a bot in the channel which gets the live stock quotes

Re: Python database access

2006-06-26 Thread BartlebyScrivener
But I don't know how to make the connectivity or rather which module to import. Try mxODBC http://www.egenix.com/files/python/mxODBC.html -- http://mail.python.org/mailman/listinfo/python-list

Re: DictProxy? What is this?

2006-06-26 Thread Maric Michaud
Le lundi 26 juin 2006 16:06, [EMAIL PROTECTED] a écrit : Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: When I tried to update a class's __dict__, I got an error saying that there is no 'update' attribute for dictproxy object. What is a dictproxy object? a CPython implementation

Questions on Threading

2006-06-26 Thread j.c.sackett
Hello--I'm using the threading module to accomplish some distributed processing on a project, and have a basic (I hope) question that I can't find an answer to elsewhere.I've noted that there's a lot of documentation saying that there is no external way to stop a thread, and yet when creating a

Re: DictProxy? What is this?

2006-06-26 Thread digitalorganics
All right. Thanks for explaining that Maric. Maric Michaud wrote: Le lundi 26 juin 2006 16:06, [EMAIL PROTECTED] a écrit : Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: When I tried to update a class's __dict__, I got an error saying that there is no 'update' attribute for dictproxy

Re: languages with full unicode support

2006-06-26 Thread Oliver Wong
Oliver Bandel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Xah Lee wrote: As far as i know, Java and JavaScript are languages with full, complete unicode support. That is, they allow names to be defined using unicode. Can you explain what you mena with the names here?

Get List of Classes

2006-06-26 Thread digitalorganics
Is there a method or attribute I can use to get a list of classes defined or in-use within my python program? I tried using pyclbr and readmodule but for reason that is dogslow. Thanks in advance DigiO -- http://mail.python.org/mailman/listinfo/python-list

Search String for Word

2006-06-26 Thread digitalorganics
What's the best way to search a string for a particular word and get a booleen value indicating whether it exists in the string or not? Thanks... -- http://mail.python.org/mailman/listinfo/python-list

Re: What is Expressiveness in a Computer Language [off-topic]

2006-06-26 Thread David Hopwood
Matthias Blume wrote: I agree with Bob Harper about safety being language-specific and all that. But, with all due respect, I think his characterization of C is not accurate. [...] AFAIC, C is C-unsafe by Bob's reasoning. Agreed. Of course, C can be made safe quite easily: Define a

Re: Search String for Word

2006-06-26 Thread Tim Chase
What's the best way to search a string for a particular word and get a booleen value indicating whether it exists in the string or not? substring = 'foo' targetstring = 'blah foo bar' substring in targetstring True if substring in targetstring: print 'yup' yup

Re: 2Qs

2006-06-26 Thread JW
2nd question: [snip] if x10 and y10 and z10 and summ(tritup(x,y,z)): print OK Others have already suggested you use the built-in sum() function. I'll suggest you don't need it at all, because it is redundant. If the sum is zero, either all three values are zero or at least one of the

Re: Formatted string to object

2006-06-26 Thread janama
Thankyou everyone for help last time: The following works ok when setting a wx.lib.buttons.GenBitmapTextButton's disabled bitmap in using wxpython instead of this: self.b1.SetBitmapDisabled(self.yellow) i can use this: aaa = 1 result1 = eval(self.b%s.SetBitmapDisabled(self.yellow) % aaa) result

Re: Search String for Word

2006-06-26 Thread digitalorganics
I thought I'd seen that somewhere! Thanks Tim. I was previously using re.search(substring, targetstring). Tim Chase wrote: What's the best way to search a string for a particular word and get a booleen value indicating whether it exists in the string or not? substring = 'foo'

Re: Python taught in schools?

2006-06-26 Thread Alex Martelli
Lawrence D'Oliveiro [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: ... let's try some google searches and see the number of million hits...: But how reliable are those estimates of numbers of hits, anyway? More than once I've got a page

Re: pypy-0.9.0: stackless, new extension compiler

2006-06-26 Thread Carl Friedrich Bolz
Hi all! Michael Hudson wrote: The PyPy development team has been busy working and we've now packaged our latest improvements, completed work and new experiments as version 0.9.0, our fourth public release. Unfortunately the download links for the release tarballs did not work until very

Dr. Dobb's Python-URL! - weekly Python news and links (Jun 26)

2006-06-26 Thread Cameron Laird
QOTW: In short, it's never what you think it is ;-) - timbot, probably on the subject of performance Real efficiency comes from elegant solutions, not optimized programs. Optimization is always just a few correctness-preserving transformations away. - Jonathan Sobel

Re: What is Expressiveness in a Computer Language [off-topic]

2006-06-26 Thread Matthias Blume
David Hopwood [EMAIL PROTECTED] writes: Matthias Blume wrote: I agree with Bob Harper about safety being language-specific and all that. But, with all due respect, I think his characterization of C is not accurate. [...] AFAIC, C is C-unsafe by Bob's reasoning. Agreed. Of course, C can

Re: Get List of Classes

2006-06-26 Thread Tim Chase
Is there a method or attribute I can use to get a list of classes defined or in-use within my python program? I tried using pyclbr and readmodule but for reason that is dogslow. Well, given that so much in python is considered a class, the somewhat crude code below walks an object/module and

Re: Python database access

2006-06-26 Thread vasudevram
The odbc module is part of the Python Standard Library. So you can search for docs on using it in the Python2x.chm help file (or the HTML version of the same docs) that comes with the Windows Python disttribution. Its quite easy to use ODBC from Python, at least for simple tasks like select *

Re: Search String for Word

2006-06-26 Thread digitalorganics
And what if I want to search for an item in a tuple, is there a similarly easy method? Tim Chase wrote: What's the best way to search a string for a particular word and get a booleen value indicating whether it exists in the string or not? substring = 'foo' targetstring = 'blah foo

Re: style question

2006-06-26 Thread Claudio Grondi
Hari Sekhon wrote: Is it better to do: message = This is line1. This is line2 This is line3\n or message = This is line1.\n message = message + This is line2\n message = message + This is line3\n Since the first method does not follow python's clean and easy looking

Re: Termination and type systems

2006-06-26 Thread Dirk Thierbach
David Hopwood [EMAIL PROTECTED] wrote: Marshall wrote: David Hopwood wrote: A type system that required an annotation on all subprograms that do not provably terminate, OTOH, would not impact expressiveness at all, and would be very useful. Interesting. I have always imagined doing this by

Re: Get List of Classes

2006-06-26 Thread digitalorganics
Wow, more than I had asked for, thank you Tim! I ended up doing this: def isClass(object): if 'classobj' in str(type(object)): return 1 elif 'type' in str(type(object)): return 1 else: return 0 def listClasses(): classes = [] for eachobj in

Re: Python taught in schools?

2006-06-26 Thread Gary Duzan
In article [EMAIL PROTECTED], Mirco Wahab [EMAIL PROTECTED] wrote: Thus spoke Cameron Laird (on 2006-06-25 13:08): I'll gratuitously add that, even though I'm personally fond of C++, I think teaching it as is done in colleges and high schools (!) amounts to child abuse. It's wildly

Re: Get List of Classes

2006-06-26 Thread Maric Michaud
Le lundi 26 juin 2006 17:25, Tim Chase a écrit :  I couldn't find any nice method for determining if a variable referenced a module other than checking to see if that item had both a __file__ and a __name__ attribute. Why not : In [8]: import types, sys In [9]: isinstance(sys,

Re: Search String for Word

2006-06-26 Thread Tim Williams
On 26 Jun 2006 08:24:54 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: And what if I want to search for an item in a tuple, is there a similarly easy method? Tim Chase wrote: What's the best way to search a string for a particular word and get a booleen value indicating whether it

Re: Get List of Classes

2006-06-26 Thread Tim Chase
I couldn't find any nice method for determining if a variable referenced a module other than checking to see if that item had both a __file__ and a __name__ attribute. Why not : In [8]: import types, sys In [9]: isinstance(sys, types.ModuleType) Out[9]: True Yes...this is the best way

Replace Whole Object Through Object Method

2006-06-26 Thread digitalorganics
How can an object replace itself using its own method? See the following code: class Mixin: def mixin(object, *classes): NewClass = type('Mixin', (object.__class__,) + classes, {}) newobj = NewClass() newobj.__dict__.update(object.__dict__) return newobj def

Re: Pygame.draw challenge is over!

2006-06-26 Thread Matthew Nuzum
Hey, just a quick note... when I visit http://pyweek.org I get a message that the site is not configured. www.pyweek.org works as expected. When I received this e-mail my e-mail client made pyweek.org clickable which is how I noticed the problem. On 6/25/06, [EMAIL PROTECTED] [EMAIL PROTECTED]

Re: Search String for Word

2006-06-26 Thread digitalorganics
Thank you thank you! Tim Williams wrote: On 26 Jun 2006 08:24:54 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: And what if I want to search for an item in a tuple, is there a similarly easy method? Tim Chase wrote: What's the best way to search a string for a particular word and

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Joe Marshall
Marshall wrote: I stand corrected: if one is using C and writing self-modifying code, then one *can* zip one's pants. Static proofs notwithstanding, I'd prefer a dynamic check just prior to this operation. I want my code to be the only self-modifying thing around here. --

Re: Mix-In Class Methods At Run-Time

2006-06-26 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: [EMAIL PROTECTED] wrote: (snip) and 2) what's the reason to use newstyle classes versus the old? All this is explained on python.org (there's a menu entry for this in the documentation menu). AFAICT, newstyle classes can do whatever oldstyle

Re: Replace Whole Object Through Object Method

2006-06-26 Thread Maric Michaud
Le lundi 26 juin 2006 17:57, [EMAIL PROTECTED] a écrit : How can an object replace itself using its own method? See the following code: class Mixin: def mixin(object, *classes): NewClass = type('Mixin', (object.__class__,) + classes, {}) newobj = NewClass()

Re: What is Expressiveness in a Computer Language

2006-06-26 Thread Joe Marshall
David Hopwood wrote: Joe Marshall wrote: I do this quite often. Sometimes I'll develop `in the debugger'. I'll change some piece of code and run the program until it traps. Then, without exiting the debugger, I'll fix the immediate problem and restart the program at the point it

Re: Replace Whole Object Through Object Method

2006-06-26 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: How can an object replace itself using its own method? AFAIK, It can't (but I can be wrong - some guru around ?). See the following code: class Mixin: def mixin(object, *classes): NewClass = type('Mixin', (object.__class__,) + classes, {})

Re: Replace Whole Object Through Object Method

2006-06-26 Thread digitalorganics
Maric Michaud wrote: Le lundi 26 juin 2006 17:57, [EMAIL PROTECTED] a écrit : How can an object replace itself using its own method? See the following code: class Mixin: def mixin(object, *classes): NewClass = type('Mixin', (object.__class__,) + classes, {})

Re: style question

2006-06-26 Thread Scott David Daniels
Claudio Grondi wrote: clever stuff to di indentation When necessary to skip first line _and_ indentation: message = This is line 1 This is line 2 This is line 3 .replace('\n ', '\n')[1:] # adjust here '\n ' to indentation Riffing on this idea: message =

Beginner Programmer Question

2006-06-26 Thread kydavis77
I am doing alot of reading and trying to teach myself how to program. I can not figure out how to make Write a program that continually reads in numbers from the user and adds them together until the sum reaches 100. this work. If someone could show me the correct code so i can learn from that it

Re: Replace Whole Object Through Object Method

2006-06-26 Thread digitalorganics
Bruno Desthuilliers wrote: [EMAIL PROTECTED] wrote: How can an object replace itself using its own method? AFAIK, It can't (but I can be wrong - some guru around ?). ... FWIW: Python 2.4.3 (#1, Jun 3 2006, 17:26:11) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2

VPW: Talk schedule available

2006-06-26 Thread Brian Quinlan
What's New? === The talk schedule for the Vancouver Python Workshop is now available: http://www.vanpyz.org/conference/talkschedule.html This years line-up might be even stronger than in 2004, so check it out! About the Vancouver Python Workshop === The

Re: Beginner Programmer Question

2006-06-26 Thread Claudio Grondi
[EMAIL PROTECTED] wrote: I am doing alot of reading and trying to teach myself how to program. I can not figure out how to make Write a program that continually reads in numbers from the user and adds them together until the sum reaches 100. this work. If someone could show me the correct code

Re: Beginner Programmer Question

2006-06-26 Thread [EMAIL PROTECTED]
Claudio Grondi wrote: [EMAIL PROTECTED] wrote: I am doing alot of reading and trying to teach myself how to program. I can not figure out how to make Write a program that continually reads in numbers from the user and adds them together until the sum reaches 100. this work. If someone

Re: Beginner Programmer Question

2006-06-26 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: Claudio Grondi wrote: [EMAIL PROTECTED] wrote: I am doing alot of reading and trying to teach myself how to program. I can not figure out how to make Write a program that continually reads in numbers from the user and adds them together until the sum

Re: Beginner Programmer Question

2006-06-26 Thread Rune Strand
I am doing alot of reading, and the problem didnt come with an answer. I dont understand how to get it to continually input numbers and add all those together Use while, raw_input, sys.argv[1] and int() and break the loop when the sum is above 100. ;-) --

  1   2   3   >