[Tutor] printing value returning from a Class

2007-09-13 Thread Varsha Purohit
Hello friends,, I have a problem in displaying data which i have invoked from class. City is the name of the class which i havent displayed here. There is another script using that class. It has a function name setCities which takes a text file as argument. Text file contains name of

[Tutor] 2.5 to 2.4 problem with Int

2007-09-13 Thread John
I've written a program which calculates areas of grid cells distributed over the globe. It works fine with Python 2.5, however, when I run it with 2.4(the Enthon edition) I get the following error: OverflowError: long int too large to convert to int It occurs on this line: for ix in range(nx):

Re: [Tutor] editTextFile.py

2007-09-13 Thread Kent Johnson
Christopher Spears wrote: I created a script that opens an existing text file, allows the user to write over the original contents, and then save the file. The original contents are then saved in a separate file. Here is the script: #!/usr/bin/python 'editTextFile.py -- write over

Re: [Tutor] 2.5 to 2.4 problem with Int

2007-09-13 Thread Kent Johnson
John wrote: I've written a program which calculates areas of grid cells distributed over the globe. It works fine with Python 2.5, however, when I run it with 2.4 (the Enthon edition) I get the following error: OverflowError: long int too large to convert to int It occurs on this line:

Re: [Tutor] printing value returning from a Class

2007-09-13 Thread Kalle Svensson
Hello! On 9/13/07, Varsha Purohit [EMAIL PROTECTED] wrote: Hello friends,, I have a problem in displaying data which i have invoked from class. City is the name of the class which i havent displayed here. There is another script using that class. It has a function name setCities

[Tutor] is this a vista issue

2007-09-13 Thread sacha rook
Hi when I run this code on a winxp box I get a nice list of url's when I run this code on a win VISTA box I get this print urlparse.urlparse(href)[1]TypeError: 'module' object is not callable can a. someone tell me why b. how do i get rid of this condition before I throw vista away

Re: [Tutor] is this a vista issue

2007-09-13 Thread Kent Johnson
sacha rook wrote: Hi when I run this code on a winxp box I get a nice list of url's when I run this code on a win VISTA box I get this print urlparse.urlparse(href)[1] TypeError: 'module' object is not callable Please show the whole traceback. Kent can a. someone tell me

Re: [Tutor] 2.5 to 2.4 problem with Int

2007-09-13 Thread John
The error occurs here: area[ix,iy]=gridarea The values of nx, ix, iy leading up to the error are: 360 0 0 360 1 0 360 2 0 360 3 0 360 4 0 360 ... ... 360 357 9 360 358 9 360 359 9 360 0 10 OverflowError: long int too large to convert to int I guess then the problem occurs when iy goes from 9 to

Re: [Tutor] 2.5 to 2.4 problem with Int

2007-09-13 Thread Kent Johnson
John wrote: The error occurs here: area[ix,iy]=gridarea What is area? Is it a dict or something else? What is gridarea? Please show more code and the complete traceback. Kent The values of nx, ix, iy leading up to the error are: 360 0 0 360 1 0 360 2 0 360 3 0 360 4 0 360 ... ...

Re: [Tutor] 2.5 to 2.4 problem with Int

2007-09-13 Thread John
In all it's glory: I'm just a bit embarrassed because I'm sure it's poor coding: def gridarea(H): returns an array of area corresponding to each nx,ny,nz %=== % %--- % input % - H : Header dict object with

[Tutor] Class Inheritance

2007-09-13 Thread Lamonte Harris
Okay class A: def __init__(self,x,y): self.x = x self.y = y def save(self,fn): f = open(fn,w) f.write(str(self.x)+ '\n') # convert to a string and add newline f.write(str(self.y)+'\n') return f # for child objects to use def restore(self, fn):

Re: [Tutor] 2.5 to 2.4 problem with Int

2007-09-13 Thread Kent Johnson
I have no clue; anyone else? Maybe you should try the numpy list. Kent John wrote: for the record: nx=360 ny=180 nz=1 On 9/13/07, *John* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: In all it's glory: I'm just a bit embarrassed because I'm sure it's poor coding:

Re: [Tutor] Class Inheritance

2007-09-13 Thread Eric Brunson
Lamonte Harris wrote: Okay class A: def __init__(self,x,y): self.x = x self.y = y def save(self,fn): f = open(fn,w) f.write(str(self.x)+ '\n') # convert to a string and add newline f.write(str(self.y)+'\n') return f # for child objects

[Tutor] evaluating AND

2007-09-13 Thread Orest Kozyar
Given a variable x that can either be None or a tuple of two floats [i.e. (0.32, 4.2)], which syntax is considered most appropriate under Python coding standards? if x and x[0] 0: pass =OR= if x: if x[0] 0: pass In the first, I'm obviously making the

Re: [Tutor] evaluating AND

2007-09-13 Thread Eric Brunson
The first is how I would code it. Python guarantees that compound boolean statements are processed from left to right and also that the AND operator will short circuit the rest of the evaluation, since the rest of the line cannot change the falseness of the entire statement. Orest Kozyar

Re: [Tutor] evaluating AND

2007-09-13 Thread Terry Carroll
On Thu, 13 Sep 2007, Orest Kozyar wrote: Given a variable x that can either be None or a tuple of two floats [i.e. (0.32, 4.2)], which syntax is considered most appropriate under Python coding standards? if x and x[0] 0: pass =OR= if x: if x[0] 0:

[Tutor] Killing an instance

2007-09-13 Thread Ara Kooser
I have two instances called and running. They interact with each other and I would like one of the instances to cease to exist in the second round based on a given condition. How do you kill an instance? The code is below. I have Red and Yellow as my instances and I want them to die when

Re: [Tutor] evaluating AND

2007-09-13 Thread Kent Johnson
Orest Kozyar wrote: Given a variable x that can either be None or a tuple of two floats [i.e. (0.32, 4.2)], which syntax is considered most appropriate under Python coding standards? if x and x[0] 0: pass =OR= if x: if x[0] 0: pass The first is

Re: [Tutor] evaluating AND

2007-09-13 Thread Adam Bark
On 13/09/2007, Terry Carroll [EMAIL PROTECTED] wrote: On Thu, 13 Sep 2007, Orest Kozyar wrote: Given a variable x that can either be None or a tuple of two floats [i.e . (0.32, 4.2)], which syntax is considered most appropriate under Python coding standards? if x and x[0] 0:

Re: [Tutor] evaluating AND

2007-09-13 Thread Terry Carroll
On Thu, 13 Sep 2007, Adam Bark wrote: The problem is what if it's an empty list or tuple? It would pass but have not value whereas if x would work fine. Exactly. The poster stated that x is supposed to be either None or a tuple of two floats. Just to put a bit of meat on the example, let's

Re: [Tutor] Suggested books for Agile Programming Testing

2007-09-13 Thread Alan Gauld
Shannon -jj Behrens [EMAIL PROTECTED] wrote Also, can anyone comment on the limits or caveats of agile development? I posted a longish response on this but it seems not to have made to gmane! Here it is again: === Stephen McInerney [EMAIL PROTECTED] wrote

Re: [Tutor] 2.5 to 2.4 problem with Int

2007-09-13 Thread Alan Gauld
John [EMAIL PROTECTED] wrote In all it's glory: I'm just a bit embarrassed because I'm sure it's poor coding: Thats what we're here for... The first thing to note is that gridarea is here a function object. So are you assigning the function object to area[x,y]. Is that what you intend?

Re: [Tutor] Killing an instance

2007-09-13 Thread Alan Gauld
Ara Kooser [EMAIL PROTECTED] wrote I have two instances called and running. They interact with each other and I would like one of the instances to cease to exist in the second round based on a given condition. How do you kill an instance? Either set the variable to something else or

Re: [Tutor] Killing an instance

2007-09-13 Thread Alan Gauld
Ara Kooser [EMAIL PROTECTED] wrote The code is below. I have Red and Yellow as my instances and I want them to die when life = 0 and not show up in the preceding rounds of the game. I'm not sure I understand this last bit. Won't they already have shown up in the preceding bits of the

[Tutor] deleting one line in multiple files

2007-09-13 Thread bhaaluu
Greetings, I'm running Python 2.4.3 on a GNU/Linux box. This question is about using 'fileinput.' I have a directory of files, and I've created a file list of the files I want to work on: $ ls file.list Each file in file.list needs to have a line removed, leaving the rest of the file intact.

[Tutor] deleting one line in multiple files

2007-09-13 Thread wormwood_3
I think the problem is that the original script you borrowed looks at the file passed to input, and iterates over the lines in that file, removing them if they match your pattern. What you actually want to be doing is iterating over the lines of your list file, and for each line (which

[Tutor] How can I extend my vocabulary that fits well with python.

2007-09-13 Thread Lamonte Harris
See theres a lot of words that I know and some that I don't know, how can I extend and improve my python vocabulary so I can interpret information in a faster manor. Makes things easier to understand if you actually understand the things the people are saying in tutorials,etc..

Re: [Tutor] evaluating AND

2007-09-13 Thread Rikard Bosnjakovic
On 14/09/2007, Terry Carroll [EMAIL PROTECTED] wrote: The second one, which just checks if x and is satisfied with any false value, including an empty tuple, does not raise the error condition, even though the data is bad. This is a bad thing. For me, if x would be enough. If you think it's

Re: [Tutor] is this a vista issue

2007-09-13 Thread Rikard Bosnjakovic
On 13/09/2007, sacha rook [EMAIL PROTECTED] wrote: [CODE] from BeautifulSoup import BeautifulSoup doc = ['htmlheadtitlePage title/title/head', 'bodyp id=firstpara align=centerThis is paragraph bone/b.', 'p id=secondpara align=blahThis is paragraph btwo/b.', 'a

Re: [Tutor] evaluating AND

2007-09-13 Thread John Fouhy
On 14/09/2007, Rikard Bosnjakovic [EMAIL PROTECTED] wrote: On 14/09/2007, Terry Carroll [EMAIL PROTECTED] wrote: The second one, which just checks if x and is satisfied with any false value, including an empty tuple, does not raise the error condition, even though the data is bad. This is

Re: [Tutor] deleting one line in multiple files

2007-09-13 Thread wormwood_3
Thought I would do some more testing and get you a more finalized form this time. So I took the mygrep.py script, and put it in a folder with 3 test files with content like this: I am some lines of text yep I love text 435345 345345345 script type=text/javascript / Then I ran: [EMAIL