Re: [Tutor] continuous running of a method

2010-08-24 Thread Greg Bair
On 08/25/2010 01:25 AM, Nitin Das wrote: The problem with this while loop is if your random value doesn't lie between the mentioned range then ur 100% cpu would be utilized. The one thing u can do is to sleep for some time lets say 0.5 sec after every while loop iteration , in this case ur cpu

Re: [Tutor] continuous running of a method

2010-08-24 Thread Nitin Das
The problem with this while loop is if your random value doesn't lie between the mentioned range then ur 100% cpu would be utilized. The one thing u can do is to sleep for some time lets say 0.5 sec after every while loop iteration , in this case ur cpu utilization will go down. --nitin On Mon, A

Re: [Tutor] python: can't open file 'ex1.py' : [Errno 2] No such file or directory

2010-08-24 Thread Karim
If it is in the sys.path you should import it: *import ex1*. Then execute something like *ex1.main()* if you did a main(). Other python */ex.py* should world. Regards Karim On 08/25/2010 05:22 AM, Carter Danforth wrote: Hi everyone, This is my first email to group - I'm just starting to pick

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Karim
Thanks Alan for you advice! Our environment is secured because the program is only for internal use. We are supporting electronic designers. Nobody at work will write delete codes inside (I hope). But, sure, I will check configParser module. I wanted a straight forward config file because for TC

[Tutor] python: can't open file 'ex1.py' : [Errno 2] No such file or directory

2010-08-24 Thread Carter Danforth
Hi everyone, This is my first email to group - I'm just starting to pick up Python and I'm going through the exercises in Zed Shaw's "Learn Python the Hard Way" ebook. Anyhow, I can't seem to be executing any files in terminal for some reason, in this case the file ex1.py: C:\Users\Carter Danfort

Re: [Tutor] Controlling a device with ioctl's?

2010-08-24 Thread Joe Veldhuis
A bit more work than I expected, but at least I have an idea what to do now. I'm working on writing a DVB binding based on the V4L2 binding you mentioned, currently about 30% complete - I can query the card's status! :) Thanks for the help so far, might post again if I run into more trouble. -J

Re: [Tutor] Adding all numbers in a file or list

2010-08-24 Thread aug dawg
Got it. Thanks everyone! On Tue, Aug 24, 2010 at 6:22 PM, Steven D'Aprano wrote: > On Wed, 25 Aug 2010 02:23:10 am Nitin Das wrote: > > alternatively you can use the lambda , reduce function for summing up > > all the numbers in a list for e.g:- > > > > lis = [1,2,3,4,5] > > p = reduce(lambda x,

Re: [Tutor] Controlling a device with ioctl's?

