dateutil and dates before today

2006-02-26 Thread dmbkiwi
I'm using the dateutil module from http://labix.org/python-dateutil. Am I right in thinking that the rrules module doesn't acknowledge days before today? An example of the issue: rule_temp = rrule(YEARLY,bymonth=1,bymonthday=1) print

Re: dateutil and dates before today

2006-02-26 Thread dmbkiwi
I'll answer my own post. If you don't specify dtstart, it defaults to datetime.today(). Therefore, there are no instances before today. Specify dtstart as a historic date, and it works on any dates after dtstart. Wish I'd engaged brain before posting. Matt --

Re: Optimize flag question

2006-02-26 Thread Felipe Almeida Lessa
Em Sáb, 2006-02-25 às 17:56 -0800, [EMAIL PROTECTED] escreveu: Steve Holden wrote: Some other functions rely on the AssertionError exception to indicate to the user that something went wrong instead of using a user defined exception. The real problem here is that you appear to be

Re: Is Python a Zen language?

2006-02-26 Thread Claudio Grondi
Crutcher wrote: You are a very silly person. Claudio -- http://mail.python.org/mailman/listinfo/python-list

Re: ImportError in Unpickle

2006-02-26 Thread Rene Pijlman
[EMAIL PROTECTED]: I have a python script that pickles and unpickles a give object. It works without any problems on windows (the data was pickled on windows first). But when I try to run the script on Linux, I get the following error: [...] ImportError: No module named __main__ There are some

Re: ImportError in Unpickle

2006-02-26 Thread Rene Pijlman
Rene Pijlman: [EMAIL PROTECTED]: ImportError: No module named __main__ There are some posts in the Usenet archive Also: http://mail.python.org/pipermail/python-list/1999-April/000916.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Re: Pure python implementation of string-like class

2006-02-26 Thread Xavier Morel
Ross Ridge wrote: Xavier Morel wrote: Not if you're still within Unicode / Universal Character Set code space. Akihiro Kayama in his original post made it clear that he wanted to use a character set larger than entire Unicode code space. Ross Ridge

Re: xslt queries in xml to SQL queries

2006-02-26 Thread Paul Boddie
Crutcher wrote: Skipping ahead, let me try to rephrase this. First, this isn't really a python question, it is SQL, XSLT, and program design, but I'll try to answer. Well, first of all, it's about mapping XPath onto a relational data model. This is clear from the original posting:

Re: Is Python a Zen language?

2006-02-26 Thread John Coleman
Crutcher wrote: You are a very silly person. You have tripped so many of my internet bullshit triggers that I think perhaps you are trolling. All languages alter the way you think. They structure the nature of questions you can ask, and problems you can solve. Do you understand 'Zen', by

Re: Is Python a Zen language?

2006-02-26 Thread André
John Coleman wrote: Crutcher wrote: You are a very silly person. You have tripped so many of my internet bullshit triggers that I think perhaps you are trolling. All languages alter the way you think. They structure the nature of questions you can ask, and problems you can solve. Do

Re: Is Python a Zen language?

2006-02-26 Thread bonono
André wrote: Some purist, like the Academie Francaise (or, apparently Crutcher) seem to believe that one can restrict the meaning of words, or the evolution of language. The rest of us are happy to let language evolution take place to facilitate communication. So instead of Zen of Python,

sort one list using the values from another list

2006-02-26 Thread Brian Blais
Hello, I have two lists, one with strings (filenames, actually), and one with a real-number rank, like: A=['hello','there','this','that'] B=[3,4,2,5] I'd like to sort list A using the values from B, so the result would be in this example, A=['this','hello','there','that'] The sort method on

Re: sort one list using the values from another list

2006-02-26 Thread Kent Johnson
Brian Blais wrote: Hello, I have two lists, one with strings (filenames, actually), and one with a real-number rank, like: A=['hello','there','this','that'] B=[3,4,2,5] I'd like to sort list A using the values from B, so the result would be in this example,

Re: sort one list using the values from another list

2006-02-26 Thread Jeffrey Schwab
Brian Blais wrote: Hello, I have two lists, one with strings (filenames, actually), and one with a real-number rank, like: A=['hello','there','this','that'] B=[3,4,2,5] I'd like to sort list A using the values from B, so the result would be in this example,

