Re: Smart factory class

2008-01-23 Thread Gabriel Genellina
En Thu, 24 Jan 2008 05:11:19 -0200, kramer31 <[EMAIL PROTECTED]> escribió: > Can anyone tell me if there is a way in python that I can implement a > factory function which takes as input a string ClassName and returns > an object of type ClassName? def InstanceFactory(classname): cls = glo

Re: Some questions about decode/encode

2008-01-23 Thread glacier
On 1月24日, 下午1时49分, [EMAIL PROTECTED] wrote: > On Jan 23, 8:49 pm, glacier <[EMAIL PROTECTED]> wrote: > > > I use chinese charactors as an example here. > > > >>>s1='你好吗' > > >>>repr(s1) > > > "'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'" > > > >>>b1=s1.decode('GBK') > > > My first question is : what strategy

Re: Creating new types and invoking super

2008-01-23 Thread Arnaud Delobelle
On Jan 24, 7:19 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: Oops again > > Change this line to: >               getattr(super.cls, obj), self.f.__name__)() I mean getattr(super(self.cls, obj), self.f.__name__)() -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Smart factory class

2008-01-23 Thread Arnaud Delobelle
On Jan 24, 7:11 am, kramer31 <[EMAIL PROTECTED]> wrote: > Can anyone tell me if there is a way in python that I can implement a > factory function which takes as input a string ClassName and returns > an object of type ClassName? >>> def mkobj(classname, ns=globals()): return ns[classname]() ... >

Re: Some questions about decode/encode

2008-01-23 Thread Gabriel Genellina
En Thu, 24 Jan 2008 04:52:22 -0200, glacier <[EMAIL PROTECTED]> escribió: > According to your reply, what will happen if I try to decode a long > string seperately. > I mean: > ## > a='你好吗'*10 > s1 = u'' > cur = 0 > while cur < len(a): > d = min(len(a)-i

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 6:30 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 24, 9:50 am, ryan k <[EMAIL PROTECTED]> wrote: > > > Steven D'Aprano, you are a prick. > > And your reasons for coming to that stridently expressed conclusion > after reading a posting that was *not* addressed to you are .? Be

Re: Creating new types and invoking super

2008-01-23 Thread Arnaud Delobelle
On Jan 23, 11:51 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: Oops: > > class callsuper(object): >     def __init__(self, f): >         self.f = f >     def __get__(self, obj, cls=None): >         def newfunc(*args, **kwargs): >             super(self.cls, obj).__init__() Change this line to:

Re: Module/package hierarchy and its separation from file structure

2008-01-23 Thread Peter Schuller
>> I do *not* want to simply break out X into org.lib.animal.x, and >> have org.lib.animal import org.lib.animal.x.X as X. > > Nevertheless, that seems the best (indeed, the Pythonic) solution to > your problem as stated. Rather than just shooting it down, we'll have > to know more about ehat actua

Smart factory class

2008-01-23 Thread kramer31
Can anyone tell me if there is a way in python that I can implement a factory function which takes as input a string ClassName and returns an object of type ClassName? -- http://mail.python.org/mailman/listinfo/python-list

Re: Can someone explain this unexpected raw_input behavior?

2008-01-23 Thread Gabriel Genellina
En Thu, 24 Jan 2008 01:00:53 -0200, Mike Kent <[EMAIL PROTECTED]> escribió: > Gabriel, thank you for clarifying the source of this behavior. Still, > I'm surprised it would be hard-coded into Python. Consider an > interactive program, that asks the user several questions, and > displays paragrap

Re: Some questions about decode/encode

2008-01-23 Thread glacier
On 1月24日, 下午1时41分, Ben Finney <[EMAIL PROTECTED]> wrote: > Ben Finney <[EMAIL PROTECTED]> writes: > > glacier <[EMAIL PROTECTED]> writes: > > > > I use chinese charactors as an example here. > > > > >>>s1='你好吗' > > > >>>repr(s1) > > > "'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'" > > > >>>b1=s1.decode('GBK')

Re: Function wrappers

2008-01-23 Thread Gabriel Genellina
En Thu, 24 Jan 2008 00:16:01 -0200, <[EMAIL PROTECTED]> escribió: > def f( callback, *bar, **bkwar ): > def preg ( callfore, *far, **fkwar ): > return g( callback, callfore, bar, bkwar, far, fkwar ) > return preg > > Does anyone see a way to

