Re: Creating classes and objects more than once?

2008-11-27 Thread Viktor Kerkez
On Nov 28, 12:32 am, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > The Python position on singletons is generally to just use a module > instead (preferred), or apply the Borg > pattern:http://code.activestate.com/recipes/66531/ The same problem appears if I use the module (as I pointed in the firs

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

2008-11-27 Thread r
> Python supporters on this list don't really care about > Python -- only money, and depravity.  you and i and the > other few, pure of heart, must fight for Python!! Unfortunatly no others besides yourself have come forward. This is not a fight for my ideas anymore as a test of the community! Y

Re: Is there any project whose patches are all available?

2008-11-27 Thread Stefan Behnel
Stefan Behnel wrote: > I think what you have in mind is that smaller changes make code reload > easier than bigger changes, especially API changes. ... or ABI changes in the general case, although that's not a major difference in the Python context. Stefan -- http://mail.python.org/mailman/listin

Re: Is there any project whose patches are all available?

2008-11-27 Thread Stefan Behnel
ZelluX wrote: > For example, by comparing two versions of a program, may be we can > generate some scripts to direct the virtual machine update a running > python program. I had to read this sentence a couple of times, as it sounds too much like StarTrek speak. My guess is that you are talking ab

Re: Is there any project whose patches are all available?

2008-11-27 Thread ZelluX
On Nov 28, 3:16 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > ZelluX <[EMAIL PROTECTED]> writes: > > I want to write a version-tracking tool for Python projects > > Not to dissuade you, but what do you hope to achieve by this? > Version-control systems are difficult to do well, and we are blessed > w

Re: Is there any project whose patches are all available?

2008-11-27 Thread Ben Finney
ZelluX <[EMAIL PROTECTED]> writes: > I want to write a version-tracking tool for Python projects Not to dissuade you, but what do you hope to achieve by this? Version-control systems are difficult to do well, and we are blessed with an abundance of them already. -- \ “Holy as

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

2008-11-27 Thread r
On Nov 28, 12:52 am, [EMAIL PROTECTED] wrote: > On Nov 27, 10:28 pm, r <[EMAIL PROTECTED]> wrote: > > > To think...that I would preach freedom to the slaves and be lynched > > for it...IS MADNESS! > > > Not one vote for Python, not a care. I think everyone here should look > > deep within their sel

Is there any project whose patches are all available?

2008-11-27 Thread ZelluX
Hi, all I want to write a version-tracking tool for Python projects, and need some sample projects whose even smallest modifications can be downloaded from the internet. Could you recommend some to me? Thanks for your reply -- http://mail.python.org/mailman/listinfo/python-list

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

2008-11-27 Thread Gerard flanagan
alex23 wrote: On Nov 28, 4:32 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: http://en.wikipedia.org/wiki/Zero-sum#Complexity You're a far more generous soul than I am, I would've been more inclined to link to the following: http://en.wikipedia.org/wiki/Persecution_complex Maybe it's just:

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

2008-11-27 Thread rurpy
On Nov 27, 10:28 pm, r <[EMAIL PROTECTED]> wrote: > To think...that I would preach freedom to the slaves and be lynched > for it...IS MADNESS! > > Not one vote for Python, not a care. I think everyone here should look > deep within their self and realize the damage that has been done > today! I hop

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

2008-11-27 Thread r
On Nov 28, 12:32 am, alex23 <[EMAIL PROTECTED]> wrote: > On Nov 28, 3:28 pm, r <[EMAIL PROTECTED]> wrote: > > > To think...that I would preach freedom to the slaves and be lynched > > for it...IS MADNESS! > > There's is madness in this thread, of that I have no doubt. > > Please don't presume to sp

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

2008-11-27 Thread alex23
On Nov 28, 4:32 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > http://en.wikipedia.org/wiki/Zero-sum#Complexity You're a far more generous soul than I am, I would've been more inclined to link to the following: http://en.wikipedia.org/wiki/Persecution_complex -- http://mail.python.org/mailman/l

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

2008-11-27 Thread alex23
On Nov 28, 3:28 pm, r <[EMAIL PROTECTED]> wrote: > To think...that I would preach freedom to the slaves and be lynched > for it...IS MADNESS! There's is madness in this thread, of that I have no doubt. Please don't presume to speak for Guido, he's a big boy and has shown he's more than capable of

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

2008-11-27 Thread Gerard flanagan
r wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! I hope Guido's eyes never see this thread, for he may l

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

2008-11-27 Thread r
[alex23] How much is this API -worth- to you? How much time are -you- willing to commit to developing it? If you lack the ability, how much -money- are you willing to spend on hiring the people with that ability? [/alex23] Alex, Are you telling me that out of all the great and wonderful developers

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

