[Tutor] concerning help() function

2009-07-28 Thread David
Dear Tutors, whenever I make use of the help() function, I have a good chance of getting an error. I have not yet understood this tool very well. Take the modules operator and random as examples. The former is built-in, the latter not. Do I wish to see the help files, I have to use a different sy

Re: [Tutor] how to get blank value

2009-07-28 Thread Paul McGuire
> -Original Message- > From: amr...@iisermohali.ac.in [mailto:amr...@iisermohali.ac.in] > Sent: Wednesday, July 29, 2009 12:13 AM > To: Paul McGuire > Cc: tutor@python.org > Subject: Re: [Tutor] how to get blank value > > Thanks for help Sir but with these commands it is showing error:- >

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
Thanks for help Sir but with these commands it is showing error:- ph08...@sys53:~> python trip.py Traceback (most recent call last): File "trip.py", line 6, in from pyparsing import * ImportError: No module named pyparsing > Ok, I've seen various passes at this problem using regex, split(

Re: [Tutor] how to get blank value

2009-07-28 Thread Paul McGuire
Ok, I've seen various passes at this problem using regex, split('='), etc., but the solutions seem fairly fragile, and the OP doesn't seem happy with any of them. Here is how this problem looks if you were going to try breaking it up with pyparsing: - Each line starts with an integer, and the stri

Re: [Tutor] Problem with multiple input

