Re: word shifts

2008-05-03 Thread George Sakkis
On May 4, 2:04 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sun, 04 May 2008 02:17:07 -0300, dave <[EMAIL PROTECTED]> escribió: > > > > > Hello, > > > I made a function that takes a word list (one word per line, text file) > > and searches for all the words in the list that are 'shifts'

Re: is +=1 thread safe

2008-05-03 Thread Carl Banks
On May 3, 7:44 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > Alexander Schmolck wrote: > > AlFire <[EMAIL PROTECTED]> writes: > > >>> The threading module already has a function to return the number of Thread > >>> objects currently alive. > > >> I have threads within threads - so it does not suit m

Re: word shifts

2008-05-03 Thread Gabriel Genellina
En Sun, 04 May 2008 02:17:07 -0300, dave <[EMAIL PROTECTED]> escribió: > Hello, > > I made a function that takes a word list (one word per line, text file) > and searches for all the words in the list that are 'shifts' of > eachother. 'abc' shifted 1 is 'bcd' > > Please take a look and tell me if

Re: Error handling in SAX

2008-05-03 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > (this is a repost, for it's been a while since I posted this text via > Google Groups and it plain didn't appear on c.l.py - if it did appear > anyway, apols) It did, although some people have added google groups to their kill file. > So I set out to learn handling thr

Re: saving a webpage's links to the hard disk

2008-05-03 Thread Gabriel Genellina
En Sun, 04 May 2008 01:33:45 -0300, Jetus <[EMAIL PROTECTED]> escribió: > Is there a good place to look to see where I can find some code that > will help me to save webpage's links to the local drive, after I have > used urllib2 to retrieve the page? > Many times I have to view these pages when I

Re: generator functions in another language

2008-05-03 Thread Gabriel Genellina
En Sun, 04 May 2008 01:08:34 -0300, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> escribió: > On Sat, 03 May 2008 16:39:43 -0700, castironpi wrote: > >> I'm actually curious if there's a way to write a generator function >> (not a generator expression) in C, or what the simplest way to do it >> is

word shifts

2008-05-03 Thread dave
Hello, I made a function that takes a word list (one word per line, text file) and searches for all the words in the list that are 'shifts' of eachother. 'abc' shifted 1 is 'bcd' Please take a look and tell me if this is a viable solution. def shift(word, amt): ans = '' for

Re: about bsddb module

2008-05-03 Thread cocobear
On 5月3日, 下午7时17分, cocobear <[EMAIL PROTECTED]> wrote: > How to deal with multiple databases in an file. I want to get the > content of several databases. > > it's the code I wrote: > > [EMAIL PROTECTED] ~]$ python > Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11) > [GCC 4.1.2 20070925 (Red Hat 4.1

saving a webpage's links to the hard disk

2008-05-03 Thread Jetus
Is there a good place to look to see where I can find some code that will help me to save webpage's links to the local drive, after I have used urllib2 to retrieve the page? Many times I have to view these pages when I do not have access to the internet. -- http://mail.python.org/mailman/listinfo/p

Re: is +=1 thread safe