2010-08-24 Thread Alan Gauld
"Joe Veldhuis" wrote control a piece of hardware using ioctl's on its device node. I've never tried this from Python but #include fd = open("/dev/dvb/adapter1/frontend0", O_RDWR) Notice the fd - that means file descriptor not file pointer. So ioctl takes a file descriptor in C and

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Alan Gauld
"Karim" wrote >>> import params >>> dir(params) ['EntryTextMail', 'EntryTextName', '__builtins__', '__doc__', But the file to import should have '.py' extension (.py) (if there is a way to avoid that I wanted to use a 'hidden' file kind of ".config" , You can exec a file and you can read

Re: [Tutor] Adding all numbers in a file or list

2010-08-24 Thread Steven D'Aprano
On Wed, 25 Aug 2010 02:23:10 am Nitin Das wrote: > alternatively you can use the lambda , reduce function for summing up > all the numbers in a list for e.g:- > > lis = [1,2,3,4,5] > p = reduce(lambda x,y : x+y, lis) > > p will have the value = 15. Sure, you *can* do this, by why would you re-inve

Re: [Tutor] Controlling a device with ioctl's?

2010-08-24 Thread Sander Sweers
On 25 August 2010 00:04, Joe Veldhuis wrote: > Hello to all. I'm working on writing a tool that will control a piece of > hardware using ioctl's on its device node. Specifically, I'm trying to > configure and tune a DVB-S receiver on Linux. > > Just for starters, I want to try opening the fronte

Re: [Tutor] FW: find() problem

2010-08-24 Thread Steven D'Aprano
On Wed, 25 Aug 2010 01:44:22 am Evert Rol wrote: > Why are you returning -1 here? > -1 is a valid list index. So? str.find() does the same thing. It guarantees to only return 0 or positive indexes if it finds the substring, and only returns -1 to indicate not found. -- Steven D'Aprano __

[Tutor] Controlling a device with ioctl's?

2010-08-24 Thread Joe Veldhuis
Hello to all. I'm working on writing a tool that will control a piece of hardware using ioctl's on its device node. Specifically, I'm trying to configure and tune a DVB-S receiver on Linux. Just for starters, I want to try opening the frontend and setting the LNB voltage. An example in C: ###

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Karim
after tests I get the following: >>> import params >>> dir(params) ['EntryTextMail', 'EntryTextName', '__builtins__', '__doc__', '__file__', '__name__', '__package__'] >>> params.EntryTextName 'myName' >>> params.EntryTextMail 'mym...@gmail.com' But the file to import should have '.py' extens

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Karim
Correction indents disappear (sic !) and lines are inverted (my mistake too) :o): def sourceConfigGui(mySourceFile,path_to_mysourcefile): import sys sys.path.append(path_to_mysourcefile) import mySourceFile Karim On 08/24/2010 09:28 PM, Karim wrote: Ok I find a solut

Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
Oh, stupid me forgot the error message. Well, for some odd reason it works now, but there are still some issues. When I tried it just a few minutes ago, it worked fine, it seemed to me. If anyone have any tips, please let me know. Thanks everyone for the tips. On Tue, Aug 24, 2010 at 2:24 PM, wrot

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Karim
Ok I find a solution (need to test it) that seems correct: Suppose we have a python file mySourceFile with this setting: EntryTextName = "myName" EntryTextMail = "mym...@gmail.com" In the calling script or main python file we could define a function sourceConfigGui as follow: def sourceCo

Re: [Tutor] Databases in Python

2010-08-24 Thread christopher . henk
aug dawg wrote on 08/24/2010 01:55:14 PM: > Now it says that the variable adder is not defined. Does anyone know about this? > It is best if you send the full error message, it helps pinpoint the problem. my copy of your code was: database = [] datafile = open('/home/~/the-db/data') for line i

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Karim
Thank you Alan for your answer. In fact I want to do it in python format. I want to source it (I will declare it each input as a python variable). I don't want to parse it. I just want to source it like an external file in bash for example. Is there a way to not use string evaluation. But really

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Alan Gauld
"Karim" wrote I am figuring this out. I want a sort of file who store values entered previously in a gui. Thats easy enough - have you succeeded with this bit - check the file with a text editor... Th e next time the user launch his gui in the same directory the gui load the previous value

Re: [Tutor] Databases in Python

2010-08-24 Thread Alan Gauld
"aug dawg" wrote select-db = raw_input("Which database to add to? >> ") SyntaxError: can't assign to operator I think it might be the >> at the end, but when I try it in the Python interpreter, it works fine. You have a minus sign in your variable name - at least thats how Python sees

Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
Now it says that the variable adder is not defined. Does anyone know about this? On Tue, Aug 24, 2010 at 1:40 PM, wrote: > > aug dawg wrote on 08/24/2010 01:13:01 PM: > > > > It's not catching that, but I haven't gotten there with the bugs yet. One > more thing I can't figure out. > > > > > line

Re: [Tutor] Databases in Python

2010-08-24 Thread christopher . henk
aug dawg wrote on 08/24/2010 01:13:01 PM: > It's not catching that, but I haven't gotten there with the bugs yet. One more thing I can't figure out. > > line 11 > select-db = raw_input("Which database to add to? >> ") > SyntaxError: can't assign to operator > > I think it might be the >> at

Re: [Tutor] find() problem

2010-08-24 Thread Alan Gauld
"Roelof Wobben" wrote But it looks like it's in a indefinitive loop. What went wrong here ? When debugging this kind of thing insert a raw_input() statement in the loop(to force a pause) and just before it print out the key variables. That way you can see what is happening and what is not

[Tutor] Retriving previous user inputs in a gui

2010-08-24 Thread Karim
Hello All, I am figuring this out. I want a sort of file who store values entered previously in a gui. Th e next time the user launch his gui in the same directory the gui load the previous value from this file. Is there any modules in Tkinter for that? I suppose the file could be in xml form

Re: [Tutor] FW: find() problem

2010-08-24 Thread Evert Rol
>>> I found it. >> >> Good. >> Few generic comments nonetheless, just for the fun of it ;-). >> >>> This one does the trick : >>> >>> def find(strng, ch, start, step=1): >>> index=start >>> while 0 <= index < len(strng): >>> if strng[index] == ch: >>> return index >>> index += step >>> return -

Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
It's not catching that, but I haven't gotten there with the bugs yet. One more thing I can't figure out. line 11 select-db = raw_input("Which database to add to? >> ") SyntaxError: can't assign to operator I think it might be the >> at the end, but when I try it in the Python interpreter, it

Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
Oh yeah. That was just a comment that I forgot to take out. On Tue, Aug 24, 2010 at 1:01 PM, Walter Prins wrote: > > > On 24 August 2010 17:47, aug dawg wrote: > >> if searcher in database: >>> # Figure this out. >>> if "exit database" in command: >>> print "Bye!" >>> sys.exit() >>> >> > Th

Re: [Tutor] Databases in Python

2010-08-24 Thread Marc Tompkins
On Tue, Aug 24, 2010 at 12:44 PM, aug dawg wrote: > if searcher in database: >> # Figure this out. >> >> You need some sort of actual Python statement there as a placeholder - even just "print()". -- www.fsrtechnologies.com ___ Tutor maillist - Tut

Re: [Tutor] Databases in Python

2010-08-24 Thread Che M
> The other day, I wrote a little database just to fiddle around, > but when I try to run it it says that it has an unexpected indent. > From what I can tell, it doesn't. Here's the code. I'm using SPE. In the future, you should copy/paste error message you get into your email. This way it ind