2009-07-28 Thread Alan Gauld
"pja" wrote One major problem is that the book is written for Python 2.x and I am using Python 3.1 (and don't want to switch back). Very few books/tutorials exist yet for v3. But you seem to be coping with the differences adequately. My tutorial for v3 is almost half-way complete, you might f

[Tutor] Problem with multiple input

2009-07-28 Thread pja
Hi! I am trying to teach myself Python (using John Zelle's book "Python Programming"). One major problem is that the book is written for Python 2.x and I am using Python 3.1 (and don't want to switch back). There is a sample script for calculating the sum and difference of two numbers: #

[Tutor] "File exists, overwrite?" dialog help

2009-07-28 Thread pedro
Hi I am learning python for use in Nuke (image compositing software). I would like to test if a file exists and receive a warning if it does. To do a Nuke command line render, it looks something like this: /Applications/Nuke5.1v5/Nuke5.1v5.app/Contents/MacOS/Nuke5.1v5 -iX WriteComp '/Volumes/s

[Tutor] searching for an ip and subnets in a dir of csv's

2009-07-28 Thread Nick Burgess
Good evening List, I am trying to have this script search for an IP or nearest subnet match in a dir of csv's. It works with an absolute match, It will be receiving a whole IP address, so if there is no absolute match no data is returned, however if it is listed somewhere in a subnet I want to kn

Re: [Tutor] self.name vs. passing a name

2009-07-28 Thread Che M
> > The "answer" to each function is then used in the next function. > > I can think of two ways to make that answer available ... > > 1) pass it in, or > > 2) declare it as self.answer Thank you Alan, Kent, and Dave. Full agreement, and it makes sense to me. (Maybe this is also an example

Re: [Tutor] how to get blank value

2009-07-28 Thread Dave Angel
amr...@iisermohali.ac.in wrote: It is not giving any value, without any error ph08...@sys53:~> python trial.py ph08...@sys53:~> it is coming out from shell. Thanks for help. Amrita amr...@iisermohali.ac.in wrote: Sorry to say, but till now I have not got the solution of my problem, I

Re: [Tutor] how to get blank value

2009-07-28 Thread शंतनू
You may like to have a look @ pyparsing module. URL: http://pyparsing.wikispaces.com/ HTH. regards, shantanoo On 29-Jul-09, at 1:03 AM, amr...@iisermohali.ac.in wrote: with these data it is giving output but when I tried if __name__ == '__main__': data = open('chem.txt').readlines() for line

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
with these data it is giving output but when I tried if __name__ == '__main__': data = open('chem.txt').readlines() for line in data: line2 = line.split('=') if not line2[5]: # C value missing if len(line2[2]) <= 5 and len(line2[3]) <= 5: # N and CA values missing

Re: [Tutor] Two problems related to dispathing.

2009-07-28 Thread Mac Ryan
On Tue, 2009-07-28 at 19:03 +0100, Alan Gauld wrote: > There is no simpler solution without changing the class. > If you can do that you could pass the container to the constructor > and get the class to add itself to the container Kent, Alan... thank you very much, indeed I finally

Re: [Tutor] how to know if process is running?

2009-07-28 Thread Alan Gauld
"shawn bright" wrote So, my question is, how can i write something that will know if there is an instance of that something already running? I am doing this in python 2.5 on Ubuntu, if that matters ( which i suspect it does ). I suspect the simplest way is to use the ps command and grep. W

Re: [Tutor] Two problems related to dispathing.

2009-07-28 Thread Alan Gauld
"Mac Ryan" wrote above function. In fact, as I have the need to access the object both individually and with the dispatcher, I am doing something like this every time I instantiate a new object: mycontent = ContentA() contents.append(mycontent) ...but although I "feel" this is silly, I

Re: [Tutor] how to get blank value

2009-07-28 Thread Alan Gauld
wrote Sorry to say, but till now I have not got the solution of my problem, I tried with this command:- import re if __name__ == '__main__': data = open('chem.txt').readlines() for line in data: RE = re.compile('C = (.)',re.M) The regex still does not match the end of line.

Re: [Tutor] Two problems related to dispathing.

2009-07-28 Thread Kent Johnson
On Tue, Jul 28, 2009 at 1:22 PM, Mac Ryan wrote: > def invokeAll(method, data): >    """This function is a dispatcher: it invokes all the content types >    of the application calling 'contenttype.method(data)'""" >    return [getattr(content, method)(data) for content in contents] In Python 2.6

Re: [Tutor] how to know if process is running?

2009-07-28 Thread shawn bright
Hey all, i used the popen with getpid() option. working well so far, thanks to all of you. shawn On Tue, Jul 28, 2009 at 12:11 PM, Mac Ryan wrote: > I am not an expert, but if I got you correctly, what you want to achieve > is a "singleton": http://en.wikipedia.org/wiki/Singleton_pattern if you >

[Tutor] Two problems related to dispathing.

2009-07-28 Thread Mac Ryan
Hello, I'm working on an application in which I need the main loop to call the same method on a number of objects. I came up with this solution that seem to work, but I was wondering if there is a better / more pythonic solution to the problem. def invokeAll(method, data): """This fu

Re: [Tutor] how to get blank value

2009-07-28 Thread bob gailer
amr...@iisermohali.ac.in wrote: It is not giving any value, without any error ph08...@sys53:~> python trial.py ph08...@sys53:~> it is coming out from shell. Try this. I embedded the test data to simplify testing: data = """48 ALA H = 8.33 N = 120.77 CA = 55.18 HA = 4.12 C = 181.50 104 ALA H

Re: [Tutor] how to know if process is running?

2009-07-28 Thread Mac Ryan
I am not an expert, but if I got you correctly, what you want to achieve is a "singleton": http://en.wikipedia.org/wiki/Singleton_pattern if you watch at the sample implementation, there is a Python example too. Mac. On Tue, 2009-07-28 at 10:45 -0500, shawn bright wrote: > Hey all, > > I have an

Re: [Tutor] how to know if process is running?

2009-07-28 Thread Chris Fuller
On Tuesday 28 July 2009 10:45, shawn bright wrote: > Hey all, > > I have an app that runs in a GUI written in pygtk. It spawns several > threads, and runs all the time. > It is mission critical that we can never have two instances of this > running at once. > > So, my question is, how can i write s

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
It is not giving any value, without any error ph08...@sys53:~> python trial.py ph08...@sys53:~> it is coming out from shell. Thanks for help. Amrita > amr...@iisermohali.ac.in wrote: >> Sorry to say, but till now I have not got the solution of my problem, I >> tried with this command:- >> >> imp

Re: [Tutor] how to know if process is running?

2009-07-28 Thread shawn bright
Thanks for the pointers Wayne, Tino, Looks easier than i had thought. sk On Tue, Jul 28, 2009 at 11:10 AM, Tino Dai wrote: > On Tue, Jul 28, 2009 at 11:45 AM, shawn bright wrote: >> >> So, my question is, how can i write something that will know if there >> is an instance of that something alread

[Tutor] how to know if process is running?

2009-07-28 Thread shawn bright
Hey all, I have an app that runs in a GUI written in pygtk. It spawns several threads, and runs all the time. It is mission critical that we can never have two instances of this running at once. So, my question is, how can i write something that will know if there is an instance of that something

Re: [Tutor] Messages not going through (testing again)

2009-07-28 Thread Ataulla S H
welcome to Tutor:) On Tue, Jul 28, 2009 at 8:18 PM, Eduardo Vieira wrote: > Hello, this is just a test. I have posted 2 different messages and > they have never reached this list. > > Eduardo > ___ > Tutor maillist - Tutor@python.org > http://mail

Re: [Tutor] [BangPypers] Django test case problem

2009-07-28 Thread B.Nanda Kishore
By default django looks for a file called *tests.py*(plural) and not * test.py*. Check that and let us know. Regards, Nandakishore On Tue, Jul 28, 2009 at 6:40 PM, VIJAY KUMAR wrote: > Hi, > >I am running testcase from django when I run them from models.py it > run. > >But when I put t

[Tutor] Messages not going through (testing again)

2009-07-28 Thread Eduardo Vieira
Hello, this is just a test. I have posted 2 different messages and they have never reached this list. Eduardo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to get blank value

2009-07-28 Thread bob gailer
amr...@iisermohali.ac.in wrote: Sorry to say, but till now I have not got the solution of my problem, I tried with this command:- import re # assuming H = , N = , CA = , HA = and C = always present in that order if __name__ == '__main__': data = open('chem.txt').readlines() for line in d

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
Sorry to say, but till now I have not got the solution of my problem, I tried with this command:- import re if __name__ == '__main__': data = open('chem.txt').readlines() for line in data: RE = re.compile('C = (.)',re.M) matches = RE.findall(line) for m in mat

[Tutor] Django test case problem

2009-07-28 Thread VIJAY KUMAR
Hi,    I am running testcase from django when I run them from models.py it run.    But when I put the same in test.py in the same directory where models is define it not even getting called.   My structure django application is  mysite Settings.py Urls.py   Polls

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-28 Thread Dick Moores
On Tue, Jul 28, 2009 at 02:20, Dave Angel wrote: > Dick Moores wrote: >> >> >> I'm not sure how to edit it. What's required for Ulipad is quite >> different, I believe. >> >> This is what I got from Dave Angel: >> e: >> cd \Python26\Lib\idlelib\ >> ..\..\pythonw.exe idle.pyw %* >> >> And I can't

Re: [Tutor] self.name vs. passing a name

2009-07-28 Thread Dave Angel
Che M wrote: This is another very basic structural question, related to one I asked last week, and again is not necessarily germane only to Python. Let's say you have a sequence of two calculations or manipulations you need to do, each one done as a function called by an overall calculate_some

Re: [Tutor] Help...

2009-07-28 Thread Dave Angel
Ryan V wrote: For this source code, i am getting some errors, and not sure how to fix it, as i am returning all the values. it is telling me that there is no value for the variables i am returning. any help is greatly appreciated! Source #main function def main(): print 'The menu is:' pr

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-28 Thread Dave Angel
Dick Moores wrote: I'm not sure how to edit it. What's required for Ulipad is quite different, I believe. This is what I got from Dave Angel: e: cd \Python26\Lib\idlelib\ ..\..\pythonw.exe idle.pyw %* And I can't decipher it. What is the "..\..\"? Just ask.The double-dots are the

Re: [Tutor] self.name vs. passing a name

2009-07-28 Thread Alan Gauld
"Che M" wrote Let's say you have a sequence of two calculations ...each one done as a function called by an overall calculate_something() function. The "answer" to each function is then used in the next function. I can think of two ways to make that answer available ... 1) pass it in, or

Re: [Tutor] Help...

2009-07-28 Thread Alan Gauld
"Ryan V" wrote as i am returning all the values. it is telling me that there is no value for the variables i am returning. any help is greatly appreciated! You are returning the values to variables in the main function. But in Python variables inside functions (aka local variables) are only