Re: Dynamic comparison operators

2012-05-24 Thread Paul Rubin
[email protected] writes: > I would like to pass something like this into a function > test(val1,val2,'>=') > > and it should come back with True or False. import operator test(val1, val2, operator.ge) -- http://mail.python.org/mailman/listinfo/python-list

Re: Email Id Verification

2012-05-24 Thread Paul Rubin
Ben Finney writes: > The point is that, having collected the email address, it's useless > unless one actually uses it *as an email address*, by sending a message > to it. Before then, “validating” it tells you nothing. Right, the only legitimate use of an email address is sending legitimate emai

Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread Paul Rubin
Roy Smith writes: > The Rasberry Pi certainly looks attractive, but isn't quite available > today. Can you run Python on an Arduino? No. YOu want a 32-bit platform with an OS and perhaps 1 meg of memory. And by the time you port Python to it unless it's there already, you may as well have jus

Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread Paul Rubin
[email protected] writes: > Rasberry Pi is available, some have arrived, mine will arrive on > Monday or Tuesday (I'm talking about UK here). Early orders have been filled, more are being filled, but there is a huge backlong and therefore a long wait if you waited til now to order. If you want on

Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread Paul Rubin
Roy Smith writes: > It sounds like I can run one on 300mA @ 5V. For my application, I'll > have about 10 A-h available at 12V (motorcycle battery). OK, the RPi should be fine power-wise in that case, though I wouldn't consider something with a 10AH motorcycle battery to be very portable. > whi

Re: python for android anyone?

2012-05-28 Thread Paul Rubin
rusi writes: > Ive been wanting to try the sl4a for a new android phone Ive got hold > of as spelt out at > http://www.linuxjournal.com/article/10940 > > Has anyone any experience/dos/donts for this? One of my co-workers used it for something, and I've been looking into it but haven't tried it ye

PIL threading problems

2012-05-29 Thread Paul Rubin
Kind of a long shot, but are there known problems in calling PIL from multiple threads? I'm getting weird intermittent core dumps from my app, no idea what's causing them, but PIL is the only C module I'm using, and I do see some mention on the interwebs that there might be an issue: http://lis

Re: English version for Mémento Python 3 (draft, readers needed)

2012-06-05 Thread Paul Rubin
key":"value"} {1:"un",3:"trois",2:"deux",3.14:""} => {1:"one", etc. } 3) "bloc" in a few places should be "block" 4) On side 2, the part about writing files is still mostly in French There are a few other

Re: English version for Mémento Python 3 (draft, readers needed)

2012-06-05 Thread Paul Rubin
Laurent Pointal writes: >> There are a few other things like that, and I'll try to look more >> carefully tonight, I can't spend more time on it right now. > I updated the document into 1.0.5a (and fix some other errors). A few more things: In "Base types" section: unmodifiable => immutable

Re: which one do you prefer? python with C# or java?

2012-06-09 Thread Paul Rubin
Yesterday Paid writes: > I'm planning to learn one more language with my python. > Someone recommended to do Lisp or Clojure, but I don't think it's a > good idea(do you?) Why do you want to do that? First of all, why not stick with learning one language at a time? Get familiar with one before

Re: which one do you prefer? python with C# or java?

2012-06-10 Thread Paul Rubin
Matej Cepl writes: > The point is that you are never interested in learning *a language*, > everybody who has at least some touch with programming can learn most > languages in one session in the afternoon. Really, that's only if the new language is pretty much the same as the old ones, in which

Re: which one do you prefer? python with C# or java?

2012-06-10 Thread Paul Rubin
Matej Cepl writes: > Well, I could at least passively read many languages (starting with > Pascal, C, and unsuccessful attempt to learn Prolog, so even > statically typed languages are not that mysterious to me), I wouldn't count Pascal or C as statically typed in any interesting way. C++ (templ

Re: which one do you prefer? python with C# or java?

2012-06-10 Thread Paul Rubin
Matej Cepl writes: > I know that, and it lies on my badtable for some time already, but I > just never got enough excited about the idea yet. Python is just much > more fun. Here is an exercise from the book that you might like to try in Python: http://mitpress.mit.edu/sicp/full-text/book/book

Re: which one do you prefer? python with C# or java?

2012-06-14 Thread Paul Rubin
>>http://blog.tmorris.net/understanding-practical-api-design-static-typing-and-functional-programming/ > > When I'm satisfied with a program, it has this ethereal property that > if the problem is slightly altered, the program is only slightly > altered. One thing I find with Haskell: the type sys

Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Paul Rubin
Alexander Blinne writes: >> def gen_s(): >> s = [1] >> m = skipdups(heapq.merge(*[(lambda j: (k*j for k in s))(n) for n in >> [2,3,5]])) >> yield s[0] >> while True: >> k = m.next() >> s.append(k) >> yield k Nice. I wouldn't have been sure that "for k in s" worked prop

Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Paul Rubin
Alexander Blinne writes: > An Element of s could be discarded, after every one of the three (k*j > for k in s)-generators went over it. I don't think that this is possible > with one deque (at least with the built-in merger of heapq, a > self-written one could be adapted). Storing everything three

Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Paul Rubin
Terry Reedy writes: > Python iterators can do lazy evaluation. All the builtin classes come > with a corresponding iterator. ... I wouldn't say iterators do lazy evaluation in the Scheme or Haskell sense. Lazy evaluation imho means evaluation is deferred until you actually try to use the value,

Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-16 Thread Paul Rubin
Yesterday Paid writes: > I'm making cipher program with random.seed(), random.random() as the > key table of encryption... > Is it really random or safe enough to keep my data safe? No. Use os.urandom instead. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-17 Thread Paul Rubin
Steven D'Aprano writes: >> /dev/urandom isn't actually cryptographically secure; it promises not to >> block, even if it has insufficient entropy. But in your instance... > > Correct. /dev/random is meant to be used for long-lasting > cryptographically-significant uses, such as keys. urandom is n

Re: How good is security via hashing

2011-06-07 Thread Paul Rubin
Robin Becker writes: > I have a vague memory that the original author felt that entropy might > run out or something like that so reading from /dev/urandom always was > not a good idea. If there is enough entropy to begin with, then /dev/urandom should be cryptographically strong. The main dange

Re: How good is security via hashing

2011-06-07 Thread Paul Rubin
geremy condra writes: > # adds random junk to the filename- should make it hard to guess > rrr = os.urandom(16) > fname += base64.b64encode(rrr) Don't use b64 output in a filename -- it can have slashes in it! :-( Simplest is to use old fashioned hexadeimal for stuff like that, unless the numbe

Re: How good is security via hashing

2011-06-07 Thread Paul Rubin
Christian Heimes writes: > PyCrypto has a strong pseudorandom number generator, too. If you mean the one at pycrypto.org, that page now says: Random number generation Do not use RandomPool to generate random numbers. Use Crypto.Random instead. RandomPool is deprecated and will be re

Re: How good is security via hashing

2011-06-07 Thread Paul Rubin
Nobody writes: > The problem with /dev/urandom is that it shares the same entropy pool as > /dev/random, so you're "stealing" entropy which may be needed for tasks > which really need it (e.g. generating SSL/TLS keys). The most thorough analysis of Linux's /dev/*random that I know of is here:

Re: How good is security via hashing

2011-06-08 Thread Paul Rubin
Nobody writes: >>> If you're going to read from /dev/urandom, limit it to a few bytes per >>> minute, not per request. >> That's really not going to help you. > In what way? > If I need security, I'll use /dev/random or /dev/urandom. If I don't, I'll > save the real entropy for something which nee

Re: Overcharged

2011-06-11 Thread Paul Rubin
Ethan writes: > I mad a call last night and never even talked to anybody, > Sent from my Samsung Epic™ 4G Your Epic 4G must not have been programmed in Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Strategy to Verify Python Program is POST'ing to a web server.

2011-06-18 Thread Paul Rubin
"[email protected]" writes: > For example, if I create a website that tracks some sort of > statistical information and don't ensure that my program is the one > that is uploading it, the statistics can be thrown off by people > entering false POST data onto the data upload page. Any remedy? If

Re: Strategy to Verify Python Program is POST'ing to a web server.

2011-06-19 Thread Paul Rubin
Steven D'Aprano writes: >> Supply the client with tamper-proof hardware containing a private key. > > Is that resistant to man-in-the-middle attacks by somebody with a packet > sniffer watching the traffic between the device and the website? Sure, why not? As long as the crypto is done properly

Re: opening a file

2011-06-19 Thread Paul Scott
gular python, but certainly in the wx GUI toolkit, there is a wx.StandardPaths.Get() function which will get the user's home or standard path where you can store all sorts of config data etc in a hidden directory as well. -- -- Paul http://www.paulscott.za.net http://twitter.com/paulscott56 http://www.chisimba.com signature.asc Description: This is a digitally signed message part -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
Terry Reedy writes: >> efficient implementation will allow a solution to be obtained on a >> modestly powered computer in less than one minute." > If something really takes a minute in C, > allow yourself at least 10 minutes or even more with plain CPython. No. The idea of the Euler problems is

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
John Salerno writes: > However, even after reading the Wikipedia page about prime numbers and > trial division, I'm still a little unclear as to why the square root > of the number is the upper bound of the range you need to check. Suppose p is the smallest divisor of n, and p > sqrt(n). ("Diviso

Re: Security test of embedded Python

2011-06-21 Thread Paul Rubin
Chris Angelico writes: > users to supply scripts which will then run on our servers... > The environment is Python 3.3a0 embedded in C++, running on Linux. This doesn't sound like a bright idea, given the well-known difficulty of sandboxing Python. Geordi

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
John Salerno writes: > It's frustrating because I have the Python right, but I'm getting > stuck on the math > "What is the smallest positive number that is evenly divisible by all > of the numbers from 1 to 20?" The answer is lcm [1,2,3, ... 20]. You can figure out how to implement lcm. Th

Re: Security test of embedded Python

2011-06-21 Thread Paul Rubin
Chris Angelico writes: > I'll also be looking into Pike. Unfortunately its community is far > smaller than Python's, so security holes may be less obvious. Actually the most obvious and widespread sandboxed language these days is Javascript. There's several embeddable implementations. Maybe you

Re: Security test of embedded Python

2011-06-21 Thread Paul Rubin
Chris Angelico writes: > Meanwhile, I'm looking into V8 and whether we can do everything we > need to that way, and how much dev time it's going to take me to > change languages... If you want to run Python, one obvious approach is a controlled-execution wrapper like Geordi uses. -- http://mail.

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
Terry Reedy writes: > If the best C program for a problem takes 10 seconds or more, then > applying the same 1 minute limit to Python is insane, and contrary to > the promotion of good algorithm thinking. The Euler problems are all designed to be doable in 1 minute or less and the Euler project s

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
Chris Torek writes: > def primes(): > """ > Yields sequence of prime numbers via Sieve of Eratosthenes. > """ I think this has the same order-complexity but is enormously slower in practice, and runs out of recursion stack after a while. Exercise: spot the recursion. from iterto

ANN: pyparsing 1.5.6 released!

2011-06-30 Thread Paul McGuire
names Download pyparsing 1.5.6 at http://sourceforge.net/projects/pyparsing/, or use 'easy_install pyparsing'. You can also access pyparsing's epydoc documentation online at http://packages.python.org/pyparsing/. The pyparsing Wiki is at http://pyparsing.wikispaces.com. -- Paul ===

Re: Does hashlib support a file mode?

2011-07-07 Thread Paul Rudin
Anssi Saari writes: > Mel writes: > >> def file_to_hash(path, m = hashlib.md5()): >> >> hashlib.md5 *is* called once; that is when the def statement is executed. > > Very interesting, I certainly wasn't clear on this. So after that def, > the created hashlib object is in the module's scope and c

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Paul Rudin
Steven D'Aprano writes: > Please don't post code with line numbers. That makes it difficult to copy > and paste your function into an interactive session, so that we can run it > and see what it does. C-x r d -- http://mail.python.org/mailman/listinfo/python-list

Re: Tips/lessons learned for writing a Python powered DSL?

2011-07-07 Thread Paul Woolcock
iate hearing about them. > > Thank you, > Malcolm > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- --- Paul Woolcock -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I make a program automatically run once per day?

2011-07-10 Thread Paul Rudin
John Salerno writes: > I have a script that does some stuff that I want to run every day for > maybe a week, or a month. So far I've been good about running it every > night, but is there some way (using Python, of course) that I can make > it automatically run at a set time each night? Well - y

Re: Partial Function Application -- Advantages over normal function?

2011-07-18 Thread Paul Woolcock
gt;> add2 = partial(add, right=2) Now, you have a new function, `add2`, that takes one parameter: >>> add2(4) 6 --- Paul Woolcock [email protected] On Mon, Jul 18, 2011 at 6:13 AM, Kurian Thayil wrote: > > Hi, > > I am a newbie in python and would like to

Re: Return and set

2011-07-19 Thread Paul Woolcock
(self): >if self.tok: >t = self.tok >self.tok = None >return t ># ... > > > Is there a way to trim the 'if' block to reset self.tok upon return? > > -- > Bill > -- > http://mail.python.org/**mailman/listinfo/python-list<http:

Re: Please code review.

2011-08-02 Thread Paul Kölle
Paul Cheers karim Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def _xrange_cellnames(rows, cols): ... """Internal itera

Re: how to separate a list into two lists?

2011-08-06 Thread Paul Rubin
smith jack writes: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i do not want to use loop, any meth

Re: __all__

2011-08-09 Thread Paul Woolcock
The gurus will have to correct me if this is not an accepted practice, but I know some projects (Fabric is the one that comes to mind) will define a submodule specifically for the 'from blah import *' situation. The submodule would be called "api", or something like that, so you can do: 'from mymod

Re: [Python-ideas] allow line break at operators

2011-08-11 Thread Paul Colomiets
be great. > > if a >  and b >  or c: >  do stuff() > If you really think so, try writing some coffeescript (remember to obey 79 chars limit). Coffeescript is amasing, but it lacks strictness of python. So you really don't know how to break line, and it really takes time to figu

Re: allow line break at operators

2011-08-15 Thread Paul Woolcock
On Aug 14, 2011 3:24 PM, "Seebs" wrote: ... > > I'm not impressed by arguments based on "but if I do something stupid, like > > select text with my eyes closed and reindent it without looking, I expect > > the compiler to save my bacon". In my opinion, it's not the compiler's job > > to protect yo

Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
d templates) , it would be simple to extend the technique to creating template functions from strings, and insert the resulting methods into a namespace for execution.) I think, given the technique is already working with the AST, that sandboxing should not be too hard either - advice on this aspect would be appreciated. Paul Wray -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 2:14 am, Chris Angelico wrote: > On Tue, Aug 16, 2011 at 12:33 PM, Paul Wray wrote: > > The idea is simply to use python ASTs to transform this code so that it > > accumulates the values of the bare expressions. > > That'd be similar to what the interactiv

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 5:23 am, Irmen de Jong wrote: > On 16-08-11 13:33, Paul Wray wrote: > > > > > > > > > > > The idea: > > Python syntax allows a statement to be a bare literal or identifier. > > These have no effect on the program. > > > So the f

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
> You code fail, see below for other comment > > Traceback (most recent call last): >   File "Download/pastie-2379978.rb", line 108, in >     make_template(template1) >   File "Download/pastie-2379978.rb", line 60, in make_template >     ast.fix_missing_locations(astFromSrc) >   File "/usr/lib/pyt

Re: pairwise combination of two lists

2011-08-18 Thread Paul Rubin
Yingjie Lin writes: > li1 = ['a', 'b'] > li2 = ['1', '2'] > > and I wish to obtain a list like this > li3 = ['a1', 'a2', 'b1', 'b2'] from itertools import * li3 = list(chain.from_iterable(izip(li1,li2))) -- http://mail.python.org/mailman/listinfo/python-list

Re: 'super' object has no attribute '__setitem__'

2011-08-19 Thread Paul Woolcock
If you really want __setitem__ and not __setattr__, you should change the base class to 'dict'. Or 'import UserDict' and use that for the base class. On Aug 18, 2011 9:45 PM, "luvspython" wrote: > I'm using Python 2.7 and the code below fails at the 'super' statement > in the __setitem__ function

Re: try... except with unknown error types

2011-08-20 Thread Paul Rubin
Steven D'Aprano writes: >> You can catch all exceptions by catching the base class Exception: > > Except that is nearly always poor advice, because it catches too much: it > hides bugs in code, as well as things which should be caught. > You should always catch the absolute minimum you need to cat

Re: try... except with unknown error types

2011-08-21 Thread Paul Rubin
Steven D'Aprano writes: >> But there's no way to know what that minimum is. Python libraries throw >> all sorts of exceptions that their documentation doesn't mention. > > Yes, you're absolutely correct. But it's also irrelevant. Most of those > exceptions should not be caught, even if you know w

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Paul Kölle
Am 22.08.2011 13:37, schrieb Roy Smith: In article , Tomas Lidén wrote: A cross-platform deterministic order would be excellent for us. "A cross-platform deterministic X would be excellent" is a true statement for almost any value of X. Many people have wasted much of their lives trying to

Re: try... except with unknown error types

2011-08-23 Thread Paul Rubin
Chris Angelico writes: > Ehh, granted. Definitely a case of "should". But certainly, there > won't be an infinite number of new exceptions invented; Right, the number is finite, but the issue is that it's unknown. It's like never knowing whether you've fixed the last bug in a program. -- http:

Re: Methods on file-like objects can only used once on one object?

2011-08-23 Thread Paul Kölle
? Thank you. use f.seek(0) between calls. The python documentation will educate you about the details. hth Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: try... except with unknown error types

2011-08-23 Thread Paul Rubin
gene heskett writes: > OTOH, ChrisA, I have it on good authority that no program is ever finished, > until someone shoots the programmer. :) The way I heard it was "software is never finished until the last user is dead". -- http://mail.python.org/mailman/listinfo/python-list

Re: Processing a large string

2011-08-28 Thread Paul Rudin
goldtech writes: > Hi, > > Say I have a very big string with a pattern like: > > akakksssk3dhdhdhdbddb3dkdkdkddk3dmdmdmd3dkdkdkdk3asnsn. > > I want to split the sting into separate parts on the "3" and process > each part separately. I might run into memory limitations if I use > "split" and

Re: killing a script

2011-08-28 Thread Paul Rubin
"Russ P." writes: > Thanks for the suggestion. Yeah, I guess I could do that, but it seems > that there should be a simpler way to just kill the "whole enchilada." > Hitting Control-C over and over is a bit like whacking moles. Hit Ctrl-Z, which stops execution of the subprogram but doesn't kill

Re: Installing WebDAV server

2011-08-31 Thread Paul Kölle
in my computer this is E:\python27\Tools\Scripts. PyXML and PyWebDAV get installed in the site-packages folder i.e. E:\python27\Lib/site-packages. You might have to look for "davserver" there... hth Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing WebDAV server

2011-08-31 Thread Paul Kölle
Hi, answers below... Am 31.08.2011 14:18, schrieb Fokke Nauta: "Paul Kölle" wrote in message news:[email protected]... Hi, Am 30.08.2011 22:00, schrieb Fokke Nauta: Hi all, I am completely new to Python, but I'm confronted with a proble

Re: Need advice on Web / Database framework...

2011-09-03 Thread Paul Kölle
and has good documentation. If you want to get your hands dirty you can compose your own "framework" cherrypy+sqlalchemy+cheetah might be a good combination. hth Paul -- http://mail.python.org/mailman/listinfo/python-list

Python Language Question?

2011-02-27 Thread Paul Symonds
Can someone give and explanation of what is happening with the following: a,b = 0,1 # this assigns a = 0 and b = 1 while b < 10: ... print b ... a, b = b, a+b ... 1 1 2 3 5 8 a=0 b=1 while b < 1000: ... print b ... a = b ... b = a+b ... 1 2 4 8 1

Re: Python Language Question?

2011-02-27 Thread Paul Symonds
cheers -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Code Examples

2011-03-01 Thread Paul Rubin
Erik de Castro Lopo writes: > Why Python? I really can't understand the rush of every man and > his dog to Python. Are you trolling? Anyway, try googling "evil mangler" and ask why it wasn't done in Haskell. Same idea. -- http://mail.python.org/mailman/listinfo/python-list

Re: arbitrary precision linear algebra

2011-03-02 Thread Paul Rubin
Ben123 writes: > I'll ask on the Sage forums about this. In the mean time, I'm still > trying to get arbitrary precision linear algebra in Python You probably have to use something like gmpy.mpq to implement your favorite eigenvalue computation algorithm. Maxima might be able to do it out of the

Re: What do I need to know in order to write a web application in python?

2011-03-04 Thread Paul Rubin
ErichCart ErichCart writes: > By real-time, I mean that I want it to be similar to the way instant > online chess works. Something like here: instantchess.com, but for > RISK. If you want to do that in a web browser, the main technique for it is called AJAX and you'd write your application in Jav

Re: Extending dict (dict's) to allow for multidimensional dictionary

2011-03-05 Thread Paul Rubin
Ravi writes: > I can extend dictionary to allow for the my own special look-up > tables. However now I want to be able to define multidimensional > dictionary which supports look-up like this: > > d[1]['abc'][40] = 'dummy' Why do that anyway? You can use a tuple as a subscript: d[1,'abc',40]

Re: having both dynamic and static variables

2011-03-07 Thread Paul Rubin
Steven D'Aprano writes: > but I call that a feature, not a bug. If you want an immutable constant, > use a tuple, not a list. Nope: L = ([1,2],[3,4]) # tuple L[0].append(5) # mutate L, in some reasonable sense of "mutate" -- http://mail.python.org/mailman/listinfo/python-list

Re: having both dynamic and static variables

2011-03-07 Thread Paul Rubin
Steven D'Aprano writes: >> L[0].append(5) # mutate L, in some reasonable sense of "mutate" > > You haven't mutated the tuple called "L". You've mutated its internal > components, which are lists. If you wanted them to also be immutable, you > should have used tuples :) Obviously you are

Re: Python language changes that first shipped in something besides CPython?

2011-03-08 Thread Paul Rubin
Terry Reedy writes: > For that type of feature, I am pretty sure the answer is no. There are > developers from other implementations that have cpython commit rights > and they have contributed new tests. Modules? I have never seen 'We > first did this with xpython on the tracker, but it is possibl

Re: What do you use with Python for GUI programming and why?

2011-03-10 Thread Paul Rubin
Robert writes: > Is there a push to one toolkit or the other? Tkinter or a simple web app with cgihttpserver. I haven't ever had occasion to write a fancy desktop app and I think of them as a mostly-obsolete medium, though I guess there are still some useful ones. I have some interest in progra

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Paul Rubin
Steven D'Aprano writes: > If anyone has any use-cases for sorting with a comparison function that > either can't be written using a key function, or that perform really > badly when done so, this would be a good time to speak up. We've had this discussion a couple times before. I remember an e

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Paul Rubin
Nobody writes: >> 2,7,1,8,... You can sort these with cmp but not with key. > > Is there some restriction on the return type of the key= function? If not, > you can define a class with appropriate comparison methods and have key= > return instances of that class. Sorry, yeah, of course you can d

Re: Guido rethinking removal of cmp from sort method

2011-03-15 Thread Paul Rubin
Ian Kelly writes: > I would think that you can sort them with key as long as none of the > sequences are equal (which would result in an infinite loop using > either method). Why not this? Yes you can do something like that, but look how ugly it is compared with using cmp. -- http://mail.python

Re: Guido rethinking removal of cmp from sort method

2011-03-15 Thread Paul Rubin
Stefan Behnel writes: > the question that remains is: are the few remaining cases worth being > supported directly, thus complicating the internal source code of the > Python runtime? The other cases were supported perfectly well already, and the support was removed. That's just ludicrous in my

Re: Guido rethinking removal of cmp from sort method

2011-03-23 Thread Paul Rubin
Carl Banks writes: > It's kind of ridiculous to claim that cmp adds much complexity (it's > maybe ten lines of extra C code), so the only reason not to include it > is that it's much slower than using key. Well, I thought it was also to get rid of 3-way cmp in general, in favor of rich comparison

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Paul Rubin
Dennis Lee Bieber writes: > The first half of the problem description -- "Elements are added at > random" seems more suited to an in-place insertion sort method. This is precisely what a priority queue is for. Insertions take O(log n) time and there's very little space overhead in heapq'

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Paul Rubin
Steven D'Aprano writes: > I don't know about that. Correctly, efficiently and *quickly* > implementing the three-argument version of pow is exactly the sort of > thing that should be in the built-ins, or at least the standard library. There is also math.pow which works slightly differently from

Re: best python games?

2011-03-26 Thread Paul Rudin
sogeking99 writes: > hey guys, what are some of the best games made in python? free games > really. like pygames stuff. i want to see what python is capable of. Apparently Eve Online is (stackless) python. -- http://mail.python.org/mailman/listinfo/python-list

Re: best python games?

2011-03-28 Thread Paul Rudin
alex23 writes: > Paul Rudin wrote: >> Apparently Eve Online is (stackless) python. > > I've dropped a ridiculous number of hours into EVE this year alone but > I'd be very hesitant to ever mention "best" in relation to its > coding :) > > It uses

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Paul Rubin
Steven D'Aprano writes: > There are lots of problems that Python is not well-suited for. > It is not well-suited for writing the driver to a graphics card. > It is not well-suited to calculating pi to a trillion decimal places. >... But sorting moderate amounts of data on complicated criteria is

Re: Directly Executable Files in Python

2011-03-29 Thread Paul Rudin
Benjamin Kaplan writes: > If you can figure out a good way to compile a language like Python, > you'll be very rich. Yes, it is running the interpreter and then > running the bytecode on the interpreter. It's the same way Java and > .NET work. Not exactly AIUI. .NET bytecodes do actually get co

Re: Guido rethinking removal of cmp from sort method

2011-03-29 Thread Paul Rubin
Ian Kelly writes: > cmp_to_key(lambda x, y: -cmp(x, y)) cmp_to_key(lambda x, y: cmp(y, x)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-31 Thread Paul Rubin
Antoon Pardon writes: > Something else the dev team can consider, is a Negation class > This would have to be done by the dev team since I > guess that writing such a thing in Python would loose all the speed > of using a key-function. That is a good idea. SQL has something like it, I think,

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Paul Rubin
Chris Angelico writes: > Provably false. Even a well-designed interface, if it is asked to deal > with a changing implementation and changing requirements, will > eventually either acquire cruft, or be found too rigid to be of use. What happens then is you define a new interface. In Microsoft-sp

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Paul Rubin
Terry Reedy writes: >> What happens then is you define a new interface. > Like key= versus cmp= Well, in an untyped language like Python, adding a feature to an interface doesn't require defining a new interface unless you change something incompatibly. key= is very useful but it can be added wi

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Paul Rubin
Terry Reedy writes: >> Never change an advertised Class interface. > > In Python, class interfaces are no more sacred than module or function > interfaces. If one takes 'no interface change' literally, then Python > would have to be frozen. Even bug fixes change a defacto interface. Oh come on, a

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Paul Rubin
Terry Reedy writes: >> IWhatever2 setting the new parameters to default values > Now you have two versions, and eventually many more, to maintain and > document. In the case of cmp= there's not two interfaces needed. Python2 does a perfectly good job supporting cmp and key with one interface.

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Paul Rubin
Steven D'Aprano writes: > What I'm saying is this: cmp is already removed from sorting, and we > can't change the past. Regardless of whether this was a mistake or > not, No it's not already removed, I just tried it (in Python 2.6, which is called "Python" for short) and it still works. It's n

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Paul Rubin
Steven D'Aprano writes: > There's always Python 4000 :) Is that on the boards yet? -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Paul Rubin
Benjamin Peterson writes: > Why would having PyPy as the reference implementation have made this design > decisions turn out better? A fair amount of Python 2's design was influenced by what was convenient or efficient to implement in CPython. There's nothing wrong with that and it's a perfectly

Re: a basic bytecode to machine code compiler

2011-04-02 Thread Paul Rubin
John Nagle writes: > There's no easy way to speed up Python; that's been tried. > It needs either a very, very elaborate JIT system, more complex > than the ones for Java or Self, or some language restrictions. Is it worse than Javascript? Tracemonkey and its descendants produce pretty fast

Re: Python CPU

2011-04-03 Thread Paul Rubin
John Nagle writes: > The Forth chips were cute, and got more done with fewer gates than > almost anything else. But that didn't matter for long. > Willow Garage has a custom Forth chip they use in their Ethernet > cameras, but it's really a FPGA. You can order 144-core Forth chips right now,

Re: integer multiplication

2011-04-03 Thread Paul Rubin
geremy condra writes: >> Does anyone know what algorithms for integer multiplication does Python use? >> I am trying to compare it to those used by Sage as it seems like it takes >> much longer for Python to do large integer multiplication as compared to >> Sage (anyone know off the top of their h

Re: Python CPU

2011-04-04 Thread Paul Rubin
Gregory Ewing writes: > What might help more is having bytecodes that operate on > arrays of unboxed types -- numpy acceleration in hardware. That is an interesting idea as an array or functools module patch. Basically a way to map or fold arbitrary functions over arrays, with a few obvious optim

Re: Python CPU

2011-04-04 Thread Paul Rubin
John Nagle writes: > That sort of thing was popular in the era of the early > Cray machines. Once superscalar CPUs were developed, > the overhead on tight inner loops went down, and several > iterations of a loop could be in the pipeline at one time, Vector processors are back, they just cal

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