[Tutor] cross platform gui

2005-02-13 Thread Lobster
=== From: Kim Branson [EMAIL PROTECTED] Hi all, i'm interested in building a gui for some code we have. I'm after pointers on gui programming, and a recommendation on a cross platform gui library, wxpython? pythoncard, qt? What do people use. Ideally i'd like something that can work on

Re: [Tutor] default argument frustration

2005-02-13 Thread Alan Gauld
Alan was saying that there is no other obvious way for Python to do it. What I am still not clear on it is why Alan's claim is true. (Not doubting it is, but would like to get why it is.) Doubt away, my knowledge of Python internals is largely intuitive, I've never got round to reading the C

Re: ****SPAM(11.2)**** [Tutor] Larger program organization

2005-02-13 Thread Alan Gauld
I am curious about Bob's Whenever you find yourself writing an if statement ask whether this would be better handled by subclasses. Could you explain a bit more? One of the basic purposes of OOP is to eliminate if/switch statements that are conditional on the type of the object being handled.

Re: [Tutor] Re: Data storage, SQL?

2005-02-13 Thread Liam Clarke
...So, trying to get this straight - if I were going to use SQLite, what would I actually download from http://www.sqlite.org/sqlite.html ? Also, would Gadfly be easier, being native Python? Regards, Liam Clarke On Sat, 12 Feb 2005 14:27:21 +0500, Sandip Bhattacharya [EMAIL PROTECTED]

Re: [Tutor] default argument frustration

2005-02-13 Thread Alan Gauld
I've combined a few email's worth of quoting as no previous post had all the elements I wanted to refer to. interface. The function should return the same result each time you call it with the same input. The only way to achieve that is to have the default calculated once. I feel the

Re: [Tutor] Accessing local variables from nested functions.

2005-02-13 Thread Karl Pflästerer
On 13 Feb 2005, [EMAIL PROTECTED] wrote: what's the Python way of accessing local variables in nesting functions? For The way you want to work with closures the Python way is not to do it but use a class to hold the state. That's sometimes sad but true. example if I have: def p():   var1

[Tutor] Re: Accessing local variables from nested functions.

2005-02-13 Thread Andrei
Karl Pflästerer wrote on Sun, 13 Feb 2005 12:15:03 +0100: what's the Python way of accessing local variables in nesting functions? For then there's no problem in running such function, but what if I'd like to modify var1 so that the change were vissible in p()? I'd use return in the form

[Tutor] (no subject)

2005-02-13 Thread Johan Kohler
Hi I still have problems pickling and unpickling. After I couldn't get complicated objects to work, i decided to use simple lists. But now there seems to be a difference between assigning a list value, and using the .append method. Please try out the code at

Re: [Tutor] Re: Accessing local variables from nested functions.

2005-02-13 Thread Karl Pflästerer
On 13 Feb 2005, [EMAIL PROTECTED] wrote: Karl Pflästerer wrote on Sun, 13 Feb 2005 12:15:03 +0100: what's the Python way of accessing local variables in nesting functions? For I didn't wrote that; please quote correctly. Thanks. Karl -- Please do *not* send copies of replies to me.

Re: [Tutor] Re: Data storage, SQL?

2005-02-13 Thread Kent Johnson
Liam Clarke wrote: ...So, trying to get this straight - if I were going to use SQLite, what would I actually download from http://www.sqlite.org/sqlite.html ? SQLite itself does not use / interface with Python. So you would download the appropriate version of SQLite for your platform from

Re: [Tutor] what is wrong with this?

2005-02-13 Thread Kent Johnson
Liam Clarke wrote: Yup, that's what I was after, the full error message. self.grid1.CreateGrid(100,6) val = gridc.wxGrid_CreateGrid(self, *_args, **_kwargs) try this self.grid1.CreateGrid(self, 100, 6) I'm pretty sure you have to explicitly pass self. No, that's not it. There is an asymmetry

Re: [Tutor] cross platform gui