Re: sort one list using the values from another list

2006-02-26 Thread Alex Martelli
Brian Blais [EMAIL PROTECTED] wrote: Hello, I have two lists, one with strings (filenames, actually), and one with a real-number rank, like: A=['hello','there','this','that'] B=[3,4,2,5] I'd like to sort list A using the values from B, so the result would be in this example,

Re: sort one list using the values from another list

2006-02-26 Thread Steven Bethard
Brian Blais wrote: Hello, I have two lists, one with strings (filenames, actually), and one with a real-number rank, like: A=['hello','there','this','that'] B=[3,4,2,5] I'd like to sort list A using the values from B, so the result would be in this example,

Re: python-list/python-dev quoting style

2006-02-26 Thread Gregory Petrosyan
me wrote: I see. -- me Wonderfull. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python a Zen language?

2006-02-26 Thread Kay Schluehr
André wrote: If appearing silly is the price of satisfying your curiousity then so be it. I would, however, like to point out that there is a well established usage of the word Zen in computer science. [snip; excellent answer from John deleted.] -John Coleman If I may add: word and

Re: sort one list using the values from another list

2006-02-26 Thread Duncan Booth
Steven Bethard wrote: Here's a solution that makes use of the key= argument to sorted(): A = ['hello','there','this','that'] B = [3,4,2,5] indices = range(len(A)) indices.sort(key=B.__getitem__) [A[i] for i in indices] ['this', 'hello', 'there', 'that'] Basically, it sorts the

Coding Problem (arbitrary thread sych)

2006-02-26 Thread peleme
Hi, Here is a code example to visualize my problem. -- import thread import threading from time import sleep def a(): print exec a sleep(1) def b(): print exec b sleep(4) def c():

Re: Pure python implementation of string-like class

2006-02-26 Thread Ross Ridge
Ross Ridge wrote: Akihiro Kayama in his original post made it clear that he wanted to use a character set larger than entire Unicode code space. Xavier Morel wrote: He implies that ... He explictly said that character set he wanted to use wouldn't fit in UTF-16. ... but in later messages he

Re: Coding Problem (arbitrary thread sych)

2006-02-26 Thread Kent Johnson
peleme wrote: The threads which arrives to the s function should wait for each other until the last one. So A, B, and C executes the last function 'together', while D executes it seperate. I only know that three threads have to be in synch. Take a look at the Barrier patter in The Little Book

How to use python regular expression to substitute string value

2006-02-26 Thread Allerdyce . John
Hi, I am new to python. I would like to know how to use python regular expression to substitute string value? I have an input string like this: x:11 y:0 w:760 h:19 area:14440 areaPerCent:0 totalAreaPerCent:-3.08011e+16 type:3 path:///-/1/1 and I would like to convert it to: rect x=11 y=0

including directories with py2exe

2006-02-26 Thread Mr BigSmoke
Hi All how do i include directories into my project when using py2exe? I have a module that has it's images directory and when it's searches it (into ../dist/library.zip/.../mymodule/) it generates an error because the directory wasn't imported... tnx Fabio --

Re: time.sleep(1) sometimes runs for 200 seconds under windows

2006-02-26 Thread Tony Nelson
In article [EMAIL PROTECTED], Claudio Grondi [EMAIL PROTECTED] wrote: Claudio Grondi wrote: Claudio Grondi wrote: Paul Probert wrote: Peter Hansen wrote: Are you saying that you believe the time.sleep(1) call is actually blocking for 200 seconds? With such rare occurrence

Re: xslt queries in xml to SQL queries

2006-02-26 Thread Crutcher
I don't know what it is with comp.lang.python/python-list these days and the cheap put-downs. Unless you know the person you're responding to personally, and thus the above counts as some kind of banter, you would do better to keep the insults to yourself. You are completely right, I was

An isalpha() that accepts underscores as well

2006-02-26 Thread egbert
The string method isalpha() returns True when all characters in the string are alphabetic. Unfortunately the underscore is not alphabetic. A function that does what I need is: def alfa_(w): return .join(w.split(_)).isalpha() but for the kind of strings that I have this is about ten times

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Pasi Savolainen
[EMAIL PROTECTED] writes: Hi, I am new to python. I would like to know how to use python regular expression to substitute string value? I have an input string like this: x:11 y:0 w:760 h:19 area:14440 areaPerCent:0 totalAreaPerCent:-3.08011e+16 type:3 path:///-/1/1 and I would like to

