Re: Difference between 'function' and 'method'

2008-03-06 Thread castironpi
On Mar 6, 7:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 06 Mar 2008 22:56:33 -0200, <[EMAIL PROTECTED]> escribió: > > > On Mar 6, 5:35 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > >> p = P() > >> print p.bar.func_name # -> bar > >> p.bar.im_func.anotherattribute = 1 >

Re: While executing the class definition which object is referenced by the first argument of the class method, Y r Object attributes not allowed as default arguments

2008-03-07 Thread castironpi
On Mar 7, 11:49 am, Krishna <[EMAIL PROTECTED]> wrote: > On Mar 6, 5:04 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > > > > > > En Thu, 06 Mar 2008 22:48:42 -0200, Krishna <[EMAIL PROTECTED]> > > escribi�: > > > class Test(object): > > > ...     def __init__(self): > > > ...          

Re: islice ==> [::]

2008-03-07 Thread castironpi
> > I find itertools.islice() useful, so for Python 3.x I may like to see > general iterables.  Third, the analogy breaks down quickly (i.e. > chain(it[:2], it[2:]) does not give the same result as iter(it) unless > >>> s = 'abcdefg' > >>> list(W(s)[2:]) Slice literals are a logical next step, pr

Re: Difference between 'function' and 'method'

2008-03-07 Thread castironpi
On Mar 7, 6:44 am, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > Gabriel Genellina <[EMAIL PROTECTED]> wrote: > >En Thu, 06 Mar 2008 23:46:43 -0200, <[EMAIL PROTECTED]> escribi�: > >> [ ... ] > >You may look at the SimpleXMLRPCServer class and see how it implements   > >introspection. It's rather

Re: Converting a string to the most probable type

2008-03-07 Thread castironpi
> And so on and so forth.  The tricky bit is how to tell the difference > between Day, Month and Year. There isn't one. -- http://mail.python.org/mailman/listinfo/python-list

Re: Timed execution in eval

2008-03-07 Thread castironpi
On Mar 7, 10:12 am, [EMAIL PROTECTED] wrote: > I have various bits of code I want to interpret and run at runtime in > eval ... > > I want to be able to detect if they fail with error, I want to be able > to time them, and I want to be able to stop them if they run too > long.  I cannot add code to

Re: Timed execution in eval

2008-03-07 Thread castironpi
On Mar 7, 10:12 am, [EMAIL PROTECTED] wrote: > I have various bits of code I want to interpret and run at runtime in > eval ... import sys from time import clock, sleep from threading import Timer TimeoutError= type('TimeoutError',(Exception,),{}) class Elapse: def __init__( self ): s

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread castironpi
On Mar 7, 3:19 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Fri, Mar 7, 2008 at 3:00 PM, DBak <[EMAIL PROTECTED]> wrote: > > >  I would like to build a class for a data structure such that nodes of > >  the data structure - of interest only to the data structure > >  implementation itself and

Re: Regarding coding style

2008-03-07 Thread castironpi
> Grant Edwards                   grante             Yow! A shapely CATHOLIC >                                   at               SCHOOLGIRL is FIDGETING >                                visi.com            inside my costume.. ... Are you wearing it? *plonkblock* So, what gets you plonked around

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread castironpi
On Mar 7, 4:39 pm, DBak <[EMAIL PROTECTED]> wrote: > On Mar 7, 1:19 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > > > On Fri, Mar 7, 2008 at 3:00 PM, DBak <[EMAIL PROTECTED]> wrote: > > >  However I can't do this, because, of course, the name Tree isn't > > >  available at the time that the class

Re: Intelligent Date & Time parsing

2008-03-07 Thread castironpi
On Mar 7, 5:00 pm, [EMAIL PROTECTED] wrote: > On Mar 7, 4:35 pm, Jeffrey Froman <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] wrote: > > > I need > > > something to parse user input for a django app, and it's awesome to be > > > able to write "last monday", "a year ago", or "10pm tuesday" like

Re: Nested phrases [was Re: Want - but cannot get - a nested class to inherit from outer class]

2008-03-07 Thread castironpi
On Mar 7, 6:39 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 07 Mar 2008 14:26:25 -0800, castironpi wrote: > > Humans have enormous "mental stacks"--- the stacks the contexts the > > speakers speak in push things they're hear

Re: Timed execution in eval

2008-03-07 Thread castironpi
On Mar 7, 4:07 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > > I want to be able to detect if [certain threads] fail with error, > > You can't? Why ever not? Try this. ext can be found in 'C Function in a Python Context' on google groops. import ext extA= ext.Ext() extA[ 'a

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-08 Thread castironpi
On Mar 7, 7:46 pm, DBak <[EMAIL PROTECTED]> wrote: > > > > >  However I can't do this, because, of course, the name Tree isn't > > > > >  available at the time that the classes _MT and _Node are defined, so > > > > >  _MT and _Node can't inherit from Tree. > > > > > Not only is the name not defined

Re: Timed execution in eval

2008-03-08 Thread castironpi
On Mar 7, 9:43 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Mar 7, 11:12 am, [EMAIL PROTECTED] wrote: > > > I have various bits of code I want to interpret and run at runtime in > > eval ... > > Check out these two recipes: > > - Using signals:http://aspn.activestate.com/ASPN/Cookbook/Python/R

Re: Intelligent Date & Time parsing

2008-03-08 Thread castironpi
On Mar 7, 9:23 pm, [EMAIL PROTECTED] wrote: > I figured I might as well share the code I ended up using, in case > anyone else wants an easy way to get strings to, for instance, SQL- > storable datetimes. > > [EMAIL PROTECTED]:~$ cat test.py > #!/usr/bin/python > from datetime import datetime > imp

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 9:31 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >> The function name also doesn't explain anything. How was the stuff got? > >> Was it paid for, or stolen, or picked up on consignment, or what? Compare > >> the above line

