Re: Python & Go

2009-11-12 Thread Patrick Sabin
kj wrote: I'm just learning about Google's latest: the GO (Go?) language. (e.g. http://golang.org or http://www.youtube.com/watch?v=rKnDgT73v8s). There are some distinctly Pythonoid features to the syntax, such as "import this_or_that", the absence of parentheses at the top of flow control const

Re: python with echo

2009-11-12 Thread Hans Mulder
Steven D'Aprano wrote: On Wed, 11 Nov 2009 17:24:37 -0800, hong zhang wrote: List, I have a question of python using echo. POWER = 14 return_value = os.system('echo 14 > /sys/class/net/wlan1/device/tx_power') can assign 14 to tx_power But return_value = os.system('echo $POWER > /sys/class/n

Re: New syntax for blocks

2009-11-12 Thread Bruno Desthuilliers
r a écrit : -snip) > Just thinking out loud here...what if variable assignments could > return a value... hmmm? Not to them selfs of course but to a caller, > like an if statement... > > if a=openfile: > # do something with a Congratulations, you just reinvented one of the most infamous source

JSR223 Access Python class instances through Java

2009-11-12 Thread Jared Klumpp
I am trying to access (from Java) a python class that extends a Java interface. The following program runs fine in the jython console (I can instantiate Tada, call t.getName() and everything prints correctly.) However, if I invoke test1() from Java using JSR223, the returned object is inaccessible

Re: New syntax for blocks

2009-11-12 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : (snip) > Hint to would-be language designers: if you start off by claiming that a > new feature will save an indent level, when in fact it *doesn't* save an > indent level, you can save yourself from embarrassment by pressing Close > on your post instead of Send. Mouaa

Re: New syntax for blocks

2009-11-12 Thread Bruno Desthuilliers
r a écrit : > On Nov 11, 2:37 am, Steven D'Aprano > wrote: >> On Wed, 11 Nov 2009 00:08:58 -0800, r wrote: > >>> Yea it's called a NameError. Would it not also blow up in the current >>> state of syntax usage? >> No. >> >>> if var: >>> print 'var' >>> Traceback (most recent call last): >>>

Re: Python & Go

