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

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

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

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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Dual look-up on keys?

2008-03-05 Thread castironpi
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? Er... -specialized- dictionary d. > To solve that pr

RE: Unit testing Web applications

2008-03-05 Thread Ryan Ginstrom
> On Behalf Of Monica Leko > Does Python has some testing frameworks for testing Web > applications (like Cactus and HttpUnit for Java), generating > requests and checking if the response is correct? I have got a lot of traction using mechanize [1] with nose [2]. Of course that still leaves out

Classes and modules are singletons?

2008-03-05 Thread Steven D'Aprano
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 weak today, I cannot find where the Python language re

[OT] Re: Why """, not '''?

2008-03-05 Thread Matt Nordhoff
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. That's an idea... Write a novel in Python docstrings. Someone

Re: Identifying messages in a thread (was: Please keep the full address)

2008-03-05 Thread D'Arcy J.M. Cain
On Thu, 06 Mar 2008 09:36:29 +1100 Ben Finney <[EMAIL PROTECTED]> wrote: > > Those of us who identify the time wasters would also like to drop > > the responses to their posts and changing the address makes this > > impossible. > > Not at all. AFAIK the messages from Google mail correctly include

Re: Returning a byte buffer from C extension

2008-03-05 Thread forwardshortleg
I just realized that I could do this as follows: static PyObject* GetByteBuffer(PyObject* self, PyObject* args) { char byteBuffer[100]; // do something to fill byteBuffer with values. return Py_BuildValue("s#", byteBuffer, numberOfBytesToReturn); } Sorry for the unnecessary distract

Re: Please keep the full address

2008-03-05 Thread D'Arcy J.M. Cain
On Wed, 5 Mar 2008 14:00:17 -0800 (PST) Mike Driscoll <[EMAIL PROTECTED]> wrote: > What are you talking about? I didn't change the address at all. I'm > not even sure what you mean. Are you talking about the post subject > line (which I have never touched in any post)? If you're talking about > the

http://httpd.apache.org/docs/2.2/mod/mod_dbd.html

2008-03-05 Thread gert
Would anybody explain to me what needs to be done to have a DB-API 2.0 layer for this ? And how many lines of code we are talking ? http://httpd.apache.org/docs/2.2/mod/mod_dbd.html -- http://mail.python.org/mailman/listinfo/python-list

Returning a byte buffer from C extension

2008-03-05 Thread forwardshortleg
Hello, I am new to Python programming. So, kindly excuse me if I don't use correct terminology here below. I am trying to write an extension function that returns an array of bytes as shown in the example below: static PyObject* GetByteBuffer(PyObject* self, PyObject* args) { char byteBuff

Re: for-else

2008-03-05 Thread bearophileHUGS
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 words are a very important part of a well designed API.

Re: ActiveX in Webpage?

2008-03-05 Thread Andrew Warkentin
Michael Wieher wrote: > Hello, > > I'm trying to design a python-based web-app from scratch, based on a > standalone MFC application. > Obviously I'll be wrapping a lot of C++ functionality in custom > extensions, but is anyone aware of any documentation/techniques that > could help me "drop" a

Re: for-else

2008-03-05 Thread bearophileHUGS
On Mar 5, 10:44 pm, "Troels Thomsen" wrote: > > The primary use case is searching a container: > > > prep_tasks() > > for item in container: > > if predicate(item): > > found_tasks() > > break > > else: > > not_found_tasks() > > follow_up_tasks > > I've foun

2nd CFP: DATICS 2008 - Design, Analysis and Tools for Integrated Circuits and Systems

2008-03-05 Thread ss . dtvcs
Apologies for any multiple copies received. We would appreciate it if you could distribute the following call for papers to any relevant mailing lists you know of. 2nd CALL FOR PAPERS === Special

access to base class __init__

2008-03-05 Thread sambo q
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 key != EXITCHARCTER: while stop_serving == False: cs, raddr

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

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 23:27:21 +, Matthew Woodcraft wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >>On Wed, 05 Mar 2008 19:19:08 +, Matthew Woodcraft wrote: >>> One advantage is that a dumb syntax highlighter is more likely to cope >>> well if the content includes an apostrophe. > >>

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

2008-03-05 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Wed, 05 Mar 2008 19:19:08 +, Matthew Woodcraft wrote: >> One advantage is that a dumb syntax highlighter is more likely to cope >> well if the content includes an apostrophe. > But if the content contains double-quote marks, the "dumb syntax > h

Re: Dual look-up on keys?

2008-03-05 Thread Grant Edwards
On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Are you vegetarian? Some days. > A little off topic. Ya think? > 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? Do you not know how to run the Python interpreter

Re: Dual look-up on keys?

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 14:51:04 -0800, castironpi 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? It would take you approximately five seconds to answer that question for yourself. >>> D = {(1,2): "x"} >>> D[(2,1)] Trace

Re: Dual look-up on keys?

2008-03-05 Thread Vlastimil Brom
2008/3/5, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > ... > 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? > ... > Well, it's probably not the most effective way, but one can use something like: >>> d={frozenset(("a","b")):7} >>

system32 directory

2008-03-05 Thread Robert Dailey
Hi, Is there a way to get the System32 directory from windows through python? For example, in C++ you do this by calling GetSystemDirectory(). Is there an equivalent Python function for obtaining windows installation dependent paths? -- http://mail.python.org/mailman/listinfo/python-list

Re: Dual look-up on keys?

2008-03-05 Thread castironpi
On Mar 5, 4:00 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > I want to hash values to keys.  How do the alternatives compare? > > http://catb.org/~esr/faqs/smart-questions.html > > >>> ... without extending the whole way to

Identifying messages in a thread (was: Please keep the full address)

2008-03-05 Thread Ben Finney
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > On Wed, 5 Mar 2008 13:38:59 -0800 (PST) > Mike Driscoll <[EMAIL PROTECTED]> wrote: > > On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: > > I'm not sure why you change the address like this but could you > please include the full address. It's a misfe

Re: What is a class?

2008-03-05 Thread Steven D'Aprano
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 Zen of Python says: >>> import this ... Namespaces are one honking great idea -- let's do mo

Re: Dual look-up on keys?

2008-03-05 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > On Mar 5, 3:38 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Wed, 05 Mar 2008 12:06:11 -0800, castironpi wrote: >>> On Mar 5, 1:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] schrieb: > I want to hash values t

Re: What is a class?

2008-03-05 Thread castironpi
On Mar 5, 3:58 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 05 Mar 2008 10:50:12 -0800, castironpi wrote: > > What is a class that is not a module? > > Er, all of them? > > I'm curious what classes you think are modules. > > -- > Steven Thank you for your time in ent

Re: What is a class?

2008-03-05 Thread Paul McGuire
On Mar 5, 3:49 pm, [EMAIL PROTECTED] wrote: > > Classes and modules are really similar.  In Python they're really > *really* similar. > > Actually, at this point, that observation may have more of a > subjective component than I'm used to asserting.  I pause here for > corroboration and others' per

Re: Dual look-up on keys?

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 13:52:38 -0800, castironpi wrote: > On Mar 5, 3:38 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Wed, 05 Mar 2008 12:06:11 -0800, castironpi wrote: >> > On Mar 5, 1:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> >> [EMAIL PROTECTED] schrieb:

re: What is a class?

2008-03-05 Thread Michael Wieher
You import classes from modules. -- http://mail.python.org/mailman/listinfo/python-list

Re: Dual look-up on keys?

2008-03-05 Thread castironpi
On Mar 5, 3:38 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 05 Mar 2008 12:06:11 -0800, castironpi wrote: > > On Mar 5, 1:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] schrieb: > > >> > I want to hash values to keys.  How do the alternati

Re: sympy: what's wrong with this picture?

2008-03-05 Thread Nanjundi
On Mar 5, 3:34 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Mar 5, 9:29 am, Nanjundi <[EMAIL PROTECTED]> wrote: > > > On Mar 4, 3:13 pm, Mensanator <[EMAIL PROTECTED]> wrote: > > > > On Mar 4, 12:32 pm, Nanjundi <[EMAIL PROTECTED]> wrote: > > > > > Does seeding ( random.seed ) random with time fi

Re: Using re module better

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 11:09:28 -0800, castironpi wrote: > On another note, why do people X, Y, and Z, including me, all hate to > write a= b(); if a: a.something()? Is this a guessing game? You want us to guess why YOU hate to do something? Okay, I'm game for guessing games... You were traumatiz

Re: Dual look-up on keys?

2008-03-05 Thread Grant Edwards
On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I want to hash values to keys.  How do the alternatives compare? >> http://catb.org/~esr/faqs/smart-questions.html >> >>> ... without extending the whole way to a full relational database? >> >> You didn't bother following the l

Re: Please keep the full address

2008-03-05 Thread Mike Driscoll
On Mar 5, 3:51 pm, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: > On Wed, 5 Mar 2008 13:38:59 -0800 (PST) > > Mike Driscoll <[EMAIL PROTECTED]> wrote: > > On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: > > I'm not sure why you change the address like this but could you please > include the full addr

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

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 19:19:08 +, Matthew Woodcraft wrote: > <[EMAIL PROTECTED]> wrote: >> Why is """ the preferred delimiter for multi-line strings? > > One advantage is that a dumb syntax highlighter is more likely to cope > well if the content includes an apostrophe. But if the content cont

