Re: Global Variables in OOP and Python

2005-12-30 Thread Brian van den Broek
Gary Herron said unto the world upon 30/12/05 08:03 PM: > newbie wrote: > > >>Hello, >> >>I have questions about global variables in OOP (in general) and Python >>(in specific). I understand (I think) that global variables are >>generally not a good idea. However, if there are variables that nee

On threads and constructors

2005-12-30 Thread techiepundit
I have a class: class ServerThreadManager(threading.Thread): def __init__(self): threading.Thread.__init__(self) # and a bunch of constructor statements def run(self): self.ReqHandlingLoop() # and a bunch of other methods ServerObj = ServerThreadManager() pr

Re: python coding contest

2005-12-30 Thread Christoph Zwerschke
Mark Dickinson wrote: > Here's a variant of André's brilliant idea that's > 119 characters long, and fully printable: > > j=''.join;seven_seg=lambda z:j(j(' _ | |_ _|_|' > [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z) > +"\n"for u in(3,7,8)) You have an escaped CR (\r) as the last character

Re: List index method for complex list item types?

2005-12-30 Thread techiepundit
Mike, I'm trying to figure out dictionaries using the documentation. Clicking on "dictionary type" takes me to "2.3.8 Mapping Types -- classdict". Is that the documentation for the dictionary type? If so, I do not see an "append" or "add" or "insert" method defined in the list of methods on that p

Re: On threads and constructors

2005-12-30 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I have a class: > > class ServerThreadManager(threading.Thread): > def __init__(self): > threading.Thread.__init__(self) > # and a bunch of constructor statements > > def run(self): > self.ReqHandlingLoop() > > # and a bunch of other

questions about py2exe and wax

