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

2009-07-16 Thread Jack Diederich
On Thu, Jul 16, 2009 at 2:21 AM, Mark Summerfield wrote: > Hi, > > I'm just wondering why <, <=, >=, and > are not supported by > collections.OrderedDict: > >    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) >    >>> d2 = d1.copy() >    >>> d2["z"] = 4 >    >>> d1 == d2 >    False >  

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

2009-07-16 Thread Mark
On 16 July, 08:12, Jack Diederich wrote: > On Thu, Jul 16, 2009 at 2:21 AM, Mark Summerfield wrote: > > Hi, > > > I'm just wondering why <, <=, >=, and > are not supported by > > collections.OrderedDict: > > >    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) > >    >>> d2 = d1.copy()

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread John Nagle
akhil1988 wrote: Sorry, it is sgmllib.py and not sgmmlib.py Oh, that bug again. See http://bugs.python.org/issue1651995 It's a bug in SGMLParser. When Python 2.5 restricted ASCII to 0..127, SGMLParser needed to be modified, but wasn't. I reported that bug in February 2007. It w

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

2009-07-16 Thread Chris Rebert
On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield wrote: > Hi, > > I'm just wondering why <, <=, >=, and > are not supported by > collections.OrderedDict: > >    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) >    >>> d2 = d1.copy() >    >>> d2["z"] = 4 >    >>> d1 == d2 >    False >

Re: missing 'xor' Boolean operator

2009-07-16 Thread Hendrik van Rooyen
"Hrvoje Niksic" wrote: > Note that in Python A or B is in fact not equivalent to not(not A and > not B). De Morgan would turn in his grave. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

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

2009-07-16 Thread Steven D'Aprano
On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: > On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield > wrote: >> Hi, >> >> I'm just wondering why <, <=, >=, and > are not supported by >> collections.OrderedDict: >> >>    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) d2 = >>  

Re: allowing output of code that is unittested?

2009-07-16 Thread Ulrich Eckhardt
per wrote: > i am using the standard unittest module to unit test my code. my code > contains several print statements which i noticed are repressed when i > call my unit tests using: > > if __name__ == '__main__': > suite = unittest.TestLoader().loadTestsFromTestCase(TestMyCode) > unittes

Re: missing 'xor' Boolean operator

2009-07-16 Thread Steven D'Aprano
On Thu, 16 Jul 2009 09:43:53 +0200, Hendrik van Rooyen wrote: > "Hrvoje Niksic" wrote: > > >> Note that in Python A or B is in fact not equivalent to not(not A and >> not B). > > De Morgan would turn in his grave. No he wouldn't. Python isn't Boolean algebra, and there is no requirement to l

EuroPython 2009: Making 50 Mio. EUR per year using Python

2009-07-16 Thread eGenix Team: M.-A. Lemburg
Now available as video... http://www.egenix.com/company/news/EuroPython-2009-Lightning-Talk.html Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 16 2009) >>> Python/Zope Consulting and Support ...http://www.egenix.com/ >>> mxODBC.Z

Memory leak involving traceback objects

2009-07-16 Thread Rotem
Hi, I'm debugging a nasty memory leak in a framework written in Python (v2.6.2). After much digging around I found that the entire object group that is leaking is held by a frame object which is subsequently held by a traceback object. Traversing the get_referrers() of each traceback frame leads

Re: How to Force exiting from program/script

2009-07-16 Thread Piet van Oostrum
> Alex (A) a écrit: >A> hi at all, >A> I have made a script with a while loop and I want that after 30 >A> seconds the program stop and exit . But the code like this doesn't >A> run: >A> In the Console I can see work so that function is correctly called... >A> #Function to exit >A> def exit

Re: missing 'xor' Boolean operator