Re: What is a class?

2008-03-08 Thread castironpi
On Mar 7, 6:16 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 06 Mar 2008 08:40:47 -0800, castironpi wrote: > > you > > could say exec( open( 'modA.py' ).read() ) ==> import modA > > Yes, you could say that, but you'

Re: Difference between 'function' and 'method'

2008-03-08 Thread castironpi
On Mar 7, 1:34 pm, [EMAIL PROTECTED] wrote: > On Mar 7, 6:44 am, Sion Arrowsmith <[EMAIL PROTECTED]> > wrote: > > > Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > >En Thu, 06 Mar 2008 23:46:43 -0200, <[EMAIL PROTECTED]> escribi�: > > >> [ ... ] > > >You may look at the SimpleXMLRPCServer class

Re: multiplication of lists of strings

2008-03-08 Thread castironpi
On Mar 5, 2:16 am, Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > (snip) > > > That reminds me:  Is there a generic 'relation' pattern/recipie, such > > as finding a computer that's "paired" with multiple users, each of who > > are "paired" with multiple computers, without maintaining

Re: multiplication of lists of strings

2008-03-08 Thread castironpi
On Mar 8, 12:04 pm, [EMAIL PROTECTED] wrote: > On Mar 5, 2:16 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] a écrit : > > (snip) > > > > That reminds me:  Is there a generic 'relation' pattern/recipie, such > > > as finding a computer that's "paired" with multiple users

Re: Converting a string to the most probable type

2008-03-08 Thread castironpi
On Mar 8, 12:05 pm, Pierre Quentel <[EMAIL PROTECTED]> wrote: > > >>> def convert(x): > > >         if '.' in x: > >                 try: return float(x) > >                 except ValueError: return x > >         else: > >                 try: return int(x) > >                 except: return x > >

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Does one side of this hold that there are no -good- comments? > > I wouldn't say there are _no_ good comments, but I would say > that 90+% of the comments I've seen in my

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Does one side of this hold that there are no -good- comments? > > I wouldn't say there are _no_ good comments, but I would say > that 90+% of the comments I've seen in my

Re: for-else

2008-03-08 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. yes = the loop completed. 'else' isn't rechecking a piece of the loop, it's checking the loop. Does it test successfully--- not the loop condition, the loop? What is 'if a

Re: Can't get items out of a set?

2008-03-08 Thread castironpi
> something something equivalence class. > The intern() builtin uses this approach: > >    interned = {} >    def intern(s): >         if s in interned: >             return interned[s] >         interned[s] = s >         return s If you've seen it before, and have the old one, return the old one

Re: List as FIFO in for loop

2008-03-08 Thread castironpi
> Notice that the language specification *deliberately* does not > distinguish between deletion of earlier and later items, but > makes modification of the sequence undefined behavior to allow > alternative implementations. E.g. an implementation that would > crash, erase your hard disk, or set you

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

2008-03-09 Thread castironpi
D'Aprano suggested callbacks. How does this work for you? class SomeNumeric(object): def __div__(a, b): if b == 0: raise ZeroDivisionError ## Hard Exception... if a == 0: msgboard- ZeroNumerator() f = a / b i = a // b if f == float(i): msgb

Re: Checking if a variable is a dictionary

2008-03-09 Thread castironpi
On Mar 9, 9:23 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sun, 09 Mar 2008 06:58:15 -0700, Guillermo wrote: > > Okay, so I think I know where's the catch now -- you must rely on the > > fact that the protocol is implemented, there's no way to enforce it if > > you're exp

Re: parralel downloads

2008-03-09 Thread castironpi
> > > >>  my problem is that I would like to download several files at the time. > > > >>  As I have not much experience in programming, could you point me the > > > >>  easier ways to do this in python ? > > > Thank you both for your help. Threads are working for me. However, a > > new problem for

Re: Regarding coding style

2008-03-09 Thread castironpi
On Mar 8, 7:51 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 08 Mar 2008 13:40:56 -0800, dave_mikesell wrote: > > On Mar 8, 2:27 pm, [EMAIL PROTECTED] wrote: > > >> Good comments are better than bad names. Good names are better than bad > >> comments. > > > If you're t

Re: Regarding coding style

2008-03-09 Thread castironpi
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 names but have > > > little or no comments compared to codes that makes bad names and have > > > Personally I don't.  Show me a go

Re: 1.5.2 and functools or similar

2008-03-09 Thread castironpi
On Mar 9, 4:26 pm, "Troels Thomsen" wrote: > Hello, > > I am writing a simple delayed-call mechanism , that is causing a bit of > headache. Works like this: > > myPrint(s) >   print "..." + s > > myTimer.add(myPrint , "hello" , 15) > > This means that the myprint function is called in 15 seconds w

Re: Logically/Selectively Sub Class?

2008-03-09 Thread castironpi
On Mar 9, 4:28 pm, xkenneth <[EMAIL PROTECTED]> wrote: > Might be a silly question, but is it possible to selectively subclass, > IE subclass is a supporting module is present and not otherwise. > > Regards, > Kenneth Miller if mod is present: class Waypoint( Mine, Yours ): pass else: class

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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

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: 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

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: 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: 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

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: 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

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: 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

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: 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

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: 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: 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: 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: 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: 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: 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
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, 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

'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, 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).

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
> > | 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-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: '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: 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

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: 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

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: 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: 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: 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: 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: 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: 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: 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

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: 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

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