Re: returning True, False or None

2005-02-04 Thread Jeremy Bowers
On Fri, 04 Feb 2005 10:48:44 -0700, Steven Bethard wrote: > I have lists containing values that are all either True, False or None, > e.g.: > > [True, None, None, False] > [None, False, False, None ] > [False, True, True, True ] > etc. > > For a given list: > * If all

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Alan McIntyre
Your first example is along the lines of what I was thinking when I said "elegant." :) I was looking for something that I could drop into one or two lines of code; I may not do that if I'm writing code that will have to be maintained, but it's still nice to know how to do it. Thanks :) Alan

(no subject)

2005-02-04 Thread Dan Smyth
Hey,   I'm trying to compile a version of Python on an SGI machine that is running IRIX 6.5.  When I run the configure option for version 2.4 I get this error:   configure: WARNING: stropts.h: present but cannot be compiledconfigure: WARNING: stropts.h: check for missing prerequisite h

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Steven Bethard
Alan McIntyre wrote: Hi all, I have a list of items that has contiguous repetitions of values, but the number and location of the repetitions is not important, so I just need to strip them out. For example, if my original list is [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5], I want to end up with [0,1,2

Re: returning True, False or None

2005-02-04 Thread Steve Holden
Steven Bethard wrote: I have lists containing values that are all either True, False or None, e.g.: [True, None, None, False] [None, False, False, None ] [False, True, True, True ] etc. For a given list: * If all values are None, the function should return None. * If at leas

Re: returning True, False or None

2005-02-04 Thread Michael Spencer
Steven Bethard wrote: I have lists containing values that are all either True, False or None, e.g.: [True, None, None, False] [None, False, False, None ] [False, True, True, True ] etc. For a given list: * If all values are None, the function should return None. * If at leas

Re: returning True, False or None

2005-02-04 Thread Steve Juranich
> This has a light code smell for me though -- can anyone see a simpler > way of writing this? How's about: def ntf(x, y): if x is None and y is None: return None if x == True or y == True: return True return False # Then... reduce(ntf, ) You might need to make sure that you init

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Alan McIntyre
I think you're right; sometimes I'm susceptible to the "I can do that in one line of code" temptation. :) Since this current bit of code will probably end up in something that's going to be maintained, I will probably stick with the straightforward method just to be nice to the maintainer (espe

Re: advice needed for simple python web app

2005-02-04 Thread Jeff Reavis
You might also want to try out Spyce. http://spyce.sourceforge.net/index.html It works in proxy mode, with mod_python, or even as cgi. Some examples: http://spyce.sourceforge.net/eg.html -- http://mail.python.org/mailman/listinfo/python-list

Re: returning True, False or None

2005-02-04 Thread Steven Bethard
Raymond Hettinger wrote: "Steven Bethard" For a given list: * If all values are None, the function should return None. * If at least one value is True, the function should return True. * Otherwise, the function should return False. . . . Right now, my code looks like: if True in lst: r

Re: OT: why are LAMP sites slow?

2005-02-04 Thread Maciej Mróz
Kartic wrote: Paul Rubin said the following on 2/3/2005 7:20 PM: LAMP = Linux/Apache/MySQL/P{ython,erl,HP}. Refers to the general class of database-backed web sites built using those components. This being c.l.py, if you want, you can limit your interest to the case the P stands for Python. I not

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Alan McIntyre
Jack, I'm not using 2.4 yet; still back in 2.3x. :) Thanks for the examples, though - they are clear enough that I will probably use them when I upgrade. Thanks, Alan Jack Diederich wrote: If you are using python2.4, import itertools as it [x[0] for (x) in it.groupby([0,0,1,1,1,2,2,3,3,3,2,2,2,

Converting strings to dates

2005-02-04 Thread Chermside, Michael
I'm trying to convert a string back into a datetime.date. First I'll create the string: Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time, datetime >>> a_date = datetime.date.today()

Re: returning True, False or None

