RSS Feed for the Python Job Board

2008-11-27 Thread Martin Thomas
The Python.org job board (http://www.python.org/community/jobs/) now has an RSS feed which can be found at http://www.python.org/community/jobs/jobs.rss which list the 20 most recent postings in summary form along with a link to the posting on the jobs page. The Python.org job board, a

Papywizard 1.4.0

2008-11-27 Thread Frédéric
I'm pleased to announce the new release of Papywizard 1.4.0! http://trac.gbiloba.org/papywizard Main new features - - total FOV and number of pictures as mosaic input params - preview all shooting positions when opening shooting dialog - rewind/forward shooting positions in

Re: special editor support for indentation needed.

2008-11-27 Thread Andreas Roehler
Eric S. Johansson wrote: Andreas Roehler wrote: with python-mode.el from http://sourceforge.net/projects/python-mode/ I think there's something wrong with the site because it tells me it's version 1.0 from year 2005. You are right, sorry. I should tell you the present place. Barry

Problem with py2exe when using bundle_files and pygtk/pygobject

2008-11-27 Thread [EMAIL PROTECTED]
Hi, I am using py2exe with pygtk and everything works fine. But when I set bundle_files to 1 or 2, I get following exception, when starting the binary: Traceback (most recent call last): File startup.py, line 1, in module File zipextimporter.pyc, line 82, in load_module File foo.pyc, line

Re: Getting in to metaprogramming

2008-11-27 Thread Lawrence D'Oliveiro
Rafe wrote: In the name of self-education can anyone share some pointers, links, modules, etc that I might use to begin learning how to do some metaprogramming. Fred Brooks, in his classic Mythical Man-Month, defined metaprogramming as simply a very high-level form of programming, using a

Re: Is the behavior expected?

2008-11-27 Thread Lawrence D'Oliveiro
Michele Simionato wrote: Guido and the Common Lisp implementors are happy with mutating the loop index. I myself prefer the functional way. I'd agree with you, except Python doesn't provide any way to create user-defined constants, so constant loop indices have no precedent. --

Re: Is the behavior expected?

2008-11-27 Thread Michele Simionato
On Nov 27, 10:11 am, Lawrence D'Oliveiro [EMAIL PROTECTED] central.gen.new_zealand wrote: Michele Simionato wrote: Guido and the Common Lisp implementors are happy with mutating the loop index. I myself prefer the functional way. I'd agree with you, except Python doesn't provide any way to

Loading multiple versions of the same package at the same time

2008-11-27 Thread della
Hi all, I've got some pickled files representing graphs (using networkx, http://networkx.lanl.gov if you're interested) that were produced using version 0.36 of the library. Now, they have released a new version of the library which is incompatible with respect to pickled files, so what I'd like

Re: rejecting newlines with re.match

2008-11-27 Thread Vlastimil Brom
2008/11/27 r0g [EMAIL PROTECTED] Hi, I want to use a regex to match a string poo but not poo\n or poo+chr(13) or poo+chr(10) or poo+chr(10)+chr(13) ... Thanks, Roger. -- http://mail.python.org/mailman/listinfo/python-list Hi, if I understand correctly, that you want to exclude

distinct fcntl flags for stdin and stdout

2008-11-27 Thread mbuna
Hello, when I set non blocking flag with fcntl on sys.stdin, then sys.stdout turns into non blocking mode too. Is it normal behaviour? How can I turn stdin into non blocking mode but not stdout? Thanks. This is a quick program that shows the (my?) problem: import fcntl import os import sys

Re: Is it possible (and wise) to extend the None-type ?

2008-11-27 Thread Bruno Desthuilliers
Stef Mientki a écrit : snip Alternative (if you *really* want to save the explicit test) is to attach the behaviour modification to the *relevant* class: class NonEvent(Event): def do_nothing(self): pass skip = jump = hop = waltz = saunter = do_nothing def __len__(self):

Re: confused about classes and tkinter object design

2008-11-27 Thread marc wyburn
On Nov 26, 12:09 pm, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: marc wyburn a écrit : Hi, I've created my firstTkinterGUI class which consists of some buttons that trigger functions.  I have also created a tkFileDialog.askdirectory control to local a root folder for log

Re: Loading multiple versions of the same package at the same time