2009-07-16 Thread Lino Mastrodomenico
2009/7/16 Hendrik van Rooyen : > "Hrvoje Niksic" wrote: > > >> Note that in Python A or B is in fact not equivalent to not(not A and >> not B). > > De Morgan would turn in his grave. If this can make him happier, in Python (not (not a and not b)) *is* equivalent to bool(a or b). (Modulo crazy thi

Re: missing 'xor' Boolean operator

2009-07-16 Thread Jean-Michel Pichavant
Nobody wrote: On Wed, 15 Jul 2009 21:05:16 +0200, Jean-Michel Pichavant wrote: So if I resume: - not 'foo' => False - 'foo' or 'foo' => 'foo' I may be missing something, but honestly, Guido must have smoked some heavy stuff to write such logic, has he ? Several languages (e.g. Lisp,

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread Piet van Oostrum
> akhil1988 (a) wrote: >a> Chris, >a> Using >a> print (u'line: %s' % line).encode('utf-8') >a> the 'line' gets printed, but actually this print statement I was using just >a> for testing, actually my code operates on 'line', on which I use line = >a> line.decode('utf-8') as 'line' is read

How to search this newsgroup by a python script.

2009-07-16 Thread Helmut Jarausch
Hi, I haven't found anything with Google's group search, so let me ask it (again?). How can I search this newsgroup from within a Python script. (Perhaps by searching Google Groups or Gmane by some Python code.) Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Math

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

2009-07-16 Thread Piet van Oostrum
> Mark (M) wrote: >M> You are right that it doesn't make sense to compare two dicts. >M> But OrderedDicts can be viewed logically as lists of (key,value) >M> tuples so they are much more like lists or tuples when it comes to >M> comparisons. >M> For example: > l = [("a", 1), ("z", 2),

Re: A Bug By Any Other Name ...

2009-07-16 Thread rwwh
On Jul 7, 2:00 pm, Steven D'Aprano wrote: > On Mon, 06 Jul 2009 22:18:20 -0700, Chris Rebert wrote: > >> Not so rare. Decimal uses unary plus. Don't assume +x is a no-op. > [...] > > Well, yes, but when would you apply it twice in a row? > > My point was that unary + isn't a no-op, and therefore n

Re: How to search this newsgroup by a python script.

2009-07-16 Thread Chris Rebert
On Thu, Jul 16, 2009 at 2:12 AM, Helmut Jarausch wrote: > Hi, > > I haven't found anything with Google's group search, so let me > ask it (again?). > > How can I search this newsgroup from within a Python script. > (Perhaps by searching Google Groups or Gmane by some Python code.) 1. Generate URL

Re: How to search this newsgroup by a python script.

2009-07-16 Thread Tim Golden
Chris Rebert wrote: On Thu, Jul 16, 2009 at 2:12 AM, Helmut Jarausch wrote: Hi, I haven't found anything with Google's group search, so let me ask it (again?). How can I search this newsgroup from within a Python script. (Perhaps by searching Google Groups or Gmane by some Python code.) 1. G

using timers to force an execution time

2009-07-16 Thread superpollo
hello. based upon previuos suggestions, i tried to write a program in which i would like to have a certain code fragment to execute only for a specified amount of time (say 3 seconds), then bail out. but i get the following: $ cat tmr004.py #!/usr/bin/python -u import threading , time e =

Re: using timers to force an execution time

2009-07-16 Thread Xavier Ho
On Thu, Jul 16, 2009 at 6:34 PM, superpollo wrote: > hello. > > based upon previuos suggestions, i tried to write a program in which i > would like to have a certain code fragment to execute only for a specified > amount of time (say 3 seconds), then bail out. > > > see? the while body ran for

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

2009-07-16 Thread Mark
On 16 July, 10:21, Piet van Oostrum wrote: > > Mark (M) wrote: > >M> You are right that it doesn't make sense to compare two dicts. > >M> But OrderedDicts can be viewed logically as lists of (key,value) > >M> tuples so they are much more like lists or tuples when it comes to > >M> comparisons

turtle dump

2009-07-16 Thread superpollo
hi there. is there a way to dump the content of a turtle window to a file or a file object? bye -- http://mail.python.org/mailman/listinfo/python-list

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

2009-07-16 Thread Mark
On 16 July, 08:51, Steven D'Aprano wrote: > On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: > > On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield > > wrote: > >> Hi, > > >> I'm just wondering why <, <=, >=, and > are not supported by > >> collections.OrderedDict: > > >>    >>> d1 = collec

Re: using timers to force an execution time

2009-07-16 Thread Diez B. Roggisch
superpollo wrote: > hello. > > based upon previuos suggestions, i tried to write a program in which i > would like to have a certain code fragment to execute only for a > specified amount of time (say 3 seconds), then bail out. > > but i get the following: > > $ cat tmr004.py > #!/usr/bin/pytho

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

2009-07-16 Thread Mark
On 16 July, 11:58, Mark wrote: > On 16 July, 08:51, Steven D'Aprano > > > > wrote: > > On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: > > > On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield > > > wrote: > > >> Hi, > > > >> I'm just wondering why <, <=, >=, and > are not supported by > >

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread akhil1988
I have switched to python 3.1 , but now I am getting some syntax errors in the code: File "./customWikiExtractor.py", line 81 __char_entities = {' ' :u'\u00A0', '¡' :u'\u00A1', '¢':u'\u00A2', ^ SyntaxError: invalid syntax line 81 is: __char_

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread akhil1988
Please click reply on the post and then read this reply in the editor. Actually, some sequences have been replaced to their graphical form when this post is published. So the python code is being displayed, what actually it is not. --Akhil akhil1988 wrote: > > I have switched to python 3.1 ,

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Diez B. Roggisch wrote: What you can't achieve in python without major black magic hackery that is very dangerous is to terminate a thread while it is executing. Termination has to be co-operative. i see. thanks a lot. bye -- http://mail.python.org/mailman/listinfo/python-list

Re: using timers to force an execution time

2009-07-16 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > superpollo wrote: > >> hello. >> >> based upon previuos suggestions, i tried to write a program in which i >> would like to have a certain code fragment to execute only for a >> specified amount of time (say 3 seconds), then bail out. >> >> but i get the following: >>

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Diez B. Roggisch wrote: superpollo wrote: see? the while body ran for about 7 seconds... i bet it has to do with the fact that the timer does not control inner loops... any suggestion? Of course the inner loop isn't affected by the set event - how should it be, if you don't check it. if you

Re: using timers to force an execution time

2009-07-16 Thread Diez B. Roggisch
superpollo wrote: > Diez B. Roggisch wrote: >> superpollo wrote: >>>see? the while body ran for about 7 seconds... i bet it has to do with >>>the fact that the timer does not control inner loops... any suggestion? >> >> >> Of course the inner loop isn't affected by the set event - how should it

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Diez B. Roggisch wrote: superpollo wrote: am i wrong? No, you are right, for threads that is. You can try & trick around with the trace-functionality of python, and some ctypes-based system-thread-module-tricks that are, as mentioned before, black-magic & a spinning gatling gun pointed to you

Re: turtle dump

2009-07-16 Thread Diez B. Roggisch
superpollo wrote: > hi there. > > is there a way to dump the content of a turtle window to a file or a > file object? Why should I want to dump a turtle? They are very benign creatures, dumping them is going to hurt them needlessly. Without a cheek-in-tongue: how are we supposed to know what a"

Re: turtle dump

2009-07-16 Thread superpollo
Diez B. Roggisch wrote: superpollo wrote: hi there. is there a way to dump the content of a turtle window to a file or a file object? Why should I want to dump a turtle? They are very benign creatures, dumping them is going to hurt them needlessly. lol. ;-) the title was indeed supposed

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread alex23
On Jul 16, 9:00 pm, akhil1988 wrote: > I have switched to python 3.1 , but now I am getting some syntax errors in > the code: Python 3.x was a major release that endeavoured to clean up a number of lingering issues with the language, the upshot being that it isn't entirely backwards compatible wi

Re: turtle dump

2009-07-16 Thread alex23
On Jul 16, 9:18 pm, superpollo wrote: > lol. ;-) the title was indeed supposed to stir a bit of curiosity upon > the reader... Which isn't really useful when trying to obtain assistance... you want certainty, not curiosity. > in fact i was looking for a *platform independent* way to draw into a

Re: turtle dump

2009-07-16 Thread superpollo
alex23 wrote: On Jul 16, 9:18 pm, superpollo wrote: lol. ;-) the title was indeed supposed to stir a bit of curiosity upon the reader... Which isn't really useful when trying to obtain assistance... you want certainty, not curiosity. ok. my bad. in fact i was looking for a *platform