Re: What is a class?

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 10:50:12 -0800, castironpi wrote: > What is a class that is not a module? Er, all of them? I'm curious what classes you think are modules. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Dual look-up on keys?

2008-03-05 Thread castironpi
On Mar 5, 3:38 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 05 Mar 2008 12:06:11 -0800, castironpi wrote: > > On Mar 5, 1:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] schrieb: > > >> > I want to hash values to keys.  How do the alternati

Please keep the full address

2008-03-05 Thread D'Arcy J.M. Cain
On Wed, 5 Mar 2008 13:38:59 -0800 (PST) Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: I'm not sure why you change the address like this but could you please include the full address. Those of us who identify the time wasters would also like to drop the re

Re: What is a class?

2008-03-05 Thread castironpi
> > > > What is a class that is not a module? > > > I'm willing to address convention, in serial or parallel--- (change > > subject to 'what goes on newsgroups'?), but it's not clear from fact > > what assumption who has made. > > Since you did not elaborate on what your efforts were and the extent

Re: for-else

2008-03-05 Thread Troels Thomsen
> > The primary use case is searching a container: > > prep_tasks() > for item in container: > if predicate(item): > found_tasks() > break > else: > not_found_tasks() > follow_up_tasks > I've found myself mimicing this again and again in c, and was pleased