2005-02-13 Thread Mark Kels
On Sun, 13 Feb 2005 08:03:45 -0800, Lobster [EMAIL PROTECTED] wrote: Hi all, i'm interested in building a gui for some code we have. I'm after pointers on gui programming, and a recommendation on a cross platform gui library, wxpython? pythoncard, qt? What do people use. Ideally i'd like

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Kent Johnson
Brian van den Broek wrote: Since you files are quite short, I'd do something like: code data_file = open(thedata.txt, 'r') # note -- 'r' not r data = data_file.readlines() # returns a list of lines def process(list_of_lines): data_points = [] for line in list_of_lines:

Re: ****SPAM(7.4)**** Re: ****SPAM(11.2)**** [Tutor] Larger program organization

2005-02-13 Thread Kent Johnson
Bob Gailer wrote: At 03:21 PM 2/12/2005, Brian van den Broek wrote: [snip] I am curious about Bob's Whenever you find yourself writing an if statement ask whether this would be better handled by subclasses. class A: ... class A1(A); def foo(self, ...): statements to process object of

Re: [Tutor] what is wrong with this?

2005-02-13 Thread Kent Johnson
You might try asking for help on the Boa users mailing list. Kent jrlen balane wrote: i'm using BOA to construct the GUI. The problem is in this MDIChildFrame. The code was sort of copy and pasted from the wxpython demo grid.py then edited so that it fits what i wanted. there seems to be no

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-02-13 14:04: Brian van den Broek wrote: Since you files are quite short, I'd do something like: code data_file = open(thedata.txt, 'r') # note -- 'r' not r data = data_file.readlines() # returns a list of lines def process(list_of_lines):

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Kent Johnson
Brian van den Broek wrote: Kent Johnson said unto the world upon 2005-02-13 14:04: Brian van den Broek wrote: Since you files are quite short, I'd do something like: code data_file = open(thedata.txt, 'r') # note -- 'r' not r data = data_file.readlines() # returns a list of lines def

RE: [Tutor] Larger program organization

2005-02-13 Thread Ryan Davis
My main reason right now is that I know C#/ASP.NET very well. I don't know how to do things in Python yet. Say I can make a C# web app with a quality of X. Until I know how to make a Python web app with quality X, I can't use it in a production environment. I'm hoping that doing some

[Tutor] Problems with test cgi script on windows XP/Apache

2005-02-13 Thread Tim Johnson
I'm attempting to run a test cgi script on windows xp with apache as the http server. I keep getting a not found error from IE, and the error log shows the following error message. No such file or directory: script not found or unable to stat: c:/program files/apache group/apache/cgi-bin/test.py

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Brian van den Broek
jrlen balane said unto the world upon 2005-02-13 18:45: ei guys, chill out! what if i choose to numbered my data from 1-96 for example. how would i be able to exclude the numbered part from the data part? and, mind if I ask, what's a YAGNI by the way?

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Kent Johnson
jrlen balane wrote: and this line: data_points.append(int(line)) this would turn the string back to an integer, am i right? Yes. and on this one: data_points = [ int(line) for line in data_file ] this did not use any read(), is this already equal to readline()? so this would already store

[Tutor] Tweaking list comprehensions

2005-02-13 Thread Liam Clarke
Hello, I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachA(files): isHTML = [] for filename in files: if

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Alan Gauld
ei guys, chill out! Its OK, we often get carried away on flights of fancy here :-) what if i choose to numbered my data from 1-96 for example. how would i be able to exclude the numbered part from the data part? You can use the string split() method to get a list of the components. Then

Re: [Tutor] error message

2005-02-13 Thread Liam Clarke
OK, so it looks like you're not matching. Remember match only matches at the start of a line, so try re.search instead. On Sun, 13 Feb 2005 17:16:24 -0800 (PST), Ron Nixon [EMAIL PROTECTED] wrote: Got the same error message after trying: x =re.match(patt,string) x.group() Traceback

Re: [Tutor] error message

