Re: advice needed for simple python web app

2005-02-03 Thread Paul Rubin
Dan Perl [EMAIL PROTECTED] writes: This is exactly the kind of summary that I think should be in a WebProgrammingShootOut (see another one of my postings in this thread) but I failed to find such a summary. Thanks, Brian! Anyone can add to the list? If you're just trying to get a conceptual

Re: OT: why are LAMP sites slow?

2005-02-04 Thread Paul Rubin
Kartic [EMAIL PROTECTED] writes: Hmm, I wasn't aware that Apache 2.x gave any significant speedups over 1.3 except under Windows. Am I missing something? Architectural differences. Apache 1.3 spawns a new process for every request and before you know, it brings your resources to their

Re: advice needed for simple python web app

2005-02-04 Thread Paul Rubin
Dan Perl [EMAIL PROTECTED] writes: This matches pretty much what I've decided to do. I'll start with cgi and CGIHTTPServer because I'll learn more from that and then move to a framework, quite likely CherryPy, although by that time I may change my choice. Philip Greenspun's book looks

Re: EDI x12 -- XML

2005-02-04 Thread Paul Rubin
Greg Lindstrom [EMAIL PROTECTED] writes: I am working on automating a system accepting input data in EDI x12 format and would like to convert it to XML. Before I start, I thought I'd ask if anyone has worked on such a beast. I have seen work by Chris Cioffi on parsing EDI records. Is

Re: CGI and HTTP Header Location redirects

2005-02-04 Thread Paul Rubin
Derek Basch [EMAIL PROTECTED] writes: A... I should have been more specific before. The Apache error log doesn't produce an error. You are probably correct that it is most likely an Apache/Unix problem. I thought perhaps someone had maybe run into this before since it seems like such a

Re: how to send an int over a socket

2005-02-04 Thread Paul Rubin
Tom Brown [EMAIL PROTECTED] writes: Ok, I think I've found what I was looking for. The marshal.dumps() function will convert my integer into a string representation of a fixed size. This way, on the other side, I know how many bytes to read to get the size of the string. Think hard about

Re: OT: why are LAMP sites slow?

