Re: scopes of local and global variable

2006-12-22 Thread Fredrik Lundh
Pyenos wrote: > does class WORK inherit t_len=0 from line1? > > does def getwork() inherit t_len=0 from line1? > > does def formattable(table_to_process,type) inherit t_len=0 from line1? > > does def format_t() inherit t_len=0 from line1? you may want to read the documentation: http://do

Re: scopes of local and global variable

2006-12-22 Thread Fredrik Lundh
Pyenos wrote: > does class WORK inherit t_len=0 from line1? > > does def getwork() inherit t_len=0 from line1? > > does def formattable(table_to_process,type) inherit t_len=0 from line1? > > does def format_t() inherit t_len=0 from line1? you may want to read the documentation: http://do

Re: Use a Thread to reload a Module?

2006-12-22 Thread Hendrik van Rooyen
"Gregory Piñero" <[EMAIL PROTECTED]> wrote: > Hi Python Experts, > > I hope I can explain this right. I'll try. > > Background: > I have a module that I leave running in a server role. It has a > module which has data in it that can change. So every nth time a > function in the server gets ca

Re: Retrieve Tkinter listbox item by string, not by index

2006-12-22 Thread Hendrik van Rooyen
"Kevin Walzer" <[EMAIL PROTECTED]> wrote: > I'm trying to set the active item in a Tkinter listbox to my > application's currently-defined default font. not sure if you can mix fonts in a listbox - the font option when you create the listbox instance seems to apply globally to all the lines in

httplib and socket.getaddrinfo

2006-12-22 Thread mirandacascade
I noticed the following lines from the connect() method of the HTTPConnection class within httplib: for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res This led me to the doc

Re: Generating all permutations from a regexp

2006-12-22 Thread Nick Craig-Wood
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > > A regular expression matcher uses a state machine to match strings. > > unless it's the kind of regular expression matcher that doesn't use a > state machine, like the one in Python. Ah! Well that is outside of my exper

Python and AltiVec

2006-12-22 Thread mo3749
Hi, Is there any library or linkings or compatibilities of Python with AltiVec(r). I KNOW, It is all very OLD stuff, but I just want to know -- http://mail.python.org/mailman/listinfo/python-list

Re: are there Tomboy and F-Spot equivalents?

2006-12-22 Thread [EMAIL PROTECTED]
On Dec 22, 4:01 am, "Tshepang Lekhonkhobe" <[EMAIL PROTECTED]> wrote: > Hi, > I dislike installing the entire Mono stack simply to take notes and > manage photos, and am totally biased towards Python. At least for > search I got Tracker, instead of Beagle. > Are there equvalents applications for

Re: How a script can know if it has been called with the -i commandlineoption?

2006-12-22 Thread Hendrik van Rooyen
"Michele Simionato" <[EMAIL PROTECTED]> wrote: > Hendrik van Rooyen wrote: > > "Michele Simionato" <[EMAIL PROTECTED]> wrote: > > > but I don't see a way to retrieve the command line flags, where should > > > I look? > > > > sys.argv() ? > > > > - Hendrik > > No, read what Carsten said: > """

Re: Question about Tkinter windows

2006-12-22 Thread Hendrik van Rooyen
Manuel Malo de Molina wrote in an email: >Hi, thanks for answering. The problem is that the window >can be closed in many ways (including some not >controlled by the program, as the X on the top right), >is there a way to capture the window closing event? Please keep it on the list so that oth

Re: Using Tools/freeze.py on AIX -- having problems