Re: What is a class?

2008-03-05 Thread Mike Driscoll
On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: > What is a class that is not a module? Why is a raven like a writing desk? As for Python class information, I would recommend reading the following sites: http://docs.python.org/tut/node11.html http://www.diveintopython.org/object_oriented_framework/

Re: Dual look-up on keys?

2008-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2008 12:06:11 -0800, castironpi wrote: > On Mar 5, 1:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] schrieb: >> >> > I want to hash values to keys.  How do the alternatives compare? >> >> http://catb.org/~esr/faqs/smart-questions.html > > ... without exte

Re: Bit twiddling floating point numbers

2008-03-05 Thread Mensanator
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 example - 0.123 in binary is 0.00011 > Rounding to 4 bits I get 0.0001. >

Re: Def generating a function to be ran in another context

2008-03-05 Thread Terry Reedy
"Marcelo de Moraes Serpa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | I'd like a certain function to generate a method for another class and this | new method to be called in the context of the "new" class. Is it possible | with Python? Yes. (Assuming I understand your questi

Re: What is a class?

2008-03-05 Thread Paul McGuire
On Mar 5, 2:04 pm, [EMAIL PROTECTED] wrote: > On Mar 5, 1:29 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > > > On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: > > > > What is a class that is not a module? > > > Please stop posting these one-liner beginner questions.  If you can > > type it in one line

Re: Bit twiddling floating point numbers

2008-03-05 Thread Mark Dickinson
On Mar 5, 3:25 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I can pack and unpack a float into a long > e.g. > struct.unpack('I',struct.pack('f',0.123))[0] > but then I'm not sure how to work with the resulting long. > > Any suggestions? One alternative to using struct is to use math.ldexp

Re: Bit twiddling floating point numbers