Re: turtle dump

2009-07-16 Thread Bearophile
Superchicken: > is there a way to dump the content of a turtle window to a file or a file > object? A possible low-tech solution is to append to a list the sequence of your plotting commands (using a decorator too, even, something like the logging decorator), and then save all of them at the end

Re: Persistent variable in subprocess using multiprocessing?

2009-07-16 Thread Piet van Oostrum
> mheavner (m) wrote: >m> I'm using multiprocessing to spawn several subprocesses, each of which >m> uses a very large data structure (making it impractical to pass it via >m> pipes / pickling). I need to allocate this structure once when the >m> process is created and have it remain in memor

Re: turtle dump

2009-07-16 Thread Peter Otten
superpollo wrote: > alex23 wrote: >> On Jul 16, 9:18 pm, superpollo wrote: >> >>>lol. ;-) the title was indeed supposed to stir a bit of curiosity upon >>>the reader... >> >> >> Which isn't really useful when trying to obtain assistance... you want >> certainty, not curiosity. >> > > ok. my

Re: turtle dump

2009-07-16 Thread superpollo
Peter Otten wrote: Tested on 2.4: import turtle turtle.reset() for i in range(4): ... turtle.forward(50) ... turtle.right(90) ... turtle._canvas.postscript(file="tmp.ps") '' I think the big rewrite has happened in 2.6, so the above should also work in 2.3. Peter mr otten,