Re: handling asynchronous callbacks from c++ in a python script

2008-01-23 Thread castironpi
On Jan 23, 5:46 pm, Tim Spens <[EMAIL PROTECTED]> wrote: > I have a c++ program running that has boost python hooks for the c++ api. > I'm running a python client that makes calls into the c++ api. The problem > is there are c++ > asynchronous callbacks that need to pass information to the python

Re: Problems getting Python scripts to run on server

2008-01-23 Thread 7stud
On Jan 23, 8:41 pm, Yansky <[EMAIL PROTECTED]> wrote: > Hi, I'm having a lot of problems getting any Python scripts to run on > my website. I have put them in the cgi-bin directory and chmodded both > the directory and files to 755. But when I try to access the script, I > get a 404 error:http://fo

Re: Terminology: "script" versus "program" (was: Linux Journal Survey)

2008-01-23 Thread Paddy
On 24 Jan, 04:59, Ben Finney <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > On Jan 23, 8:14 pm, [EMAIL PROTECTED] wrote: > > > The annual Linux Journal survey is online now for any Linux users > > > who want to vote for Python. > > >http://www.linuxjournal.com/node/10061

Re: pairs from a list

2008-01-23 Thread Paddy
On 23 Jan, 22:39, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jan 23, 4:48 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > As for your other points, I think we're actually very much in agreement, > > except for your tolerance of random posters asking what I believe is an

Re: Problems getting Python scripts to run on server

2008-01-23 Thread I V
On Wed, 23 Jan 2008 19:41:17 -0800, Yansky wrote: > Hi, I'm having a lot of problems getting any Python scripts to run on my > website. I have put them in the cgi-bin directory and chmodded both the > directory and files to 755. But when I try to access the script, I get a > 404 error: http://forbo

Re: Some questions about decode/encode

2008-01-23 Thread bbtestingbb
On Jan 23, 8:49 pm, glacier <[EMAIL PROTECTED]> wrote: > I use chinese charactors as an example here. > > >>>s1='你好吗' > >>>repr(s1) > > "'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'" > > >>>b1=s1.decode('GBK') > > My first question is : what strategy does 'decode' use to tell the way > to seperate the words.

Re: Some questions about decode/encode

2008-01-23 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > glacier <[EMAIL PROTECTED]> writes: > > > I use chinese charactors as an example here. > > > > >>>s1='你好吗' > > >>>repr(s1) > > "'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'" > > >>>b1=s1.decode('GBK') > > > > My first question is : what strategy does 'decode' use to

Issue with docking wx.listctrl window

2008-01-23 Thread tarun
Hello All, I'm trying to create a Frame with AuiManager. The code is attached. *Problem:* - I want 2 windows to be docked in the frame. One is a text control and other is a list control. - The text control gets docked, but on trying to dock the list control, all the tabs dis-appear. The tabs ap

Re: os.system behavior when calling SQLPlus with spooling

2008-01-23 Thread Martin v. Löwis
> I would prefer not to use os.system() since I want to analyze the > results. Can anyone suggest how I should go about executing sqlplus > in this case? You need to find out why it hangs. Perhaps sqlplus tries to read from its stdin, asking the user for input, yet your script doesn't provide any

Re: Some questions about decode/encode

2008-01-23 Thread Ben Finney
glacier <[EMAIL PROTECTED]> writes: > I use chinese charactors as an example here. > > >>>s1='你好吗' > >>>repr(s1) > "'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'" > >>>b1=s1.decode('GBK') > > My first question is : what strategy does 'decode' use to tell the way > to seperate the words. I mean since s1 is an

Terminology: "script" versus "program" (was: Linux Journal Survey)

2008-01-23 Thread Ben Finney
George Sakkis <[EMAIL PROTECTED]> writes: > On Jan 23, 8:14 pm, [EMAIL PROTECTED] wrote: > > The annual Linux Journal survey is online now for any Linux users > > who want to vote for Python. > > http://www.linuxjournal.com/node/1006101 > > ... > 18. What is your favorite programming language? >

Re: newbie question: On installation of additional packages to Python

