Re: Calling class method by name passed in variable

2008-05-22 Thread Gary Herron
Sagari wrote: Greetings, Can someone suggest an efficient way of calling method whose name is passed in a variable? Given something like: class X: #... def a(self): # ... def b(self): # ... #... x = X() #... v = 'a' How do I call the method of x whose name is stored in v? Use get

[Regexes] Stripping puctuation from a text

2008-05-22 Thread shabda raaj
I want to strip punctuation from text. So I am trying, >>> p = re.compile('[a-zA-Z0-9]+') >>> p.sub('', 'I love tomatoes!! hell yeah! ... Why?') ' !! ! ... ?' Which gave me all the chars which I want to replace. So Next I tried by negating the regex, >>> p = re.compile('^[a-zA-Z0-9]+') >>> p

can python do some kernel stuff?

2008-05-22 Thread Jimmy
Hi to all python now has grown to a versatile language that can accomplish tasks for many different purposes. However, AFAIK, little is known about its ability of kernel coding. So I am wondering if python can do some kernel coding that used to be the private garden of C/C++. For example, can pyt

Re: call f(a, *b) with f(*a, **b) ?

2008-05-22 Thread bukzor
On May 22, 5:29 pm, "inhahe" <[EMAIL PROTECTED]> wrote: > "bukzor" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > This question seems easy but I can't figure it out. > > Lets say there's a function: > > > def f(a, *args): > >    print a > >    for b in args: print b > > > and

Calling class method by name passed in variable

2008-05-22 Thread Sagari
Greetings, Can someone suggest an efficient way of calling method whose name is passed in a variable? Given something like: class X: #... def a(self): # ... def b(self): # ... #... x = X() #... v = 'a' How do I call the method of x whose name is stored in v? PHP code for this would be:

Re: call f(a, *b) with f(*a, **b) ?

2008-05-22 Thread bukzor
On May 22, 5:39 pm, "inhahe" <[EMAIL PROTECTED]> wrote: > >> 1 > >> 2 > > actually, you don't want it to print 3 also?  if not, then you would do > f(*map(kwargs.get, inspect.getargspec(f)[0])+args[:1]) > > > import inspect > > f(*map(kwargs.get, inspect.getargspec(f)[0])+args) > > No, that was a

Re: ctypes help

2008-05-22 Thread gianluca
On 23 Mag, 07:48, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote: > > Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an > > exception like this: > > > Traceback (most recent call last): > > File "", line 1, in > >

Re: ctypes help

2008-05-22 Thread Marc 'BlackJack' Rintsch
On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote: > Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an > exception like this: > > Traceback (most recent call last): > File "", line 1, in > myDLL.myFUNCT() > File "C:\Python25\lib\ctypes\__init__.py", line 353, in __ge

Re: MVC

2008-05-22 Thread Andrew Lee
George Maggessy wrote: Hi Gurus, I'm a Java developer and I'm trying to shift my mindset to start programming python. So, my first exercise is to build a website. However I'm always falling back into MVC pattern. I know it's a standard, but the implementation language affects the use of design p

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Andrew Lee
Dan Upton wrote: On Thu, May 22, 2008 at 2:53 PM, Mensanator <[EMAIL PROTECTED]> wrote: On May 22, 11:32 am, "Dutton, Sam" <[EMAIL PROTECTED]> wrote: I've noticed that the value of math.pi -- just entering it at the interactive prompt -- is returned as 3.1415926535897931, whereas (as every pi-

Re: Relationship between GUI and logic?

2008-05-22 Thread Marc 'BlackJack' Rintsch
On Thu, 22 May 2008 23:37:45 -0400, John Salerno wrote: > I know that it is good programming practice to keep GUI and logic code > physically separate, by using XRC for example, but I'm wondering if it's > also good practice (and even possible) to keep them separate from an > implementation sta

Re: Decorator metaclass

2008-05-22 Thread Maric Michaud
Le Friday 23 May 2008 04:28:22 [EMAIL PROTECTED], vous avez écrit : > Hi, > I would like to create a Decorator metaclass, which automatically > turns a class which inherits from the "Decorator" type into a > decorator. > A decorator in this case, is simply a class which has all of its > decorator

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Andrew Lee
Mensanator wrote: On May 22, 11:32 am, "Dutton, Sam" <[EMAIL PROTECTED]> wrote: I've noticed that the value of math.pi -- just entering it at the interactive prompt -- is returned as 3.1415926535897931, whereas (as every pi-obsessive knows) the value is 3.1415926535897932... (Note the 2 at the

Re: serach file for regexp, return if found?

2008-05-22 Thread Yves Dorfsman
[EMAIL PROTECTED] wrote: > i want to search a document for a particular regexp and then store > that regexp to a file. > but search and match only returns matchobjects(what are those anyway? > i dont get what to do with them, do they contain true/false, > stringposition etc?) > how do i do: > for

Re: Python is slow

2008-05-22 Thread Andrew Lee
cm_gui wrote: Python is slow.Almost all of the web applications written in Python are slow. Zope/Plone is slow, sloow, so very slooow. Even Google Apps is not faster. Neither is Youtube. Facebook and Wikipedia (Mediawiki), written in PHP, are so much faster than Python. Okay, they probab

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Yves Dorfsman
Peter Otten <[EMAIL PROTECTED]> wrote: > > A slightly similar problem: If I want to "merge," say, list1=[1,2,3] with > > list2=[4,5,6] to obtain [1,4,2,5,3,6], is there some clever way with "zip" > > to do so? > >>> items = [None] * 6 > >>> items[::2] = 1,2,3 > >>> items[1::2] = 4,5,6 > >>> items

Re: Python is slow

2008-05-22 Thread Kay Schluehr
On 23 Mai, 00:51, Larry Bates <[EMAIL PROTECTED]> wrote: > > I've yet to see a web application written in Python which is really > > fast. > > You are just dead wrong about this. No, he can demand whatever he wants and we can be stupid enough to respond. -- http://mail.python.org/mailman/listinfo

Re: ctypes help

2008-05-22 Thread gianluca
On 23 Mag, 01:14, Larry Bates <[EMAIL PROTECTED]> wrote: > gianluca wrote: > > Hy, > > I need help about use dll with ctypes. I've compiled my dll C library > > and I copied it in c:\windows\system32. When I load it with > > "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem all OK but > >

Re: Python and Flaming Thunder

2008-05-22 Thread Kay Schluehr
On 13 Mai, 01:39, Dave Parker <[EMAIL PROTECTED]> wrote: > I've read that one of the design goals of Python was to create an easy- > to-use English-like language. That's also one of the design goals of > Flaming Thunder athttp://www.flamingthunder.com/ , which has proven > easy enough for even ele

Re: php vs python

2008-05-22 Thread Michael Mabin
I used python to generate php code. But that was before I knew what vast troves of python web frameworks there were. :) On Thu, May 22, 2008 at 11:40 PM, inhahe <[EMAIL PROTECTED]> wrote: > > > PHP can do that. There are also a number of templating engines > > available. The nice thing about PH

Re: php vs python

2008-05-22 Thread inhahe
> PHP can do that. There are also a number of templating engines > available. The nice thing about PHP is you have a choice. i just meant that php is sort of invented to combine html and code, so if you use python instead you should use a templating engine. but i suppose it's useful for php

RE: How do I make a copy of my class object?

2008-05-22 Thread Marlin Rowley
Nevermind. I ended up making a copy of everything within the class since I'm storing bitmaps anyway. It works. I'll read up more on the deepcopy() function. > To: python-list@python.org> From: [EMAIL PROTECTED]> Subject: Re: How do I > make a copy of my class object?> Date: Thu, 22 May 20

Re: Relationship between GUI and logic?

2008-05-22 Thread alex23
On May 23, 1:37 pm, John Salerno <[EMAIL PROTECTED]> wrote: > Basically, the question is this: can you write the logic behind a > program (whether it be a game, an email client, a text editor, etc.) > without having any idea of how you will implement the GUI? Hey John, Are you familiar with the M

Re: Relationship between GUI and logic?

2008-05-22 Thread RPM1
John Salerno wrote: Basically, the question is this: can you write the logic behind a program (whether it be a game, an email client, a text editor, etc.) without having any idea of how you will implement the GUI? Chess already has at least two solutions that are in widespread use: Winboard

Relationship between GUI and logic?