2008-11-27 Thread r
On Nov 27, 11:28 pm, r <[EMAIL PROTECTED]> wrote: > To think...that I would preach freedom to the slaves and be lynched > for it...IS MADNESS! > > Not one vote for Python, not a care. I think everyone here should look > deep within their self and realize the damage that has been done > today! I hop

functions

2008-11-27 Thread Girish
Hello, Is ter any way to identify the file name and the path in which the function is called. for example: if the function definition is in the file c:\script1.py and if I call this function in a script: c:\script2.py than in the function definition part(script1.py) some how I need to know that i

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

2008-11-27 Thread r
To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! I hope Guido's eyes never see this thread, for he may lose all hop

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

2008-11-27 Thread alex23
On Nov 28, 2:08 pm, r <[EMAIL PROTECTED]> wrote: > Did you even read my OP, I mean the whole thing... not just the title? > I am working on the problem, I am trying to garner support for a > Python intergration. Grass Roots kinda thing. Jesus wept. Of course I did. It's why I actually made suggest

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

2008-11-27 Thread r
On Nov 27, 10:57 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Nov 27, 10:45 pm, r <[EMAIL PROTECTED]> wrote: > > > I am still flabbergasted by the solid resistance to promoting Python. > > Here of all places, NOT even one person(well Terry did kinda half > > agree with me =), wants to support

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

2008-11-27 Thread George Sakkis
On Nov 27, 10:45 pm, r <[EMAIL PROTECTED]> wrote: > I am still flabbergasted by the solid resistance to promoting Python. > Here of all places, NOT even one person(well Terry did kinda half > agree with me =), wants to support Python. I am completely perplexed. > I had to check and make sure this

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

2008-11-27 Thread r
On Nov 27, 10:08 pm, r <[EMAIL PROTECTED]> wrote: > On Nov 27, 9:56 pm, alex23 <[EMAIL PROTECTED]> wrote: > > > On Nov 28, 1:45 pm, r <[EMAIL PROTECTED]> wrote: > > > > Does it bother you that i am so ambitious[...] Answer that if > > > you are a man. [...] Do you feel you should give back or just

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

2008-11-27 Thread r
On Nov 27, 9:56 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Nov 28, 1:45 pm, r <[EMAIL PROTECTED]> wrote: > > > Does it bother you that i am so ambitious[...] Answer that if > > you are a man. [...] Do you feel you should give back or just > > take, take, take??? I have shared my feelings, let's hea

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

2008-11-27 Thread alex23
On Nov 28, 1:45 pm, r <[EMAIL PROTECTED]> wrote: > Does it bother you that i am so ambitious[...] Answer that if > you are a man. [...] Do you feel you should give back or just > take, take, take??? I have shared my feelings, let's hear yours. It bothers me that you seem to be off your medication

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

2008-11-27 Thread r
On Nov 27, 9:31 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Nov 28, 12:49 pm, r <[EMAIL PROTECTED]> wrote: > > > Well... 3 for Ruby 1 for python. Not looking good so far. Any more > > votes? > > I don't see -any- of the responses in this thread "voting" for > anything other than a more civil approac

Re: Getting in to metaprogramming

2008-11-27 Thread alex23
On Nov 27, 8:55 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Then another thing - it strikes me that any problem that can be solved > by metaprogramming, can be solved by putting similar code into a class > and instanciating an instance. > > Does anybody know if this is true? > > If it is,

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

2008-11-27 Thread alex23
On Nov 28, 12:49 pm, r <[EMAIL PROTECTED]> wrote: > Well... 3 for Ruby 1 for python. Not looking good so far. Any more > votes? I don't see -any- of the responses in this thread "voting" for anything other than a more civil approach to your request. If you're seeing these in a "if you're not with

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

2008-11-27 Thread r
On Nov 27, 8:01 pm, r <[EMAIL PROTECTED]> wrote: > On Nov 27, 7:40 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > r wrote: > > > On Nov 27, 6:15 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > >> r wrote: > > >>> Hello fellow Python Advocates! > > >>> Help me promote Python to a larger audience. >

Re: newbie question

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 17:58:55 -0800, Asun Friere wrote: > if __name__ == '__main__' : > import sys > sys.exit(main(sys.argv)) > > Doesn't this just pollute the namespace with main()? Agreed. I don't see anything wrong with that. You have one function more than you otherwise would have h

Re: Getting in to metaprogramming

2008-11-27 Thread Steven D'Aprano
On Fri, 28 Nov 2008 05:05:10 +0200, 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

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

