On 11/19/2011 06:03 AM, Asokan Pichai wrote:
Another way to do that is to avoid any intermediate variables altogether
That may be easier to understand YMMV
def counter(mylist, val):
if len(mylist == 0):
return 0
if mylist[0] == val:
return 1 + counter(mylist[1:]
Wayne Werner wrote:
The chances of hitting the maximum recursion depth is pretty slim, unless
your user manages to type in a wrong number about 1000 times ;)
I've had to provide desktop support to people who have done that.
Only-slightly-exaggerating-ly 'yrs,
--
Steven
___
Another way to do that is to avoid any intermediate variables altogether
That may be easier to understand YMMV
def counter(mylist, val):
if len(mylist == 0):
return 0
if mylist[0] == val:
return 1 + counter(mylist[1:], val)
else:
return counter(myl
Thank you I think I understand now, thank you very much.
-Original Message-
From: tutor-bounces+evosweet=hotmail@python.org
[mailto:tutor-bounces+evosweet=hotmail@python.org] On Behalf Of Steven
D'Aprano
Sent: 17 November 2011 19:52
To: tutor@python.org
Subject: Re: [Tutor] python
I installed the telnet client but still the same error.
Traceback (most recent call last):
File "C:\Users\Rayon\Documents\projects1\super_hia\main.py", line 6, in
child = winspawn('telnet 192.168.0.55:210')
File
"C:\Python26\lib\site-packages\winpexpect-1.5-py2.6.egg\winpexpect.py", line
On 11/17/2011 3:26 PM ADRIAN KELLY said...
i know i'm stupid but i have tried everything to get one line of text
working, i have written out pseudo and read every website.
now i am getting this error
Traceback (most recent call last):
File "F:\VTOS ATHLONE\PYTHON_VTOS\foreign exc
On Nov 18, 2011, at 13:15, ALAN GAULD wrote:
>
> > > for var in [value,value_1]:
> > >var = "green"
> >
> > Um, that won't work. You typed that example too quickly.
>
> Oops! Yes. You'd need to enumerate and access the variables
> via an index. yuk. Don't do it folks! :-)
>
> Excuse: It w
>No *need* but, often convenient, regardless of whether the data was
>written by a C struct or not.(*) It is a way to interpret binary data in
>terms of fundamental data types such as ints, floats, strings etc.
>Trying to convert raw bytes representing floats into a floating point
>number witho
On 11/18/2011 06:04 PM, Dave Angel wrote:
On 11/18/2011 08:16 AM, Kĩnũthia Mũchane wrote:
Well, it doesn't count the number of occurrences correctly if the list
is empty. It should get zero, and it gets -1. But for any non-empty
list, nothing ever looks at the -1 value, so it doesn't matte
On Fri, Nov 18, 2011 at 11:12 AM, Joe Batt wrote:
>
> pickledfile=open('///Users/joebatt/Desktop/python/pickledpuzzle5.txt','w')
> pickle.dump(filecontents,pickledfile)
> pickledfile.close()
>
>
A pickle is a binary object, so you'll need to open your picklefile in
binary mode:
pickledfi
> > for var in [value,value_1]:
> >var = "green"
>
> Um, that won't work. You typed that example too quickly.
Oops! Yes. You'd need to enumerate and access the variables
via an index. yuk. Don't do it folks! :-)
Excuse: It was early morning and I hadn't had any coffee...
Alan G.
On 11/17/2011 8:45 PM, Nidian Job-Smith wrote:
Hi all,
In my programme I am encoding what the user has in-putted.
What the user inputs will in a string, which might a mixture of letters and
numbers.
However I only want the letters to be encoded.
On Fri, Nov 18, 2011 at 11:17 AM, Max gmail wrote:
> Thank you. This will work perfectly.
>
> On Nov 18, 2011, at 11:58 AM, Prasad, Ramit wrote:
>
> >
> > Any file will eventually be able to be reverse engineered, but it
> matters how much effort you care to obfuscate it. The way you can do it
On 11/18/2011 11:12 AM, Joe Batt wrote:
Hi All,Sorry to trouble you all again with more nooby problems! Only been
programming a week so still all a haze especially since self taught…..
I am opening a url and saving it to a file on my computer, then I am trying to
pickle it. I have written the u
Thank you. This will work perfectly.
On Nov 18, 2011, at 11:58 AM, Prasad, Ramit wrote:
> Hi. I've been using a lot of text files recently, and I'm starting to worry
> about a user hacking some element by editing the text files. I know that I
> can pickle my data instead, creating less easil
Hi. I've been using a lot of text files recently, and I'm starting to worry
about a user hacking some element by editing the text files. I know that I can
pickle my data instead, creating less easily editable (try saying that five
times fast) .dat files, but I'd rather store individual variabl
Hi. I've been using a lot of text files recently, and I'm starting to
worry about a user hacking some element by editing the text files. I know
that I can pickle my data instead, creating less easily editable (try
saying that five times fast) .dat files, but I'd rather store individual
variables
Hi All,Sorry to trouble you all again with more nooby problems! Only been
programming a week so still all a haze especially since self taught…..
I am opening a url and saving it to a file on my computer, then I am trying to
pickle it. I have written the url file to a file on my computer then ope
On Fri, Nov 18, 2011 at 9:26 AM, Prasad, Ramit wrote:
> Forwarding to the list since I wasn't the only person who helped ;)
>
> From: ADRIAN KELLY [mailto:kellyadr...@hotmail.com]
> Sent: Thursday, November 17, 2011 6:08 PM
> To: Prasad, Ramit
> Subject: RE: [Tutor] urgent help!! THANKS EVERYONE!
Forwarding to the list since I wasn't the only person who helped ;)
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423
--
From: ADRIAN KELLY [mailto:kellyadr...@hotmail.com]
Sent: Thursday, November 17,
On 11/18/2011 08:16 AM, Kĩnũthia Mũchane wrote:
Hi,
I am trying to do something which is really stupid :-)
I would like to count the number of occurrences of a certain character
in a list.
This is more of an exercise in recursion rather than the underlying
problem.
I could have used a *for* l
On 11/18/2011 04:01 AM, Alan Gauld wrote:
On 18/11/11 08:16, Mic wrote:
What if I don’t write the same line of code more than once, but I write
similiar lines more than once. Is that okay? Ler
For example:
value="green”
value_1=”green”
If you had a lot of these you could shorten it with a loo
Well, I am assuming that by this you mean converting user input into a
string, and then extracting the numerals (0-9) from it. Next time, please
tell us your version of Python. I'll do my best to help with this. You
might try the following:
the_input = input("Insert string here: ") # change to
On 2011/11/18 03:16 PM, Kĩnũthia Mũchane wrote:
Hi,
I am trying to do something which is really stupid :-)
I would like to count the number of occurrences of a certain character
in a list.
This is more of an exercise in recursion rather than the underlying
problem.
I could have used a *for* l
Hi,
I am trying to do something which is really stupid :-)
I would like to count the number of occurrences of a certain character
in a list.
This is more of an exercise in recursion rather than the underlying problem.
I could have used a *for* loop or simply the list *count* method.
Here is the
On 18/11/11 08:16, Mic wrote:
What if I don’t write the same line of code more than once, but I write
similiar lines more than once. Is that okay? Ler
For example:
value="green”
value_1=”green”
If you had a lot of these you could shorten it with a loop (BTW the
English term in programming ter
From: Wayne Werner
Sent: Thursday, November 17, 2011 8:30 PM
To: Mic
Cc: tutor@python.org
Subject: Re: [Tutor] Clock in tkinter?
Say that I have a class and I want to make 100 objects.
Then it could look like this:
class Chairs(object):
#Create the objects
chair1=Chair
27 matches
Mail list logo