2009-11-12 Thread Grant Edwards
On 2009-11-12, Patrick Sabin wrote: > kj wrote: >> >> I'm just learning about Google's latest: the GO (Go?) language. >> (e.g. http://golang.org or http://www.youtube.com/watch?v=rKnDgT73v8s). >> There are some distinctly Pythonoid features to the syntax, such >> as "import this_or_that", the abs

open source linux -> windows database connectivity?

2009-11-12 Thread Tony Schmidt
I am trying to read a Pervasive database on a Windows machine from a Python script on a Linux machine. I understand that this can be done with a proprietary ODBC-to-ODBC bridge called mxODBC or Easysoft OOB. Is there anyway to do this with existing free/ open source tools? Thanks in advance for

ANN: ActivePython 2.6.4.8 is now available

2009-11-12 Thread Sridhar Ratnakumar
I'm happy to announce that ActivePython 2.6.4.8 is now available for download from: http://www.activestate.com/activepython/ This is a patch release that updates ActivePython to core Python 2.6.4. We recommend that you try 2.6 version first. See the release notes for full details: http:

Re: 3.x and 2.x on same machine (is this info at Python.org??)

2009-11-12 Thread rantingrick
On Nov 12, 2:51 pm, Terry Reedy wrote: > rantingrick wrote: > > Hello, > > > Currently i am using 2.6 on Windows and need to start writing code in > > 3.0. I cannot leave 2.x yet because 3rd party modules are still not > > converted. So i want to install 3.0 without disturbing my current > > Pytho

Re: python with echo

2009-11-12 Thread Christian Heimes
Diez B. Roggisch wrote: > with open("/sys/class/net/wlan1/device/tx_power", "w") as f: > f.write("%i" % POWER) IIRC the sys and proc virtual file system requires new line at the end of a modifier. At least echo appends \n unless it's told otherwise. Christian -- http://mail.python.org/mail

Re: open source linux -> windows database connectivity?

2009-11-12 Thread M.-A. Lemburg
Tony Schmidt wrote: > I am trying to read a Pervasive database on a Windows machine from a > Python script on a Linux machine. > > I understand that this can be done with a proprietary ODBC-to-ODBC > bridge called mxODBC or Easysoft OOB. The product is called "mxODBC Connect" and allows connectin

Re: New syntax for blocks

2009-11-12 Thread r
On Nov 12, 2:37 pm, Bruno Desthuilliers wrote: > > Oh i get it now! If i assign a valid value to a variable the variable > > is also valid...thats...thats... GENUIS! *sarcasm* > > It's not about "assigning a valid value to a variable", it's about the > name being created (or not) in the current n

Linux, Python 2.5.2, serverless binding LDAP?

2009-11-12 Thread Kevin Cole
Hi, I recently asked our IT department how to gain access to an addressbook. After carefully explaining that I was on a Linux system using Python, I got the reply: "You should use our LDAP. With LDAP you can pull any data you want from Active Directory. On our network, the serverless binding add

Re: Linux, Python 2.5.2, serverless binding LDAP?

2009-11-12 Thread alex23
On Nov 13, 10:47 am, Kevin Cole wrote: > Hi, > > I recently asked our IT department how to gain access to an > addressbook.  After carefully explaining that I was on a Linux system > using Python, I got the reply: > > "You should use our LDAP. With LDAP you can pull any data you want > from Active

Re: Linux, Python 2.5.2, serverless binding LDAP?

2009-11-12 Thread Kevin Cole
On Nov 12, 8:01 pm, alex23 wrote: > On Nov 13, 10:47 am, Kevin Cole wrote: > > > > > Hi, > > > I recently asked our IT department how to gain access to an > > addressbook.  After carefully explaining that I was on a Linux system > > using Python, I got the reply: > > > "You should use our LDAP. W

Re: python parser overridden by pymol

2009-11-12 Thread Jeremiah H. Savage
On Wed, Nov 11, 2009 at 7:48 PM, Dave Angel wrote: > > > Jeremiah wrote: >> >> Hello, >> >> I'm fairly new to python (version 2.5.4), and am writing a program >> which uses both pymol (version 1.2r1) and numpy (version 1.3.0) from >> debian. >> >> It appears that when I add pymol to $PYTHONPATH, t

Re: Linux, Python 2.5.2, serverless binding LDAP?

2009-11-12 Thread Kevin Cole
On Nov 12, 8:01 pm, alex23 wrote: > On Nov 13, 10:47 am, Kevin Cole wrote: > > > > > Hi, > > > I recently asked our IT department how to gain access to an > > addressbook.  After carefully explaining that I was on a Linux system > > using Python, I got the reply: > > > "You should use our LDAP. W

Re: New syntax for blocks

2009-11-12 Thread Steven D'Aprano
On Thu, 12 Nov 2009 21:27:31 +0100, Bruno Desthuilliers wrote: > Congratulations, you just reinvented one of the most infamous source of > bugs in C, C++, Java, PHP, javascript and quite a few other languages. > Believe it or not, but not allowing this in Python was a very deliberate > design choi

Re: python with echo

2009-11-12 Thread Steven D'Aprano
On Thu, 12 Nov 2009 19:30:01 +, MRAB wrote: >> I don't understand that. Exit status codes on all systems I'm familiar >> with are limited to 0 through 255. What operating system are you using? >> >> Assuming your system allows two-byte exit statuses, you should check >> the documentation for

Re: open source linux -> windows database connectivity?

2009-11-12 Thread Tony Schmidt
>Note: The client part of this product is free. You only need to >get a license for the server part. Yeah, but don't I need the server part to make the connection? Would it be possible to use Jython and the Pervasive JDBC driver for this? On Nov 12, 2:56 pm, "M.-A. Lemburg" wrote: > Tony Schmid

Re: QuerySets in Dictionaries

2009-11-12 Thread Steven D'Aprano
On Thu, 12 Nov 2009 10:39:33 -0800, scoopseven wrote: > I need to create a dictionary of querysets. I have code that looks > like: > > query1 = Myobject.objects.filter(status=1) > query2 = Myobject.objects.filter(status=2) > query3 = Myobject.objects.filter(status=3) > > d={} > d['a'] = query

Re: python with echo

2009-11-12 Thread MRAB
Steven D'Aprano wrote: On Thu, 12 Nov 2009 19:30:01 +, MRAB wrote: I don't understand that. Exit status codes on all systems I'm familiar with are limited to 0 through 255. What operating system are you using? Assuming your system allows two-byte exit statuses, you should check the documen

Re: Writing an emulator in python - implementation questions (for performance)

2009-11-12 Thread greg
Santiago Romero wrote: How about page, index = divmod(address, 16384) Surely, much better and faster :-) Not necessarily, because it involves a function call, and constructing and deconstructing a result tuple. If you time them, you may well find that the explicit shift and mask operation

