Re: Prototype OO

2008-03-26 Thread castironpi
On Mar 26, 3:14 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Wed, 26 Mar 2008 02:03:24 -0300, "Gabriel Genellina" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > No:http://en.wikipedia.org/wiki/Saruman Ask him any time over. -- http://mail.python.org/mailman/

Re: My python interpreter became mad !

2008-03-25 Thread castironpi
On Mar 25, 7:45 pm, John Machin <[EMAIL PROTECTED]> wrote: > Furkan Kuru incorrigibly top-posted: > > > Ok, you're right. > > > but I did not give it a chance "not trying python interpreter in another > > directory" > > I don't understand that sentence. > > > so if we assume the problem exists in e

Re: Prototype OO

2008-03-25 Thread castironpi
On Mar 25, 11:24 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Wed, 26 Mar 2008 06:49:57 +0800, "Delaney, Timothy (Tim)" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > As an aside, having lived much of my early life on a hobby farm, I've > > often wondered to m

Re: Does python hate cathy?

2008-03-25 Thread castironpi
On Mar 23, 8:05 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > When I run this script, I got the following exception: > > Exception exceptions.AttributeError: "'NoneType' object has no > > attribute 'population'" in > <__main__.Person instance at 0xb7d8ac6c>> ignored > > > To to newcomer like me, th

Re: any good g.a.'s?

2008-03-25 Thread castironpi
On Mar 25, 11:03 am, Tim Chase <[EMAIL PROTECTED]> wrote: > > Any good genetic algorithms involving you-split, i-pick? > > I've always heard it as "you divide, I decide"... > > That said, I'm not sure how that applies in a GA world.  It's > been a while since I've done any coding with GAs, but I do

Re: Inheritance question

2008-03-25 Thread castironpi
On Mar 25, 12:01 pm, Robert Bossy <[EMAIL PROTECTED]> wrote: > Hi, > > I'm not sure what you're trying to actually achieve, but it seems that > you want an identificator for classes, not for instances. In this case, > setting the id should be kept out of __init__ since it is an instance > initializ

any good g.a.'s?

2008-03-25 Thread castironpi
Any good genetic algorithms involving you-split, i-pick? "genetic algorithms involving you-split, i-pick" returned 6 results. So, people: -- http://mail.python.org/mailman/listinfo/python-list

Re: dividing tuple elements with an int or float

2008-03-24 Thread castironpi
On Mar 23, 12:22 pm, Lie <[EMAIL PROTECTED]> wrote: > On Mar 22, 2:23 pm, [EMAIL PROTECTED] wrote: > > > > Sane programmers don't write such semi-functional things (unless it > > > helps expressing the problem in certain domains). > > > I now think that deprecating map, lambda & Co. was a good thin

what are generators?

2008-03-24 Thread castironpi
I'm looking for a cool trick using generators. Know any exercises I can work? -- http://mail.python.org/mailman/listinfo/python-list

Re: Shortcutting the function call stack

2008-03-24 Thread castironpi
On Mar 24, 9:48 am, Jason <[EMAIL PROTECTED]> wrote: > On Mar 24, 5:21 am, Julien <[EMAIL PROTECTED]> wrote: > > > > > > > Hello all, > > > I would like to do something like: > > > def called(arg) > >     if arg==True: > >         !!magic!!caller.return 1 > > > def caller(arg) > >     called(arg) >

Re: finding items that occur more than once in a list

2008-03-22 Thread castironpi
On Mar 22, 3:31 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > John Machin wrote: > >> On Mar 22, 1:11 am, [EMAIL PROTECTED] wrote: > >>> A collision sequence is not so rare. > >> [ hash( 2**i ) for i in range( 0, 256, 32 ) ] > >>> [1, 1, 1, 1, 1, 1, 1, 1] > >> Bryan

Re: Can I run a python program from within emacs?

2008-03-22 Thread castironpi
On Mar 22, 3:47 am, David Reitter <[EMAIL PROTECTED]> wrote: > On Mar 20, 3:09 pm, jmDesktop <[EMAIL PROTECTED]> wrote: > > > Hi, I'm trying to learn Python.  I using Aquamac an emac > > implementation with mac os x.  I have a program.  If I go to the > > command prompt and type pythong myprog.py,

function-class frustration

