Re: It is fun.the result of str.lower(str())

2006-03-06 Thread Fredrik Lundh
"Sullivan WxPyQtKinter" wrote: > Guess what would be the result of these functions: > > >>>str.lower('ASFA') > >>>str.join(str(),['1','1','1']) > >>>str.join('a','b') > > If you guess them correctly, please explain. as I just said, I.method() and C.method(I) are equivalent, so that's just an odd

Re: Confused by Method(function) of a module and method ofaclass/instance

2006-03-06 Thread Fredrik Lundh
"Sullivan WxPyQtKinter" wrote: > More confusing things came out to me: > >>>str().lower() > '' #well, this is > understandable. > >>>str.lower(str(),'A') > 'a' > > How do you explain this result? I get: >>> str.lower(str(), 'A') Traceback (most re

It is fun.the result of str.lower(str())

2006-03-06 Thread Sullivan WxPyQtKinter
Guess what would be the result of these functions: >>>str.lower('ASFA') >>>str.join(str(),['1','1','1']) >>>str.join('a','b') If you guess them correctly, please explain. -- http://mail.python.org/mailman/listinfo/python-list

Re: generators shared among threads

2006-03-06 Thread jess . austin
Thanks for the great advice, Alex. Here is a subclass that seems to work: from Queue import Queue from itertools import count class reentrantQueue(Queue): def _init(self, maxsize): self.maxsize = 0 self.queue = [] # so we don't have to override put() self.counter =

Re: how about adding ping's uuid module to the standard lib ?

2006-03-06 Thread Thomas Heller
Fredrik Lundh wrote: > see subject and http://python.org/sf/1368955 > > comments ? > > I haven't used this module, but: The wingetaddr() function doesn't work on a german version of windows (there is no line in the output that starts with 'physical address'). In getaddr(), what if windows is

Re: minidom and unicode errors

2006-03-06 Thread Abhimanyu Seth
On 3/7/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: Abhimanyu Seth wrote:> Sorry, my mistake. The file was not saved as utf-8. Saving it as utf-8> solves my problems.> >> f = codecs.open ("c:/test.txt", "r", "utf-8") > >> dom = minidom.parseString (codecs.encode (f.read(), "utf-8"))>> However, I st

Re: Popup menus without an associated window

2006-03-06 Thread Rich Churcher
> HTH, Wonderful Miki, thank you very much! -- Cheers, Rich. -- http://mail.python.org/mailman/listinfo/python-list

Re: New python.org website

2006-03-06 Thread Ian Parker
In message <[EMAIL PROTECTED]>, Phoe6 <[EMAIL PROTECTED]> writes >beta.python.org evolved very nice and noticed today the new python.org >website going live. There is a change in the look n feel, wherein it >looks "more official" and maximum possible information about python is >now directly acce

Re: Confused by Method(function) of a module and method of aclass/instance

2006-03-06 Thread Sullivan WxPyQtKinter
Yes, I checked out that I have already run "from string import *". So the lower() means string.lower() function. However, something else came out just now: >>>instr='a' >>>instr.join('b') 'b' >>>instr.lower() 'A' >>>instr 'a' Both as the method of the type str, join never use the instr instance ob

Re: minidom and unicode errors

2006-03-06 Thread Fredrik Lundh
Abhimanyu Seth wrote: > Sorry, my mistake. The file was not saved as utf-8. Saving it as utf-8 > solves my problems. > >> f = codecs.open ("c:/test.txt", "r", "utf-8") > >> dom = minidom.parseString (codecs.encode (f.read(), "utf-8")) > > However, I still need to encode the string returned by f.re

Re: figuring out how much data was sent so far via XML-RPC?

2006-03-06 Thread Fredrik Lundh
Ratko Jagodic wrote: > I am currently using XML-RPC for a very convenient quick-and-dirty way of > sending some files (base64 encoded). > The files can be bigger sometimes (10-20mb) and I was wondering if there is > a way to see how much data was sent already and how much still needs to be > sent

Re: Confused by Method(function) of a module and method of aclass/instance