2008-11-27 Thread Diez B. Roggisch
della wrote: On 27 Nov, 11:21, Diez B. Roggisch [EMAIL PROTECTED] wrote: You can't do that. How should python distinguish between the two modules with the same name? That's why I was trying to import them with different names :) You weren't. The as creates just a local alias. It's

iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread adam carr
I call a function get_items() which returns a list of items. However, in some cases, it returns just one item. It returns the item as an object though, not as a list containing one object. In other cases it simply returns None. What is the cleanest way to iterate over the return value of this

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread Stefan Behnel
adam carr wrote: I call a function get_items() which returns a list of items. However, in some cases, it returns just one item. It returns the item as an object though, not as a list containing one object. In other cases it simply returns None. What is the cleanest way to iterate over the

How to use OpenOpt

2008-11-27 Thread Vicent Giner
Hello. I am interested in using OpenOpt, a numerical optimization framework in Python. I've been reading the official documentation about OpenOpt, but it seems a little confusing to me. So, this is a question about OpenOpt; sorry if it is too specific for this forum, but I thought maybe someone

Re: what's so difficult about namespace?

2008-11-27 Thread Xah Lee
On Nov 26, 4:57 pm, Kaz Kylheku [EMAIL PROTECTED] wrote: On 2008-11-26, Xah Lee [EMAIL PROTECTED] wrote: Can you see, how you latched your personal beef about anti software crisis philosophy into this no namespace thread? I did no such thing. My post was about explaining the decision

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread adam carr
2008/11/27 Stefan Behnel [EMAIL PROTECTED]: adam carr wrote: I call a function get_items() which returns a list of items. However, in some cases, it returns just one item. It returns the item as an object though, not as a list containing one object. In other cases it simply returns None.

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread adam carr
Denis kindly provided the following code which does this well: def mkiter( x ): list - list, el - [el], None - [] usage: for x in mkiter( func returning list or singleton ): ... return (x if hasattr( x, __iter__ ) # list tuple ... else [] if x is None else [x]

Re: Requesting direction for installation problem

2008-11-27 Thread F. Rentsch
Bruno Desthuilliers wrote: Frederic Rentsch a écrit : Hi, Where can one get assistance if a Windows installation service fails to install an msi installer? I used to download zip files, but they seem to have been replaced with msi files. I know this issue is off topic here. So my question

Re: Confused about class relationships

2008-11-27 Thread bieffe62
On 27 Nov, 06:20, John O'Hagan [EMAIL PROTECTED] wrote: Apologies if this is a D.Q., I'm still learning to use classes, and this little problem has proved too specific to find in the tutorials. I have two classes with a relationship that I find confusing. One is called Engine, and it has a

Re: Exhaustive Unit Testing

2008-11-27 Thread Emanuele D'Arrigo
On Nov 27, 5:00 am, Steven D'Aprano [EMAIL PROTECTED] wrote: Refactor until your code is simple enough to unit-test effectively, then unit-test effectively. sigh I suspect you are right... Ok, thank you! Manu -- http://mail.python.org/mailman/listinfo/python-list

PyGILState: The assertion 'autoInterpreterState' has failed

2008-11-27 Thread Luis Carrion
Hi, The project goal is to incorporate the functionality of interaction of the excel application (gnumeric) with the XO's journal. All the activities needs to register any change in that datastore (save and open files are made throw it). In order to apply this option, we need to call some

Re: [2.5.1] ShiftJIS to Unicode?

2008-11-27 Thread Walter Dörwald
Gilles Ganault wrote: Hello I'm trying to read pages from Amazon JP, whose web pages are supposed to be encoded in ShiftJIS, and decode contents into Unicode to keep Python happy: www.amazon.co.jp meta http-equiv=content-type content=text/html; charset=Shift_JIS / But this

Re: Loading multiple versions of the same package at the same time

2008-11-27 Thread della
On 27 Nov, 11:21, Diez B. Roggisch [EMAIL PROTECTED] wrote: You can't do that. How should python distinguish between the two modules with the same name? That's why I was trying to import them with different names :) What you can do is  - import the old package  - unpickle  - convert to

Re: Getting in to metaprogramming

2008-11-27 Thread Michele Simionato
On Nov 27, 5:41 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Given that, can anybody think of an example that you could not do with a class?  (excepting the stored procedure aspect) The namedtuple recipe by Raymond Hettinger (http:// code.activestate.com/recipes/500261) is an interesting

Re: newbie question

2008-11-27 Thread Bruno Desthuilliers
Asun Friere a écrit : On Nov 27, 6:11 am, Nan [EMAIL PROTECTED] wrote: Hello, I just started to use Python. I wrote the following code and expected 'main' would be called. def main(): print hello main Not an answer to your question, but I dislike functions named 'main' because the

Re: Loading multiple versions of the same package at the same time

2008-11-27 Thread Diez B. Roggisch
della wrote: Hi all, I've got some pickled files representing graphs (using networkx, http://networkx.lanl.gov if you're interested) that were produced using version 0.36 of the library. Now, they have released a new version of the library which is incompatible with respect to pickled

Re: [2.5.1] ShiftJIS to Unicode?

2008-11-27 Thread Gilles Ganault
On Thu, 27 Nov 2008 01:00:28 +, MRAB [EMAIL PROTECTED] wrote: No problem here: import urllib data = urllib.urlopen(http://www.amazon.co.jp/;).read() decoded_data = data.decode(shift-jis) Thanks, but it seems like some pages contain ShiftJIS mixed with some other code page, and Python

Re: rejecting newlines with re.match

2008-11-27 Thread MRAB
r0g wrote: Hi, I want to use a regex to match a string poo but not poo\n or poo+chr(13) or poo+chr(10) or poo+chr(10)+chr(13) \n is the same as chr(10). According to http://docs.python.org/library/re.html '.' (Dot.) In the default mode, this matches any character except a newline. If the

Re: Problems Writing £ (pound sterling) To MS SQLServer using pymssql

2008-11-27 Thread Darren Mansell
On Mon, 2008-11-17 at 14:52 +, Darren Mansell wrote: Hi. I'm relatively new to python so please be gentle :) I'm trying to write a £ symbol to an MS SQL server using pymsssql . This works but when selecting the data back (e.g. using SQL management studio) the £ symbol is replaced

Re: Exhaustive Unit Testing

2008-11-27 Thread Stefan Behnel
Steven D'Aprano wrote: If you don't test all the paths, then by definition you have program paths which have never been tested. Unless those paths are so trivially simple that you can see that they must be correct just by looking at the code, then the chances are very high that they will

Re: Matplotlib on Leopard Mac OS

2008-11-27 Thread martin . laloux
You must install numpy or scipy before installing matplotlib. If you do not want to do it yourself you cand download Scipy superpack This shell script will install recent SVN builds of Numpy (1.3) and Scipy (0.7), as well as Matplotlib (0.98), iPython (0.8.3) and PyMC (2.0 beta) for OS X 10.5

Re: Matplotlib on Leopard Mac OS

2008-11-27 Thread martin . laloux
You must install numpy or scipy before installing matplotlib. If you do not want to do it yourself you cand download Scipy superpack This shell script will install recent SVN builds of Numpy (1.3) and Scipy (0.7), as well as Matplotlib (0.98), iPython (0.8.3) and PyMC (2.0 beta) for OS X 10.5

how to document a property

2008-11-27 Thread TP
Hi everybody, I know how to document a function or a method, with a docstring (see below for foo method documentation (bar)). But, how to document a property (below, self.d)? ### class a(): def __init__( self ): self.d = 2 def foo( self ): bar b=a() print

Re: Apache mod_python: I don't receive anything with POST method

2008-11-27 Thread tengounplanb
On 26 nov, 23:22, Graham Dumpleton [EMAIL PROTECTED] wrote: On Nov 27, 12:21 am, [EMAIL PROTECTED] wrote: Hi, I'm using a simple form to make possible the users of our site upload files. html     headmeta http-equiv=Content-Type content=text/html; charset=iso-8859-1/head    

Re: special editor support for indentation needed.

2008-11-27 Thread MRAB
Eric S. Johansson wrote: Andreas Roehler wrote: with python-mode.el from http://sourceforge.net/projects/python-mode/ I think there's something wrong with the site because it tells me it's version 1.0 from year 2005. Meanwhile I'll reflect a draft addressing your needs. there is a

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread MRAB
adam carr wrote: 2008/11/27 Stefan Behnel [EMAIL PROTECTED]: adam carr wrote: I call a function get_items() which returns a list of items. However, in some cases, it returns just one item. It returns the item as an object though, not as a list containing one object. In other cases it simply

Re: [Python-mode] special editor support for indentation needed.

2008-11-27 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Nov 27, 2008, at 3:13 AM, Andreas Roehler wrote: Eric S. Johansson wrote: Andreas Roehler wrote: with python-mode.el from http://sourceforge.net/projects/python-mode/ I think there's something wrong with the site because it tells me it's

Re: Exhaustive Unit Testing

2008-11-27 Thread Roy Smith
In article [EMAIL PROTECTED], Stefan Behnel [EMAIL PROTECTED] wrote: Not to mention that you can sometimes look at awfully trivial code three times and only see the obvious bug in that code the fourth time you put an eye on it a good night's sleep later. Or never see it. Lately, I've been

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread Roy Smith
In article [EMAIL PROTECTED], adam carr [EMAIL PROTECTED] wrote: I call a function get_items() which returns a list of items. However, in some cases, it returns just one item. It returns the item as an object though, not as a list containing one object. In other cases it simply returns None.

Re: what's so difficult about namespace?

2008-11-27 Thread jon . harrop . ms . sharp
On Nov 26, 7:29 am, Xah Lee [EMAIL PROTECTED] wrote: ... It's mostly a problem of culture. If you look, for example, at chinese names, the name space is not that much important: Xee Laa only takes this space: ^^^ Instead, if you take a typical english name, say, Abraham Lincoln,

Using thread in an asyncronous application

2008-11-27 Thread Giampaolo Rodola'
Hi, I'm the maintainer of an asynchronous FTP server implementation based on asyncore. Some days ago I thought it would be interesting to add a class offering the possibility to run the asyncore loop into a thread so that a user can run the server without blocking the entire application. It could

Re: how to document a property

2008-11-27 Thread Luis Zarrabeitia
Quoting TP [EMAIL PROTECTED]: d : int(x[, base]) - integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the

Re: what's so difficult about namespace?

2008-11-27 Thread Lew
Xah Lee wrote: this one is published a decade ago by a lisp [sic] dignitary. Its theory of programing [sic] and software engineering is poetry and taoism [sic]. It suggests that C will be the last lang. In a paroxysm of precognitive genius, seemingly. -- Lew --

Re: Apache mod_python: I don't receive anything with POST method

2008-11-27 Thread tengounplanb
On 27 nov, 15:13, [EMAIL PROTECTED] wrote: On 26 nov, 23:22, Graham Dumpleton [EMAIL PROTECTED] wrote: On Nov 27, 12:21 am, [EMAIL PROTECTED] wrote: Hi, I'm using a simple form to make possible the users of our site upload files. html     headmeta http-equiv=Content-Type

Re: what's so difficult about namespace?

2008-11-27 Thread Lew
[EMAIL PROTECTED] wrote: It's mostly a problem of culture. If you look, for example, at chinese [sic] names, the name space is not that much important: Xee Laa only takes this space: ^^^ Chinese names are presumably not spelled with Roman letters in Chinese, so this really says

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread r
On Nov 27, 8:57 am, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED],  adam carr [EMAIL PROTECTED] wrote: I call a function get_items() which returns a list of items. However, in some cases, it returns just one item. It returns the item as an object though, not as a list

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
Aaron Brady [EMAIL PROTECTED] wrote: On Nov 26, 10:41 pm, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Steven D'Aprano steau wrote: Well, I don't know about any problem. And it's not so much about whether metaprograms can solve problems that can't be solved by anything else, as whether