2008-03-22 Thread castironpi
>>> FunctionType.__eq__= 0 Traceback (most recent call last): File "", line 1, in TypeError: can't set attributes of built-in/extension type 'function' >>> type( 'F', ( FunctionType, ), { '__eq__': e } ) Traceback (most recent call last): File "", line 1, in TypeError: type 'function' is not

Re: finding items that occur more than once in a list

2008-03-22 Thread castironpi
On Mar 21, 3:39 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Mar 22, 1:11 am, [EMAIL PROTECTED] wrote: > > A collision sequence is not so rare. > > > >>> [ hash( 2**i ) for i in range( 0, 256, 32 ) ] > > > [1, 1, 1, 1, 1, 1, 1, 1] > > Bryan did qualify his remarks: "If we exclude the case where

Re: dividing tuple elements with an int or float

2008-03-22 Thread castironpi
On Mar 21, 1:08 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > Sane programmers replace that crazyness with this code: > > tuple(x+1 for x in y) > > Sane programmers -like D'Aprano, Jerry Hill and me- replace that > crazyness with this code: > > tuple(x/2.5 for x in y) > > Sane programmers don'

Re: finding items that occur more than once in a list

2008-03-21 Thread castironpi
On Mar 21, 4:17 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > Bryan Olson wrote: > [...] > >> Arnaud Delobelle offered a good Wikipedia link, and for more background > >> look up "amortized analysis. > > > Hrvoje Niksic provided the link :). > > Oops, careless thread-foll

Re: What c.l.py's opinions about Soft Exception?

2008-03-21 Thread castironpi
On Mar 11, 2:30 pm, Lie <[EMAIL PROTECTED]> wrote: > On Mar 12, 12:00 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > Actually, the latter is even less cluttered, misses a raise - if pure number > > of literals is your metric, that is. > > You don't just compare by the calling code, you've

Re: dividing tuple elements with an int or float

2008-03-21 Thread castironpi
On Mar 21, 8:14 am, [EMAIL PROTECTED] wrote: > On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > > On Thu, Mar 20, 2008 at 3:42 AM, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > > On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > > > >  > suppose > > >  > origsz=(400,300) > > >  >

Re: lists v. tuples

2008-03-21 Thread castironpi
On Mar 19, 4:56 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I am puzzled by the failure on 'a in a' for a=[a].  >>> a== [a] also > > fails.  Can we assume/surmise/deduce/infer it's intentional? > > It may be less confusing if instead of an assignment following by a te

Re: dividing tuple elements with an int or float