2005-02-13 Thread Alan Gauld
string = 'My phone is 410-995-1155' pattern = r'\d{3}-\d{3}-\d{4}' re.match(pattern,string).group() AttributeError: 'NoneType' object has no attribute 'group' When match doesn't find anything it returns None, which has no group() method. Why does it not find the regex? Because you used

Re: [Tutor] error message

2005-02-13 Thread Jacob S.
Dive into Python, an excellent tutorial has a case study on this very same topic. The biggest problem that nobody has mentioned yet is the fact that group() will not have anything unless you explicitly tell it to group it. I.E. pattern = r'(\d{3})-(\d{3})-(\d{4})' You need the parenthesis to

Re: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Jacob S.
Hello, I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachA(files): isHTML = [] for filename in files: if filename.endswith('.htm') or

Re: [Tutor] error message

2005-02-13 Thread Liam Clarke
I was wondering about that also, I've only ever used .group() when I've got named groups using (?Pfoo) On Sun, 13 Feb 2005 21:04:22 -0500, Jacob S. [EMAIL PROTECTED] wrote: Dive into Python, an excellent tutorial has a case study on this very same topic. The biggest problem that nobody has

Re: [Tutor] error message

2005-02-13 Thread Kent Johnson
Jacob S. wrote: Dive into Python, an excellent tutorial has a case study on this very same topic. The biggest problem that nobody has mentioned yet is the fact that group() will not have anything unless you explicitly tell it to group it. group() defaults to returning group 0 which is the whole

Re: [Tutor] error message

2005-02-13 Thread Jacob S.
Okay... Cool. Jacob group() defaults to returning group 0 which is the whole match. import re string = 'My phone is 410-995-1155' pattern = r'\d{3}-\d{3}-\d{4}' re.search(pattern,string).group() '410-995-1155' Kent ___ Tutor maillist -

RE: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Tony Meyer
def approachB(files): isHTML = [filename if filename.endswith('.htm') or\ filename.endswith(.html') for filename in files] return isHTML No, it should be... isHTML = [filename for filename in files if filename.endswith('.htm') or\ filename.endswith('.html') for filename in

Re: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Kent Johnson
Kent Johnson wrote: Liam Clarke wrote: Hello, I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachA(files): isHTML = [] for filename in files:

[Tutor] calling an external program

2005-02-13 Thread Lobster
- I am trying to call up an external program with something like a Shell command - can not find a way of doing this (in windows) Any hints? Ed Jason ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Fwd: Delivery Status Notification (Failure)

2005-02-13 Thread Liam Clarke
Anyone else getting these? -- Forwarded message -- From: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Sun, 13 Feb 2005 17:59:35 -0800 Subject: Delivery Status Notification (Failure) To: [EMAIL PROTECTED] This is an automatically generated Delivery Status Notification. Delivery to

[Tutor] writing list to new file

2005-02-13 Thread Ron Nixon
How would I save a list to a new file for example: If line.startswith('XXX'): save list to new file But I get errors saying only stings can be saved this way. __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today!

Re: [Tutor] calling an external program

2005-02-13 Thread Max Noel
On Feb 14, 2005, at 10:37, Lobster wrote: - I am trying to call up an external program with something like a Shell command - can not find a way of doing this (in windows) Any hints? What about os.system('your_command_here')? -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you

Re: [Tutor] calling an external program

2005-02-13 Thread Bernard Lebel
The os module is the answer. Use chdir() to make the target executable's directory the current directory, and then os.system( 'command' ) to run the actual command. Cheers Bernard Lobster wrote: - I am trying to call up an external program with something like a Shell command - can not find a

[Tutor] Value Error solved. Another question

2005-02-13 Thread Ron Nixon
Ignore my first posting. Here's what I'm trying to do. I want to extract headlines from a newspaper's website using this code. It works, but I want to match the second group in h2a href=(.*)(.*)/p and print that out. Sugguestions import urllib, re pattern = re.compile(h2a href=(.*)(.*)/p,