Re: Passing python list from C to python

2009-07-16 Thread hartley
/* the first telling */ (...) /* the third telling */ (...) /* the third telling */ - If you had loosened up on the sarcasm I would probably have read what you wrote more thoroughly instead of just skimming through it. Thanks for the help, but you should seriously consider doing something with yo

Re: Passing python list from C to python

2009-07-16 Thread hartley
/* the first telling */ (...) /* the second telling */ (...) /* the third telling */ - If you had loosened up on the sarcasm I would probably have read what you wrote more thoroughly instead of just skimming through it. Thanks for the help, but you should seriously consider doing something with yo

Re: turtle dump

2009-07-16 Thread Michiel Overtoom
I got success with the following code (python 2.6.2): import turtle turtle.reset() for i in range(4): turtle.forward(50) turtle.right(90) can=turtle.getscreen().getcanvas() can.postscript(file="tmp.ps") -- "The ability of the OSS process to collect and harness the collective IQ of thousa

Re: How to check if any item from a list of strings is in a big string?

2009-07-16 Thread inkhorn
Hi all, This was more a question of programming aesthetics for me than one of great practical significance. I was looking to perform a certain function on files in a directory so long as those files weren't found in certain standard directories. In other words, I was using os.walk () to get mult

Re: Persistent variable in subprocess using multiprocessing?

2009-07-16 Thread mheavner
On Jul 16, 8:39 am, Piet van Oostrum wrote: > > mheavner (m) wrote: > >m> I'm using multiprocessing to spawn several subprocesses, each of which > >m> uses a very large data structure (making it impractical to pass it via > >m> pipes / pickling). I need to allocate this structure once when th

Re: missing 'xor' Boolean operator

2009-07-16 Thread Anthony Tolle
On Jul 15, 8:32 pm, Paul Rubin wrote: > Among other things, that uses quadratic time!  Why do you want to keep > popping items from that list instead of iterating through it anyway? > > Anyway, I think you wrote something close to this: > ... Very true! I didn't thi

Re: missing 'xor' Boolean operator

2009-07-16 Thread Emile van Sebille
On 7/16/2009 2:06 AM Jean-Michel Pichavant said... Ok then, why "or" does not return True, if the first element is considered True ? Why returning the element itself. Any reason for that ? Because it's confusing, maybe people used to that logic find it obvious, but I really don't. For example

Re: using timers to force an execution time

2009-07-16 Thread Nick Craig-Wood
superpollo wrote: > Diez B. Roggisch wrote: > > superpollo wrote: > >>am i wrong? > > > > > > No, you are right, for threads that is. You can try & trick around with the > > trace-functionality of python, and some ctypes-based > > system-thread-module-tricks that are, as mentioned before, black

Re: Why not enforce four space indentations in version 3.x?

2009-07-16 Thread Inky 788
On Jul 10, 7:35 pm, Ben Finney wrote: > walterbyrd writes: > > I believe Guido himself has said that all indentions should be four > > spaces - no tabs. > > Yes. That's a “should” and not a “must”, even though PEP 8 says it > with a simple imperative:: > >     Use 4 spaces per indentation level.

Re: Persistent variable in subprocess using multiprocessing?

2009-07-16 Thread mheavner
On Jul 16, 9:18 am, mheavner wrote: > On Jul 16, 8:39 am, Piet van Oostrum wrote: > > > > > > mheavner (m) wrote: > > >m> I'm using multiprocessing to spawn several subprocesses, each of which > > >m> uses a very large data structure (making it impractical to pass it via > > >m> pipes / pick

