In article <[EMAIL PROTECTED]>,
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote:
>
>>> try:
>>>i = a.find("3")
>>>print "It's here: ", i
>>> except NotFound:
>>>print "No 3's here"
>>
>> Nuts. I guess you're right. It wouldn't be pr
Paul Rubin wrote:
> "Kay Schluehr" <[EMAIL PROTECTED]> writes:
> > Hmm. A statement has side-effects but it returns no value. And yes, you
> > can create a name within an expression producing a value in Python,
> > using a list/generator comprehension. The solution to Bob's problem
> > would look
"Kay Schluehr" <[EMAIL PROTECTED]> writes:
> Hmm. A statement has side-effects but it returns no value. And yes, you
> can create a name within an expression producing a value in Python,
> using a list/generator comprehension. The solution to Bob's problem
> would look like this:
>
> if (I for I i
Roy Smith wrote:
> Bob Greschke <[EMAIL PROTECTED]> wrote:
> >I miss being able to do something like this in Python
> >
> >1f (I = a.find("3")) != -1:
> >print "It's here: ", I
> >else:
> >print "No 3's here"
> >
> >where I gets assigned the index returned by find() AND the if statement ge
Roy Smith wrote:
> In article <[EMAIL PROTECTED]>,
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>> Side-effects aren't always bad (import, for example, does all its work by
>> side-effect). But they are generally frowned upon, and in functional
>> languages they are verboten.
>
> How do you d
On Fri, 24 Feb 2006 08:03:49 -0500, Roy Smith wrote:
> In article <[EMAIL PROTECTED]>,
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>> Side-effects aren't always bad (import, for example, does all its work by
>> side-effect). But they are generally frowned upon, and in functional
>> languages
Roy Smith:
>How do you do any I/O in a functional language if side effects are
>verboten?
The user is a function. Output is its parameter, input its return value.
The user is not allowed to maintain state ;-)
>For that matter, how does a functional program ever stop running?
By returning to t
In article <[EMAIL PROTECTED]>,
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> Side-effects aren't always bad (import, for example, does all its work by
> side-effect). But they are generally frowned upon, and in functional
> languages they are verboten.
How do you do any I/O in a functional langu
On Fri, 24 Feb 2006 06:45:41 -0500, Kent Johnson wrote:
> Steven D'Aprano wrote:
>> Now that's a Python wart: using >>> for the prompt for interactive
>> sessions. It makes it ambiguous when posting code in email or newsgroups,
>> especially once the code gets quoted a few times.
>
> So change it
Op 2006-02-23, Roy Smith schreef <[EMAIL PROTECTED]>:
> Bob Greschke <[EMAIL PROTECTED]> wrote:
>>I miss being able to do something like this in Python
>>
>>1f (I = a.find("3")) != -1:
>>print "It's here: ", I
>>else:
>>print "No 3's here"
>>
>>where I gets assigned the index returned by fi
Steven D'Aprano wrote:
> Now that's a Python wart: using >>> for the prompt for interactive
> sessions. It makes it ambiguous when posting code in email or newsgroups,
> especially once the code gets quoted a few times.
So change it. My pythonstartup.py contains:
import sys
sys.ps1 = ' >>> '
sys.
On Fri, 24 Feb 2006 02:02:02 -0800, bonono wrote:
>> "test".index("a")
>> > Traceback (most recent call last):
>> > File "", line 1, in -toplevel-
>> > "test".index("a")
>> > ValueError: substring not found
>> "test".find("a")
>> > -1
>>
>>
>> Did you have a point?
>>
> It was abou
Steven D'Aprano wrote:
> On Thu, 23 Feb 2006 16:49:09 -0800, bonono wrote:
>
> >
> > Steven D'Aprano wrote:
> >> On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote:
> >>
> >> >> try:
> >> >>i = a.find("3")
> >> >>print "It's here: ", i
> >> >> except NotFound:
> >> >>print "No 3's
On Thu, 23 Feb 2006 16:49:09 -0800, bonono wrote:
>
> Steven D'Aprano wrote:
>> On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote:
>>
>> >> try:
>> >>i = a.find("3")
>> >>print "It's here: ", i
>> >> except NotFound:
>> >>print "No 3's here"
>> >
>> > Nuts. I guess you're right.
On Thu, 23 Feb 2006 20:41:52 -0600, Terry Hancock wrote:
> On Fri, 24 Feb 2006 09:14:53 +1100
> "Steven D'Aprano" <[EMAIL PROTECTED]> wrote:
>> There are *reasons* why Python discourages functions with
>> side-effects. Side-effects make your code hard to test and
>> harder to debug.
>
> You of co
On Fri, 24 Feb 2006 09:14:53 +1100
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote:
> There are *reasons* why Python discourages functions with
> side-effects. Side-effects make your code hard to test and
> harder to debug.
You of course meant "expressions with side-effects". Python
is pretty good at
"Bob Greschke" <[EMAIL PROTECTED]> writes:
> I miss being able to do something like this in Python
>
> 1f (I = a.find("3")) != -1:
> print "It's here: ", I
> else:
> print "No 3's here"
>
> where I gets assigned the index returned by find() AND the if statement gets
> to do its job in th
Steven D'Aprano wrote:
> On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote:
>
> >> try:
> >>i = a.find("3")
> >>print "It's here: ", i
> >> except NotFound:
> >>print "No 3's here"
> >
> > Nuts. I guess you're right. It wouldn't be proper. Things are added or
> > proposed every
On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote:
>> try:
>>i = a.find("3")
>>print "It's here: ", i
>> except NotFound:
>>print "No 3's here"
>
> Nuts. I guess you're right. It wouldn't be proper. Things are added or
> proposed every day for Python that I can't even pronoun
On Thu, 23 Feb 2006 12:04:38 -0700 in comp.lang.python, "Bob Greschke"
<[EMAIL PROTECTED]> wrote:
>
>"Roy Smith" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
[...]
>> try:
>>i = a.find("3")
>>print "It's here: ", i
>> except NotFound:
>>print "No 3's here"
>
>Nuts. I
But maybe we're talking about string methods so to get an exception
we'd want to use "index" instead of "find".
Giles
--
http://mail.python.org/mailman/listinfo/python-list
"Roy Smith" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Bob Greschke <[EMAIL PROTECTED]> wrote:
>>I miss being able to do something like this in Python
>>
>>1f (I = a.find("3")) != -1:
>>print "It's here: ", I
>>else:
>>print "No 3's here"
>>
>>where I gets assigned the
Bob Greschke <[EMAIL PROTECTED]> wrote:
>I miss being able to do something like this in Python
>
>1f (I = a.find("3")) != -1:
>print "It's here: ", I
>else:
>print "No 3's here"
>
>where I gets assigned the index returned by find() AND the if statement gets
>to do its job in the same line.
I miss being able to do something like this in Python
1f (I = a.find("3")) != -1:
print "It's here: ", I
else:
print "No 3's here"
where I gets assigned the index returned by find() AND the if statement gets
to do its job in the same line. Then you don't have to have another like
that
24 matches
Mail list logo