2005-02-04 Thread Mick Krippendorf
Steven Bethard wrote: > I have lists containing values that are all either True, False or > None, e.g.: > > [True, None, None, False] > [None, False, False, None ] > [False, True, True, True ] > etc. > > For a given list: > * If all values are None, the function should r

Re: returning True, False or None

2005-02-04 Thread Brian van den Broek
Alex Martelli said unto the world upon 2005-02-04 13:02: Steven Bethard <[EMAIL PROTECTED]> wrote: I have lists containing values that are all either True, False or None, e.g.: [True, None, None, False] [None, False, False, None ] [False, True, True, True ] etc. For a given l

Persistence design [was: RE: OT: why are LAMP sites slow?]

2005-02-04 Thread Robert Brewer
Jack Diederich wrote: > *ding*ding*ding* The biggest mistake I've made most > frequently is using > a database in applications. YAGNI. Using a database at all has it's > own overhead. Using a database badly is deadly. Most sites would > benefit from ripping out the database and doing somethin

bicyclerepairman python24 windows idle :(

2005-02-04 Thread EuGeNe
Hi there, I am no expert but wanted to give bicyclerepairman 0.9 a go just to see what a refactoring browser is and does. Followed every step of the install, I think, but idle doesn't start with the RepairMan section in config-extensions.def ... is it incompatible with 2.4? Thanks for your help

Re: Converting strings to dates

2005-02-04 Thread Kartic
py> import time py> date_str = time.strftime('%Y-%m-%d', time.localtime()) py> date_str '2005-02-04' py> time.strptime(date_str, '%Y-%m-%d') (2005, 2, 4, 0, 0, 0, 4, 35, -1) That work? -- http://mail.python.org/mailman/listinfo/python-list

Re: advice needed for simple python web app

2005-02-04 Thread Ant
> You might also look at the docs for HTML::Mason (www.masonhq.com) to > get a look at a reasonably mature template system, even if you don't > plan to use it (because it's in Perl and not Python). I'm not sure if > CherryPy is directly comparable. I haven't yet used any of the Python > template

Re: Thread in python

2005-02-04 Thread Aahz
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > >http://starship.python.net/crew/aahz/OSCON2001/index.html Thanks! But while that's still good (for the code, if nothing else), it ought to be at least supplemented with http://heather.cs.ucdavis.edu/~matloff/Python/PyThre

newbie: Syntax error