2008-05-03 Thread Gary Herron
Alexander Schmolck wrote: AlFire <[EMAIL PROTECTED]> writes: The threading module already has a function to return the number of Thread objects currently alive. I have threads within threads - so it does not suit me :-(. How about using a scalar numpy array? They are mutable,

Re: is +=1 thread safe

2008-05-03 Thread AlFire
Alexander Schmolck wrote: AlFire <[EMAIL PROTECTED]> writes: The threading module already has a function to return the number of Thread objects currently alive. I have threads within threads - so it does not suit me :-(. How about using a scalar numpy array? They are mutable, so I assume tha

Re: Light slices + COW

2008-05-03 Thread David
> That xpairs() generator is nice, but it's not the best possible code > (but you may disagree with me, and you may think that code better than > the successive D code that uses two slices). Inside it I can't use a > list slicing because it copies subparts of the list, probably becoming > too

Re: dict invert - learning question

2008-05-03 Thread Jerry Hill
On Sat, May 3, 2008 at 4:29 PM, dave <[EMAIL PROTECTED]> wrote: > here is a piece of code I wrote to check the frequency of values and switch > them around to keys in a new dictionary. Just to measure how many times a > certain key occurs: > > def invert(d): > inv = {} > for key

Re: generator functions in another language

2008-05-03 Thread Marc 'BlackJack' Rintsch
On Sat, 03 May 2008 16:39:43 -0700, castironpi wrote: > I'm actually curious if there's a way to write a generator function > (not a generator expression) in C, or what the simplest way to do it > is... besides link the Python run-time. The reference implementation of Python is written in C, so o

Script Optimization

2008-05-03 Thread lev
Can anyone provide some advice/suggestions to make a script more precise/efficient/concise, etc.? The script verifies checksums, renames dirs/files, edits checksum filenames, and htm page filenames, all from mp3cd format ([0-9][0-9] [0-9]xxx.yyy) to something more usable: for ripping an mp3cd to di

Re: Python documentation

2008-05-03 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: I have been learning python for some time using the dive into python book. I am interested to know if anyone can recommend a book which covers more advanced topics like threading and potentially GUI style coding If you don't at least browse "The Python Cookbook," you

Re: is +=1 thread safe

2008-05-03 Thread Alexander Schmolck
AlFire <[EMAIL PROTECTED]> writes: >> The threading module already has a function to return the number of Thread >> objects currently alive. > > I have threads within threads - so it does not suit me :-(. How about using a scalar numpy array? They are mutable, so I assume that x += 1 should be at

Help - IDLE Debugger Source Checkbox??

2008-05-03 Thread SFM
I have been learning the IDLE Debugger and was wondering if I was missing something with the "Source" checkbox setting in the debugger. As I single-step through my program, I have to uncheck and then recheck this box in order to see the current line in the file editing window highlighted. Is there

Re: RegEx for matching brackets

2008-05-03 Thread NevilleDNZ
To check a complete python expression use: def check_open_close(expr): try: eval(expr) except SyntaxError: return False else: return True This also ignores brackets in quotes, and checks <= & >= operators are syntatically correct etc... But is may have side effects... ;-) eg. c

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 17:43:57 -0700, George Sakkis wrote: > On May 3, 7:12 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> On Sun, 04 May 2008 00:31:01 +0200, Thomas Dybdahl Ahle wrote: >> > On Sat, 2008-05-03 at 21:37 +, Ivan Illarionov wrote: >> >> On Sat, 03 May 2008 20:44:19 +0200, Szabol

Re: dict invert - learning question

2008-05-03 Thread George Sakkis
On May 3, 5:12 pm, dave <[EMAIL PROTECTED]> wrote: > thanks Duncan and Arnaud. > > I'm learning Python from the "How to Think Like a Python Programmer" > book by Allen Downey.  My first try used the "inv[val] = [key]" and > then the next problem was to incorporate the "D.setdefault(...)" method. >

Re: PIL JPEG mis-step

2008-05-03 Thread darkblueB
On May 3, 4:52 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > Try run 'python setup.py build_ext -f' to force setup.py to rebuild > everything with JPEG. And 'sudo python setup.py install' should install > PIL with JPEG support. yes, that works (the self test still gives misleading results ?) b

Re: Light slices + COW

2008-05-03 Thread castironpi
On May 3, 1:59 pm, [EMAIL PROTECTED] wrote: > Sometimes different languages suggests me ways to cross-pollinate > them. > > (Note: probably someone has already suggested (and even implemented) > the following ideas, but I like to know why they aren't fit for > Python). > > Python generators now all

Re: PIL JPEG mis-step

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 15:25:35 -0700, darkblueB wrote: > I got the Python Imaging Library from source, built and installed, on > Ubuntu 7.10, not realizing I could run a self-test first. libjpeg is on > the machine, but was not detected.. so no JPG encoder. I got the > dev-libjpg and rebuilt PIL. Th

generator functions in another language

2008-05-03 Thread castironpi
I'm actually curious if there's a way to write a generator function (not a generator expression) in C, or what the simplest way to do it is... besides link the Python run-time. -- http://mail.python.org/mailman/listinfo/python-list

Re: dict invert - learning question

2008-05-03 Thread mrkafk
On 4 Maj, 01:27, [EMAIL PROTECTED] wrote: > >>> a={1:'a', 2:'b', 3:'c'} Oops, it should obviously be: >>> dict(zip(a.values(), a.keys())) {'a': 1, 'c': 3, 'b': 2} -- http://mail.python.org/mailman/listinfo/python-list

Re: dict invert - learning question

2008-05-03 Thread mrkafk
Assuming all the values are unique: >>> a={1:'a', 2:'b', 3:'c'} >>> dict(zip(a.keys(), a.values())) {1: 'a', 2: 'b', 3: 'c'} The problem is you obviously can't assume that in most cases. Still, zip() is very useful function. -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sun, 04 May 2008 00:31:01 +0200, Thomas Dybdahl Ahle wrote: > On Sat, 2008-05-03 at 21:37 +, Ivan Illarionov wrote: >> On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvát wrote: >> >> > Arnaud Delobelle wrote: >> >> >> >> sum() works for any sequence of objects with an __add__ method, not

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread George Sakkis
On May 3, 7:12 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On Sun, 04 May 2008 00:31:01 +0200, Thomas Dybdahl Ahle wrote: > > On Sat, 2008-05-03 at 21:37 +, Ivan Illarionov wrote: > >> On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvát wrote: > > >> > Arnaud Delobelle wrote: > > >> >> sum

Re: PIL JPEG mis-step

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 17:01:44 -0700, darkblueB wrote: > On May 3, 4:52 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> Try run 'python setup.py build_ext -f' to force setup.py to rebuild >> everything with JPEG. And 'sudo python setup.py install' should install >> PIL with JPEG support. > > yes,

Encoding Text

2008-05-03 Thread Paul Jefferson
Hi, I'm learning this and I'm making a program which takes RSS feeds and processes them and then outputs them to a HTML file. The problem I have is that some of the RSS feeds contain chachters which I think are outside of the ascii range as when I attempt to write the file containing themI get the

Re: Problems with psycopg2

2008-05-03 Thread David Anderson
The thing is this query works fine on the console through psql, but not in my code? can anyone explain me why? On Thu, May 1, 2008 at 9:31 PM, David Anderson <[EMAIL PROTECTED]> wrote: > Hi all > I have this function: > def checkName(self, name): > cur = self.conn.cursor() > > sql

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Thomas Dybdahl Ahle
On Sat, 2008-05-03 at 21:37 +, Ivan Illarionov wrote: > On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvát wrote: > > > Arnaud Delobelle wrote: > >> > >> sum() works for any sequence of objects with an __add__ method, not > >> just floats! Your algorithm is specific to floats. > > > > Thi

PIL JPEG mis-step

2008-05-03 Thread darkblueB
I got the Python Imaging Library from source, built and installed, on Ubuntu 7.10, not realizing I could run a self-test first. libjpeg is on the machine, but was not detected.. so no JPG encoder. I got the dev-libjpg and rebuilt PIL. The self-test now shows JPG support. but running setup.py insta

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread sturlamolden
On May 3, 10:13 pm, hdante <[EMAIL PROTECTED]> wrote: > I believe that moving this to third party could be better. What about > numpy ? Doesn't it already have something similar ? Yes, Kahan summation makes sence for numpy arrays. But the problem with this algorithm is optimizing compilers. The

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvát wrote: > Arnaud Delobelle wrote: >> >> sum() works for any sequence of objects with an __add__ method, not >> just floats! Your algorithm is specific to floats. > > This occurred to me also, but then I tried > > sum(['abc', 'efg'], '') Inter

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Erik Max Francis
Torsten Bronger wrote: No, the above expression should yield ''+'abc'+'efg', look for the signature of sum in the docs. You're absolutely right, I misread it. Sorry about that. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && A

using sqlite3 - execute vs. executemany; committing ...

2008-05-03 Thread Vlastimil Brom
Hi all, I'd like to ask about some (probably elementary) things about the proper usage of sqlite3 in python (2.5.2; win). - Are there any peculiarities with using curs.executemany(...) vs. multiple curs.execute(...) ? I read a notice, sqlite3 does internally some caching, hence both should be simil

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Torsten Bronger
Hallöchen! Erik Max Francis writes: > Szabolcs Horvát wrote: > >> Arnaud Delobelle wrote: >>> >>> sum() works for any sequence of objects with an __add__ method, not >>> just floats! Your algorithm is specific to floats. >> >> This occurred to me also, but then I tried >> >> sum(['abc', 'efg'],

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Erik Max Francis
Szabolcs Horvát wrote: Arnaud Delobelle wrote: sum() works for any sequence of objects with an __add__ method, not just floats! Your algorithm is specific to floats. This occurred to me also, but then I tried sum(['abc', 'efg'], '') and it did not work. Or is this just a special exceptio

Re: list.index crashes when the element is not found

2008-05-03 Thread Erik Max Francis
Jeff wrote: The generally used idiom for that is: lst = ['a', 'b', 'c'] if 'a' in lst: foo = lst.index('a') It's not a very good idiom, since it iterates over the list twice unnecessarily: first, to see if the object is in the list; then, to find the index of that object. That's pointle

Re: dict invert - learning question

2008-05-03 Thread dave
thanks Duncan and Arnaud. I'm learning Python from the "How to Think Like a Python Programmer" book by Allen Downey. My first try used the "inv[val] = [key]" and then the next problem was to incorporate the "D.setdefault(...)" method. Thank you for your help. I'm always amazed how kind peop

Error handling in SAX

2008-05-03 Thread mrkafk
(this is a repost, for it's been a while since I posted this text via Google Groups and it plain didn't appear on c.l.py - if it did appear anyway, apols) So I set out to learn handling three-letter-acronym files in Python, and SAX worked nicely until I encountered badly formed XMLs, like with bad

Re: dict invert - learning question

2008-05-03 Thread Arnaud Delobelle
dave <[EMAIL PROTECTED]> writes: > Hello, > > here is a piece of code I wrote to check the frequency of values and > switch them around to keys in a new dictionary. Just to measure how > many times a certain key occurs: > > def invert(d): > inv = {} > for key in d: > val

Re: dict invert - learning question

2008-05-03 Thread Duncan Booth
dave <[EMAIL PROTECTED]> wrote: > Hello, > > here is a piece of code I wrote to check the frequency of values and > switch them around to keys in a new dictionary. Just to measure how > many times a certain key occurs: > > def invert(d): > inv = {} > for key in d: > val =

Re: unified command line args, environment variables, .conf file settings.

2008-05-03 Thread smitty1e
On May 2, 11:29 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > smitty1e <[EMAIL PROTECTED]> writes: > > Just a fun exercise to unify some of the major input methods for a > > script into a single dictionary. > > Here is the output, given a gr.conf file in the same directory with > > the contents state

Daily WTF with XML, or error handling in SAX

2008-05-03 Thread mrkafk
So I set out to learn handling three-letter-acronym files in Python, and SAX worked nicely until I encountered badly formed XMLs, like with bad characters in it (well Unicode supposed to handle it all but apparently doesn't), using http://dchublist.com/hublist.xml.bz2 as example data, with goal to

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Arnaud Delobelle
Szabolcs Horvát <[EMAIL PROTECTED]> writes: > Arnaud Delobelle wrote: >> >> sum() works for any sequence of objects with an __add__ method, not >> just floats! Your algorithm is specific to floats. > > This occurred to me also, but then I tried > > sum(['abc', 'efg'], '') > > and it did not work.

dict invert - learning question

2008-05-03 Thread dave
Hello, here is a piece of code I wrote to check the frequency of values and switch them around to keys in a new dictionary. Just to measure how many times a certain key occurs: def invert(d): inv = {} for key in d: val = d[key] if val not in in

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread hdante
On May 3, 3:44 pm, Szabolcs Horvát <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > > sum() works for any sequence of objects with an __add__ method, not > > just floats!  Your algorithm is specific to floats. > > This occurred to me also, but then I tried > > sum(['abc', 'efg'], '') > > an

Re: IPv6 and Python

2008-05-03 Thread Roy Smith
In article "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > I would be very interested in taking a look at how you implemented > that part of code. Would it be possible? Sadly, no. It's proprietary code. But, it's really not that complicated to reconstruct, once you know the basic idea. You h

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-03 Thread Aahz
In article <[EMAIL PROTECTED]>, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > >I can't believe some angry responses in this thread - it's just a >technical question, not about which is the best team in the [preferred >sports here] National Championship... http://www.netfunny.com/rhf/jokes/91q

Re: Do you know of a much simpler way of writing a program that writes a program?

2008-05-03 Thread Aahz
In article <[EMAIL PROTECTED]>, Jeff <[EMAIL PROTECTED]> wrote: > >Use lisp? :-))) -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ Help a hearing-impaired person: http://rule6.info/hearing.html -- http://mail.python.org/mailman/listinfo/python-list

Re: State machine Example in Python

2008-05-03 Thread David
> There's plenty of results. Be more specific if you can't get what you > want from Google. You'll probably find what you're looking for here: http://wiki.python.org/moin/FiniteStateMachine David. -- http://mail.python.org/mailman/listinfo/python-list

Re: State machine Example in Python

2008-05-03 Thread David
On Sat, May 3, 2008 at 6:26 PM, Alok Kumar <[EMAIL PROTECTED]> wrote: > Can someone please redirect me for a state machine example or design pattern > used in Python. > Google for it, eg: http://www.google.com/search?q=python+state+machine There's plenty of results. Be more specific if you can't

Re: Python and SOAP status

2008-05-03 Thread Waldemar Osuch
Heikki Toivonen wrote: I have started researching the Python SOAP (and web services in general) options out there. Python 2.5 should be supported. I used Python for some web services stuff (demo quality) a few years back without major problems. However, it seems many of the libraries I remember

Light slices + COW

2008-05-03 Thread bearophileHUGS
Sometimes different languages suggests me ways to cross-pollinate them. (Note: probably someone has already suggested (and even implemented) the following ideas, but I like to know why they aren't fit for Python). Python generators now allow me to package some code patterns common in my code, t

Re: Python and SOAP status

2008-05-03 Thread Waldemar Osuch
Jeff wrote: Twisted has SOAP support. yes but it is based on no longer actively maintained SOAPpy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Szabolcs Horvát
Arnaud Delobelle wrote: sum() works for any sequence of objects with an __add__ method, not just floats! Your algorithm is specific to floats. This occurred to me also, but then I tried sum(['abc', 'efg'], '') and it did not work. Or is this just a special exception to prevent the misuse

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Nick Craig-Wood
Szabolcs Horvát <[EMAIL PROTECTED]> wrote: > I did the following calculation: Generated a list of a million random > numbers between 0 and 1, constructed a new list by subtracting the mean > value from each number, and then calculated the mean again. > > The result should be 0, but of cours

Re: Problems replacing \ with \\

2008-05-03 Thread [EMAIL PROTECTED]
Sorry for the late response. I've been travelling internationally and am just getting back to work. So--thank you to everyone who responded! To answer everyone's question I am dumping all of the data from a mysql database, then creating a postgresql database, then inserting the data into the

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 18:50:34 +0200, Szabolcs Horvát wrote: > I did the following calculation: Generated a list of a million random > numbers between 0 and 1, constructed a new list by subtracting the mean > value from each number, and then calculated the mean again. > > The result should be 0, b

Re: simple beginner question about lists and negative index

2008-05-03 Thread dwblas
On May 1, 10:04 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "jmDesktop" <[EMAIL PROTECTED]> wrote in message > | > | s = 'abcde' > | i = -1 > | for i in range (-1, -len(s), -1): > |print s[:i], i > | Why doesn't the first one have the e if -1 is the end of the list? That should be obvious.

Re: Getting started with pyvtk

2008-05-03 Thread Peter Pearson
On Fri, 02 May 2008 17:40:02 +0200, Paul Melis wrote: > > I'm not sure you've been helped so far as you seem to already understand > about pyvtk not being the official VTK bindings :) > > So, what would you like to know? Thanks, I think I'm set. For the benefit of the next instance of me googlin

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Arnaud Delobelle
Szabolcs Horvát <[EMAIL PROTECTED]> writes: [...] > A little research shows that Mathematica uses a "compensated > summation" algorithm. Indeed, using the algorithm described at > http://en.wikipedia.org/wiki/Kahan_summation_algorithm > gives us a result around ~ 10^-17: > > def compSum(arr): >

Re: pygame: rect moveto?

2008-05-03 Thread Marc 'BlackJack' Rintsch
On Sat, 03 May 2008 09:51:06 -0700, globalrev wrote: > http://www.pygame.org/docs/ref/rect.html#Rect.move > > well i need to put my rect ina specific place and i donw know from > where i will move it so i need a function rect.moveTo(x,y). > > how do i do that? No need for a function or method::

Re: IPv6 and Python

2008-05-03 Thread Giampaolo Rodola'
On 3 Mag, 05:38, Roy Smith <[EMAIL PROTECTED]> wrote: > In the application I work on, we've avoided this.  We just listen on two > separate sockets (one for each address family).  We wrote a DualSocket > class which manages the two underlying single-protocol sockets and makes > them appear to be a

Re: Phyton module for Windows Event Viewer?

2008-05-03 Thread Tzury Bar Yochay
> Can someone point me in the right direction? I'm looking for a module > to monitor the Windows Event Viewer. http://docs.python.org/lib/module-logging.html NTEventLogHandler is the one you should use. happy pythoning -- http://mail.python.org/mailman/listinfo/python-list

Re: list.index crashes when the element is not found

2008-05-03 Thread s0suk3
On May 2, 3:26 pm, TkNeo <[EMAIL PROTECTED]> wrote: > On May 2, 2:49 pm, Jeff <[EMAIL PROTECTED]> wrote: > > > The generally used idiom for that is: > > > lst = ['a', 'b', 'c'] > > if 'a' in lst: > > foo = lst.index('a') > > Jeff - Gracias !! > > I am fairly new to python. Thanks for the example

pygame: rect moveto?

2008-05-03 Thread globalrev
http://www.pygame.org/docs/ref/rect.html#Rect.move well i need to put my rect ina specific place and i donw know from where i will move it so i need a function rect.moveTo(x,y). how do i do that? -- http://mail.python.org/mailman/listinfo/python-list

Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Szabolcs Horvát
I did the following calculation: Generated a list of a million random numbers between 0 and 1, constructed a new list by subtracting the mean value from each number, and then calculated the mean again. The result should be 0, but of course it will differ from 0 slightly because of rounding

Re: How to use a parameter in a class

2008-05-03 Thread Florian Herlings
Hello Decebal, I am new to python myself, which might be the cause why I do not get that "last line" at all. To me it looks like you are trying to set a variable in the class body (if I am reading the indent correctly) and call a function (that does not exist?) to calculate the value for it. Does

Re: Why is None <= 0

2008-05-03 Thread Michael Mabin
New style classes are classes inherited from class object. Therefore: class A: pass is oldstyle, while class B(object): pass is newstyle. On Tue, Apr 29, 2008 at 8:29 AM, blaine <[EMAIL PROTECTED]> wrote: > On Apr 29, 5:32 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > > =?ISO-8859-15?

Re: How to use a parameter in a class

2008-05-03 Thread Gary Herron
Decebal wrote: I have the following class: # class Dummy(): value = 0 def __init__(self, thisValue): print thisValue self.value = thisValue value = thisValue def testing(self): print 'In test: %d' % self.value def returnValue(self): re

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-03 Thread Michael Mabin
I work on an AIX system where /usr/bin and /usr/local/bin apps can only be installed by root. Our system doesn't have python or many other tools we like to use installed so we have to install python in an alternate directory location. We have a system installation of Perl installed, but it's a rele

Re: Preventing 'bad' filenames from raising errors in os.path

2008-05-03 Thread John Nagle
[EMAIL PROTECTED] wrote: Bad file names, i.e. filenames the OS considers illegal, will cause functions in the os.path module to raise an error. Example: import os.path print os.path.getsize( 'c:/pytest/*.py' ) The issue, I think, is there's no function that checks syntax of a path name wit

State machine Example in Python

2008-05-03 Thread Alok Kumar
Can someone please redirect me for a state machine example or design pattern used in Python. Regards Alok -- http://mail.python.org/mailman/listinfo/python-list

Re: pygame.key.get_pressed[K_a], K_a is not defined!?

2008-05-03 Thread Diez B. Roggisch
globalrev schrieb: On 2 Maj, 18:13, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: globalrev schrieb: if pygame.key.get_pressed[K_a]: print "Muppet" K_a is not defined. but yes it is. why do i get this error? No it isn't - otherwise you wouldn't get this error, wouldn't you? What

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-03 Thread Lou Pecora
In article <[EMAIL PROTECTED]>, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-05-02, D'Arcy J.M. Cain <[EMAIL PROTECTED]> wrote: > > On Sat, 03 May 2008 00:44:00 +1000 > > Ben Finney <[EMAIL PROTECTED]> wrote: > >> "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > >> > As someone else pointed

Phyton module for Windows Event Viewer?

2008-05-03 Thread [EMAIL PROTECTED]
Hi all, Can someone point me in the right direction? I'm looking for a module to monitor the Windows Event Viewer. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question - probably FAQ (but not exactly answered by regular FAQ)

2008-05-03 Thread Nick Craig-Wood
Banibrata Dutta <[EMAIL PROTECTED]> wrote: > I've gone through the list of "language differences" between 2.3 / 2.4 > & 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of > CPython, and I consider myself still very very newbie. So, unable to > take a call as to how-important or des

Re: How to use a parameter in a class

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 03:05:31 -0700, Decebal wrote: > I have the following class: > # > class Dummy(): > value = 0 > def __init__(self, thisValue): > print thisValue > self.value = thisValue > value = thisValue > > def testing(self): > print 'In test

Re: How to use a parameter in a class

2008-05-03 Thread svetoslav . agafonkin
On May 3, 1:05 pm, Decebal <[EMAIL PROTECTED]> wrote: > I have the following class: > # > class Dummy(): >     value = 0 >     def __init__(self, thisValue): >         print thisValue >         self.value = thisValue >         value = thisValue > >     def testing(self): >         print 'In tes

about bsddb module

2008-05-03 Thread cocobear
How to deal with multiple databases in an file. I want to get the content of several databases. it's the code I wrote: [EMAIL PROTECTED] ~]$ python Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11) [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 Type "help", "copyright", "credits" or "license" f

How to use a parameter in a class

2008-05-03 Thread Decebal
I have the following class: # class Dummy(): value = 0 def __init__(self, thisValue): print thisValue self.value = thisValue value = thisValue def testing(self): print 'In test: %d' % self.value def returnValue(self): return self.value

Newbie question - probably FAQ (but not exactly answered by regular FAQ)

2008-05-03 Thread Banibrata Dutta
Hi, I've gone through the list of "language differences" between 2.3 / 2.4 & 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of CPython, and I consider myself still very very newbie. So, unable to take a call as to how-important or desirable the newer language features are -- so wheth

Re: Help with pyserial and sending binary data?

2008-05-03 Thread Nick Craig-Wood
Rich <[EMAIL PROTECTED]> wrote: > I am working on a python library for sending and receiving data > from a Subaru's ECU (the fuel injection computer) via the OBD-II > port and an OBD to USB cable, with the Subaru Select Monitor > protocol. [snip] > So I've been messing with it, and in as few l

Re: portable fork+exec/spawn

2008-05-03 Thread Nick Craig-Wood
Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > >For jobs which require interactivity ie send input, receive output, > >send input, receive output, ... it doesn't work well. There isn't a > >good cross platform solution for this yet. pyexpect works well under > >unix and is hopefully being porte

Re: image matching algorithms

2008-05-03 Thread Sengly
On Mar 14, 10:59 am, "Daniel Fetchinson" <[EMAIL PROTECTED]> wrote: > > > Since you seem to know quite a bit about this topic, what is your > > > opinion on the apparently 'generic' algorithm described here: > > >http://grail.cs.washington.edu/projects/query/? > > > So far it seems to me that it do

Re: IPv6 and Python

2008-05-03 Thread Martin v. Löwis
> Thanks a lot. I've been able to listen on ::1:21 after having > installed IPv6 on both Windows and Linux thanks to your suggestions. > I'd like to ask one more question: is it possible to bind my server on > both IPv4 and IPv6 addresses (note: I do not use multiple threads or > processes)? You c