Re: [Tutor] Databases in Python

2010-08-24 Thread Walter Prins
On 24 August 2010 17:47, aug dawg wrote: > if searcher in database: >> # Figure this out. >> if "exit database" in command: >> print "Bye!" >> sys.exit() >> > The first thing that caught my eye was the "#figure me out" line -- python is expecting a statement there, a comment doesn't count. You

Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
It says that it's on line 25, on the print("Bye!"). Forgot to say that. On Tue, Aug 24, 2010 at 12:44 PM, aug dawg wrote: > The other day, I wrote a little database just to fiddle around, but when I > try to run it it says that it has an unexpected indent. From what I can > tell, it doesn't. He

[Tutor] Databases in Python

2010-08-24 Thread aug dawg
The other day, I wrote a little database just to fiddle around, but when I try to run it it says that it has an unexpected indent. From what I can tell, it doesn't. Here's the code. I'm using SPE. database = [] datafile = open('/home/~/the-db/data') for line in datafile: database.append(line) whi

Re: [Tutor] FW: find() problem

2010-08-24 Thread Evert Rol
> I found it. Good. Few generic comments nonetheless, just for the fun of it ;-). > This one does the trick : > > def find(strng, ch, start, step=1): > index=start > while 0 <= index < len(strng): > if strng[index] == ch: > return index > index += step >

Re: [Tutor] FW: find() problem

2010-08-24 Thread Roelof Wobben
Hello, I found it. This one does the trick : def find(strng, ch, start, step=1): index=start while 0 <= index < len(strng): if strng[index] == ch: return index index += step return -2 fruit="" letter="" fruit= raw_input("Enter a sort of fruit:

Re: [Tutor] Adding all numbers in a file or list

2010-08-24 Thread Shashwat Anand
On Tue, Aug 24, 2010 at 9:53 PM, Nitin Das wrote: > alternatively you can use the lambda , reduce function for summing up all > the numbers in a list for e.g:- > > lis = [1,2,3,4,5] > > p = reduce(lambda x,y : x+y, lis) > > p will have the value = 15. > Another approach, >>> lis = [1,2,3,4,5] >

Re: [Tutor] Adding all numbers in a file or list

2010-08-24 Thread Nitin Das
alternatively you can use the lambda , reduce function for summing up all the numbers in a list for e.g:- lis = [1,2,3,4,5] p = reduce(lambda x,y : x+y, lis) p will have the value = 15. --nitin On Mon, Aug 23, 2010 at 9:05 PM, aug dawg wrote: > Oh okay, sorry about that. > > Thanks for the

Re: [Tutor] FW: find() problem

2010-08-24 Thread Evert Rol
> > > > > def find(strng, ch, start, step=1): > > > > > index = start > > > > The problem lies here, if you do a print on index, it never gets past > > > > the first index of the number, so > > > > your while loop below goes into an infinite loop. > > > > > > > > For example: > > > > find('starfru

Re: [Tutor] Memory error for list creation

2010-08-24 Thread Wayne Werner
On Tue, Aug 24, 2010 at 9:54 AM, Triantafyllos Gkikopoulos < t.gkikopou...@dundee.ac.uk> wrote: > Hi, > > I am looking for an alternative to: > > > > Please consider the environment. Do you really need to print this email? > > > > >>>

Re: [Tutor] FW: find() problem

2010-08-24 Thread Roelof Wobben
> Subject: Re: [Tutor] FW: find() problem > From: evert@gmail.com > Date: Tue, 24 Aug 2010 17:03:07 +0200 > CC: tutor@python.org > To: rwob...@hotmail.com > > > > > def find(strng, ch, start, step=1): > > > > index = start > > > The problem lies here, if you do a print on index, it never

[Tutor] Memory error for list creation

2010-08-24 Thread Triantafyllos Gkikopoulos
Hi, I am looking for an alternative to: Please consider the environment. Do you really need to print this email? >>> listx=[[[] for k in range(ds)] for j in range(i)] as right now I am getting a Memory error on this, I tried

Re: [Tutor] FW: find() problem

2010-08-24 Thread Evert Rol
> > > def find(strng, ch, start, step=1): > > > index = start > > The problem lies here, if you do a print on index, it never gets past > > the first index of the number, so > > your while loop below goes into an infinite loop. > > > > For example: > > find('starfruit','t',0) <- First time wil

[Tutor] FW: find() problem

2010-08-24 Thread Roelof Wobben
From: rwob...@hotmail.com To: obe...@gmail.com Subject: RE: [Tutor] find() problem Date: Tue, 24 Aug 2010 12:25:24 + > Date: Tue, 24 Aug 2010 08:09:54 -0400 > Subject: Re: [Tutor] find() problem > From: obe...@gmail.com > To: rwob...@hotmail.com > > > I will try again. > > > > def

[Tutor] find() problem

2010-08-24 Thread Roelof Wobben
Hello, I have this exercise : Now rewrite the count_letters function so that instead of traversing the string, it repeatedly calls find (the version from Optional parameters), with the optional third parameter to locate new occurences of the letter being counted. And I have this