2005-02-04 Thread Chad Everett
Hi Everyone, I am new to Python and programming in general. I bought the book "Python Programming for the Absolute Beginner" by michael Dawson. I have been working through it but am having trouble. I am trying to make a coin flip program and keep geting a Synax Error "invalid syntax". If anyone

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Mike C. Fletcher
Alan McIntyre wrote: ... I have a list of items that has contiguous repetitions of values, but the number and location of the repetitions is not important, so I just need to strip them out. For example, if my original list is [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5], I want to end up with [0,1,2,3,

empty classes as c structs?

2005-02-04 Thread Christopher J. Bottaro
I find myself doing the following very often: class Struct: pass ... blah = Struct() blah.some_field = x blah.other_field = y ... Is there a better way to do this? Is this considered bad programming practice? I don't like using tuples (or lists) because I'd rather use symbolic names, ra

Re: newbie: Syntax error

2005-02-04 Thread Kartic
Chad, The usage is like this: - if : - - elif : - - else: - So, your code should be: if tries == 1: elif tries == 2: (You have 'else' followed by a condition...hence a syntax error. else is what it means - "if no other condition is satisfied". You should use 'elif' for s

Re: newbie: Syntax error

2005-02-04 Thread Matt
Chad Everett wrote: > Hi Everyone, > > I am new to Python and programming in general. I bought the book "Python > Programming for the Absolute Beginner" by michael Dawson. > > I have been working through it but am having trouble. > I am trying to make a coin flip program and keep geting a Synax E

Re: newbie: Syntax error

2005-02-04 Thread F. Petitjean
Le Fri, 4 Feb 2005 12:49:51 -0600, Chad Everett a écrit : > Hi Everyone, > > I am new to Python and programming in general. I bought the book "Python > Programming for the Absolute Beginner" by michael Dawson. > > I am trying to make a coin flip program and keep geting a Synax Error > "invalid s

Re: newbie: Syntax error

2005-02-04 Thread Bill Mill
Chad, try "elif tries == 2" or just "else:". You are not allowed to put an expression after an else statement. I recommend you read the python tutorial at http://docs.python.org/tut/tut.html . Peace Bill Mill bill.mill at gmail.com On Fri, 4 Feb 2005 12:49:51 -0600, Chad Everett <[EMAIL PROTEC

[perl-python] get web page programatically

2005-02-04 Thread Xah Lee
# -*- coding: utf-8 -*- # Python # suppose you want to fetch a webpage. from urllib import urlopen print urlopen('http://xahlee.org/Periodic_dosage_dir/_p2/russell-lecture.html').read() # note the line # from import # it reads the library and import the function name # to see available function

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread Steven Bethard
Mike C. Fletcher wrote: Alan McIntyre wrote: ... I have a list of items that has contiguous repetitions of values, but the number and location of the repetitions is not important, so I just need to strip them out. For example, if my original list is [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5], I want t

Re: empty classes as c structs?

2005-02-04 Thread Steven Bethard
Christopher J. Bottaro wrote: I find myself doing the following very often: class Struct: pass ... blah = Struct() blah.some_field = x blah.other_field = y ... Is there a better way to do this? Yes -- help me rally behind my generic object PEP which proposes a Bunch type (probably to be re

Re: [perl-python] get web page programatically

2005-02-04 Thread Dan Perl
"Xah Lee" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] # note the line # from import # it reads the library and import the function name # to see available functions in a module one can use "dir" # import urllib; print dir(urllib) After about a month, this tutorial has finally r

string issue

2005-02-04 Thread rbt
Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that??? import time ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.

Re: empty classes as c structs?

2005-02-04 Thread Alan McIntyre
Christopher, I've found myself doing the same thing. You could do something like this: blah = type('Struct', (), {})() blah.some_field = x I think I'd only do this if I needed to construct objects at runtime based on information that I don't have at compile time, since the two lines of code for

EDI x12 --> XML

2005-02-04 Thread Greg Lindstrom
Hello, List- I am working on automating a system accepting input data in EDI x12 format and would like to convert it to XML. Before I start, I thought I'd ask if anyone has worked on such a beast. I have seen work by Chris Cioffi on parsing EDI records. Is anything else out there before I ei

Re: string issue

2005-02-04 Thread Bill Mill
On Fri, 04 Feb 2005 14:23:36 -0500, rbt <[EMAIL PROTECTED]> wrote: > Either I'm crazy and I'm missing the obvious here or there is something > wrong with this code. Element 5 of this list says it doesn't contain the > string 255, when that's *ALL* it contains... why would it think that??? > > impo

Re: string issue

2005-02-04 Thread Alan McIntyre
I think it's because you're modifying the list as you're iterating over it. Try this: import time ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34'] ips_new = [] for ip in ips: if '255' not in ip: ips_new.append(ip) print

Re: string issue

2005-02-04 Thread Steven Bethard
rbt wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that??? import time ips = ['255.255.255.255', '128.173.120.79', '198.82.247.

Re: string issue

2005-02-04 Thread Steve Holden
rbt wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that??? import time ips = ['255.255.255.255', '128.173.120.79', '198.82.247.

Re: string issue

2005-02-04 Thread rbt
Thanks guys... list comprehension it is! Bill Mill wrote: On Fri, 04 Feb 2005 14:23:36 -0500, rbt <[EMAIL PROTECTED]> wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL*

Re: string issue

2005-02-04 Thread Alan McIntyre
Wow, that's cool; I'd never seen that before. :) Thanks, Steve.. Steve Holden wrote: You are modifying the list as you iterate over it. Instead, iterate over a copy by using: for ip in ips[:]: ... regards Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting strings to dates

2005-02-04 Thread Dan Bishop
Chermside, Michael wrote: > I'm trying to convert a string back into a datetime.date. > > First I'll create the string: > > > Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import time, da

Re: string issue

2005-02-04 Thread rbt
Steve Holden wrote: rbt wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that??? import time ips = ['255.255.255.255', '128.173.

Re: ANN: PyDev 0.9.0 released

2005-02-04 Thread Christophe Cavalaria
Fabio Zadrozny wrote: > Hi All, > > PyDev - Python IDE (Python development enviroment for Eclipse) version > 0.9.0 has just been released. > > This release supports python 2.4 and has PyLint 0.6 integrated. > Code completion had some improvements too. > > Check the homepage for more details (ht

Re: exporting mesh from image data

2005-02-04 Thread Fernando Perez
John Hunter wrote: >> "Fernando" == Fernando Perez <[EMAIL PROTECTED]> writes: > > Fernando> I hope you posted this on the VTK list with a CC to > Fernando> Prabhu as well... The hopes of a positive reply there > Fernando> are, I suspect, a fair bit higher. The scipy list would

Re: IPython colors in windows

2005-02-04 Thread Fernando Perez
Claudio Grondi wrote: > I use this one, > http://heanet.dl.sourceforge.net/sourceforge/uncpythontools/readline-1.7.win > 32.exe > which I assume is the right one. Try version 1.8, some coloring problems have been recently fixed. If that doesn't do it, let me know and I'll try to get in touch wit

Re: string issue

2005-02-04 Thread Fredrik Lundh
"rbt" <[EMAIL PROTECTED]> wrote: >> You are modifying the list as you iterate over it. Instead, iterate over a >> copy by using: >> >> for ip in ips[:]: >> ... >> >> regards >> Steve > > Very neat. That's a trick that everyone should know about. I suppose that's why it's included in the Pytho

Re: OT: why are LAMP sites slow?

2005-02-04 Thread M.E.Farmer
Jeffery Froman wrote: > One caveat here -- I don't believe you can (should) nest > a inside a > , or for that matter, nest any block-level element > inside an inline element. Jeffrey, Actually I have not shown that in the example. But for the sake of clarity, I am glad you mentioned it. Overall I

Re: string issue

2005-02-04 Thread Steven Bethard
Steve Holden wrote: You are modifying the list as you iterate over it. Instead, iterate over a copy by using: for ip in ips[:]: ... Also worth noting, you can write this like: for ip in list(ips): ... if you're afraid of smiley-faces [:] in your code. ;) Steve -- http://mail.python.

Re: string issue

2005-02-04 Thread rbt
Alan McIntyre wrote: I think it's because you're modifying the list as you're iterating over In this case then, shouldn't my 'except Exception' raise an error or warning like: "Hey, stupid, you can't iterate and object and change it at the same time!" Or, perhaps something similar? -- http://mai

Re: string issue

2005-02-04 Thread Bill Mill
On Fri, 04 Feb 2005 14:43:30 -0500, rbt <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > rbt wrote: > > > >> Either I'm crazy and I'm missing the obvious here or there is > >> something wrong with this code. Element 5 of this list says it doesn't > >> contain the string 255, when that's *ALL* i

Re: string issue

2005-02-04 Thread rbt
Alan McIntyre wrote: I think it's because you're modifying the list as you're iterating over it. One last clarification on this. It's OK to modify the elements of a list, but not the list itself while iterating over it... is that the correct way to think about this? -- http://mail.python.org/m

Re: returning True, False or None

2005-02-04 Thread Fredrik Lundh
Steven Bethard wrote: >> return max(lst) > > Very clever! Thanks! too clever. boolean > None isn't guaranteed by the language specification: http://docs.python.org/ref/comparisons.html "... objects of different types always compare unequal, and are ordered consistently but arbitr

Re: returning True, False or None

2005-02-04 Thread Peter Otten
Steven Bethard wrote: > I have lists containing values that are all either True, False or None, > e.g.: > > [True, None, None, False] > [None, False, False, None ] > [False, True, True, True ] > etc. > > For a given list: > * If all values are None, the function should

Possibly OT: Controlling winamp with Python

2005-02-04 Thread Brent W. Hughes
I'm running Windows XP and I'm using winamp to listen to internet radio stations. Occasionally, an annoying commercial will come on. I would like to write a Python program that, when run, will, in essence, push on winamp's mute button. Then, after say 20 seconds, it will push the mute button

Re: returning True, False or None

2005-02-04 Thread Steven Bethard
Fredrik Lundh wrote: Steven Bethard wrote: Raymond Hettinger wrote: return max(lst) Very clever! Thanks! too clever. boolean > None isn't guaranteed by the language specification: Yup. I thought about mentioning that for anyone who wasn't involved in the previous thread discussing this behavio

Re: string issue

2005-02-04 Thread John J. Lee
Steve Holden <[EMAIL PROTECTED]> writes: [...] > You are modifying the list as you iterate over it. Instead, iterate > over a copy by using: > > for ip in ips[:]: >... Just to help popularise the alternative idiom, which IMO is significantly less cryptic (sane constructors of mutable objects

executing VBScript from Python and vice versa

2005-02-04 Thread Valentina Boycheva
Is there a way to make programs written in these two languages communicate with each other? I am pretty sure that VBScript can access a Python script because Python is COM compliant. On the other hand, Python might be able to call a VBScript through WSH. Can somebody provide a simple example? I hav

Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Kartic
Brent, Question : how will your python script distinguish between a commercial and a song? I can understand if you are writing a streaming client in Python; in that case you can analyze the audio stream and decide if it is a commercial or a song/music. Did you check to see if there is already a

Re: CGI and HTTP Header Location redirects

2005-02-04 Thread Derek Basch
A... I should have been more specific before. The Apache error log doesn't produce an error. You are probably correct that it is most likely an Apache/Unix problem. I thought perhaps someone had maybe run into this before since it seems like such a basic function to not work. Thanks for the hel

Re: string issue

2005-02-04 Thread rbt
John J. Lee wrote: Steve Holden <[EMAIL PROTECTED]> writes: [...] You are modifying the list as you iterate over it. Instead, iterate over a copy by using: for ip in ips[:]: ... Just to help popularise the alternative idiom, which IMO is significantly less cryptic (sane constructors of mutable o

Re: newbie: Syntax error

2005-02-04 Thread John Machin
Chad Everett wrote: > Hi Everyone, > > I am new to Python and programming in general. I bought the book "Python > Programming for the Absolute Beginner" by michael Dawson. > > I have been working through it but am having trouble. > I am trying to make a coin flip program and keep geting a Synax Er

Re: returning True, False or None

2005-02-04 Thread Jeff Shannon
Jeremy Bowers wrote: On Fri, 04 Feb 2005 10:48:44 -0700, Steven Bethard wrote: For a given list: * If all values are None, the function should return None. * If at least one value is True, the function should return True. * Otherwise, the function should return False. Yes, I see the smell, you are

Re: executing VBScript from Python and vice versa

2005-02-04 Thread aurora
Go to the bookstore and get a copy of Python Programming on Win32 by Mark Hammond, Andy Robinson today. http://www.oreilly.com/catalog/pythonwin32/ It has everything you need. Is there a way to make programs written in these two languages communicate with each other? I am pretty sure that VBScr

changing local namespace of a function

2005-02-04 Thread Bo Peng
Dear list, I have many dictionaries with the same set of keys and I would like to write a function to calculate something based on these values. For example, I have a = {'x':1, 'y':2} b = {'x':3, 'y':3} def fun(dict): dict['z'] = dict['x'] + dict['y'] fun(a) and fun(b) will set z in each dicti

Re: string issue

2005-02-04 Thread Jeremy Bowers
On Fri, 04 Feb 2005 14:49:43 -0500, rbt wrote: > Alan McIntyre wrote: >> I think it's because you're modifying the list as you're iterating over > > In this case then, shouldn't my 'except Exception' raise an error or > warning like: > > "Hey, stupid, you can't iterate and object and change it

Re: string issue

2005-02-04 Thread Bill Mill
On Fri, 04 Feb 2005 15:25:04 -0500, rbt <[EMAIL PROTECTED]> wrote: > John J. Lee wrote: > > Steve Holden <[EMAIL PROTECTED]> writes: > > [...] > > > >>You are modifying the list as you iterate over it. Instead, iterate > >>over a copy by using: > >> > >>for ip in ips[:]: > >> ... > > > > > > Just

Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Brent W. Hughes
The Python program won't decide whether a commercial is playing, I will. At that point, I will run my program which will press mute, wait 20 seconds, and then press mute again. Actually, I could leave the program running but minimized to the task bar. When I hear the advertisement, I just clic

Re: "Collapsing" a list into a list of changes

2005-02-04 Thread John J. Lee
Steven Bethard <[EMAIL PROTECTED]> writes: > Mike C. Fletcher wrote: [...] > > >>> def changes( dataset ): > > ... last = None > > ... for value in dataset: > > ... if value != last: > > ... yield value > > ... last = value > > ...>>> print list(changes

Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Bill Mill
Brent, You could write the Python program as a proxy of the internet stream. Basically, you would point your proxy at the web stream and receive the data it sends. At the same time, you would be listening for connections on some socket on the local machine. You would then point winamp towards the

Re: How to enable Python Scripts with MS IIS Web Server?

2005-02-04 Thread jb
hi, you should first install win32all : http://starship.python.net/crew/mhammond/ next, 2 ways 2 proceed, but the first is the easier : you make a "test.asp" page in the folder at the top, you write <@Language=Python%> a line below : <%Response.Write("Hello World")%>

Re: Thread in python

2005-02-04 Thread Do Re Mi chel La Si Do
Hi ! Look the smart/fun use of threads make by http://candygram.sourceforge.net It's good for to know... @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: string issue

2005-02-04 Thread rbt
Bill Mill wrote: On Fri, 04 Feb 2005 15:25:04 -0500, rbt <[EMAIL PROTECTED]> wrote: John J. Lee wrote: Steve Holden <[EMAIL PROTECTED]> writes: [...] You are modifying the list as you iterate over it. Instead, iterate over a copy by using: for ip in ips[:]: ... Just to help popularise the altern

Re: ANN: Frog 1.3 released (python 'blog' application)

2005-02-04 Thread Irmen de Jong
Jorey Bump wrote: Irmen de Jong <[EMAIL PROTECTED]> wrote in news:41fcf53b [EMAIL PROTECTED]: I've just uploaded the Frog 1.3 release. Frog is a blog (web log) system written in 100% Python. It is a web application written for Snakelets. It outputs XHTML, is fully unicode compatible, small, and do

Re: returning True, False or None

2005-02-04 Thread Raymond Hettinger
"Steven Bethard" > For a given list: > * If all values are None, the function should return None. > * If at least one value is True, the function should return True. > * Otherwise, the function should return False. One more approach, just for grins: s = set(lst) return True in s or s == s

Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Josef Meile
Hi Brent, Brent W. Hughes wrote: The Python program won't decide whether a commercial is playing, I will. At that point, I will run my program which will press mute, wait 20 seconds, and then press mute again. Actually, I could leave the program running but minimized to the task bar. When I he

Re: changing local namespace of a function

2005-02-04 Thread M.E.Farmer
Hello Bo, Don't use dict it is a builtin ;) Also try this stuff out in an interpreter session it is easy and fast to get your own answers. >>> def fun(d): ... __dict__ = d ... return __dict__ hth, M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Dave Brueck
Brent W. Hughes wrote: I'm running Windows XP and I'm using winamp to listen to internet radio stations. Occasionally, an annoying commercial will come on. I would like to write a Python program that, when run, will, in essence, push on winamp's mute button. Then, after say 20 seconds, it wil

FW: executing VBScript from Python and vice versa

2005-02-04 Thread Valentina Boycheva
Thanks for the reply. I already have "Learning Python" from Mark Lutz and David Ascher, which covers 2.3 (I am in 2.4). However, it seems like heavy artillery to me. What I want is, for instance, run a VBScript to get a function output and feed it to the Python script that called it. The reason is

Re: IPython colors in windows

2005-02-04 Thread Claudio Grondi
I have installed version 1.8. It makes is even worse, because now also "In [1]:" gets black background and is unreadable (it had a grey background before). Re-installing 1.7 makes the background again gray. I use German Windows 2000 SP 4 as OS. Claudio P.S. In quote marks the parts with black back

Re: [perl-python] get web page programatically

2005-02-04 Thread Chris Mattern
Xah Lee wrote: Just the standard warnings for any novices unfamiliar with Mr. Lee. Mr. Lee's posts are regularly riddled with severe errors (I found the assertion that LWP::Simple and LWP::UserAgent aren't part of the standard base perl install a particularly amusing one in this particular post

Re: returning True, False or None

2005-02-04 Thread Daniel Bickett
I'm seeing a consistent problem in most of these approaches. Verbalized, the logic of the OP's original code reads as such: If True is in the list *at all*, return True. Otherwise, if False is in the list *at all*, return False. Otherwise, return None. So if we used Alex Martelli's code: > for v

Re: string issue

2005-02-04 Thread Terry Reedy
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > You are modifying the list as you iterate over it. Instead, iterate over > > a copy by using: > for ip in ips[:]: Or if you are only deleting items, you can iterate backwards. You can also build a new list with only

Pickling and inheritance are making me hurt

2005-02-04 Thread Kirk Strauser
I have a module that defines a Search class and a SearchResult class. I use these classes by writing other modules that subclass both of them as needed to interface with particular search engines. My problem is that Search defines a method (called automatically by __del__) to save its results bet

Re: Weekly Python Patch/Bug Summary

2005-02-04 Thread Terry Reedy
"David Fraser" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Kurt B. Kaiser wrote: >> Patch / Bug Summary >> ___ >> >> Patches : 284 open ( +4) / 2748 closed ( +1) / 3032 total ( +5) >> Bugs: 804 open ( +1) / 4812 closed (+13) / 5616 total (+14) >> RFE

Re: [Fwd: [gnu.org #220719] Re: python and gpl]

2005-02-04 Thread Tim Churches
Richard Brodie wrote: "Tim Churches" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] 1) In Australia and Europe at least, loading program code from disc into memory in order to execute it is not considered as making an infringing copy under copyright law. I don't think it's as c

Re: changing local namespace of a function

2005-02-04 Thread Michael Spencer
Bo Peng wrote: Dear list, I have many dictionaries with the same set of keys and I would like to write a function to calculate something based on these values. For example, I have a = {'x':1, 'y':2} b = {'x':3, 'y':3} def fun(dict): dict['z'] = dict['x'] + dict['y'] fun(a) and fun(b) will set

Re: string issue

2005-02-04 Thread Steve Holden
Terry Reedy wrote: "Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [ ... ] This seems much more sensible to me than building a new list with everything (a copy), including things you don't want, and then deleting the things you don't want (an O(n**2) operation). Whic

Re: Possible additions to the standard library? (WAS: About standardlibrary improvement)

2005-02-04 Thread Kent Johnson
Daniel Bickett wrote: |def reverse( self ): |""" |Return a reversed copy of string. |""" |string = [ x for x in self.__str__() ] |string.reverse() |return ''.join( string ) def reverse(self): return self[::-1] Kent -- http://mail.python.org/ma

Re: [Fwd: [gnu.org #220719] Re: python and gpl]

2005-02-04 Thread Tim Churches
Tim Churches wrote: > Can't get much clearer than that. Whoops! Sorry about all the embedded HTML links, making it most unclear. Here is the relevant Australian law in a clearer form: COPYRIGHT ACT 1968 (as amended by the Copyright Amendment Act 2000) - SECT 47B *Reproduction for normal

Re: IPython colors in windows

2005-02-04 Thread Ashot
this is what it looks like: http://www.freshraisins.com/sand/ipythonscreen.PNG does cygwin have a readline utility in it? Perhaps this is overriding the correct one? Thats the only thing I can think of. .a On Fri, 4 Feb 2005 22:35:45 -, Claudio Grondi <[EMAIL PROTECTED]> wrote: I have i

Re: Persistence design [was: RE: OT: why are LAMP sites slow?]

2005-02-04 Thread Jack Diederich
On Fri, Feb 04, 2005 at 10:31:19AM -0800, Robert Brewer wrote: > Jack Diederich wrote: > > *ding*ding*ding* The biggest mistake I've made most > > frequently is using > > a database in applications. YAGNI. Using a database at all has it's > > own overhead. Using a database badly is deadly. Mo

Re: IPython colors in windows

2005-02-04 Thread Fernando Perez
Ashot wrote: > this is what it looks like: > > http://www.freshraisins.com/sand/ipythonscreen.PNG > > does cygwin have a readline utility in it? Perhaps this is overriding the > correct one? Thats the only thing I can think of. Thanks for the screenshot. I've contacted the readline author, I

Re: returning True, False or None

2005-02-04 Thread Jeremy Bowers
On Fri, 04 Feb 2005 16:44:48 -0500, Daniel Bickett wrote: > [ False , False , True , None ] > > False would be returned upon inspection of the first index, even > though True was in fact in the list. The same is true of the code of > Jeremy Bowers, Steve Juranich, and Jeff Shannon. As for Raymond

Re: returning True, False or None

2005-02-04 Thread Daniel Bickett
Jeremy Bowers wrote: > The defense rests, your honor. :-) I stand corrected :-) My apologies. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: IPython colors in windows

2005-02-04 Thread Fernando Perez
Ashot wrote: > this is what it looks like: > > http://www.freshraisins.com/sand/ipythonscreen.PNG > > does cygwin have a readline utility in it? Perhaps this is overriding the > correct one? Thats the only thing I can think of. Hi folks, could you please test under windows the 1.9 version of

Re: empty classes as c structs?

2005-02-04 Thread Scott David Daniels
Christopher J. Bottaro wrote: I find myself doing the following very often: class Struct: pass ... blah = Struct() blah.some_field = x blah.other_field = y ... Is there a better way to do this? Is this considered bad programming practice? I don't like using tuples (or lists) because I'd r

[noob] Error!

2005-02-04 Thread administrata
I'm programming Car Salesman Program. It's been "3 days" learning python... But, i got problem Write a Car Salesman program where the user enters the base price of a car. The program should add on a bunch of extra fees such as tax, license, dealer prep, and destination charge. Make tax and licens

Re: string issue

2005-02-04 Thread Steven Bethard
rbt wrote: John J. Lee wrote: Steve Holden <[EMAIL PROTECTED]> writes: [...] You are modifying the list as you iterate over it. Instead, iterate over a copy by using: for ip in ips[:]: ... Just to help popularise the alternative idiom, which IMO is significantly less cryptic (sane constructors of

Re: IPython colors in windows

2005-02-04 Thread Fernando Perez
Fernando Perez wrote: > Hi folks, > > could you please test under windows the 1.9 version of readline? > > http://sourceforge.net/project/showfiles.php?group_id=82407&package_id=84552&release_id=302513 > > This was just put up a moment ago by the developer, let me know if it fixes > these probl

Re: Persistence design [was: RE: OT: why are LAMP sites slow?]

2005-02-04 Thread Carlos Ribeiro
On Fri, 4 Feb 2005 17:46:44 -0500, Jack Diederich <[EMAIL PROTECTED]> wrote: > On Fri, Feb 04, 2005 at 10:31:19AM -0800, Robert Brewer wrote: > > Jack Diederich wrote: > > > If there is interest I'll follow up with some details on my own LAMP > > > software which does live reports on gigs of data a

<    1   2   3   >