2008-01-23 Thread Steve Holden
Gabriel Genellina wrote: > En Tue, 22 Jan 2008 00:36:34 -0200, Nasser Abbasi <[EMAIL PROTECTED]> > escribió: > >> I am running on windowz. I have downloaded and installed 2.5.1 Python. >> >> my question is on installing additional packages. >> >> What is the easiest way to do that? I read about

Some questions about decode/encode

2008-01-23 Thread glacier
I use chinese charactors as an example here. >>>s1='你好吗' >>>repr(s1) "'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'" >>>b1=s1.decode('GBK') My first question is : what strategy does 'decode' use to tell the way to seperate the words. I mean since s1 is an multi-bytes-char string, how did it determine to seper

Re: Linux Journal Survey

2008-01-23 Thread George Sakkis
On Jan 23, 8:14 pm, [EMAIL PROTECTED] wrote: > The annual Linux Journal survey is online now for any Linux users who > want to vote for Python. http://www.linuxjournal.com/node/1006101 ... 18. What is your favorite programming language? (15 choices, Python not included) 19. What is your favor

Problems getting Python scripts to run on server

2008-01-23 Thread Yansky
Hi, I'm having a lot of problems getting any Python scripts to run on my website. I have put them in the cgi-bin directory and chmodded both the directory and files to 755. But when I try to access the script, I get a 404 error: http://forboden.com/cgi-bin/wp.py I also tried running them from anot

Re: sudoku solver in Python ...

2008-01-23 Thread Shawn Milochik
On Jan 23, 2008, at 10:02 PM, Derek Marshall wrote: > This is just for fun, in case someone would be interested and because > I haven't had the pleasure of posting anything here in many years ... > > http://derek.marshall.googlepages.com/pythonsudokusolver > > Appreciate any feedback anyone w

Re: Can someone explain this unexpected raw_input behavior?

2008-01-23 Thread Ben Finney
Mike Kent <[EMAIL PROTECTED]> writes: > Consider an interactive program, that asks the user several > questions, and displays paragraphs of information based on those > questions. The paragraphs are output using print, and the questions > are asked via raw_input. Okay so far. > You want to do so

Re: Cleanup when a object dies

2008-01-23 Thread Benjamin
On Jan 22, 11:29 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > On Jan 22, 7:54 pm, Benjamin <[EMAIL PROTECTED]> wrote: > > > I writing writing a class to allow settings (options, preferences) to > > written file in a cross platform manner. I'm unsure how to go a about > > syncing the data to d

sudoku solver in Python ...

2008-01-23 Thread Derek Marshall
This is just for fun, in case someone would be interested and because I haven't had the pleasure of posting anything here in many years ... http://derek.marshall.googlepages.com/pythonsudokusolver Appreciate any feedback anyone who takes the time to have a look would want to give ... Yours

Re: Removing objects

2008-01-23 Thread programus
On Jan 23, 2:59 pm, [EMAIL PROTECTED] wrote: > I am writing a game, and it must keep a list of objects. I've been > representing this as a list, but I need an object to be able to remove > itself. It doesn't know it's own index. If I tried to make each object > keep track of it's own index, it woul

Re: Can someone explain this unexpected raw_input behavior?

2008-01-23 Thread Mike Kent
Gabriel, thank you for clarifying the source of this behavior. Still, I'm surprised it would be hard-coded into Python. Consider an interactive program, that asks the user several questions, and displays paragraphs of information based on those questions. The paragraphs are output using print, a

Function wrappers

2008-01-23 Thread castironpi
def f( callback, *bar, **bkwar ): def preg ( callfore, *far, **fkwar ): return g( callback, callfore, bar, bkwar, far, fkwar ) return preg Does anyone see a way to rewrite this, perhaps along the lines of partial( partial, partial )?

Re: Increment Variable Name

2008-01-23 Thread Pablo Ziliani
David Brochu wrote: > Pablo - Thanks for the reply. > > Basically what I am trying to do is pass each value from a list to the > following line of code (where XXX is where I need to pass each value > of the list > > tests = easygui.multchoicebox(message="Pick the test(s) you would like > to run

os.system behavior when calling SQLPlus with spooling

2008-01-23 Thread steve551979
I'm trying to execute SQLPlus in python (on Redhat linux). when calling sqlplus, i'm referencing an sql file which spools results to a file, for e.g.: spool "/tmp/qctemp2.out"; SELECT %s FROM bug WHERE BG_BUG_ID = %s; spool off; exit; I'm noticing that when using: os.system("sqlplus -S -L %s @

Linux Journal Survey

2008-01-23 Thread dwblas
The annual Linux Journal survey is online now for any Linux users who want to vote for Python. http://www.linuxjournal.com/node/1006101 -- http://mail.python.org/mailman/listinfo/python-list

REMINDER: OSCON 2008 Call for Proposals

2008-01-23 Thread Aahz
The O'Reilly Open Source Convention (OSCON) is accepting proposals for tutorials and presentations. The submission period ends Feb 4. OSCON 2008 will be in Portland, Oregon July 21-25. For more information and to submit a proposal, see http://conferences.oreilly.com/oscon/ -- Aahz ([EMAIL PROT

Re: Increment Variable Name

2008-01-23 Thread Ben Finney
Pablo Ziliani <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > This has a very bad code smell (...) > > > > \ `\ _o__) Ben Finney > > That is forcefulness. > (sorry, couldn't resist) I suspect that's a comment on my online nickname, "bignose", and talking about code smells. Nevertheless, it'

Re: Creating new types and invoking super

2008-01-23 Thread Guilherme Polo
2008/1/23, Arnaud Delobelle <[EMAIL PROTECTED]>: > On Jan 23, 10:18 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > > 2008/1/23, Arnaud Delobelle <[EMAIL PROTECTED]>: > > > > > The only way I can think of would be to create a metaclass, but I > > > don't think it's worth it. super(A, obj).__init

Re: Trouble writing to database: RSS-reader

2008-01-23 Thread member thudfoo
On 1/23/08, Arne <[EMAIL PROTECTED]> wrote: > On Jan 21, 11:25pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > En Mon, 21 Jan 2008 18:38:48 -0200, Arne <[EMAIL PROTECTED]> escribi�: > > [...] > > This look very interesting! But it looks like that no documents is > well-formed! I've tried s

Re: Increment Variable Name

2008-01-23 Thread Grant Edwards
On 2008-01-23, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > David Brochu schrieb: >> This is probably really trivial but I'm stumped :-( >> >> Does anyone know how to increment a variable name? >> >> For example: >> >> I know the length of a list and I want to pass each element of a list to

Re: Creating new types and invoking super

2008-01-23 Thread Arnaud Delobelle
On Jan 23, 10:18 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > 2008/1/23, Arnaud Delobelle <[EMAIL PROTECTED]>: > > > The only way I can think of would be to create a metaclass, but I > > don't think it's worth it.  super(A, obj).__init__() isn't that bad! > > Metaclass doesn't apply here becau

handling asynchronous callbacks from c++ in a python script

2008-01-23 Thread Tim Spens
I have a c++ program running that has boost python hooks for the c++ api. I'm running a python client that makes calls into the c++ api. The problem is there are c++ asynchronous callbacks that need to pass information to the python client. What I was hoping to do is call a python function from

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 9:50 am, ryan k <[EMAIL PROTECTED]> wrote: > Steven D'Aprano, you are a prick. And your reasons for coming to that stridently expressed conclusion after reading a posting that was *not* addressed to you are .? -- http://mail.python.org/mailman/listinfo/python-list

Re: Increment Variable Name

2008-01-23 Thread Diez B. Roggisch
David Brochu schrieb: > This is probably really trivial but I'm stumped :-( > > Does anyone know how to increment a variable name? > > For example: > > I know the length of a list and I want to pass each element of a list to > a unique variable, thus I want to increment variable names. If t

Re: Increment Variable Name

2008-01-23 Thread Pablo Ziliani
Ben Finney wrote: > This has a very bad code smell (...) > > \ `\ _o__) Ben Finney That is forcefulness. (sorry, couldn't resist) -- http://mail.python.org/mailman/listinfo/python-list

Re: creating .pyo with make

2008-01-23 Thread Diez B. Roggisch
Yann Leboulanger schrieb: > Yann Leboulanger wrote: >> Hi, >> >> I use autoconf / automake to manage my python project, and I'l like >> make / make install to create / install .pyo files instead of .py files. >> >> Is there something I should add to my Makefile.am files to do that? Or >> should I

Re: Can someone explain this unexpected raw_input behavior?

2008-01-23 Thread Gabriel Genellina
En Wed, 23 Jan 2008 18:27:56 -0200, Mike Kent <[EMAIL PROTECTED]> escribió: > It's often useful for debugging to print something to stderr, and to > route the error output to a file using '2>filename' on the command > line. > > However, when I try that with a python script, all prompt output from

Re: creating .pyo with make

2008-01-23 Thread Yann Leboulanger
Yann Leboulanger wrote: > Hi, > > I use autoconf / automake to manage my python project, and I'l like make > / make install to create / install .pyo files instead of .py files. > > Is there something I should add to my Makefile.am files to do that? Or > should I do all that myself with py_compi

Re: Increment Variable Name

2008-01-23 Thread Ben Finney
David Brochu <[EMAIL PROTECTED]> writes: > I know the length of a list and I want to pass each element of a > list to a unique variable, thus I want to increment variable names. > If the list length = 4, i want to have the following variables: > var1, var2, var3, var4. This has a very bad code sm

Re: Increment Variable Name

2008-01-23 Thread Pablo Ziliani
Hi David, David Brochu wrote: > I know the length of a list and I want to pass each element of a list > to a unique variable, thus I want to increment variable names. If the > list length = 4, i want to have the following variables: var1, var2, > var3, var4. yuck... no, believe me, you prob

port forwarding: python scrypt or C ?

2008-01-23 Thread Sambo
Anyone aware of something that I could test my new DSL modem with. when I finally unlocked it ( Siemens 4200 ) some setting I saw made me wonder if it is filtering at all, but tiberian sun internet play was having problems. After going through the instructions at {http://portforward.com/english/r

creating .pyo with make

2008-01-23 Thread Yann Leboulanger
Hi, I use autoconf / automake to manage my python project, and I'l like make / make install to create / install .pyo files instead of .py files. Is there something I should add to my Makefile.am files to do that? Or should I do all that myself with py_compile module? Are there some examples so

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 5:37 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > > ryan k <[EMAIL PROTECTED]> writes: > >> Hello. I have a string like 'LNAME > >> PASTA ZONE'. I want to create a list of those words and > >> ba

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 9:47 am, ryan k <[EMAIL PROTECTED]> wrote: > On Jan 23, 5:37 pm, Steven D'Aprano <[EMAIL PROTECTED] > > > > cybersource.com.au> wrote: > > On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > > > ryan k <[EMAIL PROTECTED]> writes: > > >> Hello. I have a string like 'LNAME > > >> PASTA

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 7:57 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > Why is it that so many Python people are regex adverse? Use the dashed > line as a regex. Convert the dashes to dots. Wrap the dots in > parentheses. Convert the whitespace chars to '\s'. Presto! Simpler, > cleaner code. Wo

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 5:37 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > > ryan k <[EMAIL PROTECTED]> writes: > >> Hello. I have a string like 'LNAME > >> PASTA ZONE'. I want to create a list of those words and > >> ba

Increment Variable Name

2008-01-23 Thread David Brochu
This is probably really trivial but I'm stumped :-( Does anyone know how to increment a variable name? For example: I know the length of a list and I want to pass each element of a list to a unique variable, thus I want to increment variable names. If the list length = 4, i want to have

Re: Creating new types and invoking super

2008-01-23 Thread Guilherme Polo
2008/1/23, Guilherme Polo <[EMAIL PROTECTED]>: > 2008/1/23, Arnaud Delobelle <[EMAIL PROTECTED]>: > > On Jan 23, 8:55 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > > > Hello, > > > > Hi > > [...] > > > First I tried this: > > > > > > def init(func): > > > def _init(inst): > > > supe

Re: pairs from a list

2008-01-23 Thread George Sakkis
On Jan 23, 4:48 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > As for your other points, I think we're actually very much in agreement, > except for your tolerance of random posters asking what I believe is an > incoherent question: "what's the fastest way to do ...?". It seem

Re: Stripping whitespace

2008-01-23 Thread Steven D'Aprano
On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > ryan k <[EMAIL PROTECTED]> writes: >> Hello. I have a string like 'LNAME >> PASTA ZONE'. I want to create a list of those words and >> basically replace all the whitespace between them with one space so i >> could just do lala.s

Re: pairs from a list

2008-01-23 Thread Steven D'Aprano
On Wed, 23 Jan 2008 11:06:44 -0800, George Sakkis wrote: > On Jan 23, 1:30 pm, Paddy <[EMAIL PROTECTED]> wrote: > >> I've heard quality expressed as "meeting requirements", which I think >> is apt. Falling short of requirements everyone knows doesn't give a >> quality result, but equally 'exceedi

Re: Creating new types and invoking super

2008-01-23 Thread Guilherme Polo
2008/1/23, Arnaud Delobelle <[EMAIL PROTECTED]>: > On Jan 23, 8:55 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > > Hello, > > Hi > [...] > > First I tried this: > > > > def init(func): > > def _init(inst): > > super(inst.__class__, inst).__init__() > > func(inst) > > > >

swig/python memory leak question

2008-01-23 Thread danwald
I am just getting into swig and trying to wrap my C++ library in python. I have a newbee question. If my C++ object has a method that allocates memory and returns a void * to it, python complains about a memory leak. For example %module test %{ #include "test.h" %} %include "typemaps.i" %newobjec

Re: get the size of a dynamically changing file fast ?

2008-01-23 Thread Gabriel Genellina
En Wed, 23 Jan 2008 16:16:58 -0200, Stef Mientki <[EMAIL PROTECTED]> escribió: >>> Yes, that's a small disadavantage of using a "high-level" language, >>> where there's no flush available, and you assume it'll done >>> automatically ;-) >> >> Uhm, there is a flush method for Python's files. Fro

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 7:23 am, ryan k <[EMAIL PROTECTED]> wrote: > On Jan 23, 3:02 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > On Jan 24, 6:57 am, ryan k <[EMAIL PROTECTED]> wrote: > > > > So yea i will just have to count dashes. > > > Read my lips: *you* counting dashes is dumb. Writing your code so tha

Re: pairs from a list

2008-01-23 Thread Steven D'Aprano
On Wed, 23 Jan 2008 11:57:05 -0500, Alan G Isaac wrote: > Steven D'Aprano wrote: >> In fact, "fastest" isn't even a meaningful attribute. Does it mean: >> >> * the worst-case is fastest >> * the best-case is fastest >> * the average-case is fastest >> * fastest on typical data >> * all of the abo

Re: Creating new types and invoking super

2008-01-23 Thread Arnaud Delobelle
On Jan 23, 8:55 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > Hello, Hi [...] > First I tried this: > > def init(func): >     def _init(inst): >         super(inst.__class__, inst).__init__() >         func(inst) > >     return _init > > class A(object): >     @init >     def __init__(self): p

Re: Just for fun: Countdown numbers game solver

2008-01-23 Thread Terry Jones
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes: >> >> Ha - you can't have it both ways Arnaud! You don't want the computation to >> go negative... doesn't that (and my "proof") have something to do with the >> inverse nature of add and sub? :-) Arnaud> I think I can have it both wa

Re: Removing objects

2008-01-23 Thread Steven D'Aprano
On Wed, 23 Jan 2008 10:32:55 -0200, Eduardo O. Padoan wrote: > On Jan 23, 2008 9:55 AM, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >> For that to work, you need to give your class an __eq__ method, and >> have it match by name: >> >> # put this in MyClass >> def __eq__(self, other): >>

Re: pairs from a list

2008-01-23 Thread Steven D'Aprano
On Wed, 23 Jan 2008 10:39:25 -0800, George Sakkis wrote: > On Jan 23, 4:37 am, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >> On Tue, 22 Jan 2008 23:33:00 -0800, George Sakkis wrote: >> > As I mentioned already, I consider the seeking of the most efficient >> > solution a legitimate question, reg

Re: Is there a HTML parser who can reconstruct the original html EXACTLY?

2008-01-23 Thread Fuzzyman
[EMAIL PROTECTED] wrote: > Hi, I am looking for a HTML parser who can parse a given page into > a DOM tree, and can reconstruct the exact original html sources. > Strictly speaking, I should be allowed to retrieve the original > sources at each internal nodes of the DOM tree. > I have tried

Re: Trouble writing to database: RSS-reader

2008-01-23 Thread Gabriel Genellina
En Wed, 23 Jan 2008 14:06:10 -0200, Arne <[EMAIL PROTECTED]> escribió: > On Jan 21, 11:25 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> > On 21 Jan, 19:15, Bruno Desthuilliers > > [EMAIL PROTECTED]> wrote: >> >> >> This should not prevent you from learning how to properly parse XML >> >>

Re: How avoid both a newline and a space between 2 print commands?

2008-01-23 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > On Jan 23, 6:12 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > sys.stdout.write("foo") > > sys.stdout.write("bar") > > Diez > > Thanks. Beautiful! I <3 Python! Even better, this form will survive unchanged into Python 3, whereas the '

Re: Module/package hierarchy and its separation from file structure

2008-01-23 Thread Ben Finney
Peter Schuller <[EMAIL PROTECTED]> writes: > Let me just shoot down one possible suggestion right away, to show > you what I am trying to accomplish: > > I do *not* want to simply break out X into org.lib.animal.x, and > have org.lib.animal import org.lib.animal.x.X as X. Nevertheless, that seem

Re: When is min(a, b) != min(b, a)?

2008-01-23 Thread Robert Kern
Russell E. Owen wrote: > In article <[EMAIL PROTECTED]>, > Christian Heimes <[EMAIL PROTECTED]> wrote: > >> Grant Edwards wrote: >>> In many applications (e.g. process control) propogating NaN >>> values are way too useful to avoid. Avoiding NaN would make a >>> lot of code far more complicated

Re: A global or module-level variable?

2008-01-23 Thread Gabriel Genellina
En Wed, 23 Jan 2008 11:58:05 -0200, Bret <[EMAIL PROTECTED]> escribió: > On Jan 22, 1:00 pm, Paul Rubin wrote: > >> If you have to do it that way, use: > > Is there a better way? A more Pythonic way? It's simple, clear and works fine, why make it more complicated? Unle

Re: Just for fun: Countdown numbers game solver

2008-01-23 Thread Arnaud Delobelle
On Jan 23, 8:40 pm, Terry Jones <[EMAIL PROTECTED]> wrote: > > "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes: > > Arnaud> FWIW, I have a clear idea of what the space of solutions is, and > Arnaud> which solutions I consider to be equivalent.  I'll explain it > Arnaud> below.  I'm not

Re: HTML parsing confusion

2008-01-23 Thread Gabriel Genellina
En Wed, 23 Jan 2008 10:40:14 -0200, Alnilam <[EMAIL PROTECTED]> escribió: > Skipping past html validation, and html to xhtml 'cleaning', and > instead starting with the assumption that I have files that are valid > XHTML, can anyone give me a good example of how I would use _ htmllib, > HTMLParser

Re: A GUI framework for running simulations

2008-01-23 Thread Martin Manns
On Wed, 23 Jan 2008 06:10:07 -0800 (PST) "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hello! I am currently working on writing a simulation engine for > special relativity physics. I'm writing it in Python, of course. I'm > doing fine with the engine, but I want a GUI framework in which I > co

RE: Stripping whitespace

2008-01-23 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of ryan k > Sent: Wednesday, January 23, 2008 3:24 PM > To: python-list@python.org > Subject: Re: Stripping whitespace > > On Jan 23, 3:02 pm, John Machin <[EMAIL PROTECTED]> wrote: > > On Jan 24,

Creating new types and invoking super

2008-01-23 Thread Guilherme Polo
Hello, Before starting, let me show some sample codes so I can explain: class A(object): def __init__(self): super(A, self).__init__() x = type("X", (A, ), {})() This works fine, but suppose I have several classes like A and I would like to create a decorator to call super. First I

Re: Just for fun: Countdown numbers game solver

2008-01-23 Thread dg . google . groups
Well I tried the NumPy array thing that I was talking about, to parallelise the problem, and there were some difficulties with it. Firstly, the pruning makes a really big difference to the speed, and you don't get that if you're trying to parallelise the problem because what is an equivalent calcul

Re: When is min(a, b) != min(b, a)?

2008-01-23 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, Christian Heimes <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > > In many applications (e.g. process control) propogating NaN > > values are way too useful to avoid. Avoiding NaN would make a > > lot of code far more complicated than would using them. > > Na

Re: Just for fun: Countdown numbers game solver

2008-01-23 Thread Terry Jones
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes: Arnaud> FWIW, I have a clear idea of what the space of solutions is, and Arnaud> which solutions I consider to be equivalent. I'll explain it Arnaud> below. I'm not saying it's the right model, but it's the one Arnaud> within which I

Can someone explain this unexpected raw_input behavior?

2008-01-23 Thread Mike Kent
It's often useful for debugging to print something to stderr, and to route the error output to a file using '2>filename' on the command line. However, when I try that with a python script, all prompt output from raw_input goes to stderr. Consider the following test program: === Start test.py ===

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 3:02 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 24, 6:57 am, ryan k <[EMAIL PROTECTED]> wrote: > > > So yea i will just have to count dashes. > > Read my lips: *you* counting dashes is dumb. Writing your code so that > *code* is counting dashes each time it opens the file is sma

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 6:57 am, ryan k <[EMAIL PROTECTED]> wrote: > So yea i will just have to count dashes. Read my lips: *you* counting dashes is dumb. Writing your code so that *code* is counting dashes each time it opens the file is smart. -- http://mail.python.org/mailman/listinfo/python-list

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 2:53 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 24, 6:17 am, ryan k <[EMAIL PROTECTED]> wrote: > > > I am taking a database class so I'm not asking for specific answers. > > Well I have this text tile: > > >http://www.cs.tufts.edu/comp/115/projects/proj0/customer.txt > > Uh-huh,

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 6:17 am, ryan k <[EMAIL PROTECTED]> wrote: > I am taking a database class so I'm not asking for specific answers. > Well I have this text tile: > > http://www.cs.tufts.edu/comp/115/projects/proj0/customer.txt Uh-huh, "column-aligned" output. > > And this code: > [snip] > > Because the

Re: When is min(a, b) != min(b, a)?

2008-01-23 Thread Christian Heimes
Grant Edwards wrote: > In many applications (e.g. process control) propogating NaN > values are way too useful to avoid. Avoiding NaN would make a > lot of code far more complicated than would using them. NaNs are very useful for experienced power users but they are very confusing for newbies or

math and numerical fixes (was: When is min(a, b) != min(b, a)?)

2008-01-23 Thread Christian Heimes
Jason wrote: > Please note that NaN's are very funky and platform dependent. They > depend on their underlying platform's C library for creation and > display. On windows, "float('nan')" will cause an exception, as there > are no valid string representations of NAN that can be converted to > the

Re: Hebrew in idle ans eclipse (Windows)

2008-01-23 Thread iu2
On Jan 23, 11:17 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > If you are claimaing that the program > > Apparently, they do the OEMtoANSI conversion when you run a console > application (i.e. python.exe), whereas they don't convert when running > a GUI application (pythonw.exe). > > I'm not

Re: How avoid both a newline and a space between 2 print commands?

2008-01-23 Thread [EMAIL PROTECTED]
On Jan 23, 6:12 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > sys.stdout.write("foo") > sys.stdout.write("bar") Diez Thanks. Beautiful! I <3 Python! Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing objects

2008-01-23 Thread Robert Kern
[EMAIL PROTECTED] wrote: > So, in general, is it more efficient to use a dictionary or to > override the __eq__ function? Sorry, I guess I wasn't as clear as I could be. If your classes have not overridden __eq__ or __cmp__, list.remove() should have worked just fine. If you want your objects

Re: Automatically Writing a Dictionary

2008-01-23 Thread Tim Chase
> input = "/usr/local/machine-lang-trans/dictionary.txt" > > input = open(input,'r') > > dict = "{" > for line in input: > ? tup = re.split(','line) > ? dict += '"' + tup[0] +'":"' + tup[1] +'", ' > dict += "}" > input.close() > > > Of course, that will just give me a string. How do I convert >

Re: Python printing!

2008-01-23 Thread Alan G Isaac
SMALLp wrote: > Hy. How to use printer in python. http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not 'foo = not f' instead of 'foo = (not f or 1) and 0'?

2008-01-23 Thread George Sakkis
On Jan 23, 4:06 am, Gary Herron <[EMAIL PROTECTED]> wrote: > However there *is* a (subtle) difference between > not f > and > (not f and 1) or 0 > > The first produces a boolean value, and the second produces an int > value, but since one is a subclass of the other, you'd have to write > quite

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 6:05 am, Paul Rubin wrote: > ryan k <[EMAIL PROTECTED]> writes: > > Hello. I have a string like 'LNAME > > PASTA ZONE'. I want to create a list of those words and > > basically replace all the whitespace between them with one space so i > > could

  1   2   3   >