2006-12-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > > Python seems to install correctly for the most part ("make test" gives > a few messages about things that are not quite right (3 failed tests > (test_mmap, test_pty, & test_resource) and 2 unexpectedly skipped Don't worry about these. > Name Fil

Re: Use a Thread to reload a Module?

2006-12-22 Thread Gregory Piñero
On 22 Dec 2006 20:02:31 -0800, Carl Banks <[EMAIL PROTECTED]> wrote: ... > There is much room for improvement. For example, can requests come in > fast enough to spawn another load_data before the first had ended? You > should consider trying to acquire a threading.Lock in load_data and > waiting

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Gabriel Genellina wrote: > At Friday 22/12/2006 22:58, Carl Banks wrote: > > > > Usually no other files need to change. Ex: you have BigOldModule > > > including ClassA, ClassB and FunctionC. Move each one onto its own > > > module, perhaps including a subset of the original imports of > > > BigO

Re: Use a Thread to reload a Module?

2006-12-22 Thread Carl Banks
Gregory Piñero wrote: > Hi Python Experts, > > I hope I can explain this right. I'll try. > > Background: > I have a module that I leave running in a server role. It has a > module which has data in it that can change. So every nth time a > function in the server gets called, I want to reload th

[ANN] pyparsing 1.4.5 released

2006-12-22 Thread Paul McGuire
This latest version of pyparsing has a few minor bug-fixes and enhancements, and a performance improvement of up to 100% increase in parsing speed. This release also includes some new examples: - parsePythonValue.py - parses strings representing lists, dicts, and tuples, with nesting support - s

Re: One module per class, bad idea?

2006-12-22 Thread Gabriel Genellina
At Friday 22/12/2006 22:58, Carl Banks wrote: > Usually no other files need to change. Ex: you have BigOldModule > including ClassA, ClassB and FunctionC. Move each one onto its own > module, perhaps including a subset of the original imports of BigOldModule. > Shrink BigOldModule to just: > > f

Re: Generating all permutations from a regexp

2006-12-22 Thread Paul McGuire
On Dec 22, 8:30 am, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[

Re: pyparsing announcement?

2006-12-22 Thread Klaas
Paul McGuire wrote: > I have tried a couple of times now to post an announcement of the latest > version of pyparsing, but it does not seem to be making it past the news > server, neither through my local ISP's server nor through GoogleGroups. > Could it be because I am also posting to comp.lang.py

Re: let me simplify my question on scope of vars

2006-12-22 Thread Pyenos
Gabriel Genellina <[EMAIL PROTECTED]> writes: > At Friday 22/12/2006 22:24, Pyenos wrote: > > > > > "code" > > > > var=1 > > > > class CLASS: > > > > def METHOD1: > > > > def METHOD2: > > > > var+=var > > > > return var > > > >

Re: let me simplify my question on scope of vars

2006-12-22 Thread Terry Reedy
"Pyenos" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | "code" | var=1 | class CLASS: |def METHOD1: |def METHOD2: |var+=var |return var |METHOD2() #line8 |return var | METHOD1()

Re: attribute decorators

2006-12-22 Thread Terry Reedy
"Gert Cuykens" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | would it not be nice if you could assign decorators to attributes too ? | for example | | class C: |@staticattribute |data='hello' | | or | | class C: |@privateattribute |data='hello' No. @g def f(): pa

pyparsing announcement?

2006-12-22 Thread Paul McGuire
I have tried a couple of times now to post an announcement of the latest version of pyparsing, but it does not seem to be making it past the news server, neither through my local ISP's server nor through GoogleGroups. Could it be because I am also posting to comp.lang.python.announce, and this

Re: Retrieve Tkinter listbox item by string, not by index

2006-12-22 Thread James Stroud
James Stroud wrote: > Kevin Walzer wrote: > >> I'm trying to set the active item in a Tkinter listbox to my >> application's currently-defined default font. >> >> Here's how I get the fonts loaded into the listbox: >> >> self.fonts=list(tkFont.families()) >> self.fonts.sort() >> >> for item i

Refactoring between files (was: One module per class, bad idea?)

2006-12-22 Thread Ben Finney
"Paddy" <[EMAIL PROTECTED]> writes: > Are there tools out their to help with the refactoring task of > splitting a module into two or more sections then showing what other > files need to change? Sounds like a good feature to add to Bicycle Repair Man: http://bicyclerepair.sourceforge.net/>

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Gabriel Genellina wrote: > At Friday 22/12/2006 20:25, Paddy wrote: > > >Are there tools out their to help with the refactoring task of > >splitting a module into two or more sections then showing what other > >files need to change? > > Usually no other files need to change. Ex: you have BigOldMod

Re: Retrieve Tkinter listbox item by string, not by index

2006-12-22 Thread James Stroud
Kevin Walzer wrote: > I'm trying to set the active item in a Tkinter listbox to my > application's currently-defined default font. > > Here's how I get the fonts loaded into the listbox: > > self.fonts=list(tkFont.families()) > self.fonts.sort() > > for item in self.fonts: > sel

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Paddy wrote: > Carl Banks wrote: > > Erik Johnson wrote: > > > The file has now grown into a 6800 line beast (including docstring, > > > whitespace, and CVS history). Pretty much any time we implement some new > > > functionality, there are at least a few changes in that file. When you > >

Re: let me simplify my question on scope of vars

2006-12-22 Thread Gabriel Genellina
At Friday 22/12/2006 22:24, Pyenos wrote: > > "code" > > var=1 > > class CLASS: > > def METHOD1: > > def METHOD2: > > var+=var > > return var > > METHOD2() #line8 > > return var > > METHOD1()

Re: scopes of local and global variable

2006-12-22 Thread Gabriel Genellina
At Friday 22/12/2006 20:45, Pyenos wrote: # Error message says: # # UnboundLocalError: local variable 't_len' referenced before assignment# See item 6 in "10 Python pitfalls": -- Gabriel Gen

Re: let me simplify my question on scope of vars

2006-12-22 Thread Pyenos
Pyenos <[EMAIL PROTECTED]> writes: > Pyenos <[EMAIL PROTECTED]> writes: > > i will try to answer my own questions(pls verify): > > > "code" > > var=1 > > class CLASS: > > def METHOD1: > > def METHOD2: > > var+=var > > return var > >

Re: scopes of local and global variable

2006-12-22 Thread Pyenos
"Max Wilson" <[EMAIL PROTECTED]> writes: > Pyenos wrote: > > does class WORK inherit t_len=0 from line1? > > > > does def getwork() inherit t_len=0 from line1? > > > > does def formattable(table_to_process,type) inherit t_len=0 from line1? > > > > does def format_t() inherit t_len=0 from line1? >

Re: One module per class, bad idea?

2006-12-22 Thread Gabriel Genellina
At Friday 22/12/2006 20:25, Paddy wrote: Are there tools out their to help with the refactoring task of splitting a module into two or more sections then showing what other files need to change? Usually no other files need to change. Ex: you have BigOldModule including ClassA, ClassB and Func

Re: let me simplify my question on scope of vars

2006-12-22 Thread Pyenos
Pyenos <[EMAIL PROTECTED]> writes: i will try to answer my own questions(pls verify): > "code" > var=1 > class CLASS: > def METHOD1: > def METHOD2: > var+=var > return var > METHOD2() #line8 >

Re: scopes of local and global variable

2006-12-22 Thread Max Wilson
Pyenos wrote: > does class WORK inherit t_len=0 from line1? > > does def getwork() inherit t_len=0 from line1? > > does def formattable(table_to_process,type) inherit t_len=0 from line1? > > does def format_t() inherit t_len=0 from line1? Not really, no. The global t_len is different than the loca

Re: scopes of local and global variable

2006-12-22 Thread Pyenos
James Stroud <[EMAIL PROTECTED]> writes: > >>>#CODE## > >>>t_len=0 > >>>class WORK: > >>>def getwork(self): > >>>def formattable(table_to_process,type): > >>>TYPE=["p","t","T","s","i"] #list of types to format > >>>if t

Xah's Edu Corner: Introduction to 3D Graphics Programing

2006-12-22 Thread Xah Lee
Of Interest: Introduction to 3D Graphics Programing http://xahlee.org/3d/index.html Currently, this introduction introduces you to the graphics format of Mathematica, and two Java Applet utilities that allows you to view them with live rotation in a web browser. Also, it includes a introductory t

Re: scopes of local and global variable

2006-12-22 Thread James Stroud
Pyenos wrote: > Fredrik Lundh <[EMAIL PROTECTED]> writes: > > >>Pyenos wrote: >> >> >>>#CODE## >>>t_len=0 >>>class WORK: >>>def getwork(self): >>>def formattable(table_to_process,type): >>>TYPE=["p","t","T","s","i"] #list of type

Re: One module per class, bad idea?

2006-12-22 Thread Gabriel Genellina
At Friday 22/12/2006 12:56, Kent Johnson wrote: It does make the imports look funny - I tend to give the module the same name as the class, Java style, so I have from foo.bar.MyClass import MyClass but that is a minor point IMO. You can always arrange things at the module level (inside __init

let me simplify my question on scope of vars

2006-12-22 Thread Pyenos
"code" var=1 class CLASS: def METHOD1: def METHOD2: var+=var return var METHOD2() #line8 return var METHOD1() #line10 "end code" Q1: do

Re: python-hosting.com projects: dead?

2006-12-22 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |Terry> To me, this is a bit too much 'blame the victim'. The fault lies |Terry> with spammers who are willing to exploit to destruction something |Terry> they did not build. The rest of us are still learning how to |

let me simplify my question about scope of vars

2006-12-22 Thread Pyenos
"code" var=1 class CLASS: def METHOD1: def METHOD2: var+=var return var METHOD2() #line8 return var METHOD1() #line10 Q1: does class CLA

Re: Spyce vs mod_python PSP

2006-12-22 Thread Pyenos
frankly, i don't konw anything about mod_python nor spyce, but i wish you good luck. -- http://mail.python.org/mailman/listinfo/python-list

Re: Spyce vs mod_python PSP

2006-12-22 Thread Ben
..or any of the many other embedded python solutions that seem to be out thee... Ben wrote: > Hi, > > I have just tarted trying to transfer some of my knowledge of python to > server side applications. I stated off using mod_python PSP because it > was what I found first. I then found spyce, wh

Spyce vs mod_python PSP

2006-12-22 Thread Ben
Hi, I have just tarted trying to transfer some of my knowledge of python to server side applications. I stated off using mod_python PSP because it was what I found first. I then found spyce, which seems a better solution. It avoids the problem of keeping indentation correct when writing code embed

Re: scopes of local and global variable

2006-12-22 Thread Pyenos
Fredrik Lundh <[EMAIL PROTECTED]> writes: > Pyenos wrote: > > > #CODE## > > t_len=0 > > class WORK: > > def getwork(self): > > def formattable(table_to_process,type): > > TYPE=["p","t","T","s","i"] #list of types to format > >

Re: scopes of local and global variable

2006-12-22 Thread Fredrik Lundh
Pyenos wrote: > #CODE## > t_len=0 > class WORK: > def getwork(self): > def formattable(table_to_process,type): > > TYPE=["p","t","T","s","i"] #list of types to format >

Re: attribute decorators

2006-12-22 Thread DH
Fredrik Lundh wrote: > Gert Cuykens wrote: > > > would it not be nice if you could assign decorators to attributes too ? > > for example > > > > class C: > > @staticattribute > > data='hello' > > > > or > > > > class C: > > @privateattribute > > data='hello' > > and that would do w

scopes of local and global variable

2006-12-22 Thread Pyenos
#CODE## t_len=0 class WORK: def getwork(self): def formattable(table_to_process,type): TYPE=["p","t","T","s","i"] #list of types to format if type==TYPE[1]:

Using Tools/freeze.py on AIX -- having problems

2006-12-22 Thread jmalone
I have a python script that I need to freeze on AIX 5.1 (customer has AIX and does not want to install Python). The python script is pretty simple (the only things it imports are sys and socket). The README file in the Tools/freeze directory of the Python-2.4.4 distribution says the following (an

Re: Tkinter, StringVar and dict

2006-12-22 Thread Kevin Walzer
James Stroud wrote: > Kevin Walzer wrote: >> I'm trying to manage user preferences in a Tkinter application by >> initializing some values that can then be configured from a GUI. The >> values are set up as a dict, like so: >> >> self.prefs= { >> 'interface': '-en1', >>

Re: One module per class, bad idea?

2006-12-22 Thread Paddy
Carl Banks wrote: > Erik Johnson wrote: > > The file has now grown into a 6800 line beast (including docstring, > > whitespace, and CVS history). Pretty much any time we implement some new > > functionality, there are at least a few changes in that file. When you have > > multiple developers

Re: attribute decorators

2006-12-22 Thread Fredrik Lundh
Gert Cuykens wrote: > would it not be nice if you could assign decorators to attributes too ? > for example > > class C: > @staticattribute > data='hello' > > or > > class C: > @privateattribute > data='hello' and that would do what? -- http://mail.python.org/mailman/listin

Re: Problem in using Pulp

2006-12-22 Thread Robert Kern
MRAB wrote: > Robert Kern wrote: >> The last character in that string is a double quote. You don't want that. >> What >> you want to do is escape all of the backslashes (or use raw strings to avoid >> the >> escaping altogether). E.g. >> >>"C:\\Documents and >> Settings\\Amit\\Desktop\\glpk

Use a Thread to reload a Module?

2006-12-22 Thread Gregory Piñero
Hi Python Experts, I hope I can explain this right. I'll try. Background: I have a module that I leave running in a server role. It has a module which has data in it that can change. So every nth time a function in the server gets called, I want to reload the module so it has the freshest data

Re: Problem in using Pulp

2006-12-22 Thread MRAB
Robert Kern wrote: > [EMAIL PROTECTED] wrote: > > Thanks, now I am not getting that error, but now I am getting a > > different error: > > -error--- > >GLPK("C:\Documents and > > Settings\Amit\Desktop\glpk-4.9\glpk-4.9\examples\"").solve(prob) >

module to implement Abstract Base Class

2006-12-22 Thread emin . shopper
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass magic, I wrote the following module. It is mainly useful as a light weight tool to help programmers c

attribute decorators

2006-12-22 Thread Gert Cuykens
would it not be nice if you could assign decorators to attributes too ? for example class C: @staticattribute data='hello' or class C: @privateattribute data='hello' -- http://mail.python.org/mailman/listinfo/python-list

Re: How to distribute an additional DLL to site-packages?

2006-12-22 Thread Bo Peng
> Use the package_data option. setup(..., packages=['yyy'], > package_data={'yyy':['xxx.dll']}, ...) > (Distutils documentation may be arcane sometimes, but this is easily > found at http://docs.python.org/dist/node12.html) > Absolute dirs are almost never necesary, usually all distutils commands >

Re: Decorator for Enforcing Argument Types

2006-12-22 Thread George Sakkis
John Machin wrote: > Peter Wang wrote: > > Bruno Desthuilliers wrote: > > > > > > Python is dynamic, and fighting against the language is IMHO a really > > > bad idea. The only places where theres a real need for this kind of > > > stuff are when dealing with the "outside world" (IOW : inputs an

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Erik Johnson wrote: > The file has now grown into a 6800 line beast (including docstring, > whitespace, and CVS history). Pretty much any time we implement some new > functionality, there are at least a few changes in that file. When you have > multiple developers working on different project

Re: textwrap.dedent replaces tabs?

2006-12-22 Thread Frederic Rentsch
Tom Plunket wrote: > Frederic Rentsch wrote: > > >>> Well, there is that small problem that there are leading tabs that I >>> want stripped. I guess I could manually replace all tabs with eight >>> spaces (as opposed to 'correct' tab stops), and then replace them when >>> done, but it's probabl

Re: One module per class, bad idea?

2006-12-22 Thread Erik Johnson
There are arguments of preference to be made on both sides. I think the question largely comes down to what is "workable" and "maintainable". To answer the original question, I think it is not necessarily a bad idea to have one class per file. But if your classes are small, or certain classes a

Re: stoppable child thread

2006-12-22 Thread Gabriel Genellina
[EMAIL PROTECTED] ha escrito: > def main(): > threads = [] > try: > for i in range(5): > t = StoppableThread() > t.start() > sleep(0.001) > threads.append(t) > > > except KeyboardInterrupt: > for t in threads: >

Retrieve Tkinter listbox item by string, not by index

2006-12-22 Thread Kevin Walzer
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: self.fonts=list(tkFont.families()) self.fonts.sort() for item in self.fonts: self.fontlist.insert(END, item) #self

Re: How to distribute an additional DLL to site-packages?

2006-12-22 Thread Gabriel Genellina
Bo Peng ha escrito: > > I am writing a python extension module that needs to link with a > > third-party DLL. How can I copy this DLL to the site-packages directory > > along with my extension modules? It seems that data_files parameter can > > do this, but I do not know how to get the absolute de

Re: Decorator for Enforcing Argument Types

2006-12-22 Thread John Machin
Peter Wang wrote: > Bruno Desthuilliers wrote: > > > > Python is dynamic, and fighting against the language is IMHO a really > > bad idea. The only places where theres a real need for this kind of > > stuff are when dealing with the "outside world" (IOW : inputs and > > outputs). And then package

stoppable child thread

2006-12-22 Thread james_w77
I am trying to use Peter's StoppableThread(threading.Thread). What I want to do is to start 5 child threads, then do something, then when got ^C keyboard exception, stop the child thread. For some reason (apparently strange for me :) ), the child threads can NOT be stopped. See the enclosed code

Re: One module per class, bad idea?

2006-12-22 Thread Carl Banks
Kent Johnson wrote: > Carl Banks wrote: > > Now, I think this is the best way to use modules, but you don't need to > > use modules to do get higher-level organization; you could use packages > > instead. It's a pain if you're working on two different classes in the > > same system you have to kee

Re: How to distribute an additional DLL to site-packages?

2006-12-22 Thread Bo Peng
> I am writing a python extension module that needs to link with a > third-party DLL. How can I copy this DLL to the site-packages directory > along with my extension modules? It seems that data_files parameter can > do this, but I do not know how to get the absolute destination > directory. Af

Re: Building python C++ extension modules using MS VC++ 2005?

2006-12-22 Thread Bo Peng
Sandra-24 wrote: > You can use 2005 to build extensions for Python 2.5. I've done this > with several extensions, both my own and others. I do not know if you > can use it for Python 2.4, so I won't advise you on that. I thought > Microsoft made its C/C++ compiler, version 7.1 (2003) freely availab

Re: removing the header from a gzip'd string

2006-12-22 Thread Gabriel Genellina
Fredrik Lundh ha escrito: > Gabriel Genellina wrote: > > > If you want to encrypt a compressed text, you must remove redundant > > information first. > > encryption? didn't the OP say that he *didn't* plan to decompress the > resulting data stream? I was trying to imagine any motivation for aski

Re: optparser question

2006-12-22 Thread Steven Bethard
Michele Petrazzo wrote: > Ok, I have not understand the "trickle" for transform the > action="callback" and provide a callback to a new action. Yeah, you're not the only one. ;-) > I believe, however, that the doc has to be more explicit about this > strange behavior, because a not so expert dev

Re: Generating all permutations from a regexp

2006-12-22 Thread Fredrik Lundh
Nick Craig-Wood wrote: > A regular expression matcher uses a state machine to match strings. unless it's the kind of regular expression matcher that doesn't use a state machine, like the one in Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating all permutations from a regexp

2006-12-22 Thread Nick Craig-Wood
BJörn Lindqvist <[EMAIL PROTECTED]> wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[A-Z]{3}\d{3}" sho

Re: removing the header from a gzip'd string

2006-12-22 Thread vasudevram
Fredrik Lundh wrote: > Gabriel Genellina wrote: > > > Using the default options ("deflate", default compression level, no > > custom dictionary) will make those first two bytes 0x78 0x9c. > > > > If you want to encrypt a compressed text, you must remove redundant > > information first. > > encr

Re: Decorator for Enforcing Argument Types

2006-12-22 Thread Fredrik Lundh
Peter Wang wrote: > I understand that we're all adults, but it's still nice to have the > computer tell us when we're being childish. :) like this? def accepts(*types): raise RuntimeError("don't be childish!") def returns(rtype): raise RuntimeError("don't be childish!") -- http://

Re: optparser question

2006-12-22 Thread Michele Petrazzo
Steven Bethard wrote: > You can try using argparse_, which doesn't make these weird > inferences, and generally assumes that your action will take a single > argument unless you specify otherwise:: > <-cut-> > Not sure exactly what your callback was trying to do though -- it > seems like you'

Re: merits of Lisp vs Python

2006-12-22 Thread Lars Rune Nøstdal
On Fri, 08 Dec 2006 03:07:09 -0800, Mark Tarver wrote: > How do you compare Python to Lisp? What specific advantages do you > think that one has over the other? > > Note I'm not a Python person and I have no axes to grind here. This is > just a question for my general education. > > Mark Kill

Re: How a script can know if it has been called with the -i command line option?

2006-12-22 Thread Tim Golden
> > Michele Simionato wrote: > >> The subject says it all, I would like a script to act differently when > >> called as > >> $ python script.py and when called as $ python -i script.py. [Michael B. Trausch] > There is a set of utilities that have UNIX-like ps behavior, but, as is > typical for Win

Re: Decorator for Enforcing Argument Types

2006-12-22 Thread George Sakkis
Duncan Booth wrote: > "John Machin" <[EMAIL PROTECTED]> wrote: > > >> > if isinstance( > >> > action_for_type1(... > >> > # big snip > >> > elif isinstance(... > >> > action_typeN( ... > >> > # no else statement > >> > >> Ouch.. someone must have skipped his/her OO class... > > > > Qui

Re: Decorator for Enforcing Argument Types

2006-12-22 Thread Peter Wang
Bruno Desthuilliers wrote: > > Python is dynamic, and fighting against the language is IMHO a really > bad idea. The only places where theres a real need for this kind of > stuff are when dealing with the "outside world" (IOW : inputs and > outputs). And then packages like formencode can do much m

Re: How a script can know if it has been called with the -i command line option?

2006-12-22 Thread Michael B. Trausch
Peter Wang wrote: > Michele Simionato wrote: >> The subject says it all, I would like a script to act differently when >> called as >> $ python script.py and when called as $ python -i script.py. I looked >> at the sys module >> but I don't see a way to retrieve the command line flags, where should

Re: How a script can know if it has been called with the -i command line option?

2006-12-22 Thread Peter Wang
Michele Simionato wrote: > The subject says it all, I would like a script to act differently when > called as > $ python script.py and when called as $ python -i script.py. I looked > at the sys module > but I don't see a way to retrieve the command line flags, where should > I look? I realize th

Re: rsync for python?

2006-12-22 Thread Caleb Hattingh
> I want to build rsync server that can run in linux and windows, and > configure by python. So I'm looking for something like rsync for python. > I find rsync.py and pysync. But rsync.py looks like a client mode, > it can't be a rsync server, is it? Can pysync be a rsync server? Hi nienfe

Re: python-hosting.com projects: dead?

2006-12-22 Thread skip
>> . It is Webfactions own fault that they haven't been able to shield >> themself from spam by changing Trac's default to something more >> restrictive. Terry> To me, this is a bit too much 'blame the victim'. The fault lies Terry> with spammers who are willing to exploit to

Re: def index(self):

2006-12-22 Thread Gert Cuykens
Ok thx i think i understand it now >>> class C: ... @staticmethod ... def fn(): ... return 'whohoo' ... >>> C.fn() 'whohoo' >>> -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating all permutations from a regexp

2006-12-22 Thread Fredrik Lundh
BJörn Lindqvist wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[A-Z]{3}\d{3}" should generate the strings

Re: python-hosting.com projects: dead?

2006-12-22 Thread Terry Reedy
"BJörn Lindqvist" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >. It is Webfactions own fault that they haven't been able >to shield themself from spam by changing Trac's default to something >more restrictive. To me, this is a bit too much 'blame the victim'. The fault lies with

Re: One module per class, bad idea?

2006-12-22 Thread Kent Johnson
Carl Banks wrote: > Now, I think this is the best way to use modules, but you don't need to > use modules to do get higher-level organization; you could use packages > instead. It's a pain if you're working on two different classes in the > same system you have to keep switching files; but I guess

Re: add encoding to standard encodings works different in python 2.5?

2006-12-22 Thread Martin v. Löwis
henk-jan ebbers schrieb: > - how can i get this to work in 2.5 (nice if it would work in both 2.4 > and 2.5) You should implement a lookup function, and register it with codecs.register. Then you can structure your modules any way you like. Regards, Martin -- http://mail.python.org/mailman/lis

Re: optparser question

2006-12-22 Thread Steven Bethard
Michele Petrazzo wrote: > I'm trying optparse and I see a strange (for me) behavior: > > def store_value(option, opt_str, value, parser): > setattr(parser.values, option.dest, value) > > parser = optparse.OptionParser() > parser.add_option("-f", "--foo", > action="callback",

PyExcelerator: how to set colours?

2006-12-22 Thread Gerry
I'd like some cell to be a Blue "ABCDE". Here's come code thatv tries various values for pattern_for_colour and font.colour_index, to no avail. Can anyone suggest the right way to set colours? Thanks! Gerry == from pyExcelerator import * w = Workbook() ws = w.a

Re: urllib.unquote and unicode

2006-12-22 Thread Martin v. Löwis
Duncan Booth schrieb: > So you believe that because something is only recommended by a standard > Python should refuse to implement it? Yes. In the face of ambiguity, refuse the temptation to guess. This is *deeply* ambiguous; people have been using all kinds of encodings in http URLs. > You do

Re: query

2006-12-22 Thread Colin J. Williams
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > >> can anyone help me on indentation in python and tell me some nice text >> editors used for a beginner in python? > > http://effbot.org/pyfaq/tutor-whats-the-best-editor-ide-for-python > > > In Windows, I like PyScripter. Colin W. -- http:

Re: Windows upgrade incomplete

2006-12-22 Thread Colin J. Williams
Pete Forman wrote: > I've a few versions of Python on my XP PC, most recently Python 2.5. > The file associations appear not to have been upgraded. Executing a > .py file turned out to still be using 2.3. > >> assoc .py > .py=Python.File > >> ftype Python.file > Python.file=D:\PROGRA~1\Python23\

Re: are there Tomboy and F-Spot equivalents?

2006-12-22 Thread BJörn Lindqvist
On 12/21/06, Tshepang Lekhonkhobe <[EMAIL PROTECTED]> wrote: > Hi, > I dislike installing the entire Mono stack simply to take notes and > manage photos, and am totally biased towards Python. At least for > search I got Tracker, instead of Beagle. > Are there equvalents applications for Tomboy and

Generating all permutations from a regexp

2006-12-22 Thread BJörn Lindqvist
With regexps you can search for strings matching it. For example, given the regexp: "foobar\d\d\d". "foobar123" would match. I want to do the reverse, from a regexp generate all strings that could match it. The regexp: "[A-Z]{3}\d{3}" should generate the strings "AAA000", "AAA001", "AAA002" ... "A

Re: Confusion over calling a nested function inside a parent function

2006-12-22 Thread Pyenos
"MacDonald" <[EMAIL PROTECTED]> writes: > Pyenos wrote: > > [code] > > class WORK: > > def getwork(self): > > def choosetable(self):pass > > choosetable() #TypeError: choosetable() takes exactly 1 > > #argument (0 given) > > [/code] > > > > Calling chooset

add encoding to standard encodings works different in python 2.5?

2006-12-22 Thread henk-jan ebbers
Greetings, I use an encoding that is not available in the std python-encodings, say encoding 'flup'; under different circumstances a user might wish different version of 'flup': a strict one or a more relaxed encoding. (yes I know, this is terrible, but this is how it is) in python2.4, I manag

Re: Confusion over calling a nested function inside a parent function

2006-12-22 Thread Duncan Booth
Pyenos <[EMAIL PROTECTED]> wrote: > [code] > class WORK: > def getwork(self): > def choosetable(self):pass > choosetable() #TypeError: choosetable() takes exactly 1 > #argument (0 given) > [/code] > > Calling choosetable() at the above location gives me t

  1   2   >