2005-12-30 Thread iclinux
Using py2exe, I can convert a GUI Application with PythonCard to a standalone windows program, and it works. Then I try another GUI Toolkit named Wax, implement a GUI App, it works. And I convert that app by py2exe. But this time, when run, it show a messagebox that says: """ This application req

Re: List index method for complex list item types?

2005-12-30 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I'm trying to figure out dictionaries using the documentation. Clicking > on "dictionary type" takes me to "2.3.8 Mapping Types -- classdict". Is > that the documentation for the dictionary type? If so, I do not see an > "append" or "add" or "insert" method defined in th

Re: List index method for complex list item types?

2005-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2005 18:56:47 -0800, techiepundit wrote: > Mike, > > I'm trying to figure out dictionaries using the documentation. Clicking > on "dictionary type" takes me to "2.3.8 Mapping Types -- classdict". Is > that the documentation for the dictionary type? If so, I do not see an > "append"

Re: Global Variables in OOP and Python

2005-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2005 20:00:51 -0500, Mike Meyer wrote: >> The other way I thought of is to create a separate class that consists >> of the variables and to use the >> >> from import * >> >> in all of the files (namespaces) where it is needed. > > Except for one detail, this is a Pythonesque meth

Re: Python as a Server vs Running Under Apache

2005-12-30 Thread grahamd
> as great as mod_python is, there are lots of restrictions and > limitations to what youc an do with it because of limitations of apache > itself, and I am refereing to apache 2.x as well as 1.x, like others > are saying if you don't need apache specific things it will just be one > more thing to

why writing list to file puts each item from list on seperate line?

2005-12-30 Thread homepricemaps
if i use the code below to write a list to a file list = (food, price, store) data.append(list) f = open(r"test.txt", 'a') f.write ( os.linesep.join( list ) ) it outputs to a file like this apple .49 star market and i want it to do apple, .49. star market any ideas -- http://mail.python.or

why writing list to file puts each item from list on seperate line?

2005-12-30 Thread homepricemaps
if i use the code below to write a list to a file list = (food, price, store) data.append(list) f = open(r"test.txt", 'a') f.write ( os.linesep.join( list ) ) it outputs to a file like this apple .49 star market and i want it to do apple, .49. star market any ideas -- http://mail.python.or

Memoization and encapsulation

2005-12-30 Thread Steven D'Aprano
I was playing around with simple memoization and came up with something like this: _cache = {} def func(x): global _cache if _cache.has_key(x): return _cache[x] else: result = x+1 # or a time consuming calculation... _cache[x] = result return result w

Re: why writing list to file puts each item from list on seperate line?

2005-12-30 Thread limodou
30 Dec 2005 20:22:52 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > if i use the code below to write a list to a file > > list = (food, price, store) > data.append(list) > f = open(r"test.txt", 'a') > f.write ( os.linesep.join( list ) ) > > > it outputs to a file like this > > apple > .49 > star m

Re: why writing list to file puts each item from list on seperate line?

2005-12-30 Thread homepricemaps
i want them to be on the same line when they are written to the file. right now they are written like this: food price store i want them to be written like this food price store how do i do that? -- http://mail.python.org/mailman/listinfo/python-list

Re: questions about py2exe and wax

2005-12-30 Thread Hans Nowak
iclinux wrote: > Using py2exe, I can convert a GUI Application with PythonCard to a > standalone windows program, and it works. > Then I try another GUI Toolkit named Wax, implement a GUI App, it > works. And I convert that app by py2exe. But this time, when run, it > show a messagebox that says:

Re: why writing list to file puts each item from list on seperate line?

2005-12-30 Thread limodou
30 Dec 2005 20:44:29 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > i want them to be on the same line when they are written to the file. > right now they are written like this: > > food > price > store > > i want them to be written like this > > food price store > > how do i do that? > >>> prin

Re: why writing list to file puts each item from list on seperate line?

2005-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2005 20:22:52 -0800, homepricemaps wrote: > if i use the code below to write a list to a file > > list = (food, price, store) Why are you shadowing the built in type list? This is bad practice. Sooner or later you will do this: list = [1, 2, 3] something = process(list) ... lots

Re: Memoization and encapsulation

2005-12-30 Thread bonono
Steven D'Aprano wrote: > I was playing around with simple memoization and came up with something > like this: > > _cache = {} > def func(x): > global _cache > if _cache.has_key(x): > return _cache[x] > else: > result = x+1 # or a time consuming calculation... >

Re: Memoization and encapsulation

2005-12-30 Thread Raymond Hettinger
Steven D'Aprano wrote: > I was playing around with simple memoization and came up with something > like this: > > _cache = {} > def func(x): > global _cache > if _cache.has_key(x): > return _cache[x] > else: > result = x+1 # or a time consuming calculation... >

Re: Memoization and encapsulation

2005-12-30 Thread Raymond Hettinger
Steven D'Aprano wrote: > I was playing around with simple memoization and came up with something > like this: > > _cache = {} > def func(x): > global _cache > if _cache.has_key(x): > return _cache[x] > else: > result = x+1 # or a time consuming calculation... >

Re: UpDate For SCSIPython Storage device test library

2005-12-30 Thread sam
Just a added note,that these routines will access any storage drive that is mounted under Windows. The Scsi Pass Through layer maps all Pcmcia,IDE,andSCSI drives to use SCSI commands. This allows a user to access all these interfaces with a common command set. Sam Schulenburg -- http://mail.pyth

Re: why writing list to file puts each item from list on seperate line?

2005-12-30 Thread homepricemaps
never mind i figured out what you were saying,. worked like a charm! thanks for your help. yaffa -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange interaction between exec, dictionary subtypes, and global variables in 2.4

2005-12-30 Thread Alex Martelli
Crutcher <[EMAIL PROTECTED]> wrote: ... > Except that there is some niggling edge case dealing with variables > which have been marked 'global'. It seems that if a compiled chunk of > python contains a 'global VAR' statement, anywhere, then that VAR, and > only that VAR, will bypass the subclass

Photogallery written in Python?

2005-12-30 Thread Arthur Pemberton
Does anyone know of a photo gallery implemented in python? Preferably one as featureful as those used at kde-look.org and art.gnome.org?Thank you. -- As a boy I jumped through Windows, as a man I play with Penguins. -- http://mail.python.org/mailman/listinfo/python-list

<    1   2