Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Thursday 16 July 2009 08:38:57 Peter Fodrek wrote: > On Thursday 16 July 2009 07:38:23 Carl Banks wrote: > > On Jul 15, 10:16 pm, Peter Fodrek wrote: > > > On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > sys.path.insert(0,'/usr/local/lib/heekscnc/') I was mentioned that this adds

Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Thursday 16 July 2009 07:38:23 Carl Banks wrote: > On Jul 15, 10:16 pm, Peter Fodrek wrote: > > On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > > > Peter Fodrek wrote: > > > > .. > > > > > What does > > > > > > import nc > > > print nc.__file__ > > > > python > > Python 2.6 (r2

Why aren't OrderedDicts comparable with < etc?

2009-07-15 Thread Mark Summerfield
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 >>> d1 < d2 Traceback (most recent call last): File "", line

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

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 4:26 PM, David Bolen wrote: Miles Kaufmann writes: On Jul 14, 2009, at 5:06 PM, David Bolen wrote: Are you sure? It seems to restrict them in the same block, but not in the entire file. At least I was able to use both space and tab indented blocks in the same file wit

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

2009-07-15 Thread akhil1988
Chris, Using print (u'line: %s' % line).encode('utf-8') the 'line' gets printed, but actually this print statement I was using just for testing, actually my code operates on 'line', on which I use line = line.decode('utf-8') as 'line' is read as bytes from a stream. And if I use line = line.e

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread Asun Friere
On Jul 16, 2:14 pm, alex23 wrote: ... > AND > you're citing back what I myself wrote in the link to which I also > referred the OP - whom (sic) has subsequently posted his success with this > technique - so I'm not really sure what the point is here other than > "if you have a different use case

Re: import module unbelieveable behaviour

2009-07-15 Thread Carl Banks
On Jul 15, 10:16 pm, Peter Fodrek wrote: > On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > > > Peter Fodrek wrote: > .. > > What does > > > import nc > > print nc.__file__ > > python > Python 2.6 (r26:66714, Feb  3 2009, 20:49:49) > [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on

Re: problem about cx_Oracle

2009-07-15 Thread Vincent
On Jul 16, 12:18 pm, Vincent wrote: > hi, all: > > i am using cx_oracle now. > > i write code as below: > > def __getfields_by_tbname(self,tbname): >         cursor = self.ora_db.cursor() >         print tbname >         sql = 'select * from %s where rownum <=2' % tbname >         print sql >    

Re: missing 'xor' Boolean operator

2009-07-15 Thread Steven D'Aprano
On Wed, 15 Jul 2009 21:05:16 +0200, Jean-Michel Pichavant wrote: > Didn't know that. > 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 ? No, it's perfectly reaso

Why does Python not stop when it's supposed to?

2009-07-15 Thread Mensanator
So, I'm playing around with Python (running 2.6 and 3.1 versions of IDLE). After I shut everything down and close the windows, I notice the Task Manager's activity light is still glowing. In looking at the Process window I see this: Image...User Name CPU Memory(... Description pythonw.exe me

Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Thursday 16 July 2009 02:18:52 Carl Banks wrote: > On Jul 15, 6:12 am, Peter Fodrek wrote: > That's a tricky one, indeed. > > Here's my guess: test.py is a symlink to a file in another directory. It is not true guess ls -la test.py -rw-r--r-- 1 peto users 1990 2009-07-15 14:19 test.py But m

Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > Peter Fodrek wrote: .. > What does > > import nc > print nc.__file__ python Python 2.6 (r26:66714, Feb 3 2009, 20:49:49) [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 Type "help", "copyright", "credits" or "license" for mo

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

2009-07-15 Thread Chris Rebert
> Chris Rebert-6 wrote: >> >> On Wed, Jul 15, 2009 at 9:34 PM, akhil1988 wrote: >>> >>> Hi! >>> >>> Can anyone please help me getting rid of this error: >>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in >>> position >>> 13: ordinal not in range(128) >>> >>> I am not a python p

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

2009-07-15 Thread akhil1988
Sorry, it is sgmllib.py and not sgmmlib.py -- Akhil akhil1988 wrote: > > Well, > All I get is this traceback: > > File "./customWikiExtractor.py", line 492, in ? > main() > File "./customWikiExtractor.py", line 480, in main > print >> sys.stdout, 'line: %s' % line > UnicodeEncodeErro

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

2009-07-15 Thread akhil1988
Well, All I get is this traceback: File "./customWikiExtractor.py", line 492, in ? main() File "./customWikiExtractor.py", line 480, in main print >> sys.stdout, 'line: %s' % line UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

Re: does python have a generic object pool like commons-pool in Java

2009-07-15 Thread John Nagle
alex23 wrote: On Jul 16, 2:03 pm, John Nagle wrote: "fcgi" is an option for this sort of thing. With "mod_fcgi" installed in Apache, and "fcgi.py" used to manage the Python side of the problem, you can have semi-persistent programs started up and shut down for you on the server side. He

Re: one more question

2009-07-15 Thread alex23
On Jul 16, 2:29 pm, koranthala wrote: > It is not that I do want to do the work for them. It is just that I > was in the same position just 6 months back. My first pieces of code > were very poor - full of errors and quite horrible indeed. I was even > afraid to post it anywhere. I came here, and

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

2009-07-15 Thread Chris Rebert
On Wed, Jul 15, 2009 at 9:34 PM, akhil1988 wrote: > > Hi! > > Can anyone please help me getting rid of this error: > UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position > 13: ordinal not in range(128) > > I am not a python programmer (though intend to start learning this wo

Re: does python have a generic object pool like commons-pool in Java

2009-07-15 Thread alex23
On Jul 16, 2:03 pm, John Nagle wrote: >      "fcgi" is an option for this sort of thing.  With "mod_fcgi" installed > in Apache, and "fcgi.py" used to manage the Python side of the problem, you > can have semi-persistent programs started up and shut down for you on the > server side. Hey John, T

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

2009-07-15 Thread akhil1988
Hi! Can anyone please help me getting rid of this error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128) I am not a python programmer (though intend to start learning this wonderful language), I am just using a python script. After doin

Re: one more question

2009-07-15 Thread koranthala
On Jul 16, 7:30 am, alex23 wrote: > On Jul 15, 5:51 pm, koranthala wrote: > > >    I am not saying that what you said was wrong, only that I felt that > > she got tense looking up regular expressions. So a python reply which > > basically does the basic checking without going to re etc might be >

problem about cx_Oracle

2009-07-15 Thread Vincent
hi, all: i am using cx_oracle now. i write code as below: def __getfields_by_tbname(self,tbname): cursor = self.ora_db.cursor() print tbname sql = 'select * from %s where rownum <=2' % tbname print sql cursor = cursor.execute(sql) return self.getfi

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread alex23
On Jul 16, 12:56 pm, Asun Friere wrote: > As you note there, this will work when running the vanilla shell (ie > running  it from the command line), but not (potentially) in other > interactive environments (IronPython being the example you give). Actually, that was IPython, which is an enhanced

Re: does python have a generic object pool like commons-pool in Java

2009-07-15 Thread John Nagle
Rick Lawson wrote: On Jul 15, 4:53 am, Jonathan Gardner wrote: On Jul 14, 6:34 pm, Rick Lawson wrote: Appreciate any help on this. I am porting an app from Java to python and need generic object pooling with hooks for object initialization / cleanup and be able to specify an object timeout.

Re: mail

2009-07-15 Thread koranthala
On Jul 15, 11:46 pm, amr...@iisermohali.ac.in wrote: > Dear all, > > Sorry that I am disturbing you all again and again but this is the way I > am trying to solve my problem:--- > > >>> import re > >>> exp = re.compile("CA") > >>> infile = open("file1.txt") > >>> for line in infile: > > ...     val

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread Asun Friere
On Jul 16, 10:47 am, alex23 wrote: ... > This older post should > help:http://groups.google.com/group/comp.lang.python/browse_frm/thread/6c5... > > But the quick answer is to import sys into your program, and do a test > on hasattr(sys, 'ps1'), which is only created when running the > interacti

Re: one more question

2009-07-15 Thread alex23
On Jul 15, 5:51 pm, koranthala wrote: >    I am not saying that what you said was wrong, only that I felt that > she got tense looking up regular expressions. So a python reply which > basically does the basic checking without going to re etc might be > more helpful for her to start her own coding

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread pdlemper
On Wed, 15 Jul 2009 19:07:18 -0500, pdlem...@earthlink.net wrote: >The WConio console module produces different colors, sometimes quite >different, when run from Windows command line vs from Python >interpreter >>> . A good foregnd/backgnd combination under one >may be unreadable under the other

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread alex23
On Jul 16, 10:07 am, pdlem...@earthlink.net wrote: > The WConio console module produces different colors, sometimes quite > different, when run from Windows command line vs from Python > interpreter >>> .  A good foregnd/backgnd combination under one > may be unreadable under the other  : ( > I'm u

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread alex23
On Jul 16, 10:41 am, alex23 wrote: > It's recommended that you search through the list for similar > questions before posting. Of course, it's even MORE important that one actually ensures they're responding to the _same_ question before pointing at an answer... This older post should help: http

Re: missing 'xor' Boolean operator

2009-07-15 Thread Paul Rubin
Anthony Tolle writes: > def xor(*operands): > if operands: > operands = list(operands) > a = bool(operands.pop(0)) > while operands: > b = bool(operands.pop(0)) > if a: > if b: > a = False > elif b:

Re: import module unbelieveable behaviour

2009-07-15 Thread Carl Banks
On Jul 15, 6:12 am, Peter Fodrek wrote: > Dear conference! > > I have test Why python based script for HeeksCNC post-processing does not > work...  And I've got unbelievable behavior  When importing module module > manually it works, but same opertaion from script does not >  work as seen > > /opt

Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread pdlemper
The WConio console module produces different colors, sometimes quite different, when run from Windows command line vs from Python interpreter >>> . A good foregnd/backgnd combination under one may be unreadable under the other : ( I'm using Python 3.0 with the corresponding WConio on XP. Is there

Re: missing 'xor' Boolean operator

2009-07-15 Thread Nobody
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, Bourne shell)

Re: missing 'xor' Boolean operator

2009-07-15 Thread Chris Rebert
On Wed, Jul 15, 2009 at 3:57 PM, Wayne Brehaut wrote: > On 15 Jul 2009 09:11:44 GMT, Steven D'Aprano > wrote: > >>On Tue, 14 Jul 2009 11:25:08 -0700, Dr. Phillip M. Feldman wrote: >> >>> Current Boolean operators are 'and', 'or', and 'not'.  It would be nice >>> to have an 'xor' operator as well.

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On 15 Jul 2009 09:11:44 GMT, Steven D'Aprano wrote: >On Tue, 14 Jul 2009 11:25:08 -0700, Dr. Phillip M. Feldman wrote: > >> Current Boolean operators are 'and', 'or', and 'not'. It would be nice >> to have an 'xor' operator as well. > >I've often wished there was too, for the sake of completenes

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson wrote: >On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" >wrote: >> Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to >> have an 'xor' operator as well. > >Hmm. I don't think 'nice' is sufficient. You'd need to make

Re: Cleaning up after failing to contructing objects

2009-07-15 Thread Shai
Since nobody else mentioned this... Python classes have a magic method called __del__ which is usually called just before an object is garbage-collected. Further, Python uses reference-counting to tell when an object is no longer accessible. This means that if your resource classes define __del__

Re: Package for fast plotting of many data points in Python?

2009-07-15 Thread mmanns
On Sat, 11 Jul 2009 15:33:32 -0700 (PDT) Daniel Platz wrote: > thanks for your repleys. I have tried matplotlib but it is extremely > slow. I think it is more optimized for good looking plots instead of > speed. I do not know the Python bindings of gnuplot and Veusz. To > clarify the issue again,

Re: Colour of output text

2009-07-15 Thread Nobody
On Wed, 15 Jul 2009 17:03:30 +0200, Jean-Michel Pichavant wrote: >> Hard-coding control/escape sequences is just lame. Use the curses modules >> to obtain the correct sequences for the terminal. >> >> > As the OP I'm really interested in doing so. I currently have all my > colors hard-coded. >

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

2009-07-15 Thread mobiledreamers
On Wed, Jul 15, 2009 at 2:25 PM, jkn wrote: > 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 reposit

Re: allowing output of code that is unittested?

2009-07-15 Thread Diez B. Roggisch
per schrieb: hi all, 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) unittest

Re: How to Force exiting from program/script

2009-07-15 Thread Diez B. Roggisch
Alex schrieb: hi at all, I have made a script with a while loop and I want that after 30 seconds the program stop and exit . But the code like this doesn't run: In the Console I can see work so that function is correctly called... #Function to exit def exit(): print "work" raise SystemE

How to Force exiting from program/script

2009-07-15 Thread Alex
hi at all, I have made a script with a while loop and I want that after 30 seconds the program stop and exit . But the code like this doesn't run: In the Console I can see work so that function is correctly called... #Function to exit def exit(): print "work" raise SystemExit() t = thread

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

2009-07-15 Thread jkn
Google quietly releases open-source NX server ...written in Python, apparently Neatx can be downloaded from Google's code repository: Regards J

allowing output of code that is unittested?

2009-07-15 Thread per
hi all, 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) unittest.TextTestRunner

interactive fiction in Python?

2009-07-15 Thread George Oliver
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 potential projects such as Curve

Re: python first assignment of a global variable

2009-07-15 Thread Rodrigue
> MY_GLOBAL, by virtue of being assigned to later in the function, and the > absence of a global statement, is identified as a local variable. > When a function contains a > single assignment (or augmented assignment) to a name, the compiler > generates bytecode such that all references to that na

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

2009-07-15 Thread David Bolen
Miles Kaufmann writes: > On Jul 14, 2009, at 5:06 PM, David Bolen wrote: >> Are you sure? It seems to restrict them in the same block, but not in >> the entire file. At least I was able to use both space and tab >> indented blocks in the same file with Python 3.0 and 3.1. > > It seems to me tha

Re: Persistent variable in subprocess using multiprocessing?

2009-07-15 Thread Diez B. Roggisch
mheavner schrieb: I'm using multiprocessing to spawn several subprocesses, each of which uses a very large data structure (making it impractical to pass it via pipes / pickling). I need to allocate this structure once when the process is created and have it remain in memory for the duration of th

Re: missing 'xor' Boolean operator

2009-07-15 Thread Hrvoje Niksic
Jean-Michel Pichavant writes: > Hrvoje Niksic wrote: > [snip] >> Note that in Python A or B is in fact not equivalent to not(not A and >> not B). >> l = [(True, True), (True, False), (False, True), (False, False)] for p in l: > ... p[0] or p[1] [...] Try with a different data se

Re: Reading a large csv file

2009-07-15 Thread drozzy
On Jun 26, 6:47 am, Mag Gam wrote: > Thankyou everyone for the responses! I took some of your suggestions > and my loading sped up by 25% what a useless post... -- http://mail.python.org/mailman/listinfo/python-list

Persistent variable in subprocess using multiprocessing?

2009-07-15 Thread mheavner
I'm using multiprocessing to spawn several subprocesses, each of which uses a very large data structure (making it impractical to pass it via pipes / pickling). I need to allocate this structure once when the process is created and have it remain in memory for the duration of the process. The way t

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Wed, 15 Jul 2009 11:51:44 -0700 (PDT), Mark Dickinson wrote: >On Jul 15, 7:29 pm, Wayne Brehaut wrote: >> On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson >> wrote: >> >I'd also guess that 'xor' would be much less used than 'and' or 'or', >> >but maybe that's just a reflection of th

Re: compiling python

2009-07-15 Thread Stefan Behnel
Mag Gam wrote: > At my university we are trying to compile python with --enable-shared Is there a reason why you need to compile the CPython interpreter yourself? > however when I do a make many things fail. Is it a good idea to > compile python with shared libraries? Perfectly fine, Linux dist

Re: mail

2009-07-15 Thread J. Cliff Dyer
On Thu, 2009-07-16 at 00:16 +0530, amr...@iisermohali.ac.in wrote: > Dear all, > > Sorry that I am disturbing you all again and again but this is the way I > am trying to solve my problem:--- > > >>> import re > >>> exp = re.compile("CA") > >>> infile = open("file1.txt") > >>> for line in infile:

Re: mail

2009-07-15 Thread Grant Edwards
On 2009-07-15, amr...@iisermohali.ac.in wrote: > Sorry that I am disturbing you all again and again but this is the way I > am trying to solve my problem:--- We could probably be a lot more helpful if you would keep these postings all in a single thread so that people who didn't read the first p

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
Miles Kaufmann wrote: On Jul 15, 2009, at 1:43 PM, Jean-Michel Pichavant wrote: Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). >>> l = [(True, True), (True, False), (False, True), (False, False)] >>> for p in l: ... p[0] or p[1]

Re: missing 'xor' Boolean operator

2009-07-15 Thread Anthony Tolle
On Jul 14, 2:25 pm, "Dr. Phillip M. Feldman" wrote: > Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to > have an 'xor' operator as well. My $0.02 on this discussion: There would be nothing gained by having non-bitwise XOR operator. You can't short-circuit XOR, because y

Re: missing 'xor' Boolean operator

2009-07-15 Thread Mark Dickinson
On Jul 15, 7:29 pm, Wayne Brehaut wrote: > On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson > wrote: > >I'd also guess that 'xor' would be much less used than 'and' or 'or', > >but maybe that's just a reflection of the sort of code that I tend to > >write. > > You're right about that!. I

Re: missing 'xor' Boolean operator

2009-07-15 Thread Robert Kern
On 2009-07-15 13:29, Wayne Brehaut wrote: On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson wrote: On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" wrote: Current Boolean operators are 'and', 'or', and 'not'. It would be nice to have an 'xor' operator as well. Hmm. I don't think 'nice'

mail

2009-07-15 Thread amrita
Dear all, Sorry that I am disturbing you all again and again but this is the way I am trying to solve my problem:--- >>> import re >>> exp = re.compile("CA") >>> infile = open("file1.txt") >>> for line in infile: ... values = re.split("\s+", line) ... if exp.search(line): ...prin

Re: Catching control-C

2009-07-15 Thread MCIPERF
On Jul 9, 7:28 pm, Miles Kaufmann wrote: > On Jul 9, 2009, at 9:20 AM, Lie Ryan wrote: > > > Michael Mossey wrote: > >> I want to understand better what the "secret" is to responding to a > >> ctrl-C in any shape or form. > > > Are you asking: "when would the python interpreter process > > Keyboar

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson wrote: >On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" >wrote: >> Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to >> have an 'xor' operator as well. > >Hmm. I don't think 'nice' is sufficient. You'd need to make

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

2009-07-15 Thread Miles Kaufmann
On Jul 14, 2009, at 5:06 PM, David Bolen wrote: Are you sure? It seems to restrict them in the same block, but not in the entire file. At least I was able to use both space and tab indented blocks in the same file with Python 3.0 and 3.1. It seems to me that, within an indented block, Python

Re: missing 'xor' Boolean operator

2009-07-15 Thread Dr. Phillip M. Feldman
I did initially ask for an infix xor operator, but eventually gave up on this. I like the first of your two one-line solutions below; this is clean and easy to understand. Thanks! I'd still like to be able to write an expression like '(a and b) xor (c and d) xor (e and f)', but it looks as thou

Re: python first assignment of a global variable

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 1:55 PM, Rodrigue wrote: Basically, I was very surprised to discover that e() raises an exception, but even more that e_raise() points to if not MY_GLOBAL Is the problem not really when I assign? My assumption is that some reordering is happening behind the scenes that creat

Re: missing 'xor' Boolean operator

2009-07-15 Thread Terry Reedy
Tim Golden wrote: I was pondering on this yesterday, and the only case I've come across in my code -- and it's reasonably common -- is checking that one and only one of two params has been passed. I have code which wants, say, an id or a name but doesn't want both. It's hardly difficult to write

Re: python first assignment of a global variable

2009-07-15 Thread Emile van Sebille
On 7/15/2009 10:55 AM Rodrigue said... I came accross a strange behaviour in python today. Here is a simple example to describe my situation: MY_GLOBAL = '' def e_raise(): if not MY_GLOBAL: MY_GLOBAL = 'bla' Traceback (most recent call last): File "glo.py", line 49, in

Re: missing 'xor' Boolean operator

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 1:55 PM, Emile van Sebille wrote: On 7/15/2009 10:43 AM Jean-Michel Pichavant said... Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). Did I make twice the same obvious error ? No -- but in the not(not... example

python first assignment of a global variable

2009-07-15 Thread Rodrigue
Hi all, I came accross a strange behaviour in python today. Here is a simple example to describe my situation: MY_GLOBAL = '' def a(): print 'global is: ', MY_GLOBAL def b(): try: MY_GLOBAL += 'bla' except Exception, e: print 'b: ', e def c(): try: globa

Re: missing 'xor' Boolean operator

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 1:43 PM, Jean-Michel Pichavant wrote: Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). >>> l = [(True, True), (True, False), (False, True), (False, False)] >>> for p in l: ... p[0] or p[1] [snip] Did I make twic

Re: missing 'xor' Boolean operator

2009-07-15 Thread Emile van Sebille
On 7/15/2009 10:43 AM Jean-Michel Pichavant said... Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). >>> l = [(True, True), (True, False), (False, True), (False, False)] >>> for p in l: ... p[0] or p[1] ... True True True False