Distutils Error while building 'win32com.client' extension

2006-02-26 Thread Math
Hello python people, Can you help me out please. I get the folllowing Error while trying to build a installer with the Distutils module: -- building

Distutils Error while building 'win32com.client' extension

2006-02-26 Thread Math
Hello python people, Can you help me out please. I get the folllowing Error while trying to build a installer with the Distutils module: -- building

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Crutcher
You don't really need regexes for this. Assuming there is no whitespace in any of your values, it should be really easy to parse the string. s = 'x:11 y:0 w:760 h:19 area:14440 areaPerCent:0 totalAreaPerCent:-3.08011e+16 type:3 path:///-/1/1' s.split() # break the string on whitespace ['x:11',

Re: sort one list using the values from another list

2006-02-26 Thread bearophileHUGS
Your solution Steven Bethard looks very intelligent, here is a small speed test, because sorting a list according another one is a quite common operation. (Not all solutions are really the same, as Alex has shown). from itertools import izip, imap from operator import itemgetter from random

Re: An isalpha() that accepts underscores as well

2006-02-26 Thread bearophileHUGS
This is probably faster: def alfa_(w): return w.replace(_, a).isalpha() This is another solution, but it's probably slower, you can time it: from string import letters _setalpha = set(letters + _) def alfa_2(w): return not (set(w) - _setalpha) Bye, bearophile --

Tail Call Optimization as a Decorator

2006-02-26 Thread Crutcher
This is fun :) {Note: I take no responsibilty for anyone who uses this in production code} #!/usr/bin/env python2.4 # This program shows off a python decorator # which implements tail call optimization. It # does this by throwing an exception if it is # it's own grandparent, and catching such #

Re: An isalpha() that accepts underscores as well

2006-02-26 Thread Zajcev Evgeny
egbert [EMAIL PROTECTED] writes: The string method isalpha() returns True when all characters in the string are alphabetic. Unfortunately the underscore is not alphabetic. A function that does what I need is: def alfa_(w): return .join(w.split(_)).isalpha() but for the kind of strings

Re: An isalpha() that accepts underscores as well

2006-02-26 Thread Fuzzyman
Zajcev Evgeny wrote: egbert [EMAIL PROTECTED] writes: The string method isalpha() returns True when all characters in the string are alphabetic. Unfortunately the underscore is not alphabetic. A function that does what I need is: def alfa_(w): return .join(w.split(_)).isalpha()

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Allerdyce . John
okay, but I have a simpler question, how can I split using only \n? I try this: strings = node.data.split(\n); print node.data for str in strings: print str where node.data has multiple lines, but in the for loop, I don't see str gets print

Re: Coding Problem (arbitrary thread sych)

2006-02-26 Thread peleme
Hi Kent, that's exactly the solution for my problem. Thanks a lot! Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Crutcher
Are you sure node.data contains newlines? You could try just: print node.data print node.data.split('\n') This should give you an idea. From the interpreter: s = ... abc ... def ... xyz s.split('\n') ['', 'abc', 'def', 'xyz'] -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Allerdyce . John
When I try your idea, I have this error x, y, width, height = re.findall(pattern, str)[0] IndexError: list index out of range How can I use findall to handle error case? i.e. what if there is no match? how can I handle it gracefully? -- http://mail.python.org/mailman/listinfo/python-list

Re: An isalpha() that accepts underscores as well

2006-02-26 Thread Zajcev Evgeny
Fuzzyman [EMAIL PROTECTED] writes: Zajcev Evgeny wrote: egbert [EMAIL PROTECTED] writes: The string method isalpha() returns True when all characters in the string are alphabetic. Unfortunately the underscore is not alphabetic. A function that does what I need is: def alfa_(w):

How can I redirect print function to an output file?

2006-02-26 Thread Plissken . s
I am using the print function in my python script. Can you please tell me what can I do to redirect the output to an file? Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: time.sleep(1) sometimes runs for 200 seconds under windows

2006-02-26 Thread Claudio Grondi
Tony Nelson wrote: In article [EMAIL PROTECTED], Claudio Grondi [EMAIL PROTECTED] wrote: Claudio Grondi wrote: Claudio Grondi wrote: Paul Probert wrote: Peter Hansen wrote: Are you saying that you believe the time.sleep(1) call is actually blocking for 200 seconds? With such rare