2006-03-06 Thread Fredrik Lundh
"Sullivan WxPyQtKinter" <[EMAIL PROTECTED]> wrote: > In python, these expression seems yields the same result: > > inputstring='ABC' > > print inputstring.lower() > print lower(inputstring) > print string.lower(inputstring) > > result: > abc > abc > abc I get >>> inputstring="ABC" >>> print inpu

Re: minidom and unicode errors

2006-03-06 Thread Abhimanyu Seth
On 3/7/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: Abhimanyu Seth wrote:> > I have the following line in my xml file:> > Exception beim Löschen des Audit-Moduls aufgetreten. Exception> Stack> > lautet: %1. > > ExpatError: not well-formed (invalid token): line 8, column 27> I've specified utf-8 in

Re: minidom and unicode errors

2006-03-06 Thread Fredrik Lundh
Abhimanyu Seth wrote: > > I have the following line in my xml file: > > Exception beim Löschen des Audit-Moduls aufgetreten. Exception > Stack > > lautet: %1. > > ExpatError: not well-formed (invalid token): line 8, column 27 > I've specified utf-8 in the xml header > are you sure you're using

Re: Peter Naur wins ACM Turing Award

2006-03-06 Thread Kay Schluehr
Terry Reedy wrote: > http://campus.acm.org/public/pressroom/press_releases/3_2006/turing_3_01_2006.cfm > > Peter Naur was co-developer of Backus/Naur grammar notation, co-author and > editor of the Algol 60 specification, and co-developer of a successful > Algol compiler. That's very fine. Peter

Confused by Method(function) of a module and method of a class/instance