2008-05-22 Thread John Salerno
I know that it is good programming practice to keep GUI and logic code physically separate, by using XRC for example, but I'm wondering if it's also good practice (and even possible) to keep them separate from an implementation standpoint as well. Basically what I mean is, should it be possible

Re: MVC

2008-05-22 Thread Michael Mabin
In fact, the Pylons web framework is geared toward the MVC approach. http://pylonshq.com/ On Thu, May 22, 2008 at 7:48 PM, George Maggessy <[EMAIL PROTECTED]> wrote: > Hi Gurus, > > I'm a Java developer and I'm trying to shift my mindset to start > programming python. So, my first exercise is to

Re: php vs python

2008-05-22 Thread Jerry Stuckle
inhahe wrote: I don't like php. I tried it once and I had it sort a list, but the list was apparently too long for its sorting function because it just sorted the first so-many elements of it and left the rest in order, and didn't generate any error. I like a language that's actually determin

Re: Python and Flaming Thunder

2008-05-22 Thread I V
On Thu, 22 May 2008 19:35:50 -0700, Charles Hixson wrote: > Although when comparing Candygram with Erlang it's worth noting that > Candygram is bound to one processor, where Erlang can operate on > multiple processors. (I'd been planning on using Candygram for a project > at one point, but this mad

Re: Python and Flaming Thunder

2008-05-22 Thread Charles Hixson
On Thursday 22 May 2008 13:30:07 Nick Craig-Wood wrote: > ... > >From Armstrong's book: The expression Pattern = Expression causes > > Expression to be evaluated and the result matched against Pattern. The > match either succeeds or fails. If the match succeeds any variables > occurring in Pattern

Decorator metaclass

2008-05-22 Thread thomas . karolski
Hi, I would like to create a Decorator metaclass, which automatically turns a class which inherits from the "Decorator" type into a decorator. A decorator in this case, is simply a class which has all of its decorator implementation inside a decorator() method. Every other attribute access is being

Re: Python is slow

2008-05-22 Thread RPM1
Larry Bates wrote: If your Python program is slow, you have almost assuredly approached it with a wrong method or algorithm. I agree for most applications. There are however times where Python just isn't fast enough, and that's usually when people write extension modules. I have yet to se

Re: MVC

2008-05-22 Thread Brad
George Maggessy wrote: Hi Gurus, I'm a Java developer and I'm trying to shift my mindset to start programming python. So, my first exercise is to build a website. However I'm always falling back into MVC pattern. I know it's a standard, but the implementation language affects the use of design p

Re: MVC

2008-05-22 Thread Patrick Mullen
In my experience, python is very pattern agnostic. You can do functional or object oriented or procedural fairly easily, have deep or light object trees, or even mix procedural style with some object oriented code if you like. "There should be one way to do it" tends to not apply as much as some

Re: Returning to 'try' block after catching an exception

2008-05-22 Thread Matthew Trevor
On May 23, 4:01 am, "inhahe" <[EMAIL PROTECTED]> wrote: > Might have a stack overflow issue, if it retries too many times? In which example? Neither of them is looping... -- http://mail.python.org/mailman/listinfo/python-list

Re: serach file for regexp, return if found?

2008-05-22 Thread Matthew Trevor
On May 23, 9:10 am, [EMAIL PROTECTED] wrote: > but search and match only returns matchobjects(what are those anyway? > i dont get what to do with them, do they contain true/false, > stringposition etc?) It's all covered in the docs: http://docs.python.org/lib/module-re.html http://docs.python.org

MVC

2008-05-22 Thread George Maggessy
Hi Gurus, I'm a Java developer and I'm trying to shift my mindset to start programming python. So, my first exercise is to build a website. However I'm always falling back into MVC pattern. I know it's a standard, but the implementation language affects the use of design patter. So, here goes my q

Re: Python is slow

2008-05-22 Thread Matthew Trevor
On May 23, 2:14 am, cm_gui <[EMAIL PROTECTED]> wrote: > I've yet to see a web application written in Python which is really > fast. Then stop looking at your own inept Python code and open your eyes. -- http://mail.python.org/mailman/listinfo/python-list

Re: call f(a, *b) with f(*a, **b) ?

2008-05-22 Thread inhahe
>> 1 >> 2 actually, you don't want it to print 3 also? if not, then you would do f(*map(kwargs.get, inspect.getargspec(f)[0])+args[:1]) > import inspect > f(*map(kwargs.get, inspect.getargspec(f)[0])+args) > -- http://mail.python.org/mailman/listinfo/python-list

