Re: Large algorithm issue -- 5x5 grid, need to fit 5 queens plus some squares

2006-03-17 Thread Tim Roberts
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >Background: >The problem I'm trying to solve is. >There is a 5x5 grid. >You need to fit 5 queens on the board such that when placed there are >three spots left that are not threatened by the queen. I know this wasn't a contest, but here's my solutio

Re: python newbie, linux novice, needs to run spamassassin

2006-03-17 Thread David Dorward
Lonnie Princehouse wrote: > * at this point someone will probably chime in saying it's possible to > rig spamassassin with a bayesian filter It is on by default AFAIK. -- David Dorward Home is where the ~/.bashrc

split() can help to read UTF-16 encoded file without codecs support, why?

2006-03-17 Thread Zhongjian Lu
Hi Guys, I was processing a UTF-16 coded file with BOM and was not aware of the codecs package at first. I wrote the following code: = Code 1 for i in open("d:\python24\lzjtest.xml", 'r').readlines(): i = i.decode("utf-16") print i ==

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread Fuzzyman
Roedy Green wrote: > On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <[EMAIL PROTECTED]> wrote, > quoted or indirectly quoted someone who said : > > >e. For example, the in-fix > >notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >= > >=E2=80=9D, where the > > Not that Mr. Lee has

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread Dinko Tenev
Roedy Green wrote: > On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <[EMAIL PROTECTED]> wrote, > quoted or indirectly quoted someone who said : > > >e. For example, the in-fix > >notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >= > >=E2=80=9D, where the > > Not that Mr. Lee has

Re: split() can help to read UTF-16 encoded file without codecs support, why?

2006-03-17 Thread Fuzzyman
Zhongjian Lu wrote: > Hi Guys, > > I was processing a UTF-16 coded file with BOM and was not aware of the > codecs package at first. I wrote the following code: > = Code 1 > for i in open("d:\python24\lzjtest.xml", 'r').readlines(): > i = i.decode("utf-16") > print

Re: comparing huge files

2006-03-17 Thread Frithiof Andreas Jensen
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > thanks for the reply, > I have used another method to solve my problem. ie > 1) get the total count of the first file > 2) write this total count to basecnt eg basecnt > 3) get another file, get the total count of this file. eg filecnt

Re: "pow" (power) function

2006-03-17 Thread Paul Rubin
"Russ" <[EMAIL PROTECTED]> writes: > I just did a little time test (which I should have done *before* my > original post!), and 2.0**2 seems to be about twice as fast as > pow(2.0,2). That seems consistent with your claim above...> > I just did another little time test comparing 2.0**0.5 with sqrt

Pythonic debugging - Re: Python Debugger / IDE ??

2006-03-17 Thread robert
bruno at modulix wrote: > [EMAIL PROTECTED] wrote: > >>Is there any editor or IDE in Python (either Windows or Linux) which >>has very good debugging facilites like MS VisualStudio has or something >>like that. >> >>I like SPE but couldn't easily use winPDP. I need tips to debug my code >>easily.

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Dinko Tenev
Heh, here's a Prolog version: == gen( _, 0, [] ) :- !. gen( S, N, [H | T] ) :- member( H, S ), M is N - 1, gen( S, M, T ). == Yep, that's it :))) Here's how to test it:

Re: How to search XML? Are there special libs?

