Re: Classes and modules are singletons?

2008-03-05 Thread Terry Reedy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |I recall that Python guarantees that module objects are singletons, and | that this must hold for any implementation, not just CPython: you can | only ever create one instance of a module via the import mechanism. But

Re: What is a class?

2008-03-05 Thread castironpi
On Mar 5, 4:25 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 05 Mar 2008 13:49:20 -0800, castironpi wrote: > > Classes and modules are really similar.  In Python they're really > > *really* similar. > > Yes they are. > > Both are namespaces. The very last line of the Z

Re: for-else

2008-03-05 Thread castironpi
On Mar 5, 6:40 pm, [EMAIL PROTECTED] wrote: > Troels Thomsen: > > > The discussion of words is silly. My surprise about "else following a for > > loop what the heck " lasted excactly as long as it takes to read > > this sentence. > > Maybe I don't follow what you are saying, but well chosen

Re: Classes and modules are singletons?

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 21:05:31 -0500, Terry Reedy wrote: > If I understand your question, classes are not singletons: ll=[] for i in range(2): > import string > ll[i]=string Where's the IndexError? :-) ll[0] is ll[1] > True But yes, modules are singletons in that way, at least i

Re: Why """, not '''?

2008-03-05 Thread Dan Bishop
On Mar 5, 7:24 pm, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > Surely it would depend on the type of text: pick up any random English > > novel containing dialogue, and you're likely to find a couple of dozen > > pairs of quotation marks per page, against a few apostrophes

Re: access to base class __init__

2008-03-05 Thread castironpi
On Mar 5, 6:09 pm, sambo q <[EMAIL PROTECTED]> wrote: > I got myself in jam trying to be too fancy with  threading.Thread > Docs say / remind to call the base __init__ > but I can't fighure out how. > > --- > def main() > . >     ls.listen(5) >     key = ' ' > #    while

Re: Classes and modules are singletons?

2008-03-05 Thread Micah Cowan
Steven D'Aprano <[EMAIL PROTECTED]> writes: > I recall that Python guarantees that module objects are singletons, and > that this must hold for any implementation, not just CPython: you can > only ever create one instance of a module via the import mechanism. But > my google-foo is obviously we

Re: access to base class __init__

2008-03-05 Thread castironpi
On Mar 5, 6:09 pm, sambo q <[EMAIL PROTECTED]> wrote: > I got myself in jam trying to be too fancy with  threading.Thread > Docs say / remind to call the base __init__ > but I can't fighure out how. > > --- > def main() > . >     ls.listen(5) >     key = ' ' > #    while

Re: Classes and modules are singletons?

2008-03-05 Thread castironpi
On Mar 5, 8:31 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 05 Mar 2008 21:05:31 -0500, Terry Reedy wrote: > > If I understand your question, classes are not singletons: > ll=[] > for i in range(2): > >  import string > >  ll[i]=string > > Where's the IndexE

Re: Classes and modules are singletons?

2008-03-05 Thread castironpi
> > > If I understand your question, classes are not singletons: > > ll=[] > > for i in range(2): > > >  import string > > >  ll[i]=string > > > Where's the IndexError? :-) > > > I accept my question about classes being singletons is not well-formed, > > not even in my own mind. I guess o

Re: documenting formal operational semantics of Python

2008-03-05 Thread Kay Schluehr
On 5 Mrz., 13:47, gideon <[EMAIL PROTECTED]> wrote: > Hi Everybody, > > In the context of a master's thesis I'm currently looking into > Python's operational semantics. Even after extensive searching on the > web, I have not found any formal model of Python. Therefore I am > considering to write on

Re: Dual look-up on keys?

2008-03-05 Thread castironpi
On Mar 5, 8:03 pm, [EMAIL PROTECTED] wrote: > On Mar 5, 5:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > > > On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Anyway, if (a,b) is a key in dictionary d, can it guarantee > > > that (b,a) is also in it, and maps to the same object?

Re: Classes and modules are singletons?

2008-03-05 Thread castironpi
On Mar 5, 9:51 pm, [EMAIL PROTECTED] wrote: > > > > If I understand your question, classes are not singletons: > > > ll=[] > > > for i in range(2): > > > >  import string > > > >  ll[i]=string > > > > Where's the IndexError? :-) > > > > I accept my question about classes being singletons

Re: Dual look-up on keys?

2008-03-05 Thread Micah Cowan
[EMAIL PROTECTED] writes: > On Mar 5, 8:03 pm, [EMAIL PROTECTED] wrote: >> On Mar 5, 5:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: >> >> > On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> > > Anyway, if (a,b) is a key in dictionary d, can it guarantee >> > > that (b,a) is also in

Re: OT[1]: Re: SV: Polymorphism using constructors

2008-03-05 Thread Jeff Schwab
Dennis Lee Bieber wrote: > On Wed, 05 Mar 2008 08:26:04 -0800, Jeff Schwab <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> Which is which? Aren't those both part of the space vehicle? Btw, do >> you work for government or industry? Do you enjoy working with the >> spa

Re: What is a class?

2008-03-05 Thread castironpi
On Mar 5, 8:06 pm, [EMAIL PROTECTED] wrote: > On Mar 5, 4:25 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > On Wed, 05 Mar 2008 13:49:20 -0800, castironpi wrote: > > > Classes and modules are really similar.  In Python they're really > > > *really* similar. > > > Yes they

Re: Dual look-up on keys?

2008-03-05 Thread castironpi
> > *plonk* > > > key is an iterable, just like the constructors to > > other collection. > > Um... "*plonk*" is the (imaginary) sound made by dropping someone into > your plonkfile (killfile, scorefile, whatever): the action of setting > your newsreader to ignore someone you perceive to be a trol

Re: Classes and modules are singletons?

2008-03-05 Thread castironpi
> I accept my question about classes being singletons is not well-formed, > not even in my own mind. I guess one way of asking is, for any two class > objects (not instances) C1 and C2, does "C1 == C2" imply "C1 is C2"? C and D are instances of metaC in that. class metaC( type ): def what( self

Re: What is a class?

2008-03-05 Thread Daniel Fetchinson
> > Where to begin? > > What does exec( open( 'modA.py' ).read() ) do? The most appropriate list to ask those questions is: http://mail.python.org/mailman/listinfo/tutor -- http://mail.python.org/mailman/listinfo/python-list

Re: Why """, not '''?

2008-03-05 Thread Dotan Cohen
On 06/03/2008, Dan Bishop <[EMAIL PROTECTED]> wrote: > On Mar 5, 7:24 pm, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > > > Steven D'Aprano wrote: > > > Surely it would depend on the type of text: pick up any random English > > > novel containing dialogue, and you're likely to find a couple of dozen

Re: Bit twiddling floating point numbers

2008-03-05 Thread [EMAIL PROTECTED]
On Mar 5, 11:27 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Mar 5, 2:25 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Hi All > > > Is there a simple way to twiddle the bits of a float? In particular, I > > would like to round my float to the n most significant bits. > > > For exampl

Hi

2008-03-05 Thread hellogaurang
Hello can u plz tell how to send and read msg from device(telit-863-GPS) and the coding is in python. if this can happen then plz send the source code to my mail account -- http://mail.python.org/mailman/listinfo/python-list

Re: Short confusing example with unicode, print, and __str__

2008-03-05 Thread Gerard Brunick
Gary Herron wrote: > Gerard Brunick wrote: >> I really don't understand the following behavior: >> >> >>> class C(object): >> ... def __init__(self, s): self.s = s >> ... def __str__(self): return self.s >> ... >> >>> cafe = unicode("Caf\xe9", "Latin-1") >> >>> c = C(cafe) >> >>> print

Re: for-else

2008-03-05 Thread Jared Grubb
I think bearophile makes an excellent point. I also have a hard time remembering what else does. I have always pictured that the "normal" behavior of a for loop is to get through all the items. In special circumstances, it is necessary to break out early. Therefore, it FEELS like the else loop shou

<    1   2