Re: python parser overridden by pymol

2009-11-12 Thread Robert Kern
Jeremiah H. Savage wrote: To use pymol and numpy together, I now do the following: To ~/.bashrc add: PYMOL_PATH=/usr/lib/pymodules/python2.5/pymol export PYMOL_PATH Then I can do the following in python: import numpy numpy.save('123',numpy.array([1,2,3])) numpy.

Re: python simply not scaleable enough for google?

2009-11-12 Thread Steven D'Aprano
On Thu, 12 Nov 2009 21:02:11 +0100, Alf P. Steinbach wrote: > Specifically, I reacted to the statement that < talk about "the" speed of an implementation>>, made in response to > someone upthread, in the context of Google finding CPython overall too > slow. > > It is quite slow. ;-) Quite slow t

Re: Writing an emulator in python - implementation questions (for performance)

2009-11-12 Thread Steven D'Aprano
On Fri, 13 Nov 2009 15:29:03 +1300, greg wrote: > Generally, I think you're going to have quite a battle on your hands to > get a pure Python implementation to run as fast as a real Z80, if it's > even possible at all. And if you do succeed, the code will be pretty > awful (due to things such as n

Re: Python & Go

2009-11-12 Thread Paul Rubin
Duncan Booth writes: > > http://scienceblogs.com/goodmath/2009/11/googles_new_language_go.php > > > Thanks for that link. I think it pretty well agrees with my first > impressions of Go: It looks like a not-so-interesting C follow-on, but the article doesn't describe any of the parallelism stuf

Re: Writing an emulator in python - implementation questions (for performance)

2009-11-12 Thread Steven D'Aprano
On Fri, 13 Nov 2009 15:33:53 +1300, greg wrote: > Santiago Romero wrote: >>>How about >>>page, index = divmod(address, 16384) >> >> Surely, much better and faster :-) > > Not necessarily, because it involves a function call, and constructing > and deconstructing a result tuple. If you time t

Re: Writing an emulator in python - implementation questions (for performance)

2009-11-12 Thread greg
Carl Banks wrote: You can define constants to access specific registers: R1L = 1 R1H = 2 R1 = 1 breg[R1H] = 2 print wreg[R1] But keep in mind that named "constants" at the module level are really global variables, and therefore incur a dictionary lookup every time they're used. For maximum s

Re: #define (from C) in Python

2009-11-12 Thread greg
TerryP wrote: If it's such a big hairy deal, just recompile a copy of the C Pre Processor to use something other then #, and hook it up to your python scripts in a pipe line from a shell wrapper. Or use a different preprocessor, such as m4, that doesn't clash with the # character. -- Greg -- h

Re: Does turtle graphics have the wrong associations?

2009-11-12 Thread Peter Nilsson
"Alf P. Steinbach" wrote: > One reaction to http://preview.tinyurl.com/ProgrammingBookP3> has > been that turtle graphics may be off-putting to some > readers because it is associated with children's learning. [I'll be honest and say that I merely glanced at the two pdf files.] Who is your targe

Re: ANN: esky 0.2.1

2009-11-12 Thread Aahz
In article , Ryan Kelly wrote: > >Esky is an auto-update framework for frozen python apps, built on top of >bbfreeze. It provides a simple API through which apps can find, fetch >and install updates, and a bootstrapping mechanism that keeps the app >safe in the face of failed or partial updates.

Python 2.6 and sys.exit()

2009-11-12 Thread H Krishnan
Hello, I have the following in exit.py: import sys sys.exit(0) I now try 'python -i exit.py': In 2.5, the script exits as I would expect. In 2.6, the following error is printed: Traceback (most recent call last): File "exit.py", line 2, in sys.exit(0) SystemExit: 0 >>> I couldn't find

Re: python parser overridden by pymol