Re: Tkinter and asyncronous socket

2008-11-27 Thread Hendrik van Rooyen
[EMAIL PROTECTED] wrote: On 26 Nov, 13:42, Steve Holden [EMAIL PROTECTED] wrote: One approach would be to run the socket code in blocking mode in a separate thread started by the (main program) GUI thread at program startup, and communicating results back via a Queue.Queue or similar to

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
Steven D'Aprano [EMAIL PROTECTED] GUI designer. You write a program to let the user create code by clicking buttons, dragging objects, drawing lines, etc. The GUI designer may use classes, but the purpose of those classes is to generate source code. Yikes, this is getting hairy- If the

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
Kay Schluehr [EMAIL PROTECTED] wrote: I just noticed that corepy 1.0 [1] has been released. Corepy is an embedded DSL for synthesizing machine code from chaining Python commands. This means it provides objects and exploits control structures used to create machine code that can finally

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
Michele Simionato [EMAIL PROTECTED] wrote: The namedtuple recipe by Raymond Hettinger (http:// code.activestate.com/recipes/500261) is an interesting example of code generation. My own decorator module use a similar trick. Here code generation (plus eval/exec) is needed since you need control on

Re: Exhaustive Unit Testing

2008-11-27 Thread Emanuele D'Arrigo
On Nov 27, 5:00 am, Steven D'Aprano [EMAIL PROTECTED] wrote: Refactor until your code is simple enough to unit-test effectively, then unit-test effectively. Ok, I've taken this wise suggestion on board and of course I found immediately ways to improve the method. -However- this generates

Re: Tkinter and asyncronous socket

2008-11-27 Thread Eric Brunel
On Fri, 28 Nov 2008 04:20:22 +0100, Hendrik van Rooyen [EMAIL PROTECTED] wrote: If you are not already doing it, you need to make a stutter thread by using the after() call on some gui object to periodically check for input on the queue. You don't need to in fact: from the secondary thread,

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
Terry Reedy [EMAIL PROTECTED] wrote: Hendrik van Rooyen wrote: I am using the term in the restricted sense of Python writing Python source. Given that, can anybody think of an example that you could not do with a class? (excepting the stored procedure aspect) I am not sure I

Creating classes and objects more than once?

2008-11-27 Thread Viktor Kerkez
Here is the situation: $ ls test $ cd test $ ls __init__.py data.py $ cat __init__.py $ cat data.py DATA = {} $ cd .. $ python import os from test.data import DATA DATA['something'] = 33 os.chdir('test') from data import DATA as NEW_DATA DATA {'something': 33} NEW_DATA {} Is this a

Re: Creating classes and objects more than once?

2008-11-27 Thread Diez B. Roggisch
Viktor Kerkez wrote: Here is the situation: $ ls test $ cd test $ ls __init__.py data.py $ cat __init__.py $ cat data.py DATA = {} $ cd .. $ python import os from test.data import DATA DATA['something'] = 33 os.chdir('test') from data import DATA as NEW_DATA DATA

Re: [2.5.1] ShiftJIS to Unicode?

2008-11-27 Thread Mark Tolonen
Gilles Ganault [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, 27 Nov 2008 01:00:28 +, MRAB [EMAIL PROTECTED] wrote: No problem here: import urllib data = urllib.urlopen(http://www.amazon.co.jp/;).read() decoded_data = data.decode(shift-jis) This is correct. You

trapping signal

2008-11-27 Thread tekion
I have a while iterates forever. I would like to trap a SIGTERM signal and execute some clean up code. How would I do this in python? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Exhaustive Unit Testing

2008-11-27 Thread Terry Reedy
Emanuele D'Arrigo wrote: On Nov 27, 5:00 am, Steven D'Aprano [EMAIL PROTECTED] wrote: Refactor until your code is simple enough to unit-test effectively, then unit-test effectively. Ok, I've taken this wise suggestion on board and of course I found immediately ways to improve the method.

Re: Creating classes and objects more than once?

2008-11-27 Thread Harold Fellermann
On Nov 27, 6:42 pm, Viktor Kerkez [EMAIL PROTECTED] wrote: Is this a bug? It is not a bug: the dictionaries are different because they are loaded from different modules. import os import test.data test.data module 'test.data' from 'test/data.pyc' os.chdir('test') import data data module

how to construct a list of only one tuple

2008-11-27 Thread TP
Hi, If I do: a=(1,2) b=[(3,4),(5,6)] list(a)+b ['1', '2', ('3', '4'), ('5', '6')] I would like rather to obtain: [('1', '2'), ('3', '4'), ('5', '6')] Am I compelled to do: c=[] c.append(a) c+b [('1', '2'), ('3', '4'), ('5', '6')] Thanks Julien -- python -c print ''.join([chr(154 -

Re: how to construct a list of only one tuple

2008-11-27 Thread bearophileHUGS
TP: a=(1,2) b=[(3,4),(5,6)] list(a)+b ['1', '2', ('3', '4'), ('5', '6')] a = (1, 2) b = [(3, 4), (5, 6)] [a] + b [('1', '2'), ('3', '4'), ('5', '6')] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Exhaustive Unit Testing

2008-11-27 Thread bearophileHUGS
Emanuele D'Arrigo: I can fragment the code of the original method into one public method and a few private support methods. Python also support nested functions, that you can put into your method. The problem is that often unit test functions aren't able to test nested functions. A question

Re: trapping signal

2008-11-27 Thread Diez B. Roggisch
tekion wrote: I have a while iterates forever. I would like to trap a SIGTERM signal and execute some clean up code. How would I do this in python? Thanks. look into module signal Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting in to metaprogramming

2008-11-27 Thread Terry Reedy
Hendrik van Rooyen wrote: Terry Reedy [EMAIL PROTECTED] wrote: Hendrik van Rooyen wrote: I am using the term in the restricted sense of Python writing Python source. Given that, can anybody think of an example that you could not do with a class? (excepting the stored procedure aspect) I

time function problem

2008-11-27 Thread willie
My code: from time import time def leibniz(terms): acc = 0.0 num = 4.0 # numerator value remains constant in the series den = 1 count = 0 start_time = 0.0 for aterm in range(terms): nextterm = num/den * (-1)**aterm # (-1) allows fractions to alternate

Re: Getting in to metaprogramming

2008-11-27 Thread Kay Schluehr
On 27 Nov., 06:11, Rafe [EMAIL PROTECTED] wrote: On Nov 27, 11:41 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Steven D'Aprano steau wrote: Well, I don't know about any problem. And it's not so much about whether metaprograms can solve problems that can't be solved by anything

Applying a decorator to a module

2008-11-27 Thread lkcl
Very simple question: how do you apply a decorator to an entire module? an idea whose time has properly arrived is to merge pyjamas (http://pyjs.org) into web2py (http://web2py.com), and to do that, it's necessary to identify functions, classes, global variables and modules that should be

Re: time function problem

2008-11-27 Thread Diez B. Roggisch
willie wrote: My code: from time import time def leibniz(terms): acc = 0.0 num = 4.0 # numerator value remains constant in the series den = 1 count = 0 start_time = 0.0 for aterm in range(terms): nextterm = num/den * (-1)**aterm # (-1) allows

Re: Applying a decorator to a module

2008-11-27 Thread skip
lkcl Very simple question: how do you apply a decorator to an entire lkcl module? Function-by-function or class-by-class. There is no decorator support for modules. -- Skip Montanaro - [EMAIL PROTECTED] - http://smontanaro.dyndns.org/ --

Memory problems

2008-11-27 Thread Ken Seehart
My beta testers are complaining about excessive memory usage. It's a wxPython app with several embedded mozilla activex controls and a local web server. Unfortunately, Python has some problems in this area. In particular, since ubiquitous lists and dictionaries are dynamically resized as

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread Arnaud Delobelle
adam carr [EMAIL PROTECTED] writes: Denis kindly provided the following code which does this well: def mkiter( x ): list - list, el - [el], None - [] usage: for x in mkiter( func returning list or singleton ): ... return (x if hasattr( x, __iter__ ) # list tuple ...

Re: Applying a decorator to a module

2008-11-27 Thread lkcl
On Nov 27, 7:43 pm, [EMAIL PROTECTED] wrote: lkcl Very simple question: how do you apply a decorator to an entire lkcl module? Function-by-function or class-by-class. There is no decorator support for modules. awWww! i'm going to quietly throw my toys out of my pram. ... but

Re: Creating classes and objects more than once?

2008-11-27 Thread Arnaud Delobelle
Viktor Kerkez [EMAIL PROTECTED] writes: Here is the situation: $ ls test $ cd test $ ls __init__.py data.py $ cat __init__.py $ cat data.py DATA = {} $ cd .. $ python import os from test.data import DATA DATA['something'] = 33 os.chdir('test') from data import DATA as NEW_DATA

Re: Applying a decorator to a module

2008-11-27 Thread George Sakkis
On Nov 27, 2:54 pm, lkcl [EMAIL PROTECTED] wrote: On Nov 27, 7:43 pm, [EMAIL PROTECTED] wrote:     lkcl Very simple question: how do you apply a decorator to an entire     lkcl module? Function-by-function or class-by-class.  There is no decorator support for modules. awWww!  i'm

Re: Applying a decorator to a module

2008-11-27 Thread skip
Function-by-function or class-by-class. There is no decorator support for modules. lkcl ... but seriously - doesn't that strike people as... a slightly lkcl odd omission? Decorators are still a new feature in the language and were purposely added in an incremental fashion. In

Re: Applying a decorator to a module

2008-11-27 Thread Arnaud Delobelle
lkcl [EMAIL PROTECTED] writes: On Nov 27, 7:43 pm, [EMAIL PROTECTED] wrote: lkcl Very simple question: how do you apply a decorator to an entire lkcl module? Function-by-function or class-by-class. There is no decorator support for modules. awWww! i'm going to quietly throw my

Re: Loading multiple versions of the same package at the same time

2008-11-27 Thread Terry Reedy
Diez B. Roggisch wrote: della wrote: On 27 Nov, 11:21, Diez B. Roggisch [EMAIL PROTECTED] wrote: You can't do that. How should python distinguish between the two modules with the same name? That's why I was trying to import them with different names :) You weren't. The as creates just a

Help with capturing error

2008-11-27 Thread tekion
Hello, I am getting the following error and my script is bailing out because of it. I have tried capturing it but it does not seem to work. Below is the error: ValueError: I/O operation on closed file the above error is received when, the following code snippet is executed:

Re: Memory problems

2008-11-27 Thread skip
Ken Unfortunately, Python has some problems in this area. In Ken particular, since ubiquitous lists and dictionaries are dynamically Ken resized as needed, memory fragmentation seems inevitable. That's not necessarily true. Also, I would say that Python has made tradeoffs in this

Re: external program crashes when run through subprocess.popen on XP

2008-11-27 Thread ckkart
On 18 Nov., 21:40, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 18 Nov 2008 09:41:46 -0200, Christan K. [EMAIL PROTECTED] escribió: ckkart ckkart at gmail.com writes: on XP when starting a certainexternalprogram (plain C calculation program which communicates via stdout/fs) from

Re: Help with capturing error

2008-11-27 Thread Diez B. Roggisch
tekion schrieb: Hello, I am getting the following error and my script is bailing out because of it. I have tried capturing it but it does not seem to work. Below is the error: ValueError: I/O operation on closed file the above error is received when, the following code snippet is executed:

Re: Applying a decorator to a module

2008-11-27 Thread Diez B. Roggisch
lkcl schrieb: On Nov 27, 7:43 pm, [EMAIL PROTECTED] wrote: lkcl Very simple question: how do you apply a decorator to an entire lkcl module? Function-by-function or class-by-class. There is no decorator support for modules. awWww! i'm going to quietly throw my toys out of my pram.

Re: Creating classes and objects more than once?

2008-11-27 Thread Viktor Kerkez
But this means that there is no way to create a safe Singleton in python, because the classes are also created twice. This is the problem that I encountered. I created a complex implementation of a Singleton pattern using metaclasses because I needed the __init__ method to be called just once and

Re: Creating classes and objects more than once?

2008-11-27 Thread Viktor Kerkez
A better way to do this was http://pastebin.com/m1130d1fe :) -- http://mail.python.org/mailman/listinfo/python-list

Re: how to construct a list of only one tuple

2008-11-27 Thread TP
[EMAIL PROTECTED] wrote: a=(1,2) b=[(3,4),(5,6)] list(a)+b ['1', '2', ('3', '4'), ('5', '6')] a = (1, 2) b = [(3, 4), (5, 6)] [a] + b [('1', '2'), ('3', '4'), ('5', '6')] Thanks a lot. Why this difference of behavior between list(a) and [a]? Julien -- python -c print

Re: how to construct a list of only one tuple

2008-11-27 Thread Diez B. Roggisch
TP schrieb: [EMAIL PROTECTED] wrote: a=(1,2) b=[(3,4),(5,6)] list(a)+b ['1', '2', ('3', '4'), ('5', '6')] a = (1, 2) b = [(3, 4), (5, 6)] [a] + b [('1', '2'), ('3', '4'), ('5', '6')] Thanks a lot. Why this difference of behavior between list(a) and [a]? Because they are different

Re: how to construct a list of only one tuple

2008-11-27 Thread Chris Rebert
On Thu, Nov 27, 2008 at 2:39 PM, TP [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: a=(1,2) b=[(3,4),(5,6)] list(a)+b ['1', '2', ('3', '4'), ('5', '6')] a = (1, 2) b = [(3, 4), (5, 6)] [a] + b [('1', '2'), ('3', '4'), ('5', '6')] Thanks a lot. Why this difference of behavior

HELP!...Google SketchUp needs a Python API

2008-11-27 Thread r
Hello fellow Python Advocates! Help me promote Python to a larger audience. An introduction to SketchUp: I don't know if you are familiar with Google Sketchup. It is the best 3d CAM program available. If you have not checked it out and do modeling of any kind, or want to

Re: how to construct a list of only one tuple

2008-11-27 Thread MRAB
TP wrote: [EMAIL PROTECTED] wrote: a=(1,2) b=[(3,4),(5,6)] list(a)+b ['1', '2', ('3', '4'), ('5', '6')] a = (1, 2) b = [(3, 4), (5, 6)] [a] + b [('1', '2'), ('3', '4'), ('5', '6')] Thanks a lot. Why this difference of behavior between list(a) and [a]? list(a) iterates through its

Re: Help with capturing error

2008-11-27 Thread Chris Rebert
On Thu, Nov 27, 2008 at 12:33 PM, tekion [EMAIL PROTECTED] wrote: Hello, I am getting the following error and my script is bailing out because of it. I have tried capturing it but it does not seem to work. Below is the error: ValueError: I/O operation on closed file the above error is

Re: HELP!...Google SketchUp needs a Python API

2008-11-27 Thread Chris Rebert
On Thu, Nov 27, 2008 at 3:18 PM, r [EMAIL PROTECTED] wrote: Hello fellow Python Advocates! Help me promote Python to a larger audience. An introduction to SketchUp: I don't know if you are familiar with Google Sketchup. It is the best 3d CAM program available. snip

Re: Creating classes and objects more than once?

2008-11-27 Thread Chris Rebert
On Thu, Nov 27, 2008 at 2:36 PM, Viktor Kerkez [EMAIL PROTECTED] wrote: A better way to do this was http://pastebin.com/m1130d1fe :) -- http://mail.python.org/mailman/listinfo/python-list The Python position on singletons is generally to just use a module instead (preferred), or apply the

Re: HELP!...Google SketchUp needs a Python API

2008-11-27 Thread r
On Nov 27, 5:27 pm, Chris Rebert [EMAIL PROTECTED] wrote: On Thu, Nov 27, 2008 at 3:18 PM, r [EMAIL PROTECTED] wrote: Hello fellow Python Advocates! Help me promote Python to a larger audience. An introduction to SketchUp: I don't know if you are familiar with

Re: HELP!...Google SketchUp needs a Python API

2008-11-27 Thread Chris Rebert
On Thu, Nov 27, 2008 at 3:33 PM, r [EMAIL PROTECTED] wrote: On Nov 27, 5:27 pm, Chris Rebert [EMAIL PROTECTED] wrote: On Thu, Nov 27, 2008 at 3:18 PM, r [EMAIL PROTECTED] wrote: Hello fellow Python Advocates! Help me promote Python to a larger audience. An introduction to SketchUp:

Re: HELP!...Google SketchUp needs a Python API

2008-11-27 Thread r
On Nov 27, 5:38 pm, Chris Rebert [EMAIL PROTECTED] wrote: On Thu, Nov 27, 2008 at 3:33 PM, r [EMAIL PROTECTED] wrote: On Nov 27, 5:27 pm, Chris Rebert [EMAIL PROTECTED] wrote: On Thu, Nov 27, 2008 at 3:18 PM, r [EMAIL PROTECTED] wrote: Hello fellow Python Advocates! Help me promote

Re: Exhaustive Unit Testing

2008-11-27 Thread Terry Reedy
[EMAIL PROTECTED] wrote: Emanuele D'Arrigo: I can fragment the code of the original method into one public method and a few private support methods. Python also support nested functions, that you can put into your method. The problem is that often unit test functions aren't able to test

Re: Applying a decorator to a module

2008-11-27 Thread Terry Reedy
Decorators are syntactic sugar. They add no functionality. @decorator def/class possibly_long_name ... abbreviates def/class possibly_long_name ... possibly many lines running off screen or page possibly_long_name = decorator(possibly_long_name) thereby warning the reader at the beginning

  1   2   >