2008-03-05 Thread Grant Edwards
On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > thanks for the reply but I'm still unsure as to how to > continue. Using the bitwise operators will help me deal with > integers but I really want to work with floats. In your original post, you said that you've got the values as integ

Re: Bit twiddling floating point numbers

2008-03-05 Thread [EMAIL PROTECTED]
On Mar 5, 10:48 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-05, Grant Edwards <[EMAIL PROTECTED]> wrote: > > > On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >> Any suggestions? > > > Just use the bitwise and/or/not operators: & | ~ > > Oh, I forgot to mention the shift

Re: Bit twiddling floating point numbers

2008-03-05 Thread Grant Edwards
On 2008-03-05, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Any suggestions? > > Just use the bitwise and/or/not operators: & | ~ Oh, I forgot to mention the shift operators << and >> -- Grant Edwards grante

Re: Bit twiddling floating point numbers

2008-03-05 Thread Grant Edwards
On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > 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 example - 0.123 in binary is 0.00011 > Rounding to 4 bits I get 0.0001. > > I can pack and

Re: sympy: what's wrong with this picture?

2008-03-05 Thread Mensanator
On Mar 5, 9:29 am, Nanjundi <[EMAIL PROTECTED]> wrote: > On Mar 4, 3:13 pm, Mensanator <[EMAIL PROTECTED]> wrote: > > > On Mar 4, 12:32 pm, Nanjundi <[EMAIL PROTECTED]> wrote: > > > > Does seeding ( random.seed ) random with time fix this? It should. > > > I suppose that depends on how long it take

Re: documenting formal operational semantics of Python

2008-03-05 Thread Matthew Woodcraft
gideon <[EMAIL PROTECTED]> wrote: > 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 one myself. To make a more informed d

Bit twiddling floating point numbers