Re: spider, why isnt it finding the url?

2008-05-22 Thread notnorwegian
On 23 Maj, 02:02, [EMAIL PROTECTED] wrote: > this program doesnt produce any output, however i know from testing > that the url-regexp matches urls... > > import urllib > import re > > site = urllib.urlopen("http://www.python.org";) > > email = re.compile(r'[EMAIL PROTECTED],4}') > url = re.compile

Re: call f(a, *b) with f(*a, **b) ?

2008-05-22 Thread inhahe
"bukzor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This question seems easy but I can't figure it out. > Lets say there's a function: > > def f(a, *args): >print a >for b in args: print b > > and elsewhere in your program you have a list and a dict like this: > args =

Re: HTMLParser error

2008-05-22 Thread alex23
On May 23, 5:06 am, [EMAIL PROTECTED] wrote: > Nope, this is my first experience with object oriented programming, > only been learning python for a few weeks but it seemed simple enough > to inspire me to be a bit ambitious. If you could hook me up with some > good docs that would be great. I was

Re: statically linking release build on mac

2008-05-22 Thread Patrick Stinson
Here is the error: code 4, error number 0 (Symbol not found: _Py_DebugFlag Referenced from: /Library/Application Support/Digidesign/Plug-Ins/Play.dpm/Contents/MacOS/Play Expected in: /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit ) On Thu, May 22, 2008 at 10:13 AM, Patrick

spider, why isnt it finding the url?

