>
>
> It didn't have to do with strings. It was a basic example of using
> append() which is to start with an empty list and and then build it
> incrementally:
>
> >>> l = [ ]
> >>> l.append(1)
> # append more
>
>
Hi Amit,
Ok, good. This context helps!
If you do know all the values of the list
On Sun, Dec 1, 2013 at 7:27 PM, spir wrote:
> On 12/01/2013 05:32 AM, Amit Saha wrote:
>>
>> Hello,
>>
>> I was told by someone (as a comment) that a code snippet such as this
>> "would make Pythonistas talk my ear off about how evil the append()"
>> function is:
>>
> mylist = []
> mylist.
On Mon, Dec 2, 2013 at 4:49 PM, eryksun wrote:
> On Mon, Dec 2, 2013 at 1:28 AM, Amit Saha wrote:
>> Indeed, that's a good point. Surprisingly, C does it just fine:
>>
>> # include
>>
>> int main(int argc, char **argv)
>> {
>> float x = 0.0;
>> while(x<1)
>> {
>> x += 0.1;
>>
On Tue, Dec 3, 2013 at 6:32 AM, Danny Yoo wrote:
>>
>> I was told by someone (as a comment) that a code snippet such as this
>> "would make Pythonistas talk my ear off about how evil the append()"
>> function is:
>>
>
>
> I think this thread demonstrates: we don't need an excuse to talk your ears
On Sat, Dec 7, 2013 at 9:01 PM, Steven D'Aprano wrote:
> For the record, slice objects existed in Python 1.5, so they have been
> around and used for extended (three argument) slicing for a long time.
> It's only the two argument slicing that called __getslice__.
According to the NEWS for 1.4b2 (
On Fri, Dec 06, 2013 at 11:34:13PM +, Lelani Slabber wrote:
> I have to add code so the user has a limited number of tries - in this
> case I have set it to less than 5 in the while loop and I want the
> program to stop if the tries are equal to 5. I get an invalid syntax
> error. Please
On Sat, Dec 07, 2013 at 06:43:12AM -0500, eryksun wrote:
> On Sat, Dec 7, 2013 at 5:42 AM, Steven D'Aprano wrote:
> > Slices go back to the earliest days of Python, although slice objects
> > may be newer. In the early days, instead of having a single method
> > __getitem__ which sometimes got a
On Sat, Dec 7, 2013 at 9:16 AM, Mark Lawrence wrote:
> On 06/12/2013 23:34, Lelani Slabber wrote:
>
>> Hi,
>> I am learning Python witht Python for beginners book by Michael Lawson
>> and have trouble with one task in chapter 3 - challenge 3.
>> I have to add code so the user has a limited number
On 06/12/2013 23:34, Lelani Slabber wrote:
Hi,
I am learning Python witht Python for beginners book by Michael Lawson
and have trouble with one task in chapter 3 - challenge 3.
I have to add code so the user has a limited number of tries - in this
case I have set it to less than 5 in the while lo
Hi,
I am learning Python witht Python for beginners book by Michael Lawson and have
trouble with one task in chapter 3 - challenge 3.
I have to add code so the user has a limited number of tries - in this case I
have set it to less than 5 in the while loop and I want the program to stop if
t
Thanks for your answers!
Hmm!
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
On Sat, Dec 7, 2013 at 6:04 AM, spir wrote:
> I knew about the common sense of slice in Python as a sysnonym of
> subsequence, meaning a partial copy; so I thought this different sense I
> just discovered, about slice _objects_ properly in Python, was about slice
> as commonly understood in other
On Sat, Dec 7, 2013 at 5:42 AM, Steven D'Aprano wrote:
>
> Python calls the special dunder method __getindex__ with a as argument.
> If you use a colon inside the square brackets, such as these examples:
__getitem__, but there's an __index __ method that can be useful in
__getitem__. Call it as o
On 12/07/2013 11:42 AM, Steven D'Aprano wrote:
>Are slices and subsequences transparently usable one for the other?
Of course not. They are completely different things. A slice has to be
applied to a sequence before you get a subsequence:
Right, thank you, Staven, that's the bit I missed.
[I k
On 12/07/2013 02:49 AM, Joel Goldstick wrote:
>>Hum, we are not talking of the same topic, apparently. I mean this, from
>>the library ref, builtin funcs:
>>http://docs.python.org/3.3/library/functions.html#slice:
>>
>> slice(start, stop[, step])
>>
>
I'm totally confused by this. What is th
On Fri, Dec 06, 2013 at 04:39:28PM +0100, spir wrote:
> Hello,
>
> How does slicing in Python really work? Apparently, there are slice objects
> (start, past-end, step), generated using either the 'slice' builtin func or
> the extended slicing syntax [i:k:s]. Is this correct? [1]
Correct. When
On 12/07/2013 02:45 AM, Mark Lawrence wrote:
The good news is there is a memoryview in Python, see
http://docs.python.org/3/library/functions.html#func-memoryview. The bad news
is it doesn't work on strings. See here for the slice object
http://docs.python.org/3/library/functions.html#slice.
T
17 matches
Mail list logo