Re: turtle dump

2009-07-16 Thread alex23
On Jul 16, 10:11 pm, superpollo wrote: > actually i am still using 2.3.4, which means that... > > > screen = turtle.Screen() > > ... is not possible Ah, sorry about that. My belief that turtle was a new module was based on a line from http://us.pycon.org/media/2009/talkdata/PyCon2009/065/SevenWa

Re: using timers to force an execution time

2009-07-16 Thread Paul Moore
2009/7/16 superpollo : > hello. > > based upon previuos suggestions, i tried to write a program in which i would > like to have a certain code fragment to execute only for a specified amount > of time (say 3 seconds), then bail out. > > but i get the following: > > $ cat tmr004.py > #!/usr/bin/pyth

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Nick Craig-Wood wrote: superpollo wrote: > ... Or if you are on unix you can use signals... It is probably just about acceptable to raise an exception in a signal handler like this code does. > ... neat! -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-16 Thread Jean-Michel Pichavant
Emile van Sebille wrote: On 7/16/2009 2:06 AM Jean-Michel Pichavant said... Ok then, why "or" does not return True, if the first element is considered True ? Why returning the element itself. Any reason for that ? Because it's confusing, maybe people used to that logic find it obvious, but I r

Re: Passing handlers between bound c++ libs

2009-07-16 Thread bobicanprogram
On Jul 14, 7:07 pm, Freyr wrote: > I have a python bound physics library that uses handler to process > events. The passing of handlers between c++ and python causes a huge > overhead slowing down the process. Can I implement a handler in my > custom python bound c++ lib B and pass it to blackbox

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Nick Craig-Wood wrote: > ... import signal, os, time ... importing os is useless of course... -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-16 Thread Grant Edwards
On 2009-07-16, Emile van Sebille wrote: > On 7/16/2009 2:06 AM Jean-Michel Pichavant said... >> Ok then, why "or" does not return True, if the first element is >> considered True ? Why returning the element itself. Any reason for that >> ? Because it's confusing, maybe people used to that logic

Re: How to search this newsgroup by a python script.