2008-05-22 Thread notnorwegian
this program doesnt produce any output, however i know from testing that the url-regexp matches urls... import urllib import re site = urllib.urlopen("http://www.python.org";) email = re.compile(r'[EMAIL PROTECTED],4}') url = re.compile("^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1} ([\w\

Re: Overloading __getitem__

2008-05-22 Thread inhahe
> Apparently, args already is a tuple, so this should be: > > def __getitem__(self, args): > > Is this documented somewhere? I couldn't find it anywhere. > Don't know, I just assumed it would take multiple arguments because I knew I had seen the form d[1,2] before, which incidentally is equival

Re: Python is slow

2008-05-22 Thread Erich
On May 22, 1:18 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > My mum's fast... > Arnaud Was it a good idea to include that bit in a troll response? If English isn't your first language, it's one of those language idioms that's not very nice to say about someone's mother (especially your own

Tun/Tap Driver using OpenVPN and DeviceIoControl

2008-05-22 Thread Andrew
Hello I am trying to port some code and I am running into some issues I may or may not be able to solve on my own and would appreciate your help Basically I am trying to open the Tun Driver through openvpn in Ether (Tap mode). code is as follows f = win32file.CreateFile("C:\\WINDOWS\\System3

Re: simple way to touch a file if it does not exist

2008-05-22 Thread bukzor
On May 22, 12:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 21 May 2008 17:56:38 -0700, bukzor wrote: > > On May 21, 5:37 pm, Nikhil <[EMAIL PROTECTED]> wrote: > > >> if os.path.exists('file'): > >> open('file', 'w').close() > > >> Right? > > > You only want to blank

Re: Overloading __getitem__

2008-05-22 Thread Andreas Matthias
[EMAIL PROTECTED] wrote: > actually i ddin't think about the fact that you're overloading dict, which > can already take multiple values in getitem Oh, I didn't know that. I totally misinterpreted the error message. > so how about > > class crazy: pass > > and then in your dict class: > > d

Re: Python is slow

2008-05-22 Thread Carl Banks
On May 22, 12:14 pm, cm_gui <[EMAIL PROTECTED]> wrote: > Python is slow.Almost all of the web applications written in > Python are slow. Zope/Plone is slow, sloow, so very slooow. Even > Google Apps is not faster. Neither is Youtube. > Facebook and Wikipedia (Mediawiki), written in PHP, ar

call f(a, *b) with f(*a, **b) ?

2008-05-22 Thread bukzor
This question seems easy but I can't figure it out. Lets say there's a function: def f(a, *args): print a for b in args: print b and elsewhere in your program you have a list and a dict like this: args = [2, 3] kwargs = {'a':1} I'd like to get f() to print something like the following, b

Re: ctypes help

2008-05-22 Thread Larry Bates
gianluca wrote: Hy, I need help about use dll with ctypes. I've compiled my dll C library and I copied it in c:\windows\system32. When I load it with "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem all OK but python don't see the dll function. with dir(myDLL) I've only this: ['_FuncPt

Re: Using os.walk to return files in subdirectories

2008-05-22 Thread Larry Bates
dj wrote: Hello All, I am attempting to us os.walk to populate two lists with values from a directory. The first list contains all the files in the directory and subdirectories. The second list contains only the files in the subdirectories. Here is the code: import os # list of matching files

serach file for regexp, return if found?

2008-05-22 Thread notnorwegian
i want to search a document for a particular regexp and then store that regexp to a file. but search and match only returns matchobjects(what are those anyway? i dont get what to do with them, do they contain true/false, stringposition etc?) how do i do: for rows in file: print regexp.find #

Re: Python is slow

2008-05-22 Thread sturlamolden
On May 22, 6:14 pm, cm_gui <[EMAIL PROTECTED]> wrote: > I've yet to see a web application written in Python which is really > fast. I bet you have a slow dial-up connection. -- http://mail.python.org/mailman/listinfo/python-list

Re: Overloading __getitem__

2008-05-22 Thread inhahe
actually i ddin't think about the fact that you're overloading dict, which can already take multiple values in getitem so how about class crazy: pass and then in your dict class: def __getitem__(*args): if args[-1] is crazy: return self.get(args[:-1])*5 else: return self.get(args)

Re: ctypes help

2008-05-22 Thread sturlamolden
On May 23, 12:33 am, gianluca <[EMAIL PROTECTED]> wrote: > Hy, > I need help about use dll with ctypes. I've compiled my dll C library > and I copied it in c:\windows\system32. When I load it with > "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem all OK but > python don't see the dll fu

Re: Python is slow

2008-05-22 Thread Larry Bates
cm_gui wrote: Python is slow.Almost all of the web applications written in Python are slow. Zope/Plone is slow, sloow, so very slooow. Even Google Apps is not faster. Neither is Youtube. Facebook and Wikipedia (Mediawiki), written in PHP, are so much faster than Python. Okay, they probab

Re: Overloading __getitem__

2008-05-22 Thread inhahe
"inhahe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > crazy = True > print foo['a',crazy] > just to clarify, you could use it like: crazy = "I'm crazy" #this only has to be done once print foo['a'] #not crazy print foo['a',crazy] #crazy (this may be totally unPythonic

Re: where is the Write method of ElementTree??

2008-05-22 Thread John Machin
On May 23, 6:56 am, [EMAIL PROTECTED] wrote: > I'm messing around with trying to write an xml file using > xml.etree.ElementTree. All the examples on the internet show the use > of ElementTree.write(), although when I try to use it it's not > available, gives me ... > >ElementTree(sectionEleme

Re: Overloading __getitem__

2008-05-22 Thread inhahe
it seems like you can't do it exactly the way you're trying but you could do this def __getitem__(*args): if len(args) > 1 and args[1]: return self.get(args[0]) * 5 return self.get(args[0]) then you would use it like print foo['a'] print foo['a',True] or even print foo['a',"crazy"] if you

ctypes help

2008-05-22 Thread gianluca
Hy, I need help about use dll with ctypes. I've compiled my dll C library and I copied it in c:\windows\system32. When I load it with "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem all OK but python don't see the dll function. with dir(myDLL) I've only this: ['_FuncPtr', '__class__', '

Re: Python and Flaming Thunder

2008-05-22 Thread Brian Quinlan
Dave Parker wrote: Or just: If command is "quit" ... Hmmm. In Flaming Thunder, I'm using "is" (and "is an", "is a", etc) for assigning and checking types. For example, to read data from a file and check for errors: Read data from "input.txt". If data is an error then go to ... H

Re: Python is slow

2008-05-22 Thread Brad
cm_gui wrote: Python is slow. It ain't C++, but it ain't a punch card either... somewhere in between. I find it suitable for lots of stuff. I use C++ when performance really matters tho... right tool for the job. Learn a good interpreted language (Pyhton) and a good compiled language (C or C

Re: php vs python

2008-05-22 Thread inhahe
I don't like php. I tried it once and I had it sort a list, but the list was apparently too long for its sorting function because it just sorted the first so-many elements of it and left the rest in order, and didn't generate any error. I like a language that's actually determined by what you

Re: 2 different versions of python compiling files.

2008-05-22 Thread [EMAIL PROTECTED]
On May 22, 3:56 pm, TkNeo <[EMAIL PROTECTED]> wrote: > On May 22, 2:44 pm, Hans Nowak <[EMAIL PROTECTED]> > wrote: > > > > > TkNeo wrote: > > > I am trying to upgrade from python 2.3 to 2.4 but not all machines can > > > be upgraded. Can you guys tell me if this scenario is possible. > > > > 1. Any

Overloading __getitem__

2008-05-22 Thread Andreas Matthias
The following code doesn't run but I hope you get what I am trying to do. class my_dict (dict): def __getitem__ (self, key, crazy = False): if crazy == True: return 5 * self.get(key) else: return self.get(key) foo = my_dict() foo['a'] = 123 print fo

Re: How do I make a copy of my class object?

2008-05-22 Thread Russell Blau
"Marlin Rowley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a class object which has the usual data members and functions. > I'm trying to make a copy of this class (which includes wx.Bitmap objects) > but deepcopy() doesn't seem to work. How would I do this? Are you try

Re: Using os.walk to return files in subdirectories

2008-05-22 Thread Chris Hulan
On May 22, 5:24 pm, dj <[EMAIL PROTECTED]> wrote: ...snip... > for d in dir: > if end == d: dir is the list of subdirs of the current dir, and the current dir is NOT a subdir of itself so end == dir is never true Are you trying to get a list per subdir? cheers -- http://mail.python.o

Re: Python and Flaming Thunder

2008-05-22 Thread Torsten Bronger
Hallöchen! Matthew Woodcraft writes: > [...] > > At one time, Guido was very keen on the idea of Python as a > language to introduce non-programmers to (under the 'Computer > Programming for Everybody' slogan). > > I think it's rather a shame that this has more-or-less fallen by > the wayside. Th

Re: Shell-independent *nix setup script

2008-05-22 Thread brad
[EMAIL PROTECTED] wrote: Hi, Is it worthwhile maintaining a production application setup script in Python as opposed to shell-script? I do not think so. Perhaps 'in conjunction with', but not 'opposed to'... sh is the lowest common denominator of shells. Script for sh and your script will r

Re: Using os.walk to return files in subdirectories

2008-05-22 Thread dj
Hello All, I am attempting to us os.walk to populate two lists with values from a directory. The first list contains all the files in the directory and subdirectories. The second list contains only the files in the subdirectories. Here is the code: import os # list of matching files allfiles =

Re: Python and Flaming Thunder

2008-05-22 Thread Matthew Woodcraft
<[EMAIL PROTECTED]> wrote: > So it seems like you're designing a language for non-programmers. > That's good, I've never heard about anyone so interested in teaching > programming for kids and non-programmers. But in that case, you > shouldn't even be comparing it to Python. At one time, Guido was

How do I make a copy of my class object?

2008-05-22 Thread Marlin Rowley
All: I have a class object which has the usual data members and functions. I'm trying to make a copy of this class (which includes wx.Bitmap objects) but deepcopy() doesn't seem to work. How would I do this? -M _ E-mail for the

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Joel Koltner
Hi Marc, "Marc Christiansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm not sure I would recommend it, but try: > [v for x in range(4) for v in (x, 2 * x)] That certainly works... and it almost seems like a bit less of a hack (if perhaps somewhat harder to read) than the

Bug in ssl-object library reference page or in ssl-object code?

2008-05-22 Thread Grant Edwards
According to http://docs.python.org/lib/ssl-objects.html 17.2.2 SSL Objects SSL objects have the following methods. read([n]) If n is provided, read n bytes from the SSL connection, otherwise read until EOF. The return value is a string of the bytes read. The behavior I obs

where is the Write method of ElementTree??

2008-05-22 Thread gray . bowman
I'm messing around with trying to write an xml file using xml.etree.ElementTree. All the examples on the internet show the use of ElementTree.write(), although when I try to use it it's not available, gives me ... ElementTree(sectionElement).write("section.xml") TypeError: 'module' object is n

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Joel Koltner
"inhahe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > i figured out a solution > > sum([x,2*x] for x in range(4)],[]) #not tested Nice... thanks; I probably had seen code using 'sum' to flatten but hadn't actually understood how it worked. After playing around some it's now cl

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Joel Koltner
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> A slightly similar problem: If I want to "merge," say, list1=[1,2,3] ... items = [None] * 6 items[::2] = 1,2,3 items[1::2] = 4,5,6 items > [1, 4, 2, 5, 3, 6] Thanks Peter, that's pretty clean -- I lik

Re: Python and Flaming Thunder

2008-05-22 Thread Nick Craig-Wood
Mel <[EMAIL PROTECTED]> wrote: > Mensanator wrote: > > On May 22, 10:30??am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > >> Dave Parker <[EMAIL PROTECTED]> wrote: > >> > But after getting input from children and teachers, etc, it started > >> > feeling right. > >> > >> > For example, consider the

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Marc Christiansen
Joel Koltner <[EMAIL PROTECTED]> wrote: > Is there an easy way to get a list comprehension to produce a flat > list of, say, [x,2*x] for each input argument? > > E.g., I'd like to do something like: > > [ [x,2*x] for x in range(4) ] > > ...and receive > > [ 0,0,1,2,2,4,3,6] > > ...but of cours

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Ivan Illarionov
On Thu, 22 May 2008 15:29:42 -0400, inhahe wrote: > "Joel Koltner" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Is there an easy way to get a list comprehension to produce a flat list >> of, say, [x,2*x] for each input argument? >> >> E.g., I'd like to do something like: >> >>

Re: Struct usage and varying sizes of h, l, etc

2008-05-22 Thread Robert Kern
Ethan Furman wrote: Next question: when using struct.pack to store an integer, I get a deprecation warning if the int is too big... I would rather have an error. Is there a setting somewhere that controls this? http://docs.python.org/dev/library/warnings -- Robert Kern "I have come to bel

Re: 2 different versions of python compiling files.

2008-05-22 Thread TkNeo
On May 22, 2:44 pm, Hans Nowak <[EMAIL PROTECTED]> wrote: > TkNeo wrote: > > I am trying to upgrade from python 2.3 to 2.4 but not all machines can > > be upgraded. Can you guys tell me if this scenario is possible. > > > 1. Any machine that uses .py files that use libraries that require 2.4 > > wi

Shell-independent *nix setup script

2008-05-22 Thread scott . hafeman
Hi, Is it worthwhile maintaining a production application setup script in Python as opposed to shell-script? The main goal of this setup script is to sniff a user's environment and export environment variables to the calling (parent) process. Either way, some file would need to be sourced into the

Re: Using MySQLdb to select into the local file

2008-05-22 Thread John Nagle
Nikhil wrote: I am using the MySQLdb python module. I have a table named 'testing' with few columns, under the 'test' database, what is hosted on a remote mysql server. I want to run the following query to get a comma-separated information from the table LOCK TABLES foo READ; SELECT a,b,a+

Re: 2 different versions of python compiling files.

2008-05-22 Thread Hans Nowak
TkNeo wrote: I am trying to upgrade from python 2.3 to 2.4 but not all machines can be upgraded. Can you guys tell me if this scenario is possible. 1. Any machine that uses .py files that use libraries that require 2.4 will have 2.4 on it. 2. rest of the machines will have 2.3 now there is a sh

Re: Python and Flaming Thunder

2008-05-22 Thread [EMAIL PROTECTED]
On 22 mai, 18:56, Mensanator <[EMAIL PROTECTED]> wrote: > On May 22, 10:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > > > > Dave Parker <[EMAIL PROTECTED]> wrote: > > > But after getting input from children and teachers, etc, it started > > > feeling right. > > > > For example, consider

Re: Restarting a program

2008-05-22 Thread Geoldr
On May 22, 11:58 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On May 22, 1:38 pm, Geoldr <[EMAIL PROTECTED]> wrote: > > > > > On May 22, 10:07 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > > > On May 22, 10:59 am, Geoldr <[EMAIL PROTECTED]> wrote: > > > > > Hello all, I have written a simple p

Re: Producing multiple items in a list comprehension

2008-05-22 Thread inhahe
"Joel Koltner" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there an easy way to get a list comprehension to produce a flat list > of, say, [x,2*x] for each input argument? > > E.g., I'd like to do something like: > > [ [x,2*x] for x in range(4) ] > > ...and receive > > [ 0,0

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Peter Otten
Joel Koltner wrote: > Is there an easy way to get a list comprehension to produce a flat list > of, say, [x,2*x] for each input argument? > > E.g., I'd like to do something like: > > [ [x,2*x] for x in range(4) ] > > ...and receive > > [ 0,0,1,2,2,4,3,6] > > ...but of course you really get a

Using MySQLdb to select into the local file

2008-05-22 Thread Nikhil
I am using the MySQLdb python module. I have a table named 'testing' with few columns, under the 'test' database, what is hosted on a remote mysql server. I want to run the following query to get a comma-seperated information from the table LOCK TABLES foo READ; SELECT a,b,a+b INTO OUTFILE

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Gerard flanagan
Joel Koltner wrote: Is there an easy way to get a list comprehension to produce a flat list of, say, [x,2*x] for each input argument? E.g., I'd like to do something like: [ [x,2*x] for x in range(4) ] ...and receive [ 0,0,1,2,2,4,3,6] ...but of course you really get a list of lists: [[0, 0

Re: HTMLParser error

2008-05-22 Thread jonbutler88
On May 22, 9:59 am, alex23 <[EMAIL PROTECTED]> wrote: > On May 22, 6:22 pm, [EMAIL PROTECTED] wrote: > > > Still getting very odd errors though, this being the latest: > > > Traceback (most recent call last): > >   File "spider.py", line 38, in > > [...snip...] > >     raise InvalidURL("nonnumeric

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Dan Upton
On Thu, May 22, 2008 at 2:53 PM, Mensanator <[EMAIL PROTECTED]> wrote: > On May 22, 11:32 am, "Dutton, Sam" <[EMAIL PROTECTED]> wrote: >> I've noticed that the value of math.pi -- just entering it at the >> interactive prompt -- is returned as 3.1415926535897931, whereas (as every >> pi-obsessive

Re: Restarting a program

2008-05-22 Thread Mike Driscoll
On May 22, 1:38 pm, Geoldr <[EMAIL PROTECTED]> wrote: > On May 22, 10:07 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > > > > On May 22, 10:59 am, Geoldr <[EMAIL PROTECTED]> wrote: > > > > Hello all, I have written a simple program, and at the end of it, > > > instead of it closing I would like i

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Mensanator
On May 22, 11:32 am, "Dutton, Sam" <[EMAIL PROTECTED]> wrote: > I've noticed that the value of math.pi -- just entering it at the interactive > prompt -- is returned as 3.1415926535897931, whereas (as every pi-obsessive > knows) the value is 3.1415926535897932... (Note the 2 at the end.) > > Is t

Re: Python and Flaming Thunder

2008-05-22 Thread Mel
Mensanator wrote: > On May 22, 10:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: >> Dave Parker <[EMAIL PROTECTED]> wrote: >> > But after getting input from children and teachers, etc, it started >> > feeling right. >> >> > For example, consider the two statements: >> >> > x = 8 >> > x = 10 >>

Re: Python is slow

2008-05-22 Thread [EMAIL PROTECTED]
On 22 mai, 18:14, cm_gui <[EMAIL PROTECTED]> wrote: > Python is slow. Oh, a troll... > Almost all of the web applications written in > Python are slow. Zope/Plone is slow, sloow, so very slooow. Even > Google Apps is not faster. Neither is Youtube. > Facebook and Wikipedia (Mediawiki), wri

Re: Restarting a program

2008-05-22 Thread Geoldr
On May 22, 10:07 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On May 22, 10:59 am, Geoldr <[EMAIL PROTECTED]> wrote: > > > Hello all, I have written a simple program, and at the end of it, > > instead of it closing I would like it to restart from the beggining. > > Is there a way to do this? Put

2 different versions of python compiling files.

2008-05-22 Thread TkNeo
I am trying to upgrade from python 2.3 to 2.4 but not all machines can be upgraded. Can you guys tell me if this scenario is possible. 1. Any machine that uses .py files that use libraries that require 2.4 will have 2.4 on it. 2. rest of the machines will have 2.3 now there is a shared drive. let

  1   2   >