2008-11-27 Thread r
On Nov 27, 7:40 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > r wrote: > > On Nov 27, 6:15 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > >> r wrote: > >>> Hello fellow Python Advocates! > >>> Help me promote Python to a larger audience. > >>> An introduction to SketchUp: > >>> >

Re: newbie question

2008-11-27 Thread Asun Friere
On Nov 27, 9:05 pm, Bruno Desthuilliers wrote: > The problem is that you often have more to do in the __main__ section of > a script than just calling one simple function, and you don't > necessarily want to pollute the module's namespace with all this code. As I said, it's probably just me ;)

Re: Tools for using virtual environments and PEP 370

2008-11-27 Thread Дамјан Георгиевски
> Python 2.6 implemented PEP 370: Per-user site-packages Directory[1] > > Now, are there any tools I could use to create and activate virtual > environments like workingenv, virtualenv etc. but that will use > PYTHONUSERBASE instead of hard-linking the python program. > > > [1] > http://docs.pyt

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

2008-11-27 Thread Terry Reedy
r wrote: On Nov 27, 6:15 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: r wrote: Hello fellow Python Advocates! Help me promote Python to a larger audience. An introduction to SketchUp: There is no need to puff up Python or put down Ruby to this audience. Given how much Google

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

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 12:12:38 +, adam carr wrote: > I'm still in the position of having to right code to deal with > converting None to an empty list and one object to a list with a single > entry. > Python casting doesn't work here. Python doesn't have type-casting. Python has type conversion

Re: Exhaustive Unit Testing

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 08:32:12 -0800, 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 fo

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

2008-11-27 Thread r
On Nov 27, 7:13 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Nov 28, 10:09 am, r <[EMAIL PROTECTED]> wrote: > > > Are you against promoting python? > > > Maybe your a Ruby fan, i don't know, but that > > would explain your quick disposal of the idea though. > > Are you intending to come off so patron

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

2008-11-27 Thread alex23
On Nov 28, 10:09 am, r <[EMAIL PROTECTED]> wrote: > Are you against promoting python? > > Maybe your a Ruby fan, i don't know, but that > would explain your quick disposal of the idea though. Are you intending to come off so patronising? To angrily dismiss someone who has been posting some solid h

Re: Exhaustive Unit Testing

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 10:45:47 -0800, bearophileHUGS wrote: > A question for other people: Can Python change a little to allow nested > functions to be tested? I think this may solve some of my problems. Remember that nested functions don't actually exist as functions until the outer function is c

Re: time function problem

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 11:17:04 -0800, 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 This line is wrong. You're starting your timer at the

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

2008-11-27 Thread r
On Nov 27, 6:15 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > r wrote: > > Hello fellow Python Advocates! > > Help me promote Python to a larger audience. > > > An introduction to SketchUp: > > > > There is no need to puff up Python or put down Ruby to this audience. > Given how

Re: Exhaustive Unit Testing

2008-11-27 Thread Benjamin
On Nov 27, 5:47 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > [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 >

Re: Applying a decorator to a module

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 11:54:54 -0800, lkcl 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!

[ann] Python appscript 0.19.0 (beta 1) released

2008-11-27 Thread has
Announcing the first beta release of appscript for Python 2.x, a user- friendly Apple event bridge that allows you to control AppleScriptable applications using ordinary Python scripts. Py-appscript 0.19.0 adds Python 2.6 compatibility and 64-bit support, and cleans up the codebase and documentati

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

2008-11-27 Thread Terry Reedy
r wrote: Hello fellow Python Advocates! Help me promote Python to a larger audience. An introduction to SketchUp: There is no need to puff up Python or put down Ruby to this audience. Given how much Google uses Python as a core language, I am a bit shocked that they would

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

2008-11-27 Thread r
On Nov 27, 5:42 pm, r <[EMAIL PROTECTED]> wrote: > 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 <[EM

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_long_name = decorator(possibly_long_name) thereby warning the reader at the beginning that possibly_long_name will be rebound and avoid

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 nest

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! >

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 introductio

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 f

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 th

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.

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 e

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) itera

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 lea

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'

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 th

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

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: 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: 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: 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: 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 gmail.com> writes: > >> on XP when starting a certainexternalprogram (plain C calculation > >> program which communicates via stdout/fs) fr

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

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: try:

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 jus

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 qu

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

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. > >

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')

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: 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__" )

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 ne

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/ -- http://mail.python.org/mailman/listinfo/python

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)

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 compil

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" 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 sol

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 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" aspec

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: 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: 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

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

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 >>> os.chdir('test') >>> import data >>> data >>> test.data is data Fals

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. -Ho

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: [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") >>> T

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

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_DAT

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: 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 ano

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 >c

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 f

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 "

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

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 simil

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" 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 anythi

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,

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 sa

  1   2   >