2009-11-12 Thread Dave Angel
Robert Kern wrote: Jeremiah H. Savage wrote: To use pymol and numpy together, I now do the following: To ~/.bashrc add: PYMOL_PATH=/usr/lib/pymodules/python2.5/pymol export PYMOL_PATH Then I can do the following in python: import numpy numpy.save('123',numpy.arra

Re: ANN: esky 0.2.1

2009-11-12 Thread Ryan Kelly
> >Esky is an auto-update framework for frozen python apps, built on top of > >bbfreeze. It provides a simple API through which apps can find, fetch > >and install updates, and a bootstrapping mechanism that keeps the app > >safe in the face of failed or partial updates. > > Recently I was looki

2.6 and sys.exit()

2009-11-12 Thread hetchkay
Hello, I have the following in exit.py: import sys sys.exit(0) I now try 'python -i exit.py': In 2.5, the script exits as I would expect. In 2.6, the following error is printed: Traceback (most recent call last): File "exit.py", line 2, in sys.exit(0) SystemExit: 0 >>> I couldn't find

Re: New syntax for blocks

2009-11-12 Thread r
On Nov 12, 7:44 pm, Steven D'Aprano wrote > Oh, but those hundreds of thousands of man-hours lost to bugs caused by > assignment-as-an-expression is nothing compared to the dozens of man- > minutes saved by having one fewer line of code! OK, what *if* the variable would only be valid in *that* bl

Re: 2.6 and sys.exit()

2009-11-12 Thread r
On Nov 12, 10:07 pm, hetchkay wrote: > Hello, > > I have the following in exit.py: > import sys > sys.exit(0) > > I now try 'python -i exit.py': > > In 2.5, the script exits as I would expect. > > In 2.6, the following error is printed: > > Traceback (most recent call last): >   File "exit.py", li

Re: 2.6 and sys.exit()

2009-11-12 Thread r
PS: Python even answers questions: >>> import sys >>> help(sys.exit) Help on built-in function exit in module sys: exit(...) exit([status]) Exit the interpreter by raising SystemExit(status). If the status is omitted or None, it defaults to zero (i.e., success). If the status is

Re: 2.6 and sys.exit()

2009-11-12 Thread hetchkay
Hello, Thanks for your help. I know what SystemExit is. In 2.5 as well SystemExit is raised when sys.exit() is called. For example: try: import sys sys.exit(0) except SystemExit: print "system exit raised" raise But I don't understand why the interpreter does not exit in 2.6 but does exi

how to install python-spidermonkey on windows

2009-11-12 Thread elca
Hello all, im making some script with python mechanize, one of problem is it really hard to find which support javascript supported web client scraping or crawler. actually i was found some such as python-spidermonkey and pykhtml and so on. but most of all only support on linux . i want to make my

Re: 2.6 and sys.exit()

2009-11-12 Thread John Yeung
On Nov 12, 11:22 pm, r wrote: > On Nov 12, 10:07 pm, hetchkay wrote: > > I have the following in exit.py: > > import sys > > sys.exit(0) > > > I now try 'python -i exit.py': > > > In 2.5, the script exits as I would expect. > > > In 2.6, the following error is printed: > > > Traceback (most recen

Re: 2.6 and sys.exit()

2009-11-12 Thread John Yeung
On Nov 12, 11:32 pm, hetchkay wrote: > But I don't understand why the interpreter does not exit in 2.6 but > does exit in 2.5. Well, I do not need to understand that but I need to > know how to get the interpreter to exit in 2.6. Well, taken at face value, I would say the answer is to not use the

Re: Writing an emulator in python - implementation questions (for performance)

2009-11-12 Thread Carl Banks
On Nov 12, 6:37 am, Santiago Romero wrote: > > >  I'm trying to port (just for fun), my old Sinclair Spectrum emulator, > > > ASpectrum, from C to Python + pygame. > > > The answer to your question is, "Use numpy".  More details below. > >  Let's see :-) > > > >  How can I implement this in Python

Re: 2.6 and sys.exit()

2009-11-12 Thread Ned Deily
In article <008aa7ef-b945-4f70-b5e4-def66546e...@2g2000prl.googlegroups.com>, hetchkay wrote: > I have the following in exit.py: > import sys > sys.exit(0) > > I now try 'python -i exit.py': > > In 2.5, the script exits as I would expect. > > In 2.6, the following error is printed: > > Trace

Re: Writing an emulator in python - implementation questions (for performance)

2009-11-12 Thread Carl Banks
On Nov 12, 6:29 pm, greg wrote: > I would be taking a different approach -- develop a prototype > in Python, concentrating on clarity rather than speed, and > later reimplement the core of the emulator as an extension > module, using Pyrex or Cython or otherwise. But keep in mind he said he was d

Re: regex remove closest tag

2009-11-12 Thread S.Selvam
On Fri, Nov 13, 2009 at 12:47 AM, MRAB wrote: > S.Selvam wrote: > >> Hi all, >> >> >> 1) I need to remove the tags which is just before the keyword(i.e >> some_text2 ) excluding others. >> >> 2) input string may or may not contain tags. >> >> 3) Sample input: inputstr = """start > href="so

Re: 2.6 and sys.exit()

2009-11-12 Thread hetchkay
On Nov 13, 9:50 am, John Yeung wrote: > On Nov 12, 11:22 pm, r wrote: > > > > > On Nov 12, 10:07 pm, hetchkay wrote: > > > I have the following in exit.py: > > > import sys > > > sys.exit(0) > > > > I now try 'python -i exit.py': > > > > In 2.5, the script exits as I would expect. > > > > In 2.6

Re: python simply not scaleable enough for google?

2009-11-12 Thread Vincent Manis
When I was approximately 5, everybody knew that higher level languages were too slow for high-speed numeric computation (I actually didn't know that then, I was too busy watching Bill and Ben the Flowerpot Men), and therefore assembly languages were mandatory. Then IBM developed Fortran, and hig

Re: 2.6 and sys.exit()

2009-11-12 Thread hetchkay
On Nov 13, 10:28 am, hetchkay wrote: > On Nov 13, 9:50 am, John Yeung wrote: > > > > > On Nov 12, 11:22 pm, r wrote: > > > > On Nov 12, 10:07 pm, hetchkay wrote: > > > > I have the following in exit.py: > > > > import sys > > > > sys.exit(0) > > > > > I now try 'python -i exit.py': > > > > > In

Re: 3.x and 2.x on same machine (is this info at Python.org??)

2009-11-12 Thread Dan Bishop
On Nov 12, 1:52 pm, rantingrick wrote: > Hello, > > Currently i am using 2.6 on Windows and need to start writing code in > 3.0. I cannot leave 2.x yet because 3rd party modules are still not > converted. So i want to install 3.0 without disturbing my current > Python2.x. What i'm afraid of is tha

Re: Does turtle graphics have the wrong associations?

2009-11-12 Thread Vincent Manis
On 2009-11-12, at 11:36, AK Eric wrote: > On Nov 12, 11:31 am, Terry Reedy wrote: >> Alf P. Steinbach wrote: >>> One reaction to >> http://preview.tinyurl.com/ProgrammingBookP3> has been that turtle >>> graphics may be off-putting to some readers because it is associated >>> with children's learni

Re: New syntax for blocks

2009-11-12 Thread Stephen Hansen
On Thu, Nov 12, 2009 at 8:10 PM, r wrote: > On Nov 12, 7:44 pm, Steven D'Aprano cybersource.com.au> wrote > > Oh, but those hundreds of thousands of man-hours lost to bugs caused by > > assignment-as-an-expression is nothing compared to the dozens of man- > > minutes saved by having one fewer li

Re: Does turtle graphics have the wrong associations?

2009-11-12 Thread Raymond Hettinger
On Nov 11, 10:21 pm, "Alf P. Steinbach" wrote: > One reaction to http://preview.tinyurl.com/ProgrammingBookP3> has > been that turtle graphics may be off-putting to some readers because it is > associated with children's learning. > > What do you think? How about calling it Raptor Graphics that w

Re: Does turtle graphics have the wrong associations?

2009-11-12 Thread Vincent Manis
On 2009-11-12, at 19:13, Peter Nilsson wrote: > My recollection is that many children struggled with Turtle > graphics because they had very little concept of trigonometry. > [Why would they? Many wouldn't learn for another 2-10 years.] > Adults tend to have even less concept since they almost neve

Re: python simply not scaleable enough for google?

2009-11-12 Thread Steven D'Aprano
On Thu, 12 Nov 2009 22:20:11 -0800, Vincent Manis wrote: > When I was approximately 5, everybody knew that higher level languages were > too slow for high-speed numeric computation (I actually didn't know that > then, I was too busy watching Bill and Ben the Flowerpot Men), and therefore > asse

Re: python simply not scaleable enough for google?

2009-11-12 Thread Vincent Manis
On 2009-11-12, at 23:19, Steven D'Aprano wrote: > On Thu, 12 Nov 2009 22:20:11 -0800, Vincent Manis wrote: > > Vincent, could you please fix your mail client, or news client, so > that it follows the standard for mail and news (that is, it has a > hard-break after 68 or 72 characters? My apologi

Re: Does turtle graphics have the wrong associations?

2009-11-12 Thread Alf P. Steinbach
* Raymond Hettinger: On Nov 11, 10:21 pm, "Alf P. Steinbach" wrote: One reaction to http://preview.tinyurl.com/ProgrammingBookP3> has been that turtle graphics may be off-putting to some readers because it is associated with children's learning. What do you think? How about calling it Raptor

<    1   2