2006-03-17 Thread Diez B. Roggisch
Sullivan WxPyQtKinter wrote: > I am now using XML to record my lab records in quite a complex way, in > which about 80 tags are used to identify different types of data. I > think it is a good idea to search for a popular and mature XML search > engine before I started to program it myself: > >

Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Julien Fiore
Hi, I wrote a function to compute openness (a digital elevation model attribute). The function opens the gdal-compatible input raster and reads the values in a square window around each cell. The results are stored in a "1 line buffer". At the end of the line, the buffer is written to the output ra

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Tomasz Zielonka
Dan Piponi wrote: > Is this Haskell implementation what you want? It does the wildcard > matching through a state machine and it essentially threads the > state machine through the cartesian product, switching to the > ordinary cartesian product when possible as an optimisation. > The execution of

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Tomasz Zielonka
[EMAIL PROTECTED] wrote: > -- The states are lists of regular expressions > -- where [a,b,..] means match a or b or... > > I haven't run or studied your program yet myself but what I had in mind > was that the list of wc's are *all* to be excluded, so the list > [wc1..wcn] is to correspond generati

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread Timo Stamm
Fuzzyman schrieb: > Roedy Green wrote: >> On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <[EMAIL PROTECTED]> wrote, >> quoted or indirectly quoted someone who said : >> >>> e. For example, the in-fix >>> notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >= >>> =E2=80=9D, where the

Re: How to search XML? Are there special libs?

2006-03-17 Thread Ravi Teja
Yes! XPath is a good bet. You can also try some Pythonic XML libraries like Amara. You need not learn any special language even. There are good database approaches to XML too, especially if you are going to query a document collection as a whole rather than file by file. You can try XQuery. I thin

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread [EMAIL PROTECTED]
You may be interested in, or already know about http://www.lambdassociates.org/ http://www.lambdassociates.org/aboutqi.htm http://www.lambdassociates.org/webbook/contents.htm http://www.lambdassociates.org/prolog.htm Let me know what you think. -- http://mail.python.org/mailman/listinfo/python-

Re: A Frame-space syntax ? - Re: global, globals(), _global ?

2006-03-17 Thread robert
Alex Martelli wrote: > robert <[EMAIL PROTECTED]> wrote: >... > >>>Not sure I entirely understand what you're proposing, but locals access >>>must remain compile-time-optimized for crucial practical reasons, so >>>"writing to locals()" just will not work right. >> >>Why will a definite write

Re: can httplib.HTTPConnection use proxy?