Do I need to convert string to integer in python?

2006-02-26 Thread Allerdyce . John
Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? In my python script, I have this line: x /= 10; when i run it, I get this error: TypeError: unsupported operand type(s) for /=: 'unicode' and 'int' I want to divide x by 10 and assign that value

Re: How can I redirect print function to an output file?

2006-02-26 Thread Enoodle
http://diveintopython.org/scripts_and_streams/stdin_stdout_stderr.html example 10.9 , redurectung output -- http://mail.python.org/mailman/listinfo/python-list

Re: Do I need to convert string to integer in python?

2006-02-26 Thread Heiko Wundram
[EMAIL PROTECTED] wrote: Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? Yes. Dynamic typing doesn't say anything about a string and a number being equal, as they are (e.g.) in Perl, it just says that you don't have to care what type of object a

How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
I have a string array: colors = [#ff, #00FF00, #FF] colorIndex = 0; and I want to loop thru each element of colors for str in strings: print colors[colorIndex++ % colors.length] But i get an invalid syntax error when I execute the script: print colors[colorIndex++ %

Re: How can I redirect print function to an output file?

2006-02-26 Thread Alex Martelli
[EMAIL PROTECTED] wrote: I am using the print function in my python script. Can you please tell me what can I do to redirect the output to an file? f = open('aaargh', 'w') printf, 'killew wabbit' Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Do I need to convert string to integer in python?

2006-02-26 Thread Alex Martelli
[EMAIL PROTECTED] wrote: Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? Nope, no such implicit conversion (thanks be!). Strings are strings and ints and ints and never the twain shall meet, except by explicit request;-). In my python script,

Re: Do I need to convert string to integer in python?

2006-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? In my python script, I have this line: x /= 10; when i run it, I get this error: TypeError: unsupported operand type(s) for /=: 'unicode' and 'int' I want to

Re: An isalpha() that accepts underscores as well