Re: Python Equivalent for dd & fold

2009-07-15 Thread Emile van Sebille
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:] You might still need to tweak the above code as regards ho

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). >>> l = [(True, True), (True, False), (False, True), (False, False)] >>> for p in l: ... p[0] or p[1] ... True True True False >>> for p in l: ... not(not p[0] and not p[1]) ... T

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Wed, 15 Jul 2009 13:37:22 +0200, Christian Heimes wrote: >pdpi wrote: >> On Jul 15, 12:08 am, 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 >>> >>> I

Re: missing 'xor' Boolean operator

2009-07-15 Thread Paul Rubin
Hrvoje Niksic writes: > > While everyone's trying to tell the OP how to workaround the missing > > xor operator, nobody answered the question "why is there no [boolean] > > xor operator ?". > > Probably because there isn't one in C. The bitwise XOR operator, on the > other hand, exists in both C

Re: Python Equivalent for dd & fold

2009-07-15 Thread MRAB
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 indeed. Really that long? Indeed." fold(s,10) Output: A

Re: Python Equivalent for dd & fold

2009-07-15 Thread seldan24
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 indeed. Really that long? Indeed." > fold(s,10) > > Output:

Re: missing 'xor' Boolean operator

2009-07-15 Thread Hrvoje Niksic
Jean-Michel Pichavant writes: > While everyone's trying to tell the OP how to workaround the missing > xor operator, nobody answered the question "why is there no [boolean] > xor operator ?". Probably because there isn't one in C. The bitwise XOR operator, on the other hand, exists in both C an

Re: How to keep a function as a generator function when the yield operator is moved into its sub-functions??

2009-07-15 Thread weafon
Hi DaveA, Thank for your responses even though my problem has been solved based on Miles' suggestion. I am writing programs by using the SimPy library, which is a discrete-event simulator library. Below is my actual code segment class RAID(Process): def ReqServ(self): while(now()In

Re: Python Equivalent for dd & fold

2009-07-15 Thread Michiel Overtoom
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 indeed. Really that long? Indeed." fold(s,10) Output: A very lon g string i ndeed. Rea lly that l ong? Indee d. Greeting

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Ethan Furman
John Machin wrote: If dbfpy can't handle any new-fangled stuff you may have in your files, drop me a line ... I have a soon-to-be released DBF module that should be able to read the "new" stuff up to dBase7 and VFP9, including memo files, conversion from whatever to Unicode if needed, ... Cheer

Re: select lines in python

2009-07-15 Thread Rhodri James
On Tue, 14 Jul 2009 20:10:32 +0100, wrote: Can i become more precise like instead of printing all lines for PHE and ASP is it possible that for PHE python will print only those lines which will have information about H and HA and for ASP it will print those lines which will have information

Python Equivalent for dd & fold

2009-07-15 Thread seldan24
Hello, I have a shell script, that I'm attempting to convert to Python. It FTP's files down from an AS/400 machine. That part is working fine. Once the files arrive, the script converts them from EBCDIC to ASCII and then formats their line width based on a pre-determined size. For example, if I

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread John Machin
On Jul 15, 8:39 pm, David Lyon wrote: > On Wed, 15 Jul 2009 11:53:28 +0200, Helmut Jarausch > > wrote: > > Hi, > > > I have a lot of old Dbase files (.dbf) and I'll like to convert these > > to SQLite databases as automatically as possible. > > Does anybody know a tool/Python script to do so? > >

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Ethan Furman
Helmut Jarausch wrote: Hi, I have a lot of old Dbase files (.dbf) and I'll like to convert these to SQLite databases as automatically as possible. Does anybody know a tool/Python script to do so? I know, I could use dbfpy and create the SQLite table and import all data. But is there something e

Python-URL! - weekly Python news and links (Jul 15)

2009-07-15 Thread Gabriel Genellina
QOTW: "Everyone gets so caught up in programming via languages that you get, well, people trying to teach 'Computer Programming' as if it were only necessary to grok a language, rather than grokking /symbol manipulation/ itself." - Simon Forman http://groups.google.com/group/comp.lang.python/m

Re: import module unbelieveable behaviour

2009-07-15 Thread Diez B. Roggisch
Peter Fodrek wrote: > Dear conference! > > I have test Why python based script for HeeksCNC post-processing does not > work... And I've got unbelievable behavior When importing module module > manually it works, but same opertaion from script does not > work as seen > > /opt/HeeksCAD8/HeeksCN

Re: missing 'xor' Boolean operator

2009-07-15 Thread Robert Kern
On 2009-07-15 10:15, 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): if bool(a) + bool(b) + bool(c) + b

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

2009-07-15 Thread skip
JM> By the way why would you prevent us from using tabs for indenting ? JM> If I'm not wrong, from a semantic point of view, that's what tabs JM> are for: indenting. Spaces are meant to separate tokens, aren't they JM> ? I love my tabs, don't take them away from me ! I don't thin

Re: Best Way to Handle All Exceptions

2009-07-15 Thread Jean
On Jul 13, 6:26 am, seldan24 wrote: > Hello, > > I'm fairly new at Python so hopefully this question won't be too > awful.  I am writing some code that will FTP to a host, and want to > catch any exception that may occur, take that and print it out > (eventually put it into a log file and perform

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
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): if bool(a) + bool(b) + bool(c) + bool(d) != 1: raise ValueError("

Re: Colour of output text

2009-07-15 Thread Jean-Michel Pichavant
Nobody wrote: On Fri, 10 Jul 2009 09:23:54 +, garabik-news-2005-05 wrote: I would like to learn a way of changing the colour of a particular part of the output text. I've tried the following On Unix operating systems this would be done through the curses interface: http://docs

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

2009-07-15 Thread Jean-Michel Pichavant
John Nagle wrote: walterbyrd wrote: I believe Guido himself has said that all indentions should be four spaces - no tabs. Since backward compatibility is being thrown away anyway, why not enforce the four space rule? At least that way, when I get python code from somebody else, I would know wh

Re: import module unbelieveable behaviour

2009-07-15 Thread Tycho Andersen
On Wed, Jul 15, 2009 at 8:12 AM, Peter Fodrek wrote: > > Would anyone be helpful for me to get more information about this problem > because  pydb does not show anything usable for me,please? What is the directory structure for the HeeksCNC module? Although I'm no expert, I suspect it looks someth

Re: missing 'xor' Boolean operator

2009-07-15 Thread Bill Davy
"MRAB" wrote in message news:mailman.3158.1247667680.8015.python-l...@python.org... > Steven D'Aprano wrote: >> On Tue, 14 Jul 2009 11:25:08 -0700, Dr. Phillip M. Feldman wrote: >> >>> Current Boolean operators are 'and', 'or', and 'not'. It would be nice >>> to have an 'xor' operator as well. >

Re: [Python-projects] [TIP] Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread Aurélien Campéas
On Wed, Jul 15, 2009 at 09:22:11AM -0500, s...@pobox.com wrote: > > Nicolas> Here is the ticket: > Nicolas> https://www.logilab.net/elo/ticket/9634 > > Is it possible to get read-only access to the tracker? It's prompting me > for a login which I don't have. > > Thx, that should be htt

Re: promlems with threading and print

2009-07-15 Thread Piet van Oostrum
> Piet van Oostrum (PvO) wrote: >PvO> def run(self): >PvO> with lock: All the 'with lock:' lines should have been 'with self.lock:' but as lock is also a global variable, it did work. Of course you can decide to use only the global variable and get rid of the self.lock altogether

Re: [Python-projects] [TIP] Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread skip
Nicolas> Here is the ticket: Nicolas> https://www.logilab.net/elo/ticket/9634 Is it possible to get read-only access to the tracker? It's prompting me for a login which I don't have. Thx, -- Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/ when i wake up with a heart r

  1   2   >