2006-03-17 Thread robert
JuHui wrote: > sorry, would you please give a sample code? > I want to use HTTPConnection to get a html page content via a http > proxy. > thanks. > -> adam and maybe you just want plain GET/POST. use urllib >>> url='http://www.google.ca' >>> urllib.FancyURLopener(proxies={'http':'http://vs

Using yacas within Python for symbolis computation

2006-03-17 Thread JCDenton
Hi group! I am not sure if I am at the right place with my question so I welcome any link. I found that one can build yacas as a python module on the www.koders.com" The python setup.py build and python setup.py install went well so far. I modigied the setup.py script a little bit since it was wr

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread [EMAIL PROTECTED]
It would seem that your program is just filtering the full cartesian product, right? The solution I'm looking for generates the elements one-by-one so that it could be used in a loop. -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting nested loop iterations

2006-03-17 Thread Joel Hedlund
> for index, color in enumerate(color > for animal in zoo > for color in animal): > # the something more goes here. > pass I've been thinking about these nested generator expressions and list comprehensions. How come we write: a

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread axel
In comp.lang.perl.misc Timo Stamm <[EMAIL PROTECTED]> wrote: > Fuzzyman schrieb: >> Roedy Green wrote: >>> On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <[EMAIL PROTECTED]> wrote, >>> quoted or indirectly quoted someone who said : >>> e. For example, the in-fix notation =E2=80=9C(3+(2*5))>7=E2

Re: Python / glade fundamentals

2006-03-17 Thread Doug
OK, I have solved the problem. The reference was a help. The clue is that the events may not get passed through the parent. For reference here is the code that worked. It's good to finally get the basics working. Doug import gtk import gtk.glade def key_press(widget,event): print "keypress"

Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-17 Thread Joel Hedlund
>>This "release" is as alpha as alpha gets. It's so alpha it >>actually loops back around to zeta -- but it's a start, and I >>think it's exactly what the Python community needs. > > > Not to pick nits, but that should actually be "... so alpha that it actually > loops back around to *OMEGA*." >

Detecting arguments of a function - possible?

2006-03-17 Thread Chance Ginger
I am trying to write a tool to examine a function (I'd like it to work with pyc files only). So here are a few questions I have; any pointers would be very welcome. Can I determine the number of arguments required of a function? Is there a way to detect is the function will throw an exception (I

Re: Counting nested loop iterations

2006-03-17 Thread Fredrik Lundh
Joel Hedlund wrote: > I've been thinking about these nested generator expressions and list > comprehensions. How come we write: > > a for b in c for a in b > > instead of > > a for a in b for b in c > > More detailed example follows below. > > I feel the latter variant is more intuitive. Could any

Re: Python / glade fundamentals

2006-03-17 Thread Ido Yehieli
Hi Doug, mabe you will find it easyer to use GladeGen to generate the skeleton of your application rather then coding it yourself. Take a look here: http://www.linuxjournal.com/article/7421 Cheers, Ido Yehieli -- http://mail.python.org/mailman/listinfo/python-list

Re: Python / glade fundamentals

2006-03-17 Thread Ido Yehieli
Hi Doug, maybe you will find it easyer to use GladeGen to generate the skeleton of your application rather then coding it yourself. Take a look here: http://www.linuxjournal.com/article/7421 Cheers, Ido Yehieli -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting arguments of a function - possible?

2006-03-17 Thread Kent Johnson
Chance Ginger wrote: > I am trying to write a tool to examine a function (I'd like it > to work with pyc files only). So here are a few questions I > have; any pointers would be very welcome. > > Can I determine the number of arguments required of a function? See inspect.getargspec() > Is there

Re: Detecting arguments of a function - possible?

2006-03-17 Thread Diez B. Roggisch
> I am trying to write a tool to examine a function (I'd like it > to work with pyc files only). So here are a few questions I > have; any pointers would be very welcome. Try playing around with reflection - the function-code reveals some properties of the code. for example >>> import inspect >>

Re: Counting nested loop iterations

2006-03-17 Thread Joel Hedlund
> a list comprehension works exactly like an ordinary for > loop, except that the important thing (the expression) is moved to the > beginning of the statement. Right. Thanks! /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting nested loop iterations

2006-03-17 Thread Jeffrey Schwab
Fredrik Lundh wrote: > Joel Hedlund wrote: > >> I've been thinking about these nested generator expressions and list >> comprehensions. How come we write: >> >> a for b in c for a in b >> >> instead of >> >> a for a in b for b in c >> >> More detailed example follows below. >> >> I feel the latter

Re: Detecting arguments of a function - possible?

2006-03-17 Thread Diez B. Roggisch
inspect.getargs(foo) Copy-and-paste error. Ignore that line. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread Timo Stamm
[EMAIL PROTECTED] schrieb: > In comp.lang.perl.misc Timo Stamm <[EMAIL PROTECTED]> wrote: >> Other charsets than US-ASCII are widely accepted in non-english >> newsgroups as long as the charset is properly declared. > >> Xah's posting was properly encoded and will display fine in every decent >

Re: Counting nested loop iterations

2006-03-17 Thread Diez B. Roggisch
> Which is utterly counter-intuitive, the opposite of Perl, and remains > one of the most confusing and surprising things I have encountered in > Python so far. AFAIK stems from mathematics where you write things like {y | \forall x \in X : \forall y \in x } And so many people consider it pretty

Re: Converting to ARGB and writing to a bitmap

2006-03-17 Thread Steve Juranich
[EMAIL PROTECTED] wrote: > Hi, > I don't know what type of files they are, but the script allows me to > save to a bitmap just fine. But I do know they need to be in RGBA > format, so I've followed what most of the tutorials for RGBA > conversions said to do...shifting the bytes. > > The maj

How do I use the subprocess module with mswindows?

2006-03-17 Thread Darren Dale
I'm a developer on the matplotlib project, and I am having trouble with the subprocess module on windows (Python 2.4.2 on winXP). No trouble to report with linux. I need to use _subprocess instead of pywin32, but my trouble exists with either option: import subprocess process = subprocess.Popen

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Dan Piponi
[EMAIL PROTECTED] said: > I haven't run or studied your program yet myself but what I had in mind > was that the list of wc's are *all* to be excluded I think it already does what you want. You might want to change run n alphabet pat = generate terminal null transition [pat] n alphabet to

Re: Loop Backwards

2006-03-17 Thread john_sips_tea
Tim Roberts wrote: > "Dave" <[EMAIL PROTECTED]> wrote: > > > >Please be mindful of making statements such as: > >"it's silly to believe both will behave equally" > > > >One of the greatest weaknesses of Python is the less than friendly > >attitude Pythonistas display towards one another. > > I don

Re: How do I use the subprocess module with mswindows?

2006-03-17 Thread Fredrik Lundh
Darren Dale wrote: > If I change my script a bit, I get a different error: > > import subprocess > process = subprocess.Popen(['dir']) > stat = process.wait() > print process.stdout.read() > WindowsError: [Errno 2] The system cannot find the file specified "dir" is a shell command under Windows,

Python train spotting doodle

2006-03-17 Thread Diez B. Roggisch
Hi, a year or two ago, somebody posted a link to an image he created. It was basically a remake of the famous trainspotting-poster that begins all sentences with "Choose ..." Back then I printed it out and hung it on my office wall. New emplyoer, empty wall, crying for a printout... But I didn't

Re: How do I use the subprocess module with mswindows?

2006-03-17 Thread Darren Dale
Fredrik Lundh wrote: > Darren Dale wrote: > >> If I change my script a bit, I get a different error: >> >> import subprocess >> process = subprocess.Popen(['dir']) >> stat = process.wait() >> print process.stdout.read() > >> WindowsError: [Errno 2] The system cannot find the file specified > >

Re: Counting nested loop iterations

2006-03-17 Thread Duncan Booth
Diez B. Roggisch wrote: >> Which is utterly counter-intuitive, the opposite of Perl, and remains >> one of the most confusing and surprising things I have encountered in >> Python so far. > > AFAIK stems from mathematics where you write things like > > {y | \forall x \in X : \forall y \in x } >

Re: Python train spotting doodle

2006-03-17 Thread Duikboot
http://apipes.blogspot.com/2005/01/choose-python.html I have printed on my office wall too. Duikboot Diez B. Roggisch wrote: > Hi, > > a year or two ago, somebody posted a link to an image he created. It was > basically a remake of the famous trainspotting-poster that begins all > sentences wit

Python vs. Java gzip performance

2006-03-17 Thread Bill
I've written a small program that, in part, reads in a file and parses it. Sometimes, the file is gzipped. The code that I use to get the file object is like so: if filename.endswith(".gz"): file = GzipFile(filename) else: file = open(filename) Then I parse the contents of the file in t

Re: Pythong CGI scrips on Windows Server 2003

2006-03-17 Thread Hugh Beyer
Tim Roberts <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hugh Beyer <[EMAIL PROTECTED]> wrote: >> >>We are moving to a new server running Windows Server 2003 from existing >>servers runing Windows Server 2002 and IIS is giving us fits. > > Do you mean Windows 2000 Server? > > My expe

Re: Counting nested loop iterations

2006-03-17 Thread Diez B. Roggisch
> I think the problem is that y is used before the loop which creates it, > but x is used after the loop which creates it. Well, you got me on that. Seems to be a matter of convention all the time. > People can cope with the expanded loop form where everything it is used > after it is introduced

Re: Python train spotting doodle

2006-03-17 Thread Diez B. Roggisch
Duikboot wrote: > http://apipes.blogspot.com/2005/01/choose-python.html > > I have printed on my office wall too. Great, thanks! Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Mount/Unmount Drives on Windows?

2006-03-17 Thread dpickles
thank you! devcon was a little more than I needed, and I couldn't get it to work for how I wanted to use it. I will try mountvol. If it has an argument to unmount a volume as well, then it will fit the bill perfectly. -- http://mail.python.org/mailman/listinfo/python-list

Python poly obsolete?

2006-03-17 Thread Thierry Lam
I have a piece of python code which goes like the following: import poly list = [1, 2, 3] result = poly.scan(list) I'm using Python 2.3.4 and I don't think that poly library is working properly, I read somewhere that's it's obsolete now. What's the alternative? Thanks Thierry -- http://mail.

Re: accessing a USB HID

2006-03-17 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Serge Orlov <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: . . . >> The obstacle our group currently faces is communicating with a >> microcontroller (ACS USB Servo II) that appears in Wind

Re: Printable string for 'self'

2006-03-17 Thread Michael Tobis
> What were you planning to do with this object exactly that didn't involve > binding it to any other names during its lifetime? Nothing so silly as that. The idea is not to prevent other references from binding to the object, but to allow the object to ensure that a certain symbol always points

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Dinko Tenev
[EMAIL PROTECTED] wrote: > It would seem that your program is just filtering the full cartesian > product, right? The solution I'm looking for generates the elements > one-by-one so that it could be used in a loop. Oops...missed that part. It took me a while to study the exchange on this topic mo

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Azolex
sa wrote: > in k: > > cp:{[c;n;p]+(n#c)_vs(!_ c^n)_dvl,/{2_sv+(,/,/:\:)/(),/:@[x;&x=-1;:[;!c]]}'p} That one goes a long way as a proof of eg evolution theory, you know, monkeys reproducing shakespeare with a typewriter k-board and all that :) > > examples: > > cp[2;3;,0 -1 1] > (0 0 0 > 0

How should variables' docstrings be written?

2006-03-17 Thread Edward Loper
Epydoc 3 supports extracting information about Python modules by parsing. As a result, it can extract "docstrings" for variables. There are several possible ways these docstrings could be expressed in the Python source file, and I wanted to get some feedback on which ways people prefer. It's my h

Need design advice. What's my best approach for storing this data?

2006-03-17 Thread Mudcat
Hi, I am trying to build a tool that analyzes stock data. Therefore I am going to download and store quite a vast amount of it. Just for a general number - assuming there are about 7000 listed stocks on the two major markets plus some extras, 255 tradying days a year for 20 years, that is about 36

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Dan Piponi
Tomasz Zielonka said: > I've implemented the same concept yesterday evening... It's uncanny reading such similar code coming from another person! -- http://mail.python.org/mailman/listinfo/python-list

Problem with C-API

2006-03-17 Thread John Dean
Hi I spent the whole of yesterday trying the get the following C code to execute PyRun_String("def title();", Py_file_input, dict, dict); PyRun_String("\treturn 'Foo Bar'", Py_file_input, dict, dict); PyRun_String("x = title()", Py_file_input, dict, dict); PyObject * result = PyRun_String("print

Re: Need design advice. What's my best approach for storing this data?

2006-03-17 Thread J Correia
"Mudcat" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am trying to build a tool that analyzes stock data. Therefore I am > going to download and store quite a vast amount of it. Just for a > general number - assuming there are about 7000 listed stocks on the two > major

Re: Problem with C-API

2006-03-17 Thread Diez B. Roggisch
John Dean wrote: > Hi > > I spent the whole of yesterday trying the get the following C code to > execute > > PyRun_String("def title();", Py_file_input, dict, dict); ^^^ Try using a colon here > PyRun_String("\treturn 'Foo Bar'", Py_file_input, dict, dict); > P

Re: accessing a USB HID

2006-03-17 Thread jodansmif
Thanks! I'll get cranking along and post my progress to the thread. -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Geoffrey Summerhayes
Wade Humeniuk wrote: > [EMAIL PROTECTED] wrote: > > What I have in mind is the efficient, generation of the > > complement S^n/WC(S^n). A good program should initialize, generate, and > > terminate. > > > > T=cartprodex(S,n,WC); //initialize > > for all i in T do > > what you want with i > >

unicode error

2006-03-17 Thread Allerdyce . John
I have this python code: print >> htmlFile, ""; But that caues this error, and I can't figure it out why. Any help is appreicate File "./run.py", line 193, in ? print >> htmlFile, ""; UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9: ordinal not in range(128) Thanks.

Re: Problem with C-API

2006-03-17 Thread Duncan Booth
John Dean wrote: > PyRun_String("def title();", Py_file_input, dict, dict); > PyRun_String("\treturn 'Foo Bar'", Py_file_input, dict, dict); > PyRun_String("x = title()", Py_file_input, dict, dict); > PyObject * result = PyRun_String("print x", Py_file_input, dict, dict); > printf( "The result is

Re: Is there a python library to parse C++ code file?

2006-03-17 Thread Roman Yakovenko
On 3/17/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > Is there a python library to parse C++ code file? > > If yes, can you please tell me where is it? pygccxml. http://www.language-binding.net/pygccxml/pygccxml.html Very powerful package :-)! It has built-in supp

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-17 Thread Alan Crowe
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > What I have in mind is the efficient, generation of the > complement S^n/WC(S^n). A good program should initialize, generate, and > terminate. > > T=cartprodex(S,n,WC); //initialize > for all i in T do > what you want with i > test to see if

Re: Need design advice. What's my best approach for storing this data?

2006-03-17 Thread Rene Pijlman
Mudcat: >My initial thought was to put the data in large dictionaries and shelve >them (and possibly zipping them to save storage space until the data is >needed). However, these are huge files. ZODB solves that problem for you. http://www.zope.org/Wikis/ZODB/FrontPage More in particular "5.3 BTr

Re: Python poly obsolete?

2006-03-17 Thread Georg Brandl
Thierry Lam wrote: > I have a piece of python code which goes like the following: > > import poly > > list = [1, 2, 3] > > result = poly.scan(list) > > I'm using Python 2.3.4 and I don't think that poly library is working > properly, I read somewhere that's it's obsolete now. What's the > alter

Re: Computing correlations with SciPy

2006-03-17 Thread Travis Oliphant
[EMAIL PROTECTED] wrote: > I want to compute the correlation between two sequences X and Y, and > tried using SciPy to do so without success.l Here's what I have, how > can I correct it? > This was a bug in NumPy (inherited from Numeric actually). The fix is in SVN of NumPy. Here are the new v

Parsing Hints

2006-03-17 Thread mwt
Hi - I'm working on parsing a file that has data that looks like the sample below. Obviously, I can't just split the string by colons. I'm pretty new to regex, but I was thinking of something that would essentially "split" by colons only if the are preceded by alpha characters -- thus eliminating p

Is there no end to Python?

2006-03-17 Thread Kamilche
I have been programming in Python for years, and I'm STILL learning new features about the language. I'm looking for the best way to handle events with my own UI developed in PyGame, and I've programmed up 4 ways to do it so far, and have a couple more waiting to be done! Python is so amazingly fl

Re: Is there no end to Python?

2006-03-17 Thread John Salerno
Kamilche wrote: > in PyGame, and I've programmed up 4 ways to do it so far, and have a > couple more waiting to be done! Python is so amazingly flexible, it > will happily accommodate whatever I manage to spew forth as my event > handling system. > > It really fires the imagination. In other lang

Re: Python vs. Java gzip performance

2006-03-17 Thread Martin v. Löwis
Bill wrote: > The Java version of this code is roughly 2x-3x faster than the Python > version. I can get around this problem by replacing the Python > GzipFile object with a os.popen call to gzcat, but then I sacrifice > portability. Is there something that can be improved in the Python > version

Re: Is there no end to Python?

2006-03-17 Thread Kamilche
Because Python doesn't take as many CPU cycles in your brain, it spares more time for 'big picture' ideas, such as the event handling framework I'm working on. -- http://mail.python.org/mailman/listinfo/python-list

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread Roedy Green
On 17 Mar 2006 00:58:55 -0800, "Fuzzyman" <[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who said : >Hmmm... it displays fine via google groups. Maybe it's the reader which >is 'non-compliant' ? I am using Agent. You configure your database with an encoding, which is by default t

Re: Is there no end to Python?

2006-03-17 Thread Mark Warburton
John Salerno wrote: > > But isn't Python sort of known for the opposite, i.e. 'one simple way', > or something to that effect? Ha! I was thinking the same thing. But then I realized this only applies at the microscopic level. If you're doing something like reversing the order of the elements in

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread PofN
Dinko Tenev wrote: > If only someone could persuade this guy to stay away from CS... I still hope that at some point in time he will manage to tender his nomination for the darvin award. You can't rationalize with that troll, because there is nothing between his ears capable of catching a clue. -

Re: My Generator Paradox!

2006-03-17 Thread vbgunz
I believe I understand now. the yield keyword is sort of like a cousin to return. return will bring back an object I can work with and so does yield *but* yield's object will most likely support the .next() method. So, if I worked with a function that ends with the return keyword and it returns a

style guideline for naming variables?

2006-03-17 Thread John Salerno
After reading the PEP, I'm still not quite sure if there is a recommended (or widely preferred) method of naming variables. Here are the relevant bits: > Global Variable Names > > (Let's hope that these variables are meant for use inside one module > only.) The conventions are abou

Re: style guideline for naming variables?

2006-03-17 Thread John Salerno
John Salerno wrote: > some_function > > But this seems awkward to me. someFunction seems nicer Sorry, I was asking about variables but used a function example. But really I'm asking about any situation where you might want to use multiple words (except for classes, which is recommended to use

Re: Python vs. Java gzip performance

2006-03-17 Thread Caleb Hattingh
I tried this: from timeit import * #Try readlines print Timer('import gzip;lines=gzip.GzipFile("gztest.txt.gz").readlines();[i+"1" for i in lines]').timeit(200) # This is one line # Try file object - uses buffering? print Timer('import gzip;[i+"1" for i in gzip.GzipFile("gztest.txt.gz")]').time

Importing an output from another function

2006-03-17 Thread Byte
Probably a stupid question, but I'm a newbie and this really pisses me off. Run this script: import random def Func1(): choice = ('A', 'B', 'C') output = random.choice(choice) def Func2(): print output Func1() Func2() And: an error message.. It says: Traceback (most recent cal

Re: unicode error

2006-03-17 Thread jean-michel bain-cornu
[EMAIL PROTECTED] wrote: > I have this python code: > print >> htmlFile, " style=\"width: 200px; height:18px;\">"; > > > But that caues this error, and I can't figure it out why. Any help is > appreicate > File "./run.py", line 193, in ? > print >> htmlFile, " style=\"width: 200px; height:18

Re: Problem with C-API

2006-03-17 Thread John Dean
Hi Duncan Your version of the app works apart from this part else { PyObject *rString = PyObject_Str(result); if (rString==NULL) { Py_DECREF(result); PyErr_Print(); return; } printf( "The result is %s\n", PyStr

Re: Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Caleb Hattingh
Hi The documentation for the python profiler in the python library reference is extremely readable (well done James Roskin!?). Profile your code, and when you find where the speed problem occurs, try pitching just that section of code in comp.lang.python. You will likely get much feedback. Ever

Re: Importing an output from another function

2006-03-17 Thread bearophileHUGS
Generally, a name defined into a function can't be read outside of it, so you have to return the function result explicitely: import random def Func1(): choice = ('A', 'B', 'C') output = random.choice(choice) return output def Func2(item): print item output1 = Func1() Func2(outp

Re: Problem with C-API

2006-03-17 Thread John Dean
Hi Duncan's example worked to a point. The line PyRun_String( "print x", Py_file_input, dict, dict); print out the contents of x, but I don't want to print x out. I want to be able to grab whateven the variable x contains so that I can pass it on for further processing by the C++ application. BTW

Re: Is there no end to Python?

2006-03-17 Thread sjmsoft
John Salerno wrote: > But isn't Python sort of known for the opposite, i.e. 'one simple way', > or something to that effect? The Python language is clear and concise and so I don't think takes long to learn. But there's so many libraries and packages available that I'll probably never use more th

Re: Parsing Hints

2006-03-17 Thread mwt
OK. I think the solution was much easier than I thought. The key is the semicolon. I'm doing it in 3 steps: 1) Break string into 13 lines 2) Split each line by the semi-colon 3) Ummm... done already. Time to wake up. ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Hints

2006-03-17 Thread Kent Johnson
mwt wrote: > Hi - > I'm working on parsing a file that has data that looks like the sample > below. > > Here's a sample of the data: > > Index 4: folding now > server: 171.65.199.158:8080; project: 1809 > Folding: run 17, clone 19, generation 35; benchmark 669; misc: 500, > 400 > issue: W

Re: Importing an output from another function

2006-03-17 Thread Byte
Great, thanks -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list

Linear regression in NumPy

2006-03-17 Thread nikie
I'm a little bit stuck with NumPy here, and neither the docs nor trial&error seems to lead me anywhere: I've got a set of data points (x/y-coordinates) and want to fit a straight line through them, using LMSE linear regression. Simple enough. I thought instead of looking up the formulas I'd just se

Re: Importing an output from another function

2006-03-17 Thread Byte
Now what do I do if Func1() has multiple outputs and Func2() requires them all to give its own output, as follows: import random def Func1(): choice = ('A', 'B', 'C') output = random.choice(choice) output2 = random.choice(choice) return output return output2 def Func2(item1,

No module named glade?

2006-03-17 Thread Terry Hancock
I've run into something a little odd on my Debian-installed Python 2.3. I have deb packages "python2.3", "python-gtk2", and "python2.3-glade2" installed on this machine. Among other things, these DO give me the following (verified): /usr/lib/python2.3/site-packages/pygtk.pth /usr/lib/python2.3/s

Re: Linear regression in NumPy

2006-03-17 Thread Robert Kern
nikie wrote: > I'm a little bit stuck with NumPy here, and neither the docs nor > trial&error seems to lead me anywhere: > I've got a set of data points (x/y-coordinates) and want to fit a > straight line through them, using LMSE linear regression. Simple > enough. I thought instead of looking up t

Re: Importing an output from another function

2006-03-17 Thread John Salerno
Byte wrote: > Now what do I do if Func1() has multiple outputs and Func2() requires > them all to give its own output, as follows: You can return them as a tuple: >>> def func1(): output1 = 'hi' output2 = 'bye' return (output1, output2) >>> def func2(data): prin

Re: My Generator Paradox!

2006-03-17 Thread Robert Kern
vbgunz wrote: > I believe I understand now. the yield keyword is sort of like a cousin > to return. return will bring back an object I can work with and so does > yield *but* yield's object will most likely support the .next() method. No, that's not really how it works. When a generator function i

Re: Counting nested loop iterations

2006-03-17 Thread Scott David Daniels
Duncan Booth wrote: > Oh well, just wait until Python 2.5 comes out and we get people complaining > about the order of the new if statement. Or rather, the order of the new if _expression_. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs. Java gzip performance

2006-03-17 Thread Peter Otten
Caleb Hattingh wrote: > I tried this: > > from timeit import * > > #Try readlines > print Timer('import > gzip;lines=gzip.GzipFile("gztest.txt.gz").readlines();[i+"1" for i in > lines]').timeit(200) # This is one line > > > # Try file object - uses buffering? > print Timer('import gzip;[i+"1"

  1   2   >