2006-02-26 Thread Alex Martelli
Zajcev Evgeny [EMAIL PROTECTED] wrote: ... The following will work, and probably only be twice as slow as 'isalpha' :-) : def alfa(w): return w.replace('_', '').isalpha() Yeah, great performance indeed, thanks! Except it rejects a w that's JUST an underscore, while it would

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread David
[EMAIL PROTECTED] wrote: I have a string array: colors = [#ff, #00FF00, #FF] colorIndex = 0; and I want to loop thru each element of colors for str in strings: print colors[colorIndex++ % colors.length] But i get an invalid syntax error when I execute the script:

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
okay, I try you suggestion, and re-write my code like this: colors = [#ff, #00FF00, #FF] colorIndex = 0 def getText(nodelist): for str in strings: print colors[colorIndex % colors.length] colorIndex += 1 but i get this error:

Re: Do I need to convert string to integer in python?

2006-02-26 Thread Michael Amrhein
[EMAIL PROTECTED] schrieb: Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? In my python script, I have this line: x /= 10; when i run it, I get this error: TypeError: unsupported operand type(s) for /=: 'unicode' and 'int' I want to

Re: Is Python a Zen language?

2006-02-26 Thread Crutcher
My point is simply that, for some languages L, Zen and the art of L or The Tao of L are plausible titles (Zen and the Art of Lisp Programming would be plausible) but for some languages they wouldn't (The Tao of Fortran ?) Do you disagree? No, I don't disagree that people do this. The history

Re: Tail Call Optimization as a Decorator

2006-02-26 Thread Crutcher
I've tossed it to python-dev, but how do I submit it to the cookbook? -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
Can you please tell me what is the meaning of UnboundLocalError: local variable 'colorIndex' referenced before assignment in general? -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Can you please tell me what is the meaning of UnboundLocalError: local variable 'colorIndex' referenced before assignment in general? Well, pretty much of what it says: You tried to access a variable without prior assignment to it. Like this: a = b**2 + c**2

UnboundLocalError: local variable 'colorIndex' referenced

2006-02-26 Thread silverburgh . meryl
Can you please tell me what is the meaning this error in general? UnboundLocalError: local variable 'colorIndex' referenced before assignment In my python script, I have a variable define and init to 0, like this colorIndex = 0 and in one of my functions, I increment it by 1 def myFunc

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Kent Johnson
Diez B. Roggisch wrote: [EMAIL PROTECTED] schrieb: okay, I try you suggestion, and re-write my code like this: colors = [#ff, #00FF00, #FF] colorIndex = 0 def getText(nodelist): for str in strings: print colors[colorIndex % colors.length]

Re: UnboundLocalError: local variable 'colorIndex' referenced

2006-02-26 Thread Rick Zantow
[EMAIL PROTECTED] wrote in news:1140987642.195734.187540 @t39g2000cwt.googlegroups.com: Can you please tell me what is the meaning this error in general? UnboundLocalError: local variable 'colorIndex' referenced before assignment In my python script, I have a variable define and init to

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Pasi Savolainen
[EMAIL PROTECTED] writes: When I try your idea, I have this error x, y, width, height = re.findall(pattern, str)[0] IndexError: list index out of range How can I use findall to handle error case? i.e. what if there is no match? how can I handle it gracefully? This is explained in

Re: UnboundLocalError: local variable 'colorIndex' referenced

2006-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Can you please tell me what is the meaning this error in general? UnboundLocalError: local variable 'colorIndex' referenced before assignment In my python script, I have a variable define and init to 0, like this colorIndex = 0 and in one of my functions,

Re: Is Python a Zen language?

2006-02-26 Thread Alex Martelli
Crutcher [EMAIL PROTECTED] wrote: ... No, I don't disagree that people do this. The history of Zen and the Art of X dates from Zen and the Art of Motorcycle Repair, which is That's Maintenance, not Repair. Subtle but important distinction. Alex --

Re: sort one list using the values from another list

2006-02-26 Thread Ron Adam
[EMAIL PROTECTED] wrote: Your solution Steven Bethard looks very intelligent, here is a small speed test, because sorting a list according another one is a quite common operation. (Not all solutions are really the same, as Alex has shown). Try this one. def psort10(s1, s2): d =

Re: Do I need to convert string to integer in python?

2006-02-26 Thread Steven D'Aprano
On Sun, 26 Feb 2006 11:55:54 -0800, Allerdyce.John wrote: Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? In my python script, I have this line: x /= 10; when i run it, I get this error: TypeError: unsupported operand type(s) for /=:

Re: sort one list using the values from another list

2006-02-26 Thread Alex Martelli
Ron Adam [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Your solution Steven Bethard looks very intelligent, here is a small speed test, because sorting a list according another one is a quite common operation. (Not all solutions are really the same, as Alex has shown). Try this

python newbie question

2006-02-26 Thread ken . carlino
I am new to python, can you please tell me how can I convert my python script into an executable on linux? i.e. instead of typing 'python myscript.py abc', I just need to do 'myscript.py abc'? and how can I get the input argument from my script , in my example, how can I read 'abc'? Thank you.

Re: Is Python a Zen language?

2006-02-26 Thread Steve Holden
Alex Martelli wrote: Crutcher [EMAIL PROTECTED] wrote: ... No, I don't disagree that people do this. The history of Zen and the Art of X dates from Zen and the Art of Motorcycle Repair, which is That's Maintenance, not Repair. Subtle but important distinction. Since the purpose of

Kill forked processes

2006-02-26 Thread kmkz
Hi, I have a program A that forks off two other programs, B and C. I need B and C to both terminate if A is closed, but by using the subprocess.call() method this seems to not be the case; I can shut down the black box that is program A and B/C will still stay up. How can I achieve the desired

Re: sort one list using the values from another list

2006-02-26 Thread bearophileHUGS
It's faster on my system because d.keys() is already sorted. But that may not be the case on other versions of python. In my version it's a little slower. But what system are you using where keys is already sorted? IronPython maybe? Bye, bearophile --

Re: python newbie question

2006-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: I am new to python, can you please tell me how can I convert my python script into an executable on linux? i.e. instead of typing 'python myscript.py abc', I just need to do 'myscript.py abc'? and how can I get the input argument from my script , in my example, how

Re: python newbie question

2006-02-26 Thread Christoph Haas
On Sunday 26 February 2006 22:44, [EMAIL PROTECTED] wrote: I am new to python, can you please tell me how can I convert my python script into an executable on linux? i.e. instead of typing 'python myscript.py abc', I just need to do 'myscript.py abc'? Use the shebang syntax. Use this as a

Re: Can optparse do dependencies?

2006-02-26 Thread Mike Erickson
* Bob ([EMAIL PROTECTED]) wrote: I'd like to setup command line switches that are dependent on other switches, similar to what rpm does listed below. From the grammar below we see that the query-options are dependent on the query switch, {-q|--query}. Can optparse do this or do I have to code

Use of __slots__

2006-02-26 Thread Don Taylor
Hi: I am puzzled about the following piece of code which attempts to create a class that can be used as record or struct with a limited set of allowed attributes that can be set into an instance of the class. class RecordClass(object): __slots__ = [foo] def __init__(self, args):

Memory allocation in for loops

2006-02-26 Thread invitro81
Which one is better w.r.t. memory allocation but also w.r.t. speed: ## 1.1 ## def forloop(a,b): for idx in range(a,b): ## .. ## do something ## .. ## 1.2 ## def whileloop(a,b): idx = a while idx b: ## ..

Re: Is Python a Zen language?

2006-02-26 Thread Steven D'Aprano
On Sun, 26 Feb 2006 12:48:47 -0800, Crutcher wrote: My central thesis: you are using a poor understanding of language to classify languages into things you understand (tool languages) and things which _you_ find 'deep' (and difficult to learn), which you call 'Zen languages'. This is

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Steven D'Aprano
On Sun, 26 Feb 2006 21:58:30 +0100, Diez B. Roggisch wrote: [EMAIL PROTECTED] schrieb: Can you please tell me what is the meaning of UnboundLocalError: local variable 'colorIndex' referenced before assignment in general? Well, pretty much of what it says: You tried to access a

TypeError when subclassing 'list'

2006-02-26 Thread Gerard Flanagan
Hello all Could anyone shed any light on the following Exception? The code which caused it is below. Uncommenting the 'super' call in 'XmlNode' gives the same error. If I make XmlNode a subclass of 'object' rather than 'list' then the code will run. Thanks in advance. Exception: Traceback

Re: Kill forked processes

2006-02-26 Thread Steve Juranich
kmkz wrote: I have a program A that forks off two other programs, B and C. I need B and C to both terminate if A is closed, but by using the subprocess.call() method this seems to not be the case; I can shut down the black box that is program A and B/C will still stay up. How can I achieve

Re: Use of __slots__

2006-02-26 Thread Steven D'Aprano
On Sun, 26 Feb 2006 17:01:45 -0500, Don Taylor wrote: Hi: I am puzzled about the following piece of code which attempts to create a class that can be used as record or struct with a limited set of allowed attributes that can be set into an instance of the class. class

wxPython: help(wx) causes segfaulting?

2006-02-26 Thread Tim Chase
Trying to get my feet wet with wxPython (moving from just command-line apps), I tried the obvious (or, at least to me was obvious): Start python, import wx and then do a help(wx) to see what it can tell me. Unfortunately, it spewed back a handful of errors, gasped, wheezed and died

Re: Use of __slots__

2006-02-26 Thread Crutcher
Steven is right, however, there is a way: def new_record(slotlist): class R(object): __slots__ = slotlist return R() record1 = new_record([age, name, job]) record1.age = 27 record1.name = 'Fred' record1.job = 'Plumber' record1.salary = 5 --

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Andrea Griffini
Writing a while loop with ++x to increment the index was the first mistake i made with python. ++x unfortunately is valid, it's not a single operator but a double unary plus Andrea -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError when subclassing 'list'

2006-02-26 Thread Steve Juranich
Gerard Flanagan wrote: Hello all Could anyone shed any light on the following Exception? The code which caused it is below. Uncommenting the 'super' call in 'XmlNode' gives the same error. If I make XmlNode a subclass of 'object' rather than 'list' then the code will run. ... Code:

Re: Use of __slots__

2006-02-26 Thread Steve Juranich
Don Taylor wrote: I am puzzled about the following piece of code which attempts to create a class that can be used as record or struct with a limited set of allowed attributes that can be set into an instance of the class. I don't understand why I cannot set an attribute 'age' into record1.

Re: TypeError when subclassing 'list'

2006-02-26 Thread Gerard Flanagan
Steve Juranich wrote: Gerard Flanagan wrote: Hello all Could anyone shed any light on the following Exception? The code which caused it is below. Uncommenting the 'super' call in 'XmlNode' gives the same error. If I make XmlNode a subclass of 'object' rather than 'list' then the

wxGlade, wxPython.... pyOpenGL wxWidget?

2006-02-26 Thread physci
I've been combing google for the past week trying to find an appropriate set of tools for a project I'm working on. Simply put, what I need is a GUI, powered by python, (I really don't want to touch any C++ code at all), that has an openGL canvas/scene(?), with a python interpreter sitting beside

Re: Pure python implementation of string-like class

2006-02-26 Thread Akihiro KAYAMA
Hi Ross. Thanks a lot for your clarifying. I didn't think my post could be an Unicode frame. I don't know this mailing list is the right place talking about Unicode issue, but as for me, a million codespace which UTF-16 brings is not enough. It presume that same characters has a same

Re: Is Python a Zen language?

2006-02-26 Thread Andrea Griffini
I think that the classification has some meaning, even if of course any language has different shades of both sides. I'd say that with python is difficult to choose one of the two categories because it's good both as a pratical language and as a mind-opener language. IMO another language that

Re: Memory allocation in for loops

2006-02-26 Thread Diez B. Roggisch
I mean what I really would like is to have something C++ - like for (int idx = a; idx b; i++) { .. } where no internal vector or something like that is allocated but only a few op's on registers are performed; in the whileloop in python the picture is roughly the same Use xrange instead

RE: Use of __slots__

2006-02-26 Thread Delaney, Timothy (Tim)
Steve Juranich wrote: IMHO, __slots__ is unpythonic. Many others have stated so on the list. That's why it's great that you're free to ignore that variable. I suggest that you do so (as I have chosen to do). I'm sure that there are situations where you *MUST* have this kind of capability,

Re: wxGlade, wxPython.... pyOpenGL wxWidget?

2006-02-26 Thread Karsten W.
PyOpenGL comes with a Tkinter widget for OpenGL, and searching google wxwidgets opengl yields http://www.wxwidgets.org/opengl.htm Kind regards, Karsten. -- http://mail.python.org/mailman/listinfo/python-list

SyntaxError: can't assign to a function call

2006-02-26 Thread Fuzzyman
What gives ? a = [] def f(): return a f() [] a.append(3) f() [3] a += [3] a [3, 3] f() [3, 3] f() += [4] SyntaxError: can't assign to function call Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Alex Martelli
Fuzzyman [EMAIL PROTECTED] wrote: What gives ? ... a = [] def f(): return a ... f() += [4] SyntaxError: can't assign to function call Exactly what the error message says: it's syntactically forbidden to perform any assignment on a function-call. If you're keen on these

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Lawrence Oluyede
Fuzzyman [EMAIL PROTECTED] writes: f() += [4] SyntaxError: can't assign to function call It's obvious that that line gives you a syntax error. += is the increment operator overloaded for strings and lists and so on. It changes the lhs in place appending the rhs. In this case the rhs is a

Local variables initialization

2006-02-26 Thread Michal Kwiatkowski
Hi! I'm building a class that most of methods have similar intro, something like this: def method(self): var_one = self.attr_one var_two = self.attr_two.another_attr empty_list = [] # significant code goes here # ... It's done for clarity reasons, aliasing most used

Re: SyntaxError: can't assign to a function call

2006-02-26 Thread Fuzzyman
Alex Martelli wrote: Fuzzyman [EMAIL PROTECTED] wrote: What gives ? ... a = [] def f(): return a ... f() += [4] SyntaxError: can't assign to function call Exactly what the error message says: it's syntactically forbidden to perform any assignment on a

Re: Is Python a Zen language?

2006-02-26 Thread Cameron Laird
In article [EMAIL PROTECTED], Kay Schluehr [EMAIL PROTECTED] wrote: . . . Lucid in the mid 80s that gone down a few years later. As it turned out that time Lisp was not capable to survive in what we call today a heterogenous

Re: wxGlade, wxPython.... pyOpenGL wxWidget?

2006-02-26 Thread physci
Ok, I initially thought the Tkinter route would be too low level (Ha, low level python), but I noticed a link to VTK which looks promising. Thanks for your quick reply! Derek. -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >