Re: If Scheme is so good why MIT drops it?

2009-07-25 Thread Xah Lee
PHP is popular because it is geared for the server-side web scripting lang, and simpler and easy to use, than popular free alternatives at the time (such as Perl and Java's JSP). Python became popular primarily because its ease-to-read syntax. Btween the two, PHP is much easier to use, and much a

Re: len() should always return something

2009-07-25 Thread Steven D'Aprano
On Fri, 24 Jul 2009 19:50:54 -0700, Dr. Phillip M. Feldman wrote: > Here's a simple-minded example: > > def dumbfunc(xs): >for x in xs: > print x > > This function works fine if xs is a list of floats, but not if it is > single float. It can be made to work as follows: > > def dumbfu

Re: If Scheme is so good why MIT drops it?

2009-07-25 Thread Tayssir John Gabbour
On Jul 24, 11:58 pm, ACL wrote: > I actually think that the thing holding lisp back is 'bus factor'. > > Lets assume I have a java project and a lisp project: > > Java project: > I have maybe 10 or 12 people on my team working on various subsystems > of my project. There are probably one or two 't

Re: len() should always return something

2009-07-25 Thread Hendrik van Rooyen
On Friday 24 July 2009 16:45:40 Mark Dickinson wrote: > On Jul 24, 3:11 pm, "Rhodri James" > > wrote: > > Which doesn't make your point less valid.  In fact I'd go so > > far as to argue that what len() gives you is the number of > > items in a container, so len(7) should return 0. > > Nah. 7 c

Re: len() should always return something

2009-07-25 Thread Carl Banks
On Jul 23, 11:35 pm, "Dr. Phillip M. Feldman" wrote: > Some aspects of the Python design are remarkably clever, while others leave > me perplexed. Here's an example of the latter: Why does len() give an error > when applied to an int or float? len() should always return something; in > particular,

Re: len() should always return something

2009-07-25 Thread Diez B. Roggisch
Dr. Phillip M. Feldman schrieb: Here's a simple-minded example: def dumbfunc(xs): for x in xs: print x This function works fine if xs is a list of floats, but not if it is single float. It can be made to work as follows: def dumbfunc(xs): if isinstance(xs,(int,float,complex)): xs=

Re: len() should always return something

2009-07-25 Thread Piet van Oostrum
> Steven D'Aprano (S) wrote: >S> Chris, I'm curious why you think that these Zen are relevant to the OP's >S> complaint. >S> Re explicit vs implicit, len(42) is just as explicit as len([42, 23]). >S> Arguably (I wouldn't argue this, but some people might) ints aren't >S> "special enough"

Re: How do I generate dia diagrams from python source code?

2009-07-25 Thread Gabriel Genellina
En Fri, 24 Jul 2009 17:52:47 -0300, Qauzzix escribió: Since I have been using dia to make my UML diagrams. I also found an util named dia2code that generates python code from dia diagram. Now that I have that option I really want to find a way to generate dia diagram from existing code and/or m

Re: Help understanding the decisions *behind* python?

2009-07-25 Thread Hendrik van Rooyen
On Friday 24 July 2009 17:07:30 Inky 788 wrote: > On Jul 23, 3:42 am, Hendrik van Rooyen > > wrote: 8< > > Steven showed why you cannot have a mutable thing > > as a key in a dict. > > > > if you think it is contrived, then please consider how you would > > keep track of sa

Re: len() should always return something

2009-07-25 Thread Hendrik van Rooyen
On Friday 24 July 2009 21:04:55 Roy Smith wrote: > Compressing strings to a single bit is easy. It's the uncompressing that's > tricky. Not really - all you have to do is to apply the EXACT same sequence of operations that compressed it, in reverse. The unfortunate part is that this informatio

Re: len() should always return something

2009-07-25 Thread Hendrik van Rooyen
On Friday 24 July 2009 22:09:15 Marcus Wanner wrote: > First one to correctly decompress the value 0 into an ASCII character > wins the title of the world's most capable hacker :p that is easy. the xor of 0 and 1 is 1, which is ASCII soh, if I remember right. soh is start of header. Burroughs

Re: strange python scripting error

2009-07-25 Thread Mark Tarver
On 24 July, 15:45, nn wrote: > On Jul 23, 7:03 pm, Dave Angel wrote: > > > > > > > Mark Tarver wrote: > > > I have a very strange error.  I have two test python files test.py and > > > python.py which contain the following code > > > > #!/usr/bin/python > > > print "Content-type: text/html" > > >

Re: strange python scripting error

2009-07-25 Thread Mark Tarver
On 25 July, 10:30, Mark Tarver wrote: > On 24 July, 15:45, nn wrote: > > > > > > > On Jul 23, 7:03 pm, Dave Angel wrote: > > > > Mark Tarver wrote: > > > > I have a very strange error.  I have two test python files test.py and > > > > python.py which contain the following code > > > > > #!/usr/b

Re: If Scheme is so good why MIT drops it?

2009-07-25 Thread Jon Harrop
ACL wrote: > Lisp project: > I don't need as many people... Is there any actual evidence of that? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listinfo/python-list

Re: non-owning references?

2009-07-25 Thread Piet van Oostrum
> "Rhodri James" (RJ) wrote: >RJ> The point was, and remains, that this newsgroup gets regular traffic >RJ> from people who expect Python's variables to act like C's variables, >RJ> demonstrating that describing them as "quite compatible" is somewhat >RJ> misleading. So let' study these post

Re: strange python scripting error

2009-07-25 Thread Dave Angel
Mark Tarver wrote: Use dos2unix for conversion of the longer file and try again: http://linux.about.com/od/commands/l/blcmdl1_dos2uni.htm-Hide quoted text - - Show quoted text - That sounds the ticket - but is there anything that runs under Windows to do the trick? M

Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread Piet van Oostrum
> davidj411 (d) wrote: >d> could i see an example of this maybe? queue is a shared Queue instance. The parent puts the work in the queue with queue.put(work_object). After all work has been put in the queue it puts a sentinel queue.put(None) Each child thread (consumer) has a loop

Re: cgi.fieldstorage()

2009-07-25 Thread gert
On Jul 25, 2:33 am, "Diez B. Roggisch" wrote: > gert schrieb: > > > On Jul 24, 7:32 pm, "Diez B. Roggisch" wrote: > >> gert schrieb: > > >>> this is a non standard way to store multi part post data on disk > >>> def application(environ, response): > >>>     with open('/usr/httpd/var/wsgiTemp','w'

Re: non-owning references?

2009-07-25 Thread Carl Banks
On Jul 24, 8:14 am, Ben Finney wrote: > Hrvoje Niksic writes: > > The term "variable" is used in the Python language reference and > > elsewhere > > Yes. It should also be abundantly clear from the constant stream of > confused newbies on this point that its usage of that term is different > to w

Re: If Scheme is so good why MIT drops it?

2009-07-25 Thread Carl Banks
On Jul 24, 11:54 pm, Xah Lee wrote: [snip] > References: > > • Language, Purity, Cult, and Deception >  http://xahlee.org/UnixResource_dir/writ/lang_purity_cult_deception.html > > • What Languages to Hate >  http://xahlee.org/UnixResource_dir/writ/language_to_hate.html > > • Lambda in Python 3000

Re: len() should always return something

2009-07-25 Thread Marcus Wanner
On 7/25/2009 5:34 AM, Hendrik van Rooyen wrote: On Friday 24 July 2009 22:09:15 Marcus Wanner wrote: First one to correctly decompress the value 0 into an ASCII character wins the title of the world's most capable hacker :p that is easy. the xor of 0 and 1 is 1, which is ASCII soh, if I reme

Re: Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-25 Thread Piet van Oostrum
> ryles (r) wrote: >r> According to http://www.python.org/doc/essays/packages.html: >r> "The import statement first tests whether the item is defined in the >r> package; if not, it assumes it is a module and attempts to load it." >r> However, I've noticed that once a module is imported using

Re: len() should always return something

2009-07-25 Thread Steven D'Aprano
On Sat, 25 Jul 2009 10:03:58 +0200, Piet van Oostrum wrote: >>S> And there's nothing ambiguous about len(42). > > len(42) should be 7.5 million. And "I don't understand your reasoning".upper() should be "Millennium Hand and Shrimp!". Every function would be ambiguous if we treat it as returnin

Re: non-owning references?

2009-07-25 Thread Steven D'Aprano
On Sat, 25 Jul 2009 04:45:48 -0700, Carl Banks wrote: > On Jul 24, 8:14 am, Ben Finney wrote: >> Hrvoje Niksic writes: >> > The term "variable" is used in the Python language reference and >> > elsewhere >> >> Yes. It should also be abundantly clear from the constant stream of >> confused newbie

Re: len() should always return something

2009-07-25 Thread Piet van Oostrum
> Steven D'Aprano (SD) wrote: >SD> Ambiguity essentially boils down to being unable to reasonably predict >SD> the expectation of the coder. I say "reasonably", because if you allow >SD> unreasonable situations, everything is "ambiguous": That's for me the reason that len(42) is ambiguous.

Re: comments? storing a function in an object

2009-07-25 Thread Aahz
In article <20efdb6a-c1a5-47dc-8546-7c4ae548e...@g1g2000pra.googlegroups.com>, Carl Banks wrote: >On Jul 22, 8:38=A0pm, a...@pythoncraft.com (Aahz) wrote: >> In article .com>, >> Carl Banks =A0 wrote: >>> >>>You have to be REALLY REALLY careful not to pass any user-supplied >>>data to it if this

Re: python fast HTML data extraction library

2009-07-25 Thread Aahz
In article <37da38d2-09a8-4fd2-94b4-5feae9675...@k1g2000yqf.googlegroups.com>, Filip wrote: > >I tried to fix that with BeautifulSoup + regexp filtering of some >particular cases I encountered. That was slow and after running my >data scraper for some time a lot of new problems (exceptions from >

Re: missing 'xor' Boolean operator

2009-07-25 Thread Albert van der Horst
In article , Jean-Michel Pichavant wrote: >Christian Heimes wrote: >> Chris Rebert wrote: >> >>> Using the xor bitwise operator is also an option: >>> bool(x) ^ bool(y) >>> >> >> I prefer something like: >> >> bool(a) + bool(b) == 1 >> >> It works even for multiple tests (super xor): >> >>

Re: len() should always return something

2009-07-25 Thread Hendrik van Rooyen
On Saturday 25 July 2009 14:59:43 Steven D'Aprano wrote: > On Sat, 25 Jul 2009 10:03:58 +0200, Piet van Oostrum wrote: > >>S> And there's nothing ambiguous about len(42). > > > > len(42) should be 7.5 million. > > And "I don't understand your reasoning".upper() should be "Millennium > Hand and Shri

Re: strange error when trying to log something

2009-07-25 Thread Aahz
In article , Peter Otten <__pete...@web.de> wrote: > >I have a hunch that you are triggering a reload() somewhere. Example: > >Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18) >[GCC 4.3.3] on linux2 >Type "help", "copyright", "credits" or "license" for more information. import weakref >>

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-25 Thread Albert van der Horst
In article , Jack Diederich wrote: >On Mon, Jul 20, 2009 at 10:00 AM, Steven >D'Aprano wrote: >> On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: >> >>> Terry Reedy =A0 wrote: Sion Arrowsmith wrote: > Jack Diederich =A0 wrote: >> It isn't an OrderedDict thing, it is a compar

Re: missing 'xor' Boolean operator

2009-07-25 Thread Terry Reedy
Albert van der Horst wrote: Remains whether we need an xor that only works and requires that both operands are booleans. That one we have already! It is called != . (a!=b)!=c and a!=(b!=c) are the same for booleans, so can indeed be expressed a!=b!=c (associativy of xor) Not in Python >>>

Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread scriptlear...@gmail.com
First of all, let me say thank you to all of you. I have asked many questions (some of them are dump questions), and you have kindly helped me. I am not going to reply every message to say thank-you since that would be annoying for such group with such high daily traffics. Thank you very much.

Form/Template Fill-in the blanks

2009-07-25 Thread allan
I'm attempting to create a generic python script that will take an EDI document specification and a database of transactions and be able to generate a raw EDI file (ansi X12). I'm looking for ideas on how best to use the strengths of Python to implement this. I've initially tackled the EDI 812 spe

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-25 Thread Piet van Oostrum
> Albert van der Horst (AvdH) wrote: >AvdH> With regard to < and > you are right. >AvdH> But I think there is a sensible == w.r.t. dict's. >AvdH> It is to mean that for each key dict1(key) == dict2(key) >AvdH> (implying that their key set must be the same) >AvdH> [I could have used that fo

Distinguishing active generators from exhausted ones

2009-07-25 Thread Michal Kwiatkowski
Hi, Is there a way to tell if a generator has been exhausted using pure Python code? I've looked at CPython sources and it seems that something like "active"/"exhausted" attribute on genobject is missing from the API. For the time being I am using a simple C extension to look at f_stacktop pointer

Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread MRAB
scriptlear...@gmail.com wrote: First of all, let me say thank you to all of you. I have asked many questions (some of them are dump questions), and you have kindly helped me. I am not going to reply every message to say thank-you since that would be annoying for such group with such high daily

RSA cryptography between Python and Java

2009-07-25 Thread Rob Knop
I've created an RSA key in Java. I have exported the public key by making it into a X509EncodedKeySpec and spitting out the result of getEncoded(). I want to use this public key to encode something in python that I will send to Java, and then decode in Java with the corresponding private key. A

Re: RSA cryptography between Python and Java

2009-07-25 Thread Paul Rubin
Rob Knop writes: > Are there any python libraries that will take a public key in this > format and do RSA encoding on it? Try www.trevp.com/tlslite -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-25 Thread ryles
On Jul 25, 8:57 am, Piet van Oostrum wrote: > > ryles (r) wrote: > >r> According tohttp://www.python.org/doc/essays/packages.html: > >r> "The import statement first tests whether the item is defined in the > >r> package; if not, it assumes it is a module and attempts to load it." > >r> Howeve

Re: len() should always return something

2009-07-25 Thread Rhodri James
On Sat, 25 Jul 2009 03:50:54 +0100, Dr. Phillip M. Feldman wrote: Here's a simple-minded example: def dumbfunc(xs): for x in xs: print x This function works fine if xs is a list of floats, but not if it is single float. It can be made to work as follows: def dumbfunc(xs):

Removing newlines from string on windows (without replacing)

2009-07-25 Thread Tom
This is my first post to this mailing list, so hi :) I have an annoying problem. While I mainly use Linux when I distribute this program to friends and on the internet, it'll get used on Windows. So, I tested my python program on my Windows Vista dual boot, running the same version of python (2.6)

Re: Distinguishing active generators from exhausted ones

2009-07-25 Thread Jason Tackaberry
On Sat, 2009-07-25 at 11:30 -0700, Michal Kwiatkowski wrote: > Is there a way to tell if a generator has been exhausted using pure > Python code? I've looked at CPython sources and it seems that Upon a cursory look, after a generator 'gen' is exhausted (meaning gen.next() has raised StopIteration)

Re: Removing newlines from string on windows (without replacing)

2009-07-25 Thread Rhodri James
On Sat, 25 Jul 2009 20:27:37 +0100, Tom wrote: This is my first post to this mailing list, so hi :) I have an annoying problem. While I mainly use Linux when I distribute this program to friends and on the internet, it'll get used on Windows. So, I tested my python program on my Windows Vista

Re: RSA cryptography between Python and Java

2009-07-25 Thread Rob Knop
Paul Rubin writes: > www.trevp.com/tlslite Thanks, but that looks like a library for setting up a secure connection between two ends. What I need is the ability to encrypt with a public key in Python, where that public key was generated in Java as described, and wh

Re: RSA cryptography between Python and Java

2009-07-25 Thread Paul Rubin
Rob Knop writes: > > www.trevp.com/tlslite > > Thanks, but that looks like a library for setting up a secure connection > between two ends. What I need is the ability to encrypt with a public > key in Python, where that public key was generated in Java as described, > and where the cipertext can

Re: Distinguishing active generators from exhausted ones

2009-07-25 Thread Michal Kwiatkowski
On Jul 25, 10:00 pm, Jason Tackaberry wrote: > On Sat, 2009-07-25 at 11:30 -0700, Michal Kwiatkowski wrote: > > Is there a way to tell if a generator has been exhausted using pure > > Python code? I've looked at CPython sources and it seems that > > Upon a cursory look, after a generator 'gen' is

Re: available formats and params for Image.save()

2009-07-25 Thread News123
Thanks a lot Gabriel, Your answer is perfect. I was only looking in part II of the PIL manual and overlooked the Appendix :-(. I also apreciate Image.ID , Image.SAVE , Image.OPEN I saw them when typing dir Image but I never had the idea of calling Image.init() first bye N Gabriel Genellin

Re: len() should always return something

2009-07-25 Thread Robert Kern
On 2009-07-24 21:50, Dr. Phillip M. Feldman wrote: Here's a simple-minded example: def dumbfunc(xs): for x in xs: print x This function works fine if xs is a list of floats, but not if it is single float. It can be made to work as follows: def dumbfunc(xs): if isinstance(xs,(in

Re: len() should always return something

2009-07-25 Thread Robert Kern
On 2009-07-25 02:55, Diez B. Roggisch wrote: Dr. Phillip M. Feldman schrieb: Here's a simple-minded example: def dumbfunc(xs): for x in xs: print x This function works fine if xs is a list of floats, but not if it is single float. It can be made to work as follows: def dumbfunc(xs): if isinst

Failed Regression Test: What socket.gethostname() is supposed to return?

2009-07-25 Thread Lie Ryan
In my laptop, socket.gethostname() returned my username, and causing one of python's "make test" regression test to error (test_socket): == ERROR: testSockName (test.test_socket.GeneralModuleTests)

Re: len() should always return something

2009-07-25 Thread Marcus Wanner
On 7/25/2009 10:08 AM, Piet van Oostrum wrote: Steven D'Aprano (SD) wrote: SD> Ambiguity essentially boils down to being unable to reasonably predict SD> the expectation of the coder. I say "reasonably", because if you allow SD> unreasonable situations, everything is "ambiguous": That's fo

Re: Distinguishing active generators from exhausted ones

2009-07-25 Thread Ben Finney
Michal Kwiatkowski writes: > I may be missing something obvious here. Is there a better way to tell > if a given generator object is still active or not? foo = the_generator_object try: do_interesting_thing_that_needs(foo.next()) except StopIteration: generator_is_exh

Re: len() should always return something

2009-07-25 Thread Erik Max Francis
Steven D'Aprano wrote: But it's not "practically every function". It's hardly any function at all -- in my code, I don't think I've ever wanted this behavior. I would consider it an error for function(42) and function([42]) to behave the same way. One is a scalar, and the other is a vector -- t

Re: len() should always return something

2009-07-25 Thread Chris Rebert
On Sat, Jul 25, 2009 at 4:21 PM, Erik Max Francis wrote: > Steven D'Aprano wrote: >> >> But it's not "practically every function". It's hardly any function at all >> -- in my code, I don't think I've ever wanted this behavior. I would >> consider it an error for function(42) and function([42]) to b

Re: strange python scripting error

2009-07-25 Thread Dave Angel
Dennis Lee Bieber wrote: On Sat, 25 Jul 2009 07:18:58 -0400, Dave Angel declaimed the following in gmane.comp.python.general: Another thing I'd point out is that some ftp programs will do this conversion as the file is being sent between a local DOS machine and a Unix machine on the inte

Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread scriptlear...@gmail.com
I decided to go with one big log file, which will be shared by all threads (child and parent). A log message Queue is used to store all log entries, and a customized logger thread will get log entries from the Queue. #from the logger thread# def run(self): while self.flag == 1: #if th

Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread MRAB
scriptlear...@gmail.com wrote: I decided to go with one big log file, which will be shared by all threads (child and parent). A log message Queue is used to store all log entries, and a customized logger thread will get log entries from the Queue. #from the logger thread# def run(self):

Re: len() should always return something

2009-07-25 Thread Erik Max Francis
Chris Rebert wrote: On Sat, Jul 25, 2009 at 4:21 PM, Erik Max Francis wrote: Steven D'Aprano wrote: But it's not "practically every function". It's hardly any function at all -- in my code, I don't think I've ever wanted this behavior. I would consider it an error for function(42) and function(

Re: len() should always return something

2009-07-25 Thread Chris Rebert
On Sat, Jul 25, 2009 at 6:47 PM, Erik Max Francis wrote: > Chris Rebert wrote: >> >> On Sat, Jul 25, 2009 at 4:21 PM, Erik Max Francis wrote: >>> >>> Steven D'Aprano wrote: But it's not "practically every function". It's hardly any function at all -- in my code, I don't think I'

Re: uniicode and executing a process with subprocess.call, or os.system

2009-07-25 Thread Martin v. Löwis
> I am very confused about unicode. Can someone point me in the right > direction? Try Python 3.1. This should accept Unicode strings directly for sp.call, so you wouldn't need to encode first. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: If Scheme is so good why MIT drops it?

2009-07-25 Thread Raffael Cavallaro
On 2009-07-25 00:55:26 -0400, Carl Banks said: But please don't put it on the same level as PHP. Their situations have almost nothing in common. Their situations have much in common; Python attracted programmers away from (for example) C++, becuse python is easier to master; Then php came

multiprocessing and __main__

2009-07-25 Thread is un
Hi, Trying the multiprocessing module for the first time, I spent quite a bit on making this code run: from multiprocessing import Process import time def my_process(): i = 0 while 1: print i i += 1 time.sleep(0.5) p = Process(target=my_process, args=()) p.start

Re: MySQLdb for Python 3.1 getting close?

2009-07-25 Thread John Nagle
(This is actually a repost; outgoing netnews server was down for a while.) John Nagle wrote: Is MySQLdb available for Python 3.1 yet? http://sourceforge.net/projects/mysql-python/ says the last supported Python version is 2.5. Any progress in sight? John Nagle -- http:

Re: multiprocessing and __main__

2009-07-25 Thread is un
Me again, fix a type in my question: So my question is what actually happens when I call p.start()? Is the *entire* file reloaded under a different module name? > > Thanks > iu2 -- http://mail.python.org/mailman/listinfo/python-list

Re: non-owning references?

2009-07-25 Thread John Nagle
Peter Otten wrote: Utpal Sarkar wrote: Is there a way I can tell a variable that the object it is pointing too is not owned by it, in the sense that if it is the only reference to the object it can be garbage collected? http://docs.python.org/library/weakref.html Yes. Weak references ca

Re: code debugging

2009-07-25 Thread Chris Rebert
On Sat, Jul 25, 2009 at 11:23 PM, golu wrote: > here is a code which crawls links sent to it. theres some problem with > the retrieve_url function ,plz help me out in debugging the fuction > retrive_url. This function retrives pages and saves them in file Please specify exactly what the problem is

code debugging

2009-07-25 Thread golu
here is a code which crawls links sent to it. theres some problem with the retrieve_url function ,plz help me out in debugging the fuction retrive_url. This function retrives pages and saves them in file #TODO:Visited dict grows in size it needs to be handled smartly #Moreover server program needs

Re: code debugging

2009-07-25 Thread golu
On Jul 26, 11:28 am, Chris Rebert wrote: > On Sat, Jul 25, 2009 at 11:23 PM, golu wrote: > > here is a code which crawls links sent to it. theres some problem with > > the retrieve_url function ,plz help me out in debugging the fuction > > retrive_url. This function retrives pages and saves them i