2005-02-04 Thread Paul Rubin
Maciej Mróz [EMAIL PROTECTED] writes: Mmcache (which is both optimizer and shared memory caching library for php) can do _miracles_. One of my company servers uses Apache 1.3/php/mmcache to serve about 100 GB of dynamic content a day (it could do more but website does not have enough visitors

Re: how to send an int over a socket

2005-02-04 Thread Paul Rubin
Tom Brown [EMAIL PROTECTED] writes: However, in my actual program I will not know the length of testmessage in advance. So how do I convert msglen into a suitable format for the send method? str(123) '123' You might also look at http://cr.yp.to/proto/netstrings.txt which

Re: Alternative to standard C for

2005-02-05 Thread Paul Rubin
[EMAIL PROTECTED] writes: problem. If i do ..in range(1, 1).. (what I really need sometimes), it takes few hundred megs of memory and slows down. Are there other good ways for this simple problem? Generators? use xrange instead of range. --

Re: multi threading in multi processor (computer)

2005-02-12 Thread Paul Rubin
John Lenton [EMAIL PROTECTED] writes: and buying more, cheap computers gives you more processing power than buying less, multi-processor computers. The day is coming when even cheap computers have multiple cpu's. See hyperthreading and the coming multi-core P4's, and the finally announced Cell

Re: Kill GIL

2005-02-13 Thread Paul Rubin
Mike Meyer [EMAIL PROTECTED] writes: Threads are also good for handling blocking I/O. Actually, this is one of the cases I was talking about. I find it saner to convert to non-blocking I/O and use select() for synchronization. That solves the problem, without introducing any of the

Re: Pythonic poker client

2005-02-13 Thread Paul Rubin
[EMAIL PROTECTED] writes: I'm assuming that I need to figure out the port it uses, find the server, analyze the packets for commands, and then build an app that masquerades as the real client. Anyone have any experience with this? If you mean you want to write your own real-money poker

Re: AES crypto in pure Python?

2005-02-14 Thread Paul Rubin
[EMAIL PROTECTED] writes: I'm looking for an implementation of AES (the Advanced Encryption Standard) in pure Python. I'm aware of pycrypto, but that uses C code. I'm hoping to find something that only uses Python...I'm willing to trade speed for portability, since my application is designed

Re: Scan document pages to a compressed PDF

2005-02-14 Thread Paul Rubin
Ed Suominen [EMAIL PROTECTED] writes: What's the best way currently to do CCITT4 compression (e.g., of intermediate TIFF-format images) from Python? PIL doesn't seem to support CCITT4 compression, and the read-only patch [1] that's available won't help in my case. I'd like to incorporate as

Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Pickle and marshal are not safe. They can do harmful things if fed maliciously constructed data. That is a pity, because marshal is fast. I think marshal could be fixed; the only unsafety I'm aware of is that it doesn't always act rationally

Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong [EMAIL PROTECTED] writes: There's another issue with marshal that makes it unsuitable for Pyro, which is that its data format is (for legitimate reasons) not guaranteed to be the same across different Python releases. That means that if the two ends of the Pyro application

Re: parsing IMAP responses?

2005-02-14 Thread Paul Rubin
Grant Edwards [EMAIL PROTECTED] writes: The imaplib module return values are mostly useless as-is: they're just whatever string the server sent (or in some cases a list of strings). You've got to parse them using the IMAP syntax before you can do much with them. Is there a library

Re: array of bits?

2005-02-14 Thread Paul Rubin
MM [EMAIL PROTECTED] writes: What is the best structure/way to create an array of bits (actually true/false flags) of an arbitrary length ranging from about 20 upto about 500. Speed of access more of an issue than compactness. Use a normal list: [False, False, True, False, True, ... ] . --

Re: Kill GIL (was Re: multi threading in multi processor (computer))

2005-02-14 Thread Paul Rubin
[EMAIL PROTECTED] (Aahz) writes: [phr] The day is coming when even cheap computers have multiple cpu's. See hyperthreading and the coming multi-core P4's, and the finally announced Cell processor. Conclusion: the GIL must die. It's not clear to what extent these processors will perform

Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong [EMAIL PROTECTED] writes: What do you do about the security issue if you're using pickle? Do you have to trust the other end to not send you malicious pickles? I do nothing about it. Yes, you have to trust the other end. So you have to use your own -or Pyro's-

Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong [EMAIL PROTECTED] writes: Well, ok, if you trust then other end then I think it's enough to just authenticate all the pickles (say using hmac.py) without needing something as heavyweight as SSL. An interesting idea that hadn't crossed my mind yet. Pyro *does* already have

Re: Inheritance error in python 2.3.4???

2005-02-14 Thread Paul Rubin
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: The problem is that I actually do need them to be private to the outside world... but not to subclasses. I guess what I actually need is something like protected in C++ but I don't think I'm going to get that luxury. The only way to make

Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong [EMAIL PROTECTED] writes: Note you should also put sequence numbers in the messages, to stop the attacker from fooling you by selectively deleting or replaying messages. Thanks for the tip. I'll think about this. Hmm, you also want a random blob in each packet (including

Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong [EMAIL PROTECTED] writes: I know a bit about this stuff, but not nearly enough to come up with a water tight design by myself, so it's much easier and safer to rely on trusted work by others. Yeah, at this point I think it's safest to just use SSL. If I use Pyro for anything

Re: newbie question convert C to python

2005-02-14 Thread Paul Rubin
[EMAIL PROTECTED] writes: How do i handle this piece of code in python: # define vZero 15 # define vOne 20 unsigned int vTable[Zero][One] if(vGroup[vZero][vOne] == 0) { vGroup[vZero][vOne]-- . . } Simplest might be with a dictionary:

low-end persistence strategies?

2005-02-15 Thread Paul Rubin
I've started a few threads before on object persistence in medium to high end server apps. This one is about low end apps, for example, a simple cgi on a personal web site that might get a dozen hits a day. The idea is you just want to keep a few pieces of data around that the cgi can update.

SHA1 broken

2005-02-15 Thread Paul Rubin
FYI. From http://www.schneier.com/blog/archives/2005/02/sha1_broken.html: The research team of Xiaoyun Wang, Yiqun Lisa Yin, and Hongbo Yu (mostly from Shandong University in China) have been quietly circulating a paper announcing their results: * collisions in the the full

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Diez B. Roggisch [EMAIL PROTECTED] writes: Maybe ZODB helps. I think it's way too heavyweight for what I'm envisioning, but I haven't used it yet. I'm less concerned about object persistence (just saving strings is good enough) than finding the simplest possible approach to dealing with

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Diez B. Roggisch [EMAIL PROTECTED] writes: I think it's way too heavyweight for what I'm envisioning, but I haven't used it yet. I'm less concerned about object persistence (just saving strings is good enough) than finding the simplest possible approach to dealing with concurrent update

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Diez B. Roggisch [EMAIL PROTECTED] writes: It has to be installed. And it has C-modules - but I don't see that as a problem. Of course this is my personal opinion - but it's certainly easier installed than to cough up your own transaction isolated persistence layer. I started using it over

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Tom Willis [EMAIL PROTECTED] writes: Sounds like you want pickle or cpickle. No, the issue is how to handle multiple clients trying to update the pickle simultaneously. -- http://mail.python.org/mailman/listinfo/python-list

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Michele Simionato [EMAIL PROTECTED] writes: What about bsddb? On most Unix systems it should be already installed and on Windows it comes with the ActiveState distribution of Python, so it should fullfill your requirements. As I understand it, bsddb doesn't expose the underlying Sleepycat

Re: SHA1 broken

2005-02-16 Thread Paul Rubin
Irmen de Jong [EMAIL PROTECTED] writes: Also, the new findings only apply to hash collisions, not to the invertibility of SHA1 hashes - thus, as Schneier points out, uses of keyed hashes (such as HMAC) are not compromised by this. What about HMAC-MD5? HMAC-MD5 and HMAC-SHA1 should be

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Michele Simionato [EMAIL PROTECTED] writes: The documentation hides this fact (I missed that) but actually python 2.3+ ships with the pybsddb module which has all the functionality you allude too. Check at the test directory for bsddb. Thanks, this is very interesting. It's important

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Michele Simionato [EMAIL PROTECTED] writes: The documentation hides this fact (I missed that) but actually python 2.3+ ships with the pybsddb module which has all the functionality you allude too. Check at the test directory for bsddb. Oh yow, it looks pretty complicated. Do you have any

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Fred Pacquier [EMAIL PROTECTED] writes: KirbyBase sounds like something that could fit the bill. Hmm, this looks kind of nice. However, when used in embedded mode, the overview blurb doesn't say anything about concurrency control. I don't want to use it in client/server mode, for reasons

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Jamey Cribbs [EMAIL PROTECTED] writes: Either of these server scripts would have to be running as a process either on your web server or on another server on your network in order for them to work. I don't know if that would be an issue for you. Yes, that's the whole point. I don't want to

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Jamey Cribbs [EMAIL PROTECTED] writes: The only time there might be trouble is if two clients try to write to the same table (physical file) at the same time. Yes, that's what I'm concerned about. When it writes to a file, KirbyBase opens it in append mode (r+, I think). My guess would be,

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Michele Simionato [EMAIL PROTECTED] writes: This was my impression too :-( The ZODB is way much easier to use so at the end I used just that. Apparently the bsddb stuff is more complicated than needed and the documentation sucks. However, it does satisfy your requirements of being already

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
John Lenton [EMAIL PROTECTED] writes: flock(fp, LOCK_EX) # block until can write ... Of course I'm probably overlooking something, because it really can't be this easy, can it? Yes, maybe so. I'm just way behind the times and didn't realize flock would block until existing

Re: Pausing a program - poll/sleep/threads?

2005-02-16 Thread Paul Rubin
Simon John [EMAIL PROTECTED] writes: So, how would I make a Python program automatically call a function after a preset period of time, without the Python process running in the foreground (effectively single-tasking)? See the signal module and use the alarm signal. --

Re: DBM scalability

2005-10-21 Thread Paul Rubin
George Sakkis [EMAIL PROTECTED] writes: I'm trying to create a dbm database with around 4.5 million entries but the existing dbm modules (dbhash, gdbm) don't seem to cut it. What happens is that the more entries are added, the more time per new entry is required, so the complexity seems to be

Re: how to modify text in html form from python

2005-10-21 Thread Paul Rubin
Philippe C. Martin [EMAIL PROTECTED] writes: * HOW (if there's a better way let me know please) ** As I have not found any better solution yet, I am trying to do the following (on the server there is an html file and a cgi file) If I understand it, you're trying to use a smart card to

Re: Microsoft Hatred FAQ

2005-10-26 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: If you want to sell meals with Whoppers in them, you have to get permission to do so from Burger King corporate. And they will not let you also sell Big Macs in the same store, even if McDonald's had no objection. Why do you keep comparing

Re: Microsoft Hatred FAQ

2005-10-26 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: So, your observations about Burger King are irrelevant to Microsoft. Because the error I'm correcting is the belief that Microsoft's conduct was extremely unusual (unlike anything any reputable company had ever done, essentially). MS's

Re: Microsoft Hatred FAQ

2005-10-27 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: But there is no law against that type of conduct, *unless* you are a monopolist. So your conclusion hinges on the determination that Microsoft had a monopoly, and that hinges on the definition of the market. That's a different can of worms for a

Re: Sorting with only a partial order definition

2005-10-27 Thread Paul Rubin
Lasse Vågsæther Karlsen [EMAIL PROTECTED] writes: I have a list of items and a rule for ordering them. Unfortunately, the rule is not complete so it won't define the correct order for any two items in that list. In other words, if I pick two random items from the list I may or may not

Re: Sorting with only a partial order definition

2005-10-27 Thread Paul Rubin
Lasse Vågsæther Karlsen [EMAIL PROTECTED] writes: In that application we talked about presenting the user with two and two images and he just had to click on the image that came first. The problem with this was to try to present the right images to the user so that he had to minimize the

Re: Microsoft Hatred FAQ

2005-10-27 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: The appeals courts upheld that the trial court did not abuse its discretion. However, both a finding of yes, Microsoft had a monopoly and a finding of no, Microsoft did not have a monopoly would both have been within the trial court's

Re: Microsoft Hatred FAQ

2005-10-27 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: I defy you to find any court that has ruled this practice illegal for a company that does not have a monopoly. Because if they did, I'm going after Doctor's Associates and Kenmore. Of course it's legal for non-monopoly companies. You seem to

Re: Microsoft Hatred FAQ

2005-10-27 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: Of course it's legal for non-monopoly companies. You seem to think Microsoft's illegal monopoly is an irrelevant detail. It is not. What is an illegal monopoly? It's what Microsoft still stands convicted of having.

Re: Microsoft Hatred FAQ

2005-10-27 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: Sorry to be pedantic, but I think it's an important point that no court ever found that Microsoft illegally acquired a monopoly. So to characterize the monopoly itself as illegal is simply erroneous. Who is paying you to tell these ridiculous

Re: Scanning a file

2005-10-28 Thread Paul Rubin
[EMAIL PROTECTED] writes: I want to scan a file byte for byte for occurences of the the four byte pattern 0x0100. I've tried with this: use re.search or string.find. The simplest way is just read the whole file into memory first. If the file is too big, you have to read it in chunks and

Re: Microsoft Hatred FAQ

2005-10-28 Thread Paul Rubin
David Schwartz [EMAIL PROTECTED] writes: Is it your position that Micorosoft's monopoly was illegal when they first acquired it? It's utterly irrelevant whether it was illegal when they acquired it. The law is against acquiring OR MAINTAINING a monopoly by anticompetitive means. That's

Re: How do I sort these?

2005-10-28 Thread Paul Rubin
KraftDiner [EMAIL PROTECTED] writes: In C++ you can specify a comparision method, how can I do this with python... Yes, see the docs. Just pass a comparison func to the sort method. -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file

2005-10-29 Thread Paul Rubin
Paul Watson [EMAIL PROTECTED] writes: How could I identify when Python code does not close files and depends on the runtime to take care of this? I want to know that the code will work well under other Python implementations and future implementations which may not have this provided.

Re: Scanning a file

2005-10-31 Thread Paul Rubin
[EMAIL PROTECTED] (John J. Lee) writes: Closing off this particular one would make it harder to get benefit of non-C implementations of Python, so it has been judged not worth it. I think I agree with that judgement. The right fix is PEP 343. --

Re: Most efficient way of storing 1024*1024 bits

2005-11-02 Thread Paul Rubin
Tor Erik Sønvisen [EMAIL PROTECTED] writes: I need a time and space efficient way of storing up to 6 million bits. Time efficency is more important then space efficency as I'm going to do searches through the bit-set. Umm, what kind of searches do you want to do? For speed you want to use

Re: Most efficient way of storing 1024*1024 bits

2005-11-02 Thread Paul Rubin
Mike Meyer [EMAIL PROTECTED] writes: Six megabytes is pretty much nothing on a modern computer. I'd store the things as a string of 0 and 1, and then use .find (or maybe the in keyword) for doing the searches. This doesn't work very well if you're going to mutate the string, though. You

Re: where to download md5.py?

2005-11-02 Thread Paul Rubin
Bell, Kevin [EMAIL PROTECTED] writes: I've been looking around, but haven't found a place to download the md5.py module. I need it to run the dupinator.py It's part of the standard Python distro. There is a C module that you need along with it. --

Re: Class Variable Access and Assignment

2005-11-03 Thread Paul Rubin
Steve Holden [EMAIL PROTECTED] writes: class A: a = 1 b = A() b.a += 2 print b.a print A.a Which results in 3 1 I don't suppose you'd care to enlighten us on what you'd regard as the superior outcome? class A: a = [] b = A() b.append(3) print b.a

Re: Class Variable Access and Assignment

2005-11-03 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: Then you don't approve of inheritance? That's fine, it is your choice, but as far as I know, all OO languages include inheritance. Some OO languages only implement inheritance for method calls. Class variables don't get inherited. --

Re: OT - Re: Microsoft Hatred FAQ

2005-11-03 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: There is a difference between what is *illegal* and what constitutes a *crime*. Why thank you, you've really made my day. That's the funniest thing I've heard in months. Please, do tell, which brand of corn flakes was it that you got your law

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Stefan Arentz [EMAIL PROTECTED] writes: Would it be too much to ask that in a line like. x = x + 1. both x's would resolve to the same namespace? ... Consider changing the semantics of what you are proposing and think about all those Python projects that will break because they depend

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Stefan Arentz [EMAIL PROTECTED] writes: Are you seriously saying there's lots of Python projects that would break if this particular weirdness were fixed? I have no numbers of course. But, why is this a weirdness? Do you seriously think the number is larger than zero? Do you think that's

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Mike Meyer [EMAIL PROTECTED] writes: I've already argued that the kludges suggested to solve this problem create worse problems than this. The most obvious solution is to permit (or even require) the programmer to list the instance variables as part of the class definition. Anything not in the

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: There are good usage cases for the current inheritance behaviour. Can you name one? Any code that relies on it seems extremely dangerous to me. -- http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: Follow the logical implications of this proposed behaviour. class Game: current_level = 1 # by default, games start at level one That's bogus. Initialize the current level in the __init__ method where it belongs. --

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: A basic usage case: class Paper: size = A4 def __init__(self, contents): # it makes no sense to have class contents, # so contents go straight into the instance self.contents = contents So add: self.size

Re: python gc performance in large apps

2005-11-04 Thread Paul Rubin
Robby Dermody [EMAIL PROTECTED] writes: t = 120 seconds (1st run after being fully initialized): list alloced: 2394620, freed: 17565, max in use: 2377056 dict alloced: 2447968, freed: 67999, max in use: 2379969 This looks like a garden variety memory leak. I think the next thing

Re: C extension + libm oddity [fmod(2.0, 2.0) == nan ?!]

2005-11-04 Thread Paul Rubin
Lonnie Princehouse [EMAIL PROTECTED] writes: Now, fmod(2.0, 2.0) should be 0.0. The problem? ans is getting assigned nan! I have stepped through it in the debugger now dozens of times. Either fmod is putting the wrong return value on the stack, or the stack is getting corrupted by

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
[EMAIL PROTECTED] (Bengt Richter) writes: Hm, the fix? Why wouldn't e.g. treating augassign as shorthand for a source transformation (i.e., asstgt op= expr becomes by simple text substitution asstgt = asstgt op expr) be as good a fix? Then we could discuss what Consider a[f()] += 3. You

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
-- http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: It also allows you to do something like this: class ExpertGame(Game): current_level = 100 and then use ExpertGame anywhere you would have used Game with no problems. Well, let's say you set, hmm, current_score = 100 instead of current_level.

Re: Class Variable Access and Assignment

2005-11-04 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: Next you get some performance gain by using gmpy to handle the long int arithmetic, Then whatever happens next will be my own stupid fault for prematurely optimising code. Huh? There's nothing premature about using gmpy if you need better long

Re: Class Variable Access and Assignment

2005-11-05 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: But do you want x += y to work for immutable objects as well? Then __iadd__ cannot be a statement, because x can't be modified in place. It never occurred to me that immutable objects could implement __iadd__. If they can, I'm puzzled as to why.

Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Paul Rubin
Mike Meyer [EMAIL PROTECTED] writes: The thing is, the library documentation that Xah Lee is complaining about is a *reference document*. It says so right in the title: Python Library Reference. As such, it makes lousy tutorial documentation. I'm not sure which particular library Xah Lee was

Re: Class Variable Access and Assignment

2005-11-05 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: It never occurred to me that immutable objects could implement __iadd__. If they can, I'm puzzled as to why. I'm surprised that it never occurred to you that people might want to do something like x = 1; x += 1 in Python, But I wouldn't expect

Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Paul Rubin
Mike Meyer [EMAIL PROTECTED] writes: To my knowledge the PSF isn't doing anything about including the documentation with their distribution, so they shouldn't care about the licenses. Wanting to bundle a good tutorial for everything in the library might be on the list, but the licenses on

Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Paul Rubin
Mike Meyer [EMAIL PROTECTED] writes: It's only -because- of those licenses that there's any reason not to bundle. Actually, there are other reasons, just as there are reasons besides licensing for not simply including third party libraries into the standard library. I'm not talking about

Re: Learning multiple languages (question for general discussion)

2005-11-06 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: I can't imagine NOT getting enthusiastic and stimulated by reading Van Roy and Hariri's book -- it IS quite as good and readable as SICP. It's been on my want-to-read list for a long time. I have the downloaded draft edition (from before the print

Re: Learning multiple languages (question for general discussion)

2005-11-06 Thread Paul Rubin
Diez B. Roggisch [EMAIL PROTECTED] writes: It's a great book - I cetainly owe it the better part of my thesis about multi level specification for functional languages. If you want to understand type-systems, its a great comprehensive read. So do I really want to understand type systems? I

Re: PyFLTK - an underrated gem for GUI projects

2005-11-06 Thread Paul Rubin
aum [EMAIL PROTECTED] writes: To me, wxPython is like a 12-cylinder Hummer, ... Whereas PyFLTK feels more like an average suburban 4-door sedan Interesting. What would Tkinter be at that car dealership? What about PyGTK? -- http://mail.python.org/mailman/listinfo/python-list

Re: gmpy 1.01 rc near... anybody wanna test

2005-11-07 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: gmpy users able to download and build from sourceforge's cvs are encouraged to test the current CVS version. Oh cool, I wondered whether any gmpy maintenance was still going on. I'll see if I can give the new version a try. --

Re: Using python for writing models: How to run models in restricted python mode?

2005-11-07 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: I suspect your best bet might be to write a mini-language using Python, and get your users to use that. You will take a small performance hit, but security will be very much improved. What do others think? That is the only approach that makes any

Re: Using python for writing models: How to run models in restricted python mode?

2005-11-07 Thread Paul Rubin
vinjvinj [EMAIL PROTECTED] writes: No. I was hoping to leverage the work done for restricted pythonscript by zope at: http://www.zope.org/Control_Panel/Products/PythonScripts/Help/PythonScript.py How does Pythonscript deal with xxx = 'x' * 10 as a memory DOS attack? --

Re: How to convert a number to hex number?

2005-11-08 Thread Paul Rubin
dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex() output can vary. Try hex(33**33). -- http://mail.python.org/mailman/listinfo/python-list

Re: which feature of python do you like most?

2005-11-08 Thread Paul Rubin
Alex Stapleton [EMAIL PROTECTED] writes: People like Python as a whole usually. It's not like C++ or PHP or anything where it's generally usable and occasionally pisses you off. As somebody once said about Lisp, you can feel the bits between your toes. --

Re: How to convert a number to hex number?

2005-11-08 Thread Paul Rubin
Steve Holden [EMAIL PROTECTED] writes: Try hex(33**33). You're usually smarter than this, or am I missing some joke? hex(33*33) '0x441' You used only one * (multiplication), I used two *'s (exponentiation). hex(33**33) '0x5857366DCE0162CB5DDCD1BF0FC7C03A6438304421L' --

Re: random number generator thread safety

2005-11-08 Thread Paul Rubin
Raymond Hettinger [EMAIL PROTECTED] writes: Thread-safety has nothing to do with preserving entropy or guarding against attack. All of the entropy in an MT sequence is contained in the seed (upto 624 bytes) and that entropy is preserved through all subsequent calls. I think the concern is

Iterator addition

2005-11-09 Thread Paul Rubin
Is there a good reason to not define iter1+iter2 to be the same as itertools.chain(iter1, iter2)? Examples: # all lines in a collection of files, like perl all_lines = file1 + file2 + file3 candidate_primes = (2,) + (1+2*i for i in itertools.count(1)) # candidate_primes is

Re: Iterator addition

2005-11-09 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: Is there a good reason to not define iter1+iter2 to be the same as If you mean for *ALL* built-in types, such as generators, lists, files, dicts, etc, etc -- I'm not so sure. Yes, that's what I mean. Right now, if I mistakenly try to add a list to

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread Paul Rubin
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: How does a useless generator expression make it more generic? xrange is only picked as an example. I may be newbie on python but not that dumb if all I want is a list of integer(sorted) that meets certain criteria. takewhile(p, (x for x in

Re: exceptions, internals (introspection?)

2005-11-10 Thread Paul Rubin
ej ej at wellkeeper com writes: I have often wondered how to get at other internals, such as the name of the current function, file, line number I am in? The arguments to the current function, etc. It's messy. Look at sys.exc_info() and go from there. --

Re: exceptions, internals (introspection?)

2005-11-10 Thread Paul Rubin
ej ej at wellkeeper com writes: for key in dir(traceback_): print traceback_.%s = % key, eval(traceback_.%s % key) Don't use eval for this. Use getattr(traceback_, key). traceback_.tb_frame = frame object at 0x8177b3c traceback_.tb_lasti = 18 traceback_.tb_lineno = 6

Re: different binding behavior

2005-11-10 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: Imagine that ints could be changed in place. Then you could do this: x = 0 x += 1 No nothing like that. Nothing stops you from having multiple int objects with the same value. Lists, for example, are mutable, but x = [0,1] x += [2,3] doesn't

Re: LARGE numbers

2005-11-11 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: As the author of gmpy, I'd like to point out that the speed difference isn't all that large, if all you're doing is ordinary arithmetic -- a few times at most (it can be better if you need some of GMP's functionality which gmpy exposes, such as

Re: LARGE numbers

2005-11-11 Thread Paul Rubin
[EMAIL PROTECTED] writes: Python's native longs use Karatsuba multiplication with is O(n^1.585). My early version of DecInt (BigDecimal) uses 4-way Toom-Cook ... Wow, cool! Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: list of lambda

2005-11-11 Thread Paul Rubin
jena [EMAIL PROTECTED] writes: l=[lambda:x.upper() for x in ['a','b','c']] then l[0]() returns 'C', i think, it should be 'A' Yeah, this is Python late binding, a standard thing to get confused over. You want: l = [lambda x=x: x.upper() for x in ['a', 'b', 'c']] --

Re: Internal Variables

2005-11-11 Thread Paul Rubin
James Colannino [EMAIL PROTECTED] writes: Basically, I just want to know how from within a script I can get information about the python interpreter that I'm running. Thanks in advance. import sys print sys.version -- http://mail.python.org/mailman/listinfo/python-list

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