2009-07-16 Thread Grant Edwards
On 2009-07-16, Chris Rebert wrote: > On Thu, Jul 16, 2009 at 2:12 AM, Helmut > Jarausch wrote: >> Hi, >> >> I haven't found anything with Google's group search, so let me >> ask it (again?). >> >> How can I search this newsgroup from within a Python script. >> (Perhaps by searching Google Groups o

This is a mess...

2009-07-16 Thread Nick
I've been coding python for about a week now, and i'm trying to make an object oriented version of a program i just wrote. in this post is the original program. the next post will include the new programs and the traceback. i'm sure there are many underlying problems, but have been stuck on this

Re: Python Equivalent for dd & fold

2009-07-16 Thread seldan24
On Jul 15, 1:48 pm, Emile van Sebille wrote: > On 7/15/2009 10:23 AM MRAB said... > > >> On Jul 15, 12:47 pm, Michiel Overtoom wrote: > >>> seldan24 wrote: > what can I use as the equivalent for the Unix 'fold' command? > >>> def fold(s,len): > >>>      while s: > >>>          print s[:len]

Re: ImportError: No module named _functools

2009-07-16 Thread Aahz
In article <45228cf4-0b37-4c52-bf6f-d7bd124b0...@l32g2000vbp.googlegroups.com>, Tony Lay wrote: > >Traceback (most recent call last): > File "/usr/local/bin/meld", line 35, in >import gettext > File "/usr/local/lib/python2.6/gettext.py", line 49, in >import locale, copy, os, re, stru

Re: Why not enforce four space indentations in version 3.x?

2009-07-16 Thread Tim Chase
I realize that a small portion of the community likes the tabs. They're sold on the tabs. They like the tabs. But tabs are an archaic holdover from an era when typewriters had physical tabstops on them. However, they are a single logical level of indentation -- I come down fairly solidly on the

Re: This is a mess...

2009-07-16 Thread Nick
this is the new oop version, its pretty messy currently, and i do understand it is a simple routine, but i'm using it as an exercise to learn oop python... first the (current) traceback: [:~/python]$ python oop_covariance.py b2ar_all_test b2ar_all_test Traceback (most recent call last): File

Re: Passing python list from C to python

2009-07-16 Thread John Machin
On Jul 16, 11:13 pm, hartley wrote: > /* the first telling */ > (...) > /* the second telling */ > (...) > /* the third telling */ > > - > If you had loosened up on the sarcasm That wasn't sarcasm, it was an attempt at humourous watering-down the expression of exasperation at continued ignoring o

Re: Memory leak involving traceback objects

2009-07-16 Thread Aahz
In article , Rotem wrote: > >I'm debugging a nasty memory leak in a framework written in Python >(v2.6.2). >After much digging around I found that the entire object group that is >leaking is held by a frame object which is subsequently held by a >traceback object. > >Traversing the get_referrers(

IFL 2009: Third Call for Papers

2009-07-16 Thread IFL 2009
Call for Papers IFL 2009Seton Hall UniversitySOUTH ORANGE, NJ, USAhttp://tltc.shu.edu/blogs/projects/IFL2009/* NEW *Registration is now opened! Register at: http://tltc.shu.edu/blogs/projects/IFL2009/registration.htmlInvited Speaker:    Benjamin C. Pierce    University of Pennsylvania    Ta

Re: interactive fiction in Python?

2009-07-16 Thread J Kenneth King
George Oliver writes: > hi, I'm just curious who might be working on interactive fiction > modules in the style of Inform or TADS for Python. I've seen a few > threads on this list [1] (among many that mention IF tangentially), > and there are old projects like PUB and PAWS. There are some newer

Re: Ann: Google releases Python-based open-source NX server

2009-07-16 Thread J Kenneth King
jkn writes: > Google quietly releases open-source NX server ...written in Python, > apparently > > Google_quietly_releases_open_source_NX_server?taxonomyId=88> > > Neatx can be downloaded from Google's code repository: > >

no return value for threading.Condition.wait(timeout)?

2009-07-16 Thread Gabriel Rossetti
Hello everyone, I am using threading.Condition.wait(timeout) and was surprised to see that there is no return value nor an exception when wait() is used w/ a timeout. How am I supposed to know if it was notified or if it timed out? cheers, Gabriel -- http://mail.python.org/mailman/listinfo/py

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread Max Erickson
akhil1988 wrote: > > akhil1988 wrote: >> >> I have switched to python 3.1 , but now I am getting some syntax >> errors in the code: >> >> File "./customWikiExtractor.py", line 81 >> __char_entities = {' ' :u'\u00A0', '¡' >> :u'\u00A1', >> '¢':u'\u00A2', >>

Re: Python Equivalent for dd & fold

2009-07-16 Thread Michiel Overtoom
seldan24 wrote: I know that Emile suggested that I can slice out the substrings rather than do the gradual trimming of the string variable as is being done by moving around the length. An excellent idea. def fold(s,chunklength): offset=0 while offsethttp://www.catb.org/~esr/halloween

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread John Machin
On Jul 16, 9:04 pm, akhil1988 wrote: > Please click reply on the post and then read this reply in the editor. > Actually, some sequences have been replaced to their graphical form when > this post is published. So the python code is being displayed, what actually > it is not. What editor? I guess

Re: Python Equivalent for dd & fold

2009-07-16 Thread Casey Webster
On Jul 16, 10:12 am, seldan24 wrote: > On Jul 15, 1:48 pm, Emile van Sebille wrote: > > > > > On 7/15/2009 10:23 AM MRAB said... > > > >> On Jul 15, 12:47 pm, Michiel Overtoom wrote: > > >>> seldan24 wrote: > > what can I use as the equivalent for the Unix 'fold' command? > > >>> def fold(s

Re: How to check if any item from a list of strings is in a big string?

2009-07-16 Thread Pablo Torres N.
On Thu, Jul 9, 2009 at 22:07, Steven D'Aprano wrote: > On Thu, 09 Jul 2009 18:36:05 -0700, inkhorn wrote: > >> def list_items_in_string(list_items, string): >>     for item in list_items: >>         if item in string: >>             return True >>     return False > ... >> Any ideas how to make tha

Re: Python Equivalent for dd & fold

2009-07-16 Thread pdpi
On Jul 16, 3:12 pm, seldan24 wrote: > On Jul 15, 1:48 pm, Emile van Sebille wrote: > > > > > > > On 7/15/2009 10:23 AM MRAB said... > > > >> On Jul 15, 12:47 pm, Michiel Overtoom wrote: > > >>> seldan24 wrote: > > what can I use as the equivalent for the Unix 'fold' command? > > >>> def fol

Re: list of all possible values

2009-07-16 Thread David Gibb
> Certainly possible with list comprehensions. > a = "abc" [(x, y) for x in a for y in a] > [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', 'c'), > ('c', 'a'), ('c', 'b'), ('c', 'c')] > > But I like bearophile's version better. > Andreas, Thanks, but I think you were

Re: missing 'xor' Boolean operator

2009-07-16 Thread Emile van Sebille
On 7/16/2009 7:04 AM Unknown said... On 2009-07-16, Emile van Sebille wrote: daysInAdvance = int(inputVar) or 25 I don't get it. That doesn't work right when inputVar == "0". Aah, but you didn't get to define right. :) For that particular example 0 is not a valid response. Emile -- ht

Re: Python Equivalent for dd & fold

2009-07-16 Thread ryles
On Jul 15, 1:14 pm, seldan24 wrote: > On Jul 15, 12:47 pm, Michiel Overtoom wrote: > > > > > seldan24 wrote: > > > what can I use as the equivalent for the Unix 'fold' command? > > > def fold(s,len): > >      while s: > >          print s[:len] > >          s=s[len:] > > > s="A very long string i

RE: list of all possible values

2009-07-16 Thread Andreas Tawn
> > Certainly possible with list comprehensions. > > > a = "abc" > [(x, y) for x in a for y in a] > > [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', 'c'), > > ('c', 'a'), ('c', 'b'), ('c', 'c')] > > > > But I like bearophile's version better. > > > > Andreas, > > Tha

Re: Python Equivalent for dd & fold

2009-07-16 Thread MRAB
seldan24 wrote: On Jul 15, 1:48 pm, Emile van Sebille wrote: On 7/15/2009 10:23 AM MRAB said... On Jul 15, 12:47 pm, Michiel Overtoom wrote: seldan24 wrote: what can I use as the equivalent for the Unix 'fold' command? def fold(s,len): while s: print s[:len] s=s[len

Re: Python Equivalent for dd & fold

2009-07-16 Thread MRAB
Michiel Overtoom wrote: seldan24 wrote: I know that Emile suggested that I can slice out the substrings rather than do the gradual trimming of the string variable as is being done by moving around the length. An excellent idea. def fold(s,chunklength): offset=0 while offset More Pyt

Re: Persistent variable in subprocess using multiprocessing?

2009-07-16 Thread Piet van Oostrum
> mheavner (m) wrote: >m> 'The process' refers to the subprocess. I could do as you say, load >m> the data structure each time, but the problem is that takes a >m> considerable amount of time compared to the the actual computation >m> with the data it contains. I'm using these processes withi

Re: Persistent variable in subprocess using multiprocessing?

2009-07-16 Thread mheavner
I realize that the Queue would be the best way of doing this, however that involves transferring the huge amount of data for each call - my hope was to transfer it once and have it remain in memory for the subprocess across run() calls. On Jul 16, 1:18 pm, Piet van Oostrum wrote: > > mheavner

Re: Why not enforce four space indentations in version 3.x?

2009-07-16 Thread Inky 788
On Jul 16, 10:18 am, Tim Chase wrote: > > I realize that a small portion of the community likes the tabs. > > They're sold on the tabs. They like the tabs. But tabs are an archaic > > holdover from an era when typewriters had physical tabstops on them. > > However, they are a single logical level

Re: missing 'xor' Boolean operator

2009-07-16 Thread Jean-Michel Pichavant
Emile van Sebille wrote: On 7/16/2009 7:04 AM Unknown said... On 2009-07-16, Emile van Sebille wrote: daysInAdvance = int(inputVar) or 25 I don't get it. That doesn't work right when inputVar == "0". Aah, but you didn't get to define right. :) For that particular example 0 is not a vali

Re: Ann: Google releases Python-based open-source NX server

2009-07-16 Thread jkn
On Jul 16, 3:51 pm, J Kenneth King wrote: > It's pretty cool, but not PEP8! Probably because they just bought the > source off of another smaller proprietary project.  Makes me sad seeing > Google, proud supporter of all things Python, release non-PEP8 code. Personally, I don't follow PEP8 eithe

Re: Ann: Google releases Python-based open-source NX server

2009-07-16 Thread Emile van Sebille
On 7/16/2009 10:59 AM jkn said... Personally, I don't follow PEP8 either. Note: PEP-8 gives 'coding conventions for the Python code **comprising the standard library in the main Python distribution**' (my emphasis). My coding conventions are similar to, but not exactly the same as, PEP-8. Mine

Re: Ann: Google releases Python-based open-source NX server

2009-07-16 Thread Robert Kern
On 2009-07-16 09:51, J Kenneth King wrote: jkn writes: Google quietly releases open-source NX server ...written in Python, apparently Neatx can be downloaded from Google's code repos

Re: Why not enforce four space indentations in version 3.x?

2009-07-16 Thread Tim Chase
However, they are a single logical level of indentation -- I come down fairly solidly on the "tabs" side of the "tabs vs. spaces" argument. My bet is that the problem is this: some people like to format their code in ways that don't work well when you're using tabs. For example, they might want

Re: Why not enforce four space indentations in version 3.x?

2009-07-16 Thread Carl Banks
On Jul 16, 6:32 am, Inky 788 wrote: > On Jul 10, 7:35 pm, Ben Finney wrote: > > > walterbyrd writes: > > > I believe Guido himself has said that all indentions should be four > > > spaces - no tabs. > > > Yes. That's a “should” and not a “must”, even though PEP 8 says it > > with a simple impera

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

2009-07-16 Thread Terry Reedy
Mark wrote: On 16 July, 10:21, Piet van Oostrum wrote: But why should the order be as if the OrderedDict was a list of tuples. A dict can be considered as a mapping and then you might want to treat either the key or the value as contravariant (the key I guess). So there is ambiguity. Why woul

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread akhil1988
Hi, Thanks all for the replies. I am working on a cluster of 15 nodes and I have now installed python 3.1 on all of them. I tried installing python2.6 but there was some make error. So, I do not want to give more time in installing 2.4 and rather use 3.1 but for that I need to convert my 2.4 co

URLError errno and strerror not set

2009-07-16 Thread 1x7y2z9
python 2.5.2 errno, strerror and message do not appear to be set in the following two cases (at least). Is this to be expected? (as an aside, arg[0] is set) # case 1 > print exception, exception.errno, exception.strerror, exception.message == '' None None True # case 2 > print exception, exce

Re: Persistent variable in subprocess using multiprocessing?

2009-07-16 Thread Piet van Oostrum
> mheavner (m) wrote: >m> I realize that the Queue would be the best way of doing this, however >m> that involves transferring the huge amount of data for each call - my >m> hope was to transfer it once and have it remain in memory for the >m> subprocess across run() calls. Which huge amount

Re: Passing python list from C to python

2009-07-16 Thread Aahz
In article <0afc5c4d-1af5-4d0e-9442-26b51b12e...@m11g2000yqh.googlegroups.com>, hartley wrote: > >If you had loosened up on the sarcasm I would probably have read what >you wrote more thoroughly instead of just skimming through it. Thanks >for the help, but you should seriously consider doing som

Re: Ann: Google releases Python-based open-source NX server

2009-07-16 Thread J Kenneth King
Robert Kern writes: > On 2009-07-16 09:51, J Kenneth King wrote: >> jkn writes: >> >>> Google quietly releases open-source NX server ...written in Python, >>> apparently >>> >>> >> Google_quietly_releases_open_source_NX_server?taxonomyId=88> >>>

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread akhil1988
ok! I got the indentation errors fixed. Bu I get another error: Traceback (most recent call last): File "./temp.py", line 484, in main() File "./temp.py", line 476, in main line.decode('utf-8').strip() AttributeError: 'str' object has no attribute 'decode' I am using Python3.1 Than

Re: ImportError: No module named _functools

2009-07-16 Thread Tony Lay
On Jul 16, 10:14 am, a...@pythoncraft.com (Aahz) wrote: > In article > <45228cf4-0b37-4c52-bf6f-d7bd124b0...@l32g2000vbp.googlegroups.com>, > Tony  Lay   wrote: > > > > >Traceback (most recent call last): > >  File "/usr/local/bin/meld", line 35, in > >    import gettext > >  File "/usr/local/lib

  1   2   >