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
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
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 will return 1
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
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 gets past
the
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?
listx=[[[] for
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 will
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 augdaw...@gmail.com wrote:
Oh okay, sorry about that.
On Tue, Aug 24, 2010 at 9:53 PM, Nitin Das nitin@gmail.com 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 =
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: )
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
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)
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 augdaw...@gmail.com 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,
On 24 August 2010 17:47, aug dawg augdaw...@gmail.com 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.
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
On Tue, Aug 24, 2010 at 12:44 PM, aug dawg augdaw...@gmail.com 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
Oh yeah. That was just a comment that I forgot to take out.
On Tue, Aug 24, 2010 at 1:01 PM, Walter Prins wpr...@gmail.com wrote:
On 24 August 2010 17:47, aug dawg augdaw...@gmail.com wrote:
if searcher in database:
# Figure this out.
if exit database in command:
print Bye!
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 works
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 -2
You can actually use 'return
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
Roelof Wobben rwob...@hotmail.com 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
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 the end,
Now it says that the variable adder is not defined. Does anyone know about
this?
On Tue, Aug 24, 2010 at 1:40 PM,
christopher.h...@allisontransmission.comwrote:
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
aug dawg augdaw...@gmail.com 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
Karim karim.liat...@free.fr 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
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
aug dawg augdaw...@gmail.com 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 =
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
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,
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
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' extension
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:
###
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
On 25 August 2010 00:04, Joe Veldhuis electrob...@gmail.com 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
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-invent the
Karim karim.liat...@free.fr wrote
import params
dir(params)
['EntryTextMail', 'EntryTextName', '__builtins__', '__doc__',
But the file to import should have '.py' extension (Module.py) (if
there is a way to avoid that I wanted to use a 'hidden' file kind of
.config ,
You can exec a
Joe Veldhuis electrob...@gmail.com wrote
control a piece of hardware using ioctl's on its device node.
I've never tried this from Python but
#include linux/dvb/frontend.h
fd = open(/dev/dvb/adapter1/frontend0, O_RDWR)
Notice the fd - that means file descriptor not file pointer.
So
Got it. Thanks everyone!
On Tue, Aug 24, 2010 at 6:22 PM, Steven D'Aprano st...@pearwood.infowrote:
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 =
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.
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
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
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 *path to ex.py/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
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,
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
44 matches
Mail list logo