2006-03-06 Thread Sullivan WxPyQtKinter
In python, these expression seems yields the same result: inputstring='ABC' print inputstring.lower() print lower(inputstring) print string.lower(inputstring) result: abc abc abc Question: Is the method lower() just a method for the inputstring instance( an instrance object of a string class ob

Re: minidom and unicode errors

2006-03-06 Thread Abhimanyu Seth
On 3/7/06, Abhimanyu Seth <[EMAIL PROTECTED]> wrote: On 3/7/06, Fredrik Lundh < [EMAIL PROTECTED]> wrote: Abhimanyu Seth wrote:> I'm trying to parse and modify an XML document using xml.dom.minidom module> and Python 2.4.2>> >> from xml.dom import minidom> >> dom = minidom.parse ("c:/test.txt")>

Re: minidom and unicode errors

2006-03-06 Thread Abhimanyu Seth
On 3/7/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: Abhimanyu Seth wrote:> I'm trying to parse and modify an XML document using xml.dom.minidom module> and Python 2.4.2>> >> from xml.dom import minidom> >> dom = minidom.parse ("c:/test.txt")>> If the xml file contains a non-ascii character, then i

Re: minidom and unicode errors

2006-03-06 Thread Fredrik Lundh
Abhimanyu Seth wrote: > I'm trying to parse and modify an XML document using xml.dom.minidom module > and Python 2.4.2 > > >> from xml.dom import minidom > >> dom = minidom.parse ("c:/test.txt") > > If the xml file contains a non-ascii character, then i get a parse error. > I have the following li

Re: spliting on ":"

2006-03-06 Thread Peter Hansen
Cyril Bazin wrote: > I agree. None is an object! If you want to compare an object to another > object why not using "=="? The term "compare" is ambiguous. If you want to compare for *identity*, you use "is". If you want to compare for equality, you use "==". In most cases with None you are i

minidom and unicode errors

2006-03-06 Thread Abhimanyu Seth
Hi all,I'm trying to parse and modify an XML document using xml.dom.minidom module and Python 2.4.2>> from xml.dom import minidom>> dom = minidom.parse ("c:/test.txt")If the xml file contains a non-ascii character, then i get a parse error. I have the following line in my xml file:Exception beim Lö

Re: New python.org website

2006-03-06 Thread mwt
Wow. That does look fantastic. Thumbs up! -- http://mail.python.org/mailman/listinfo/python-list

Re: Cryptographically random numbers

2006-03-06 Thread Tuvas
Thanks for the function Paul, it works alot nicer than the one I had in my program... Now, with all of this knowledge, I'm going to be brave and try out everything with AES. It seems to be working alright, I'll debug this more on my own than I did with my RSA code, which turned out to be full of bu

Re: need a start point for wsdl

2006-03-06 Thread nephish
cool, thank you very much -- http://mail.python.org/mailman/listinfo/python-list

Re: Cryptographically random numbers

2006-03-06 Thread Bryan Olson
Tuvas wrote: [...] > As to the s2num(text), well, that looks really neat. Is there an easy > way to do the reverse of that? Thanks! Easy? Well, you be the judge: def num2string(n): """ Pass a non-negative int or long n. Returns a string with bytes holding the big-endian base

Re: Cryptographically random numbers

2006-03-06 Thread Tuvas
Wow, that would have been nice to know... Oh well, I've already got the function, might as well use it... I'm starting to learn alot more of the standard libraries that exist for alot of the little functions. It seems like every project I have I build a misc.py file that contains several small, but

Re: Cryptographically random numbers

2006-03-06 Thread Bryan Olson
Tuvas wrote: > Ahh, you are correct, that is a large bug... How about this one? Much better. Do note the comments from Emile van Sebille and Paul Rubin. There are some minor style and efficiency points, but it looks reasonable. Incidentally, as of Python 2.4, the standard library offers random.Sy

Re: Cryptographically random numbers

2006-03-06 Thread Paul Rubin
"Tuvas" <[EMAIL PROTECTED]> writes: > Wait, I now see that there is a native base 2 log in python, so I will > just do that rather than my adhoc way. The reason for adding one is to > make sure there isn't any problems if the log is, for instance, 2.2. It > will always round up. It's better to have

Re: raw strings and \

2006-03-06 Thread Alex Martelli
John Salerno <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > >> Now get back to work on your new Nutshell book :-) > > > > Yep, good point!-) > > Are you working on a new edition? I didn't see any new Python books > listed on O'Reilly's site through April, but I'd definitely be > intere

Re: Checking function calls

2006-03-06 Thread James Stroud
Jay Parlar wrote: > > On Mar 6, 2006, at 8:44 PM, James Stroud wrote: > >> Since python is "weakly typed", you will not be able to check what >> "type" of arguments a function expects. TypeErrors relating to the >> type of argemtns you pass will be raised inside the function only and >> not wh

New python.org website

2006-03-06 Thread Phoe6
beta.python.org evolved very nice and noticed today the new python.org website going live. There is a change in the look n feel, wherein it looks "more official" and maximum possible information about python is now directly accessible from the home page itself. Kudoes to the design team. Senthi

Re: Checking function calls

2006-03-06 Thread Jay Parlar
On Mar 6, 2006, at 8:44 PM, James Stroud wrote: > Since python is "weakly typed", you will not be able to check what > "type" of arguments a function expects. TypeErrors relating to the > type of argemtns you pass will be raised inside the function only and > not when it is called. I.e. there

Re: Cryptographically random numbers

2006-03-06 Thread Tuvas
Wait, I now see that there is a native base 2 log in python, so I will just do that rather than my adhoc way. The reason for adding one is to make sure there isn't any problems if the log is, for instance, 2.2. It will always round up. It's better to have to try twice to make sure the number can ha

Re: Need help initializing a list or tuple.

2006-03-06 Thread Terry Reedy
"KraftDiner" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thank you that worked great! > > a = [[None] * 256] * 256 > for i in range(0,256): > for j in range(0,256): > a[i][j] = i**2 > > Now.. Can I change this quickly into a 1 dimensional list of length > 65536? If 'a' were a N

Re: RPC client class?

2006-03-06 Thread Fredrik Lundh
Dick Watson wrote: > > if the RPC you're talking about is Sun RPC, the whole concept is pretty > > dated (the original RFCs are from the late eighties). > > Just because it's dated doesn't meant it isn't still something that > occasionally needs done. Thanks for the advice! oh, absolutely. I jus

Re: reshape a list?

2006-03-06 Thread Robert Kern
Michael Spencer wrote: > Robert Kern wrote: > >>KraftDiner wrote: >> >>>I have a list that starts out as a two dimensional list >>>I convert it to a 1D list by: >>> >>>b = sum(a, []) >>> >>>any idea how I can take be and convert it back to a 2D list? >> >>Alternatively, you could use real multidi

Re: Checking function calls

2006-03-06 Thread James Stroud
Fredrik Tolf wrote: > If I have a variable which points to a function, can I check if certain > argument list matches what the function wants before or when calling it? > > Currently, I'm trying to catch a TypeError when calling the function > (since that is what is raised when trying to call it w

Re: reshape a list?

2006-03-06 Thread Michael Spencer
Robert Kern wrote: > KraftDiner wrote: >> I have a list that starts out as a two dimensional list >> I convert it to a 1D list by: >> >> b = sum(a, []) >> >> any idea how I can take be and convert it back to a 2D list? > > Alternatively, you could use real multidimensional arrays instead of fakin

Re: need a start point for wsdl

2006-03-06 Thread Ravi Teja
Everything you need. http://diveintopython.org/soap_web_services/index.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking function calls

2006-03-06 Thread paul . dale
I will be out of the office from March 3rd to March 31st. In urgent cases please contact [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking function calls

2006-03-06 Thread Ravi Teja
You can match if the list contains the legal number of arguments with. func_variable.func_code.co_argcount Type checking arguments has to be done manually since Python is a dynamic language. Perhaps, you could try some typechecking decorators. http://www.ilowe.net/software/typecheck/ >From the doc

Re: need a start point for wsdl

2006-03-06 Thread Ravi Teja
Everything you need. http://diveintopython.org/soap_web_services/index.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Python advocacy in scientific computation

2006-03-06 Thread Andy Salnikov
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > sturlamolden wrote: >> Robert Kern wrote: >> >> >>>And you need to ask why Python is a better Matlab than Matlab? >> >> >> >> First there are a few things I don't like: >> >> 1. Intendation as a part of the syntax, reall

Re: Python and Java

2006-03-06 Thread Ravi Teja
For most purposes Jython 2.1 is just fine. The lack of recent features is not a show stopper. What do you need metaclasses? decorators? BTW, there is Jython 2.2 as an alpha release. There are a number of ways you can use Java code through Python. Use JPype to start a Java VM http://jpype.sourcefo

RE: style question: how to delete all elements in a list

2006-03-06 Thread Delaney, Timothy (Tim)
gry@ll.mit.edu wrote: > To delete all the elements of a list, should one do: > >lst[:] = [] > or >del(lst[:]) del lst[:] Note that del is not a function - the parentheses are not needed, and in fact obscure the intent. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

need a start point for wsdl

2006-03-06 Thread nephish
hello there, i have recently been tasked with grabbing info to pipe into our database from an information server. The server guys told me i need to grab their wsdl file. Untill earlier this afternoon, i had no idea what wsdl is. From what i gather, it is much like SOAP. So anyway, any pythoneers ou

Re: Argument Precedence (possible bug?)

2006-03-06 Thread Terry Reedy
"vbgunz" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, Steven D'Aprano, Terry Jan Reedy! > > I would really like to extend my thanks to you guys. I hope I've got it > right this time! > > def posKeyArgs(a, b=2, c=3): >print a, b, c > > #posKeyArgs(b=20) # too few posit

Re: Cryptographically random numbers

2006-03-06 Thread Bryan Olson
Paul Rubin wrote: > My favorite way to convert strings to numbers is with binascii: > > from binascii import hexlify > def s2num(text): >return int(hexlify(text), 16) Neat. I use the empty string as a binary representation of zero, which you can accommodate with: def s2num(text): ret

Checking function calls

2006-03-06 Thread Fredrik Tolf
If I have a variable which points to a function, can I check if certain argument list matches what the function wants before or when calling it? Currently, I'm trying to catch a TypeError when calling the function (since that is what is raised when trying to call it with an illegal list), but that

style question: how to delete all elements in a list

2006-03-06 Thread gry
Just curious about people's sense of style: To delete all the elements of a list, should one do: lst[:] = [] or del(lst[:]) I seem to see the first form much more often in code, but the second one seems more clearly *deleting* elements, and less dangerously mistaken for the completely diff

problem with multiple Py_Initialize/Py_Finalize calls

2006-03-06 Thread Andrew Trevorrow
Hi folks, I've only been using Python for a few weeks, so please be gentle. :) Lovely language by the way -- I really enjoying using it -- but I've struck a very nasty problem when running Python scripts from my app. Summary: Multiple Py_Initialize/Py_Finalize calls result in bad memory leaks, a

how about adding ping's uuid module to the standard lib ?

2006-03-06 Thread Fredrik Lundh
see subject and http://python.org/sf/1368955 comments ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this not infinite?

2006-03-06 Thread John Salerno
Kent Johnson wrote: > This should be > def __init__(self, etc): > Base.__init__(self, etc...) > It's a typo in the book. > Thank goodness! At least I know my mind is heading in the right direction then... :) -- http://mail.python.org/mailman/listinfo/python-list

SAX/Python : read an xml from the end to the top

2006-03-06 Thread kepioo
I currently have an xml input file containing lots of data. My objectiv is to write a script that reports in another xml file only the data I am interested in. Doing this is really easy using SAX. The input file is continuously updated. However, the other xml file should be updated only on request

Re: Help - just a few lines of code needed

2006-03-06 Thread johnzenger
There is some fine permutation code in the cookbook. Take a look at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 . You can easily code something like: # xcombinations from the cookbook def xcombinations(items, n): if n==0: yield [] else: for i in xrange(len(item

Re: wanted: ftp server class

2006-03-06 Thread Jean-Paul Calderone
On Mon, 06 Mar 2006 16:37:21 GMT, John Pote <[EMAIL PROTECTED]> wrote: >Hi everyone, > >I have a 'client' with a built in ftp client that I wish to use to access a >server via the internet. But I do not want to use a standard disk accessing >ftp server as I need to do my own processing between the

Re: %r

2006-03-06 Thread Blackbird
Blackbird wrote: > Blackbird <[EMAIL PROTECTED]> skrev: > >>> >> Is the interpreter in fact using repr(), or parts of it, to generate >> output when you type an expression at the command prompt? The >> results sure look similar. > > Let me clarify this: The interpreter uses eval. No doubt about

Re: Help - just a few lines of code needed

2006-03-06 Thread James Stroud
[EMAIL PROTECTED] wrote: > Unfortunately I am not able to program it myself, so You should learn how. Its very easy and will make your life better. Go to www.python.org. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/

Re: Mixin class error

2006-03-06 Thread Kent Johnson
Ed Leafe wrote: > On Mar 6, 2006, at 8:08 PM, Kent Johnson wrote: >> One workaround might be to use delegation instead of subclassing... > > Yeah, but that would involve a lot more work at this point. The > mixin approach has been working quite well up until this problem. Automatic delegati

Re: Is this not infinite?

2006-03-06 Thread Kent Johnson
John Salerno wrote: > From a book: > > class Derived(Base): > def __init__(self, etc): > self.__init__(self, etc...) This should be def __init__(self, etc): Base.__init__(self, etc...) or possibly def __init__(self, etc): super(Derived, self).

Re: Python advocacy in scientific computation

2006-03-06 Thread bearophileHUGS
Michael Tobis: > Python plays so well with others. For many applications, NumPy is fine. > Otherwise write your own C or C++ or F77; building the Python bindings > is trivial. On Windows I have found that creating such bindings is very very difficult... I have succed only partially, with C++, and

Re: Does '#hash' mean anything in IDLE?

2006-03-06 Thread Paul Rubin
Kent Johnson <[EMAIL PROTECTED]> writes: > use > max((len(words), i, words) for i, words in enumerate(d.itervalues())) > > The index will always disambiguate and words will never be compared. OK, but that starts to get pretty obscure. Supporting key and cmp args for max and min is a lot cleaner.

Re: Mixin class error

2006-03-06 Thread Ed Leafe
On Mar 6, 2006, at 8:08 PM, Kent Johnson wrote: > I have no clue but googling 'type is not an acceptable base type' > finds > this thread > http://groups.google.com/group/comp.lang.python/browse_thread/ > thread/628b8ad34a36db17/579f716b143f4967%23579f716b143f4967? > sa=X&oi=groupsr&start=0&nu

Is this not infinite?

2006-03-06 Thread John Salerno
From a book: class Derived(Base): def __init__(self, etc): self.__init__(self, etc...) I don't understand why the 'self' in the call to the Base class constructor doesn't still refer to the Derived instance. If you say: x = Derived() then that triggers the def above. And the

figuring out how much data was sent so far via XML-RPC?

2006-03-06 Thread Ratko Jagodic
I am currently using XML-RPC for a very convenient quick-and-dirty way of sending some files (base64 encoded). The files can be bigger sometimes (10-20mb) and I was wondering if there is a way to see how much data was sent already and how much still needs to be sent (like a progress bar). I would o

Help - just a few lines of code needed

2006-03-06 Thread lory88
Hi I hope someone can help me out with a very SIMPLE program about whole string permutations. That is: given a list of strings, the required outcome is a complete set of all their possible permutations. It's like character permutations of a string, but this time it is whole strings instead of sing

Re: Does '#hash' mean anything in IDLE?

2006-03-06 Thread Kent Johnson
Paul Rubin wrote: > Scott David Daniels <[EMAIL PROTECTED]> writes: >>Using a variant of DSU (Decorate-Sort-Undecorate) with max for S, >>rather than sort: >> >> print max((len(words), words) for words in d.itervalues()) >>or: >> size, words = max((len(words), words) for words in d.itervalu

Re: Python and Java

2006-03-06 Thread Kent Johnson
JKPeck wrote: > Suppose you have an application written in Java, and you want to enable > other applications or processes written in Python to communicate with > it, i.e., to use Python as a scripting language for the application. > On Windows you could do this with COM and various addons such as >

Re: %r

2006-03-06 Thread Blackbird
Blackbird <[EMAIL PROTECTED]> skrev: >> > Is the interpreter in fact using repr(), or parts of it, to generate > output when you type an expression at the command prompt? The > results sure look similar. Let me clarify this: The interpreter uses eval. No doubt about that. But >>> eval('f') >

Re: Mixin class error

2006-03-06 Thread Kent Johnson
Ed Leafe wrote: > In Dabo, we create cursor classes that combine the backend-specific > dbapi cursor class with our own mixin class that adds framework- > specific behaviors. This has been working well for a couple of years > now with many different backends, but today I'm getting errors w

Re: raw strings and \

2006-03-06 Thread plahey
Interesting, so thats where this comes from. Of course the problem is that I thought that a raw string was a different animal than a regular string (i.e. truely "raw" where no characters are special, except of course the closing quote) so parsing consistency is surprising to an end user (who has a

Re: Python advocacy in scientific computation

2006-03-06 Thread David M. Cooke
Robert Kern <[EMAIL PROTECTED]> writes: > sturlamolden wrote: > >> 5. Versioning control? For each program there is only one developer and >> a single or a handful users. > > I used to think like that up until two seconds before I entered this gem: > > $ rm `find . -name "*.pyc"` > > Okay, I did

Re: %r

2006-03-06 Thread Blackbird
Peter Hansen wrote: > [...]> > On the other hand, if 'something' is actually some arbitrary object, > then it's definitely not always true, especially for anything not > built in to Python. > > -Peter Yes, I had strings in mind. And I guess it will work with the other primitive types, but anythin

Re: Use python from command line

2006-03-06 Thread nak
have you added the path to 'c:\program files\python2.4\python.exe' in the Environment variables? -- http://mail.python.org/mailman/listinfo/python-list

Re: Cryptographically random numbers

2006-03-06 Thread Paul Rubin
"Tuvas" <[EMAIL PROTECTED]> writes: > def s2num(text): > if(len(text)==1): > return ord(text) > else: > return ord(text[0])+256*s2num(text[1:]) My favorite way to convert strings to numbers is with binascii: from binascii import hexlify def s2num(text): return int(hexl

Re: Cryptographically random numbers

2006-03-06 Thread Tuvas
Ahh, you are correct, that is a large bug... How about this one? def s2num(text): if(len(text)==1): return ord(text) else: return ord(text[0])+256*s2num(text[1:]) def cran_rand(min,max): range=int(log(abs(max-min))/log(2))+1 num=max+1 if range%8==0: cra

Re: Python advocacy in scientific computation

2006-03-06 Thread val bykoski
sturlamolden wrote: > Robert Kern wrote: > >> 1. Write grant proposals. >> >> 2. Advise and teach students. > > > Sorry I forgot the part about writing grant applications. As for > teaching students, I have thankfully not been bothered with that too > much. > >> Yes, and this is why you will

Re: IronPython on Shootout

2006-03-06 Thread bearophileHUGS
This is the answer that I did receive about Boo: https://alioth.debian.org/tracker/index.php?func=detail&aid=302999&group_id=30402&atid=411005 igouy-guest>We already have languages no one uses and no one writes rograms for - once there are a bunch of shootout programs written in Boo and tested on

Re: Random Prime Generator/Modular Arithmetic

2006-03-06 Thread Tuvas
Actually, there was a small bug fix that I found, and I had a teacher who told me once that there was only 5 pseudoprimes. I realized that large numbers of prime numbers were returning false, and discovered the root of the problem, which was that my M-R test ended too late... But, it works now, tha

Re: IronPython on Shootout

2006-03-06 Thread cdunn2001
On Mono, it makes more sense to add Boo. I've been looking for Boo benchmarks. -- http://mail.python.org/mailman/listinfo/python-list

Re: %r

2006-03-06 Thread Blackbird
Fredrik Lundh wrote: > "Blackbird" <[EMAIL PROTECTED]> wrote: > [...] >>> >> a = 'I don\'t think so' >> print '%r' % a >>> "I don't think so" >> a = r'I don\'t think so' >> print "'%s'" % a >>> 'I don\'t think so' >> >> Excellent counterexample. Can something like this happen

Re: Python and Java

2006-03-06 Thread Paul Rubin
"JKPeck" <[EMAIL PROTECTED]> writes: > Suppose you have an application written in Java, and you want to enable > other applications or processes written in Python to communicate with > it, i.e., to use Python as a scripting language for the application. > On Windows you could do this with COM and v

Python and Java

2006-03-06 Thread JKPeck
Suppose you have an application written in Java, and you want to enable other applications or processes written in Python to communicate with it, i.e., to use Python as a scripting language for the application. On Windows you could do this with COM and various addons such as J-Integra and Mark Hamm

Re: Does '#hash' mean anything in IDLE?

2006-03-06 Thread Paul Rubin
Scott David Daniels <[EMAIL PROTECTED]> writes: > > Note that I sorted the dictionary items in order to get the max > > element. That is sort of bogus because it's an O(N log N) operation > > while finding the maximum should only need O(N). But it leads to > > a convenient spelling. It would be

Re: %r

2006-03-06 Thread Peter Hansen
Blackbird wrote: > a = 'something' > b = ('%r'%a) > eval(b) == a > > that in general should return True. I hope. But I'm sure there are > counterexamples to that, too. Provided 'something' is a string, that should be true, as should the simpler statement a == eval(repr(a)) (since '%r' is jus

Re: Need help initializing a list or tuple.

2006-03-06 Thread cdunn2001
# Nested list comprehensions act like real for loops: >>> a = [[None for i in range(3)] for j in range(3)] >>> a [[None, None, None], [None, None, None], [None, None, None]] >>> a[0][0] = 5 >>> a [[5, None, None], [None, None, None], [None, None, None]] # Side-effect: i and j will be changed. # An

Re: Need help initializing a list or tuple.

2006-03-06 Thread BranoZ
How about: a = [ [i**2 for j in range(256)] for i in range(256) ] b = sum(a, []) c = [ b[slice(i,i+256)] for i in range(0,256*256,256) ] >>> a is c False >>> a == c True BranoZ -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening files without closing them

2006-03-06 Thread Robert Kern
Paul Rubin wrote: > "3c273" <[EMAIL PROTECTED]> writes: > >>>f = open(file) >>>try: >>>contents = f.read() >>>finally: >>>f.close() >>> >> >>Pardon the newbie question, but could you explain why? I have been doing it >>the same way as the OP and would like to know the difference. Thank you

Re: Opening files without closing them

2006-03-06 Thread Paul Rubin
"3c273" <[EMAIL PROTECTED]> writes: > > f = open(file) > > try: > > contents = f.read() > > finally: > > f.close() > > > Pardon the newbie question, but could you explain why? I have been doing it > the same way as the OP and would like to know the difference. Thank you. Say that the open

Dr. Dobb's Python-URL! - weekly Python news and links (Mar 6)

2006-03-06 Thread Cameron Laird
QOTW: "This PyCon has been better in so many respects than the three that preceded it. ... PyCon will continue to improve." - Steve Holden, chairman of PyCon 2003-2005 http://holdenweb.blogspot.com/ "Design patterns are kind of like sarcasm: hard to use well, not always appropriate, and di

Re: Opening files without closing them

2006-03-06 Thread 3c273
"Erik Max Francis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Note quite. The assignment of the resources to its variable needs to be > done before the try: > > f = open(file) > try: > contents = f.read() > finally: > f.close() > Pardon the newbie question, but could you

Mixin class error

2006-03-06 Thread Ed Leafe
In Dabo, we create cursor classes that combine the backend-specific dbapi cursor class with our own mixin class that adds framework- specific behaviors. This has been working well for a couple of years now with many different backends, but today I'm getting errors with our Firebird c

Re: Pyserial again

2006-03-06 Thread Petr Jakes
Grant and Steve, I am wowed and amazed how supportive and helpful you (and other people in this group as well of course) are. Thanks. (sorry for OT) Petr Jakes -- http://mail.python.org/mailman/listinfo/python-list

Re: raw strings and \

2006-03-06 Thread John Salerno
Alex Martelli wrote: >> Now get back to work on your new Nutshell book :-) > > Yep, good point!-) Are you working on a new edition? I didn't see any new Python books listed on O'Reilly's site through April, but I'd definitely be interested in new versions of the books I plan to get soon (Cookb

IronPython on Shootout

2006-03-06 Thread bearophileHUGS
I have suggested the Shootout site to add tests for IronPython too (tests are done on Mono): http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&lang=iron People that use IronPython can probably fix some of those programs. Bye, bearophile -- http://mail.python.org/mailman/listi

Re: Python advocacy in scientific computation

2006-03-06 Thread Peter Maas
Steve Holden schrieb: > sturlamolden wrote: >> First there are a few things I don't like: >> >> 1. Intendation as a part of the syntax, really annoying. >> > Troll. You think this is going away because *you* don't like it? You are over-reacting. Keep in mind that sturlamolden has criticized Python

Re: Pyserial again

2006-03-06 Thread Grant Edwards
On 2006-03-06, Luca <[EMAIL PROTECTED]> wrote: >>> Another point is the textctrl: it store only the first byte >>> and not the other why?, the byte are like 22 and all are >>> readed >> >> No clue. I don't know what "textctrl" is or what it's >> supposed to do. > > a = ser.readline() >

Re: pyparsing: crash on empty element

2006-03-06 Thread Paul McGuire
To indicate that a particular parse expression may be empty, pyparsing includes the Optional element. Change: pp.delimitedList(withquotes | withoutquotes) + \ to: pp.Optional( pp.delimitedList(withquotes | withoutquotes) ) + \ and I think this will have the desired effect. -- Paul wrote in m

Re: slicing the end of a string in a list

2006-03-06 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > >>>[line.rstrip() for line in open('C:\\switches.txt')] > > How would I manually close a file that's been opened this way? Or is > > it not possible in this case? Is it necessary? > > In CPython it's not strictly necessary to close the file, but other > im

Re: Python advocacy in scientific computation

2006-03-06 Thread Peter Maas
Duncan Booth schrieb: > sturlamolden wrote: >> 1. Can python do "pass by reference"? Are datastructures represented by >> references as in Java (I don't know yet). >> > Python only does "pass by reference", although it is more normally referred > to as "pass by object reference" to distinguish it

  1   2   3   >