2008-03-21 Thread castironpi
On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 3:42 AM, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > > >  > suppose > >  > origsz=(400,300) > >  > i want to divide the origsize by 2.5 so i can resize to (

Re: Beautiful Code in Python?

2008-03-21 Thread castironpi
On Mar 9, 6:44 pm, [EMAIL PROTECTED] wrote: > On Mar 2, 1:18 pm, [EMAIL PROTECTED] wrote: > > > On Mar 2, 12:01 pm, John DeRosa <[EMAIL PROTECTED]> wrote: > > > > On Mon, 3 Mar 2008 01:23:32 +0900, js <[EMAIL PROTECTED]> wrote: > > > >Hi, > > > > >Have you ever seen Beautiful Python code? > > > >Zo

decoupling a certain method

2008-03-21 Thread castironpi
class Proxy: def __init__( self, proxer ): object.__setattr__( self, '_proxer', proxer ) ComplexObject= object viewA= type( 'ComplexView', ( Proxy, ComplexObject ), { '__eq__': lambda self, other: abs( self._proxer- other )<= 1 } ) j= range( 10 ) g= 5 for a in j: p= viewA( a ) pr

Re: Is this valid ?

2008-03-20 Thread castironpi
On Mar 20, 6:06 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 20 Mar 2008 15:09:08 +0100, Rolf van de Krol wrote: > > > John Machin wrote: > >> Of course. You can chain comparisons as much as you like and is > >> (semi-)sensible, e.g. > > > Hmm, 'of course' is not the

Re: finding items that occur more than once in a list

2008-03-20 Thread castironpi
On Mar 20, 2:07 am, John Machin <[EMAIL PROTECTED]> wrote: > On Mar 20, 12:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote:> En Wed, 19 Mar 2008 20:16:36 -0300, John Machin <[EMAIL PROTECTED]>   > > escribió: > > > > On Mar 20, 9:14 am, sturlamolden <[EMAIL PROTECTED]> wrote: > > >> Is a Pyt

Re: Improving datetime

2008-03-20 Thread castironpi
On Mar 19, 5:32 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 19 Mar 2008 17:40:39 -0400, Nicholas F. Fabry wrote: > > To summarize my proposal VERY briefly: > > > - Make aware datetime objects display in local time, but calculate/ > > compare in UTC. > > What possible

seek into file-like for ipc

2008-03-20 Thread castironpi
Hive: How about a shared-memory/file-map to a Python object? Seek and tell. Has its own GIL? Raises Exceptions? Standard C++ prohibits returning pointer-to-members. File runs in its own thread, can callback host and raise its own exceptions, iow file process. Think live persistence. Client

Re: stdout custom

2008-03-19 Thread castironpi
> >> > Can I allocate a second console window, so I can place certain output > >> > to that directly, and leave the original streams alone?  I tried > >> Have you tried using the creationflags argument to subprocess.Popen? > >> Specially the CREATE_NEW_CONSOLE flag. See the Microsoft documentation

Re: finding items that occur more than once in a list

2008-03-18 Thread castironpi
On Mar 18, 10:08 pm, Bryan Olson <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > Ninereeds wrote: > >> Hrvoje Niksic wrote: > >>> This doesn't apply to Python, which implements dict storage as an > >>> open-addressed table and automatically (and exponentially) grows the > >>> table when th

Re: lists v. tuples

2008-03-18 Thread castironpi
> >> >>> b in b > >> False > > > That's actually interesting. > > Just for the avoidance of doubt, I didn't write the 'b in b' line: > castironpi is replying to himself without attribution. > > P.S. I still don't see t

Re: finding items that occur more than once in a list

2008-03-18 Thread castironpi
On Mar 18, 6:38 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Mar 18, 3:59 pm, Ninereeds <[EMAIL PROTECTED]> wrote: > > > Hrvoje Niksic wrote: > > > This doesn't apply to Python, which implements dict storage as an > > > open-addressed table and automatically (and exponentially) grows the >

Re: lists v. tuples

2008-03-18 Thread castironpi
> > > On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > > >> A common explanation for this is that lists are for homogenous > > >> collections, tuples are for when you have heterogenous collections i.e. > > >> related but different things. > > > > I interpret this as meaning that in a

Re: stdout custom

2008-03-18 Thread castironpi
> > >>> Can I allocate a second console window, so I can place certain output > > >>> to that directly, and leave the original streams alone?   > > > I've rather lost track of what you're trying to do, but I would > > second Gabriel's suggestion of the standard Windows method of > > debug output: u

Re: stdout custom

2008-03-18 Thread castironpi
On Mar 18, 8:51 am, Tim Golden <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >>> Can I allocate a second console window, so I can place certain output > >>> to that directly, and leave the original streams alone?   > > I've rather lost track of what you're trying to do, but I would > seco

Re: Get actual call signature?

2008-03-18 Thread castironpi
On Mar 18, 5:40 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > Say, I have a function defined as: > > def fun(arg_one, arg_two='x', arg_three=None): >     pass > > Is there any way to get actual arguments that will be effectively used > when I call this function in various ways, like: > > fun(5) => [

Re: stdout custom

2008-03-18 Thread castironpi
On Mar 17, 8:16 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > On 17 mar, 19:43, [EMAIL PROTECTED] wrote: > > > Can I allocate a second console window, so I can place certain output > > to that directly, and leave the original streams alone?  I tried some > > things in subprocess (Py 3a3 /WinXP

In regards to threads of today:

2008-03-17 Thread castironpi
Speaking of the standards, anyone ever try to override a method in xmlrpclib.ServerProxy? Case in point, and it's on your computer. Tear it up & tell your manager. Class Transport isn't even documented, despite its being the second parameter to the initializer. The module is > 1000 lines long.

Re: how to create instances of classes without calling the constructor?

2008-03-17 Thread castironpi
On Mar 17, 7:08 pm, "Dominik Jain" <[EMAIL PROTECTED]> wrote: > Hi! > > Does anyone know how an instance of a (new-style) class can be created > without having to call the constructor (and providing the arguments it > requires)? With old-style classes, this was possible using new.instance. > Surely

Re: String To List

2008-03-17 Thread castironpi
On Mar 17, 10:26 am, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Girish wrote: > > I have a string a = "['xyz', 'abc']".. I would like to convert it to a > > list with elements 'xyz' and 'abc'. Is there any simple solution for > > this?? > > Do you want: > > (1) Specifically to vivify lists formatted

Re: Interesting math problem

2008-03-17 Thread castironpi
On Mar 17, 5:24 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > Here is an interesting math problem: > > You have a number X > 0 and another number Y > 0. The goal is to > divide X into a list with length Y. Each item in the list is an > integer. The sum of all integers is X. Each integer is eit

Re: stdout custom

2008-03-17 Thread castironpi
On Mar 17, 8:16 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sun, 16 Mar 2008 22:27:28 -0200, <[EMAIL PROTECTED]> escribió: > > > Specifically, before the prompts.  Where does the prompt write come > > from; why doesn't it honor my settings of sys.stdout and sys.stderr? > > The interacti

Re: lists v. tuples

2008-03-17 Thread castironpi
On Mar 17, 11:03 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > Ninereeds <[EMAIL PROTECTED]> wrote: > > On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > >> A common explanation for this is that lists are for homogenous > >> collections, tuples are for when you have heterogenous colle

Re: lists v. tuples

2008-03-17 Thread castironpi
On Mar 17, 6:49 am, [EMAIL PROTECTED] wrote: > What are the considerations in choosing between: > >    return [a, b, c] > > and > >     return (a, b, c) # or return a, b, c > > Why is the immutable form the default? Using a house definition from some weeks ago, a tuple is a data structure such whi

Re: String To List

2008-03-17 Thread castironpi
> > > > I have a string a = "['xyz', 'abc']".. I would like to convert it to a > > > > list with elements 'xyz' and 'abc'. Is there any simple solution for > > > > this?? > > > > Thanks for the help... > > > > eval(a) will do the job, but you have to be very careful about using > > > that function.

Re: writing to a binary file without intervening spaces

2008-03-17 Thread castironpi
On Mar 17, 3:28 am, Paul Rubin wrote: > Larry <[EMAIL PROTECTED]> writes: > > My data is a = [23, 45, 56, 255]. > > My desire output is: 234556255, of course in binary file > > representation already. > > > I tried to make one using write after pack method of struct modul

Re: Converting a string to the most probable type

2008-03-16 Thread castironpi
> > > The trick in the case of when you do not want to guess, or the choices > > > grow too much, is to ask the user to tell you in what format they want > > > it and format according to their wishes. > > > > Neatly avoids too much guessing and isn't much extra to add. > > > The plot is about under

stdout custom

2008-03-16 Thread castironpi
The code should have extra colons. >>> class ThreadedOut: ... def __init__( self, old ): ... self._old= old ... def write( self, s ): ... self._old.write( ':' ) ... return self._old.write( s ) ... def flush( self ): ... self._old.flush()

Re: Socket Performance

2008-03-16 Thread castironpi
On Mar 16, 1:29 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sat, 15 Mar 2008 20:08:05 -0200, <[EMAIL PROTECTED]> escribi�: > > > > > > > On Mar 15, 8:18 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] wrote: > >> > Newbie question:  Can you write to the 'file-like obje

Re: 'join' in the wrong word for the method in class Thread.

2008-03-16 Thread castironpi
On Mar 16, 3:42 am, Torsten Bronger <[EMAIL PROTECTED]> wrote: > Hallöchen! > > [EMAIL PROTECTED] writes: > > [...] > > *** English is SVO, subject-verb-object.  French is too, unless the > > object is direct: subject- direct-object -verb. > > Really?  I thought this is only the case for pronouns.

Re: 'join' in the wrong word for the method in class Thread.

2008-03-16 Thread castironpi
On Mar 16, 1:43 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > 'join' in the wrong word for the method in class Thread. > > That's the standard term in threading.  If it's not familiar to you, > well, bummer, but there's not much more that can be done about that than

Re: string literal or NoneType

2008-03-15 Thread castironpi
> > | hi all > > | i want to check a condition and if true should return a filename > > | string  from a list.if the condition is false i am returning a > > | ""  (string literal).. Identity is the strictest test, and you can't define your own. Lots of things can evaluate to True. Only None is N

Re: 'join' in the wrong word for the method in class Thread.

2008-03-15 Thread castironpi
On Mar 15, 9:28 pm, Benjamin <[EMAIL PROTECTED]> wrote: > On Mar 15, 7:29 pm, [EMAIL PROTECTED] wrote:> 'join' in the wrong word for > the method in class Thread. > > > The agent-patient semantics of calling functions can get ambiguous. > > It is not a problem of native Pythoners alone.  Is it due

Re: string literal or NoneType

2008-03-15 Thread castironpi
On Mar 15, 2:41 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | hi all > | i want to check a condition and if true should return a filename > | string  from a list.if the condition is false i am returning a > | ""  (string literal).

'join' in the wrong word for the method in class Thread.

2008-03-15 Thread castironpi
'join' in the wrong word for the method in class Thread. The agent-patient semantics of calling functions can get ambiguous. It is not a problem of native Pythoners alone. Is it due to lazy programming, an inability of English (do you have it in other languages?), or not a problem at all? th1.jo

Re: string literal or NoneType

2008-03-15 Thread castironpi
On Mar 15, 10:27 am, [EMAIL PROTECTED] wrote: > hi all > i want to check a condition and if true should return a filename > string  from a list.if the condition is false i am returning a > ""  (string literal).. > > retv="" > if  somecondition: >     retv=mylist[x] > ... > return retv > > The calli

Re: Socket Performance

2008-03-15 Thread castironpi
On Mar 15, 8:18 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Gabriel Genellina wrote: > >> No need to reinvent the wheel. socket objects already have a makefile   > >> method returning a file-like object, which behaves like a buffered socket. > > That wheel is far from

Re: Joseph Weizenbaum

2008-03-15 Thread castironpi
> >>> I am embarrassed to say that this vaguely disrespectful exchange made me > >>> laugh out loud. > > >> Serious: why do you think this is disrespectful? > > >Not to speak for Tim, but I imagine it could be perceived as > >disrespectful because Prof. Weizenbaum has only recently passed away. > >

Re: Joseph Weizenbaum

2008-03-15 Thread castironpi
On Mar 15, 4:56 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Mar 15, 5:47 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > > > > > > > Jeff Schwab <[EMAIL PROTECTED]> wrote: > > >Roel Schroeven wrote: > > >> [EMAIL PROTECTED] schreef: > > >>> On Mar 14, 1:47 pm, "Reedick, Andrew" <[EMAIL PROTEC

Re: Socket Performance

2008-03-15 Thread castironpi
On Mar 15, 3:33 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 13 Mar 2008 15:18:44 -0200, <[EMAIL PROTECTED]> escribió: > > > Well, lets say you have a situation where you're going to be > > alternating between sending large and small chunks of data. Is the > > solution to create a N

Re: call by reference howto????

2008-03-15 Thread castironpi
On Mar 15, 12:39 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On 14 Mar 2008 10:38:52 GMT, Antoon Pardon <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > In that case I find it very strange that when this question comes > > up, I see so few attempts to explain how the

Re: Joseph Weizenbaum

2008-03-14 Thread castironpi
On Mar 14, 5:16 pm, Roel Schroeven <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schreef: > > > On Mar 14, 1:47 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > >>> Subject: RIP: Joseph Weizenbaum > >>> Creator of Eliza: > >>>http://www-tech.mit.edu/V128/N12/weizenbaum.html > >>> -- > >> How do

Re: Joseph Weizenbaum

2008-03-14 Thread castironpi
On Mar 14, 1:47 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of Aahz > > Sent: Friday, March 14, 2008 2:05 PM > > To: [EMAIL PROTECTED] > > Subject: RIP: Joseph Weizenbaum > > > Creator of

Re: Network server- / client-side messaging

2008-03-14 Thread castironpi
On Mar 2, 3:43 pm, [EMAIL PROTECTED] wrote: > ''' > Last time, we left off at: > ''' > > class InterfaceClientSide( ClientSide ): >         message= MessageDec() >         incremental= message.incremental() >         settings= AYT( .5, 3 ) >         user_act= message.out() >         def __init__( s

Re: Socket Performance

2008-03-14 Thread castironpi
> > Well, lets say you have a situation where you're going to be > > alternating between sending large and small chunks of data. Is the > > solution to create a NetworkBuffer class and only call send when the > > buffer is full, always recv(8192)? > >         Or create a protocol where the first 16

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
On Mar 13, 8:15 pm, [EMAIL PROTECTED] wrote: > On Mar 13, 7:45 pm, [EMAIL PROTECTED] wrote: > > > > > > > On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote: > > > > Diez B. Roggisch wrote: > > > >> My understanding is that foo.bar does *not* create a new object. > > > > > Your understanding is not

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
On Mar 13, 7:45 pm, [EMAIL PROTECTED] wrote: > On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote: > > > > > > > Diez B. Roggisch wrote: > > >> My understanding is that foo.bar does *not* create a new object. > > > > Your understanding is not correct. > > > >>  All it > > >> does is return the value

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: > >> My understanding is that foo.bar does *not* create a new object. > > > Your understanding is not correct. > > >>  All it > >> does is return the value of the bar attribute of object foo.  What new > >> object is being

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
> > Basically, the above code is saying that foo.foobar is not the same as > > getattr(foo, 'foobar'). > > > What gives?  This breaks my understanding of id(), the is operator, and > > getattr(). > > 4.  Both points above follow from the fact that foo.bar is really a > function call that returns a

Re: newbie question structure of function

2008-03-13 Thread castironpi
Just some FYI options. >     if not matchfilename: May return positive if you someday return an object that holds a 'not' value. >     resultname=""" That starts a string literal. > if (matchdistance < threshold): Parentheses optional. >     return (matchdistance,resultname) Parentheses opt

Re: What's Going On?

2008-03-13 Thread castironpi
On Mar 13, 6:12 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > (Accompanied by Marvin Gaye) > > def f(list=[0]): > > ...list[0]+=1 > > ...return list[0] > > ... > f() > > 1 > f() > > 2 > f() # 'list' is a name bound to a list (mutable) s

Re: sys.stdout assign to- bug

2008-03-13 Thread castironpi
> import sys > class ThreadedOut: >         def __init__( self, old ): >                 self._old= old >         def write( self, s ): >                 self._old.write( s ) > sys.stdout= ThreadedOut( sys.stdout ) > > Python 3.0a2 WinXP, on the console.  'a' is undeclared but error > message isn't

Re: string / split method on ASCII code?

2008-03-12 Thread castironpi
>    import re >    splitter_re = re.compile(chr(174) + '|' + chr(175)) >    for line in file(FILENAME): >      parts = splitter_re.split(line) >      do_something(parts) > > and then go find a large blunt object with which to bludgeon the > creator of the file... :) p>> creator= CreatorOfTheFile(

Re: for-else

2008-03-12 Thread castironpi
On Mar 11, 4:43 am, NickC <[EMAIL PROTECTED]> wrote: > On Mar 4, 11:27 pm, [EMAIL PROTECTED] wrote: > > > > > The meaning is explicit. While "else" seems to mean little there. > > So I may like something similar for Python 3.x (or the removal of the > > "else"). > > Consider a loop with the followi

Re: tcp client socket bind problem

2008-03-12 Thread castironpi
On Mar 11, 2:19 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > >On Mar 10, 9:40 am, Marc Christiansen <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] wrote: > >> > I have a linux box with multiple ip addresses. I want to make my > >> > python client connect from one of

sys.stdout assign to- bug

2008-03-12 Thread castironpi
I'm actually intimidated enough by a few tries I make to say something on Python-Ideas, that I thought I'd run this by youguys first. import sys class ThreadedOut: def __init__( self, old ): self._old= old def write( self, s ): self._old.write( s ) s

Re: best way to have enum-like identifiers?

2008-03-11 Thread castironpi
> > [enums snip] > Thus, those names are all bound to unique objects, that won't be > unexpectedly duplicated by some other value. > > > but I'm curious if there's a better way of doing this, some kind of > > enum-like thing or somesuch. > > Please try the 'enum' package in the Cheeseshop: Am I th

Re: difference b/t dictionary{} and anydbm - they seem the same

2008-03-11 Thread castironpi
> > Are there any that aren't persistent? > >         SQLite -- when opening a "memory" database rather than giving it a > physical file. {I'm a tad too busy to look up the format of the memory > parameter, but it shouldn't be too difficult to find it} What? If I wanted to code string literals, I

Re: merging intervals repeatedly

2008-03-11 Thread castironpi
> > Correct. I meant the final should be > > (1,30), (29,40), (50,100) > >         Actually, even that is incorrect -- note that ,30 overlaps 29, Actually, given the specification, (overlaps > N count), (1,15), (20, 30), (29, 40), (50, 66), (62,100) is right, since 66-62= 4<= 5. [1] >         Sin

base-class call decorator

2008-03-11 Thread castironpi
If you had this, class KType( BaseType ): def __init__( self, *ar, **kwar ): self.setProp= True BaseType.__init__( self, *ar, **kwar ) a lot, and wanted a decorator, what would it be? What are the pros and cons? class KType( BaseType ): @basecall def __init__( self ):

Re: difference b/t dictionary{} and anydbm - they seem the same

2008-03-11 Thread castironpi
> >  Thanks, that makes sense. Are there any local relational databases > >  available to python that don't require a server backend? > > sqlite > http://www.sqlite.org/ Are there any that aren't persistent? -- http://mail.python.org/mailman/listinfo/python-list

Re: python interactive - threaded console (run -i)

2008-03-11 Thread castironpi
>         self._doneevents= {} is extraneous. > id, fun, ar, kw= self.get() done, fun, ar, kw= self.get() suffices. > def _draintilclose( conn, understandfun= None ): >         if None is not understandfun: >             understandfun( _curmsg ) yield _curmsg is an interesti

Re: mulithreaded server

2008-03-11 Thread castironpi
> > >In the above program, why there is an unhandeled exception ??? > > > Just a guess. You should really include the traceback when you ask a > > question like this. > > It's not a traceback error. It's an unhandeled exception. Have a look at this: http://groups.google.com/group/comp.lang.python

Re: Regarding coding style

2008-03-11 Thread castironpi
On Mar 11, 11:31 am, Lie <[EMAIL PROTECTED]> wrote: > On Mar 10, 4:16 am, [EMAIL PROTECTED] wrote: > > > > > > > On Mar 9, 4:25 am, Lie <[EMAIL PROTECTED]> wrote: > > > > On Mar 9, 3:27 am, [EMAIL PROTECTED] wrote: > > > > > To Lie: > > > > > > Personally I preferred a code that has chosen good nam

python interactive - threaded console (run -i)

2008-03-10 Thread castironpi
#interactive run -i import threading import Queue import functools class GenThread( threading.Thread, Queue.Queue ): _taskid= 0 def __init__( self, *ar, **kw ): threading.Thread.__init__( self, *ar, **kw ) Queue.Queue.__init__( self ) self.setDaemon( True ) s

Re: is operator

2008-03-10 Thread castironpi
On Mar 10, 11:36 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Mon, 10 Mar 2008 07:39:25 -0700, Gary Herron wrote: > > If either is a surprise, then understand that the "is" operator should > > probably *never* be used with immutable types. > > Mutable or immutable, it make

Re: tcp client socket bind problem

2008-03-10 Thread castironpi
On Mar 10, 9:40 am, Marc Christiansen <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I have a linux box with multiple ip addresses. I want to make my > > python client connect from one of the ip addresses. Here is my code, > > no matter what valid information I put in the bind it always

Re: for-else

2008-03-10 Thread castironpi
> > The idea of the if-else is: > > . depending on some condition either do this or do something else, > > . don't do them both. > > constructs, I asked myself whether the application of a different idea > resulted in a consistent, sensible interpretation. They could just as easily have defined

Re: is operator

2008-03-10 Thread castironpi
> I believe Python automatically creates and caches int objects for 0-256, > so whenever you use them, they refer to the same exact objects. Since > ints are immutable, it doesn't matter. One of the biggest hits on start-up time, by the way. ;) -- http://mail.python.org/mailman/listinfo/python-l

Re: Distributed App - C++ with Python for Portability?

2008-03-10 Thread castironpi
> >> And if you really need the efficiency of "well-tuned raw C", it's one > >> function > >> call away in your Cython code. > > > What do you mean by that? > > > I know nothing about how Cython compares to C in performance, so I said > > "well-tuned" because it must be possible to write C that is

Re: image matching algorithms

2008-03-09 Thread castironpi
On Mar 10, 1:32 am, "Daniel Fetchinson" <[EMAIL PROTECTED]> wrote: > Hi all, > > There are a number of free tools for image matching but it's not very > easy to decipher the actual algorithm from the code that includes db > management, GUI, etc, etc. I have my own image database and GUI so all > I

Re: BitVector

2008-03-09 Thread castironpi
> > I am trying to solve a genetic algorithm problem where I want to read > > a bitvector of very large size (say 1) and manipulate bits based > > on certain algorithms. Here's one on the Python website: http://search.live.com/results.aspx?q=python+bitvector&src=IE-SearchBox => http://pypi.pyt

Re: Intelligent Date & Time parsing

2008-03-09 Thread castironpi
On Mar 8, 12:57 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > I am a GNU newbie.  (I know C &o.)  Can you point me to a > > place to find the source for 'date'? > > It's part of the GNU Coreutils: > > http://ftp.gnu.org/gnu/coreutils/ > > Within the file, you're likely interested in lib/getdate.* >

Re: Solve a Debate

2008-03-09 Thread castironpi
> days_in_month 12: > 31 > 30 > 28 > 31 > ... > 30 > 31 > assign $days days_in_month[$month] > > This program consists of 2 operations (table jump and assignment) > and 12 values. This makes a memory consumption of 12+2 = 14 Along the same lines, you could populate the table somewhat sparsely, and

Re: Timed execution in eval

2008-03-09 Thread castironpi
> Write the docs: > > > when two threads simultaneously increment the reference count of the same > > object > > Well, the example sucked.  Just synchronize ref count manipulation. > Every OS has locking primitives, and a library exists to deny requests > to block that lock dead.  How integral is

Re: Timed execution in eval

2008-03-09 Thread castironpi
> >  > and I want to be able to stop [functions] if they run too long. > > > That's tricky [due to a synthetic limitation]. It would suck if you couldn't hold the GIL for as long as you need to. But how much is it used? Wrote the docs: > when two threads simultaneously increment the reference co

Re: parralel downloads

2008-03-09 Thread castironpi
> > That's it.  Far easier than threads. I'll order a 'easyness' metric from the warehouse. Of course, resources are parameters to the metric, such as facility given lots of time, facility given lots of libraries, facility given hot shots, &c. > Easier? If you omit all the relevant details, yes,

Re: What c.l.py's opinions about Soft Exception?

2008-03-09 Thread castironpi
On Mar 9, 4:51 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Perhaps similar technique the compiler uses to determine whether a > > function is a normal function or a generator function? Positive > > forward lookup for any soft exceptions, which would then activate > > matching soft excepti

Re: Returning values from function to Python shell/IPython

2008-03-09 Thread castironpi
> >  > well after all it's a function so the only ways you can get things out > >  > of it are: > >  > - return a dict with all the objects > >  > - use global (very messy) > >  > - use a decorator to do either of the above. > > >  Messy, all of those... :(. > > >  > on the other hand have you cons

Re: Beautiful Code in Python?

2008-03-09 Thread castironpi
On Mar 2, 1:18 pm, [EMAIL PROTECTED] wrote: > On Mar 2, 12:01 pm, John DeRosa <[EMAIL PROTECTED]> wrote: > > > On Mon, 3 Mar 2008 01:23:32 +0900, js <[EMAIL PROTECTED]> wrote: > > >Hi, > > > >Have you ever seen Beautiful Python code? > > >Zope? Django? Python standard lib? or else? > > > >Please te

Re: execute

2008-03-09 Thread castironpi
> >  os.exec*() will close the current program. > > On *nix, you can use os.fork().  According > tohttp://effbot.org/librarybook/os.htm, you can use Do you mean, and block for the process to terminate? Or do you mean, do something else in the meantime, perhaps for a certain amount (of meantime)?

Re: Regarding coding style

2008-03-09 Thread castironpi
> > >> Good comments are better than bad names. Good names are better than bad > > >> comments. > > > > If you're taking the time to write good comments, why not just fix the > > > bad names?  The compiler/interpreter can never, ever catch bad comments. > > > Yes, but the Python compiler can only c

<    2   3   4   5   6   7   8   9   10   11   >