2008-03-05 Thread [EMAIL PROTECTED]
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 example - 0.123 in binary is 0.00011 Rounding to 4 bits I get 0.0001. I can pack and unpack a float into a long e.g. struct.unpack('I',struct.pack('f

Def generating a function to be ran in another context

2008-03-05 Thread Marcelo de Moraes Serpa
I'd like a certain function to generate a method for another class and this new method to be called in the context of the "new" class. Is it possible with Python? Thanks, Marcelo. -- http://mail.python.org/mailman/listinfo/python-list

Re: Dual look-up on keys?

2008-03-05 Thread castironpi
On Mar 5, 1:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > > I want to hash values to keys.  How do the alternatives compare? > > http://catb.org/~esr/faqs/smart-questions.html ... without extending the whole way to a full relational database? -- http://mail

Re: What is a class?

2008-03-05 Thread castironpi
On Mar 5, 1:29 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: > > > What is a class that is not a module? > > Please stop posting these one-liner beginner questions.  If you can > type it in one line, you can enter it on the Google.com or Ask.com > query

Re: documenting formal operational semantics of Python

2008-03-05 Thread Paul Rubin
gideon <[EMAIL PROTECTED]> writes: > 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 one myself. I doubt if anything ser

Embedding vs Configuring Python build

2008-03-05 Thread [EMAIL PROTECTED]
I am using Python in an application that cannot depend on an existing Python installation or require Python to be installed. The application itself should not have an install procedure, but rather should be runnable from any location in the file system. Ideally I would prefer not to embed at all,

Re: What is a class?

2008-03-05 Thread Paul McGuire
On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: > What is a class that is not a module? Please stop posting these one-liner beginner questions. If you can type it in one line, you can enter it on the Google.com or Ask.com query page and get a wealth of *existing* information, from tutorials, documen

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

2008-03-05 Thread Matthew Woodcraft
<[EMAIL PROTECTED]> wrote: > Why is """ the preferred delimiter for multi-line strings? One advantage is that a dumb syntax highlighter is more likely to cope well if the content includes an apostrophe. -M- -- http://mail.python.org/mailman/listinfo/python-list

Re: documenting formal operational semantics of Python

2008-03-05 Thread davidj411
Python 3.0 might end up better, but converting all those scripts will be a chore. I'd be curious to know how that will be done. -- http://mail.python.org/mailman/listinfo/python-list

change user-agent

2008-03-05 Thread davidj411
I came across this post on the net and wanted to know what was meant by down-level module. So, how can we change the User-Agent? If we don't want to change the headers using a lower-level module such as httplib, the solution is quite easy -- http://mail.python.org/mailman/listinfo/python-list

Re: Dual look-up on keys?

2008-03-05 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I want to hash values to keys. How do the alternatives compare? http://catb.org/~esr/faqs/smart-questions.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Using re module better

2008-03-05 Thread castironpi
On Mar 5, 6:12 am, Tim Chase <[EMAIL PROTECTED]> wrote: > > if (match = re.search('(\w+)\s*(\w+)', foo)): > > Caveat #1:  use a raw string here > Caveat #2:  inline assignment is verboten > >    match = re.search(r'(\w+)\s*(\w*+)', foo) >    if match: > > >     field1 = match.group(1) > >     field

Dual look-up on keys?

2008-03-05 Thread castironpi
I want to hash values to keys. How do the alternatives compare? -- http://mail.python.org/mailman/listinfo/python-list

What is a class?

2008-03-05 Thread castironpi
What is a class that is not a module? -- http://mail.python.org/mailman/listinfo/python-list

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

2008-03-05 Thread Gary Herron
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 "Print using c.s:", c.s > Prin

Short confusing example with unicode, print, and __str__

2008-03-05 Thread Gerard Brunick
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 "Print using c.s:", c.s Print using c.s: Café >>> print "Print using

Re: Better grammar.txt

2008-03-05 Thread MartinRinehart
[EMAIL PROTECTED] wrote: > It includes three corrections to grammar.txt (imagnumber, xor_expr and > and_expr) that I've reported. Make that four corrections. Add augop. -- http://mail.python.org/mailman/listinfo/python-list

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

2008-03-05 Thread MartinRinehart
D'Arcy J.M. Cain wrote: > Where did you see that? The only place I saw it was the style guide > and it was only talking about docstrings. PEP 8 and 257, and you're right, they are both about docstrings. Also, I'd never seen an example of the triple apostrophe form until I dove into the formal

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

2008-03-05 Thread Jeff Schwab
Dennis Lee Bieber wrote: > On Tue, 4 Mar 2008 20:06:38 -0500, Tommy Grav <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > >> SV = "Svar" is the Norwegian word for Reply. >> > Ah, good... In my working life, "SV" => "Space Vehicle", often used > to differentiate between th

Re: Talking to a usb device (serial terminal)

2008-03-05 Thread blaine
> Because it is NOT 0x10007... It is OCTAL 010007 -- which just > happens to map to hexadecimal 0x1007 > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ >

ActiveX in Webpage?

2008-03-05 Thread Michael Wieher
Hello, I'm trying to design a python-based web-app from scratch, based on a standalone MFC application. Obviously I'll be wrapping a lot of C++ functionality in custom extensions, but is anyone aware of any documentation/techniques that could help me "drop" an ActiveX control into a webpage, and j

Re: Unit testing Web applications

2008-03-05 Thread Diez B. Roggisch
Monica Leko wrote: > Hi! > > Does Python has some testing frameworks for testing Web applications > (like Cactus and HttpUnit for Java), generating requests and checking > if the response is correct? mechanize and webunit come to my mind. Yet the most powerful will be selenium together with sel

Re: Python CGI & Webpage with an Image

2008-03-05 Thread Miki
Hello Rod, > I have a set of CGI scripts set up and in one page (which is stored in > an HTML file then printed via a python CGI) there is an image. However > the image never displays, can anyone recommend a way round this > problem? We need more information, can you post a code snippet? error pag

Re: OT: Failed saving throw

2008-03-05 Thread Dan Upton
On 5 Mar 2008 07:36:37 -0800, Aahz <[EMAIL PROTECTED]> wrote: > For anyone who hasn't heard, E. Gary Gygax died yesterday. Some people > think we should build a tomb in his honor. ;-) Yeah, I just saw a tribute on Order of the Stick: http://www.giantitp.com/comics/oots0536.html -- http://mail

Unit testing Web applications

2008-03-05 Thread Monica Leko
Hi! Does Python has some testing frameworks for testing Web applications (like Cactus and HttpUnit for Java), generating requests and checking if the response is correct? -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >