On Tuesday, December 5, 2017 at 12:40:01 AM UTC+5:30, Jason Maldonis wrote:
> I was extending a `list` and am wondering why slicing lists will never
> raise an IndexError, even if the `slice.stop` value if greater than the
> list length.
>
> Quick example:
>
> my_list = [1, 2, 3]
> my_list[:100]
Ned Batchelder wrote:
[...]
> The point of the example was to demonstrate what happens
> when slicing beyond the bounds of the list. It's beyond
> the scope of the thread to debate whether you might want to
> perform an action in that case.
But, nevertheless, the else-clause is there! And th
On 12/4/17 9:31 PM, Rick Johnson wrote:
On Monday, December 4, 2017 at 7:47:20 PM UTC-6, Ned Batchelder wrote:
[...]
Here are details filled in:
$ python3.6
Python 3.6.3 (default, Oct 4 2017, 06:03:25)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
On Tue, Dec 5, 2017 at 1:31 PM, Rick Johnson
wrote:
> On Monday, December 4, 2017 at 7:47:20 PM UTC-6, Ned Batchelder wrote:
>
> [...]
>
>> Here are details filled in:
>>
>> $ python3.6
>> Python 3.6.3 (default, Oct 4 2017, 06:03:25)
>> [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-90
On Monday, December 4, 2017 at 7:47:20 PM UTC-6, Ned Batchelder wrote:
[...]
> Here are details filled in:
>
> $ python3.6
> Python 3.6.3 (default, Oct 4 2017, 06:03:25)
> [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
> Type "help", "copyright", "credits
On 2017-12-05 01:37, Jason Maldonis wrote:
[snip]
So I guess the conclusion (as far as I can tell) is that: `my_string[:n]`
is more convenient than `my_string[:min(n, len(my_string))]`, and that
sounds okay enough to me.
If I'm being completely honest I kinda like the logical explicitness of t
On 12/4/17 8:03 PM, Rick Johnson wrote:
On Monday, December 4, 2017 at 6:13:19 PM UTC-6, Chris Angelico wrote:
[...]
Ahhh, I see how it is. You didn't run the code, ergo you
don't understand it. Makes perfect sense. :)
Being that Terry didn't offer any declarations or defintions
for his
I'll try to summarize what I've learned with a few responses in hodge-podge
order and to no one in particular:
>That's a feature dude, not a bug.
Absolutely. I _do not_ think that how slicing works in python should be
changed, but I _do_ want to understand its design decisions because it will
mak
On Monday, December 4, 2017 at 6:13:19 PM UTC-6, Chris Angelico wrote:
[...]
> Ahhh, I see how it is. You didn't run the code, ergo you
> don't understand it. Makes perfect sense. :)
Being that Terry didn't offer any declarations or defintions
for his variables or functions, i assumed,
On Mon, Dec 4, 2017 at 7:36 PM, Thomas Jollans wrote:
> On 05/12/17 01:21, Larry Martell wrote:
>> On Mon, Dec 4, 2017 at 7:15 PM, Chris Angelico wrote:
>>> On Tue, Dec 5, 2017 at 10:46 AM, Larry Martell
>>> wrote:
Trying to zip a large file is failing with OverflowError: 'size does
n
On 05/12/17 01:21, Larry Martell wrote:
> On Mon, Dec 4, 2017 at 7:15 PM, Chris Angelico wrote:
>> On Tue, Dec 5, 2017 at 10:46 AM, Larry Martell
>> wrote:
>>> Trying to zip a large file is failing with OverflowError: 'size does
>>> not fit in an int'. Googling I found this:
>>>
>>> https://bugs
On 05/12/17 01:15, Chris Angelico wrote:
> On Tue, Dec 5, 2017 at 10:46 AM, Larry Martell
> wrote:
>> Trying to zip a large file is failing with OverflowError: 'size does
>> not fit in an int'. Googling I found this:
>>
>> https://bugs.python.org/issue23306
>>
>> and this:
>>
>> https://hg.python
On Mon, Dec 4, 2017 at 7:15 PM, Chris Angelico wrote:
> On Tue, Dec 5, 2017 at 10:46 AM, Larry Martell
> wrote:
>> Trying to zip a large file is failing with OverflowError: 'size does
>> not fit in an int'. Googling I found this:
>>
>> https://bugs.python.org/issue23306
>>
>> and this:
>>
>> htt
On 05/12/17 01:03, Michael Torrie wrote:
> On 12/04/2017 04:49 AM, Thomas Jollans wrote:
>> On 2017-12-04 10:48, dhananjaysingh091...@gmail.com wrote:
>>> Respected Sir/Mam,
>>> I am Dhananjay Singh,Student of IIIT Manipur. Sir/Mam when i am
>>> double click in python program (Dhananjay.py
On Tue, Dec 5, 2017 at 10:46 AM, Larry Martell wrote:
> Trying to zip a large file is failing with OverflowError: 'size does
> not fit in an int'. Googling I found this:
>
> https://bugs.python.org/issue23306
>
> and this:
>
> https://hg.python.org/cpython/rev/2192edcfea02
>
> which seems to make
On Tue, Dec 5, 2017 at 10:50 AM, Rick Johnson
wrote:
> Chris Angelico wrote:
>> wrote:
>> > Terry Reedy wrote:
>> >
>> > [...]
>> >
>> >> try:
>> >> item = seq[n]
>> >> except IndexError
>> >> do_without_item()
>> >> else:
>> >> process(item)
>> >>
>> >> item = seq[n:n+1]
>> >> if
On 12/04/2017 04:49 AM, Thomas Jollans wrote:
> On 2017-12-04 10:48, dhananjaysingh091...@gmail.com wrote:
>> Respected Sir/Mam,
>> I am Dhananjay Singh,Student of IIIT Manipur. Sir/Mam when i am
>> double click in python program (Dhananjay.py),it is opening in Text Editor
>> by Default i
Chris Angelico wrote:
> wrote:
> > Terry Reedy wrote:
> >
> > [...]
> >
> >> try:
> >> item = seq[n]
> >> except IndexError
> >> do_without_item()
> >> else:
> >> process(item)
> >>
> >> item = seq[n:n+1]
> >> if item:
> >> process(item)
> >> else:
> >> do_without_item()
>
Trying to zip a large file is failing with OverflowError: 'size does
not fit in an int'. Googling I found this:
https://bugs.python.org/issue23306
and this:
https://hg.python.org/cpython/rev/2192edcfea02
which seems to make me think this was fixed this was fixed on Jul 23 2016.
I am running Ce
On 04Dec2017 14:13, Jason Maldonis wrote:
And I'll be honest -- I like the implementation of the LazyList I wrote
above. I think it's pretty logical, because it allows you to think about
the lazy list like this: "Treat the list like a norma list. If you run out
of bounds, get more data, then tr
Against my better judgement, I'm going to ask...
On Tue, Dec 5, 2017 at 9:22 AM, Rick Johnson
wrote:
> Terry Reedy wrote:
>
> [...]
>
>> try:
>> item = seq[n]
>> except IndexError
>> do_without_item()
>> else:
>> process(item)
>>
>> item = seq[n:n+1]
>> if item:
>> process(ite
Terry Reedy wrote:
[...]
> try:
> item = seq[n]
> except IndexError
> do_without_item()
> else:
> process(item)
>
> item = seq[n:n+1]
> if item:
> process(item)
> else:
> do_without_item()
>
> Many prefer the second.
And they'll prefer it even more when they real
On 12/4/2017 1:54 PM, Jason Maldonis wrote:
I was extending a `list` and am wondering why slicing lists will never
raise an IndexError, even if the `slice.stop` value if greater than the
list length.
Is there any background on why that doesn't raise an IndexError?
Slicing is perhaps most com
On 2017-12-04 21:22, Jason Maldonis wrote:
>> This is explained in the Python tutorial for strings
>> https://docs.python.org/3/tutorial/introduction.html#strings, as a list
>> is a sequence just like a string it will act in exactly the same way.
>>
>
> The only relevant bit I found in that link
On Monday, December 4, 2017 at 1:10:01 PM UTC-6, Jason Maldonis wrote:
> I was extending a `list` and am wondering why slicing lists will never
> raise an IndexError, even if the `slice.stop` value if greater than the
> list length.
>
> Quick example:
>
> my_list = [1, 2, 3]
> my_list[:100] # does
On 4 December 2017 at 20:13, Jason Maldonis wrote:
> And I'll be honest -- I like the implementation of the LazyList I wrote
> above. I think it's pretty logical, because it allows you to think about
> the lazy list like this: "Treat the list like a norma list. If you run out
> of bounds, get mor
>
> >> This is explained in the Python tutorial for strings
> >> https://docs.python.org/3/tutorial/introduction.html#strings, as a list
> >> is a sequence just like a string it will act in exactly the same way.
> >>
> >
> > The only relevant bit I found in that link is: "However, out of range
> >
On Tue, Dec 5, 2017 at 8:03 AM, Jason Maldonis wrote:
>>
>> This is explained in the Python tutorial for strings
>> https://docs.python.org/3/tutorial/introduction.html#strings, as a list
>> is a sequence just like a string it will act in exactly the same way.
>>
>
> The only relevant bit I found
>
> This is explained in the Python tutorial for strings
> https://docs.python.org/3/tutorial/introduction.html#strings, as a list
> is a sequence just like a string it will act in exactly the same way.
>
The only relevant bit I found in that link is: "However, out of range
slice indexes are hand
On Monday, December 4, 2017 at 7:10:01 PM UTC, Jason Maldonis wrote:
> I was extending a `list` and am wondering why slicing lists will never
> raise an IndexError, even if the `slice.stop` value if greater than the
> list length.
>
> Quick example:
>
> my_list = [1, 2, 3]
> my_list[:100] # does
Same with me, except that I tried to install Python 3.6.3. Unchecking "Install
launcher for all users" helped, however.
--
https://mail.python.org/mailman/listinfo/python-list
>Why would this simplify your code? What are you doing that would benefit
>from an IndexError here?
Without simplifying too much, I'm writing a wrapper around a REST API. I
want lazy-loading functionality for lists-of-things, so I am creating a
LazyList class.
This LazyList class will load items
>
> Have you ever used a language that does that?
I have.
> The String class in the C# language does that, and it's /really/ annoying.
> I have to add extra code to prevent such exceptions.
> In practice, I find that the way that Python does it is much nicer. (And
> Python isn't unique in this res
On 2017-12-04 18:54, Jason Maldonis wrote:
I was extending a `list` and am wondering why slicing lists will never
raise an IndexError, even if the `slice.stop` value if greater than the
list length.
Quick example:
my_list = [1, 2, 3]
my_list[:100] # does not raise an IndexError, but instead re
On Mon, Dec 4, 2017, at 13:54, Jason Maldonis wrote:
> Is there any background on why that doesn't raise an IndexError? Knowing
> that might help me design my extended list class better. For my specific
> use case, it would simplify my code (and prevent `if isinstance(item,
> slice)` checks) if the
Neil Cerutti writes:
> On 2017-12-04, Cecil Westerhof wrote:
>> Joel Goldstick writes:
>>
>>> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder
>>> wrote:
>>>
On 12/4/17 4:36 AM, Cecil Westerhof wrote:
> I have a script that was running perfectly for some time. It uses:
> a
Rick Johnson writes:
>> There is now also a line that starts with: PCH_CPU_TEMP:
>> And I do not want that one.
>
> Yes. But be aware, that while the `str.startswith(target)`
> method is indeed more efficient than a more generalized
> "inclusion test", if the target is not _always_ at the
> begin
I was extending a `list` and am wondering why slicing lists will never
raise an IndexError, even if the `slice.stop` value if greater than the
list length.
Quick example:
my_list = [1, 2, 3]
my_list[:100] # does not raise an IndexError, but instead returns the full
list
Is there any background
On 2017-12-04, Cecil Westerhof wrote:
> Joel Goldstick writes:
>
>> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder
>> wrote:
>>
>>> On 12/4/17 4:36 AM, Cecil Westerhof wrote:
>>>
I have a script that was running perfectly for some time. It uses:
array = [elem for elem in output if
On 12/4/2017 11:14 AM, Ned Batchelder wrote:
On 12/4/17 9:13 AM, Rick Johnson wrote:
Perhaps it's not politically correct for me to say this, but
i've never been one who cared much about political
correctness, so i'm just going to say it...
Cecil, feel free to ignore the rest of Rick's message
On 12/4/17 9:13 AM, Rick Johnson wrote:
Perhaps it's not politically correct for me to say this, but
i've never been one who cared much about political
correctness, so i'm just going to say it...
Cecil, feel free to ignore the rest of Rick's message. His messages are
famous for their outrageo
On Monday, December 4, 2017 at 3:49:11 AM UTC-6, dhananjays...@gmail.com wrote:
> I am Dhananjay Singh,Student of IIIT Manipur. Sir/Mam when
> i am double click in python program (Dhananjay.py),it is
> opening in Text Editor by Default in Ubuntu.I want to run
> this program when i double click on i
Cecil Westerhof wrote:
> Joel Goldstick writes:
[...]
> > I like Ned's clear answer, but I'm wondering why the
> > original code would fail because the substring is at the
> > start of the line, since 'in' would still be true no
> > matter where the desired string is placed. It would be
> >
Joel Goldstick writes:
> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder
> wrote:
>
>> On 12/4/17 4:36 AM, Cecil Westerhof wrote:
>>
>>> I have a script that was running perfectly for some time. It uses:
>>> array = [elem for elem in output if 'CPU_TEMP' in elem]
>>>
>>> But because output h
Ned Batchelder writes:
> On 12/4/17 4:36 AM, Cecil Westerhof wrote:
>> I have a script that was running perfectly for some time. It uses:
>> array = [elem for elem in output if 'CPU_TEMP' in elem]
>>
>> But because output has changed, I have to check for CPU_TEMP at the
>> beginning of the l
On 2017-12-04 10:48, dhananjaysingh091...@gmail.com wrote:
> Respected Sir/Mam,
> I am Dhananjay Singh,Student of IIIT Manipur. Sir/Mam when i am
> double click in python program (Dhananjay.py),it is opening in Text Editor by
> Default in Ubuntu.I want to run this program when i double cl
On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder
wrote:
> On 12/4/17 4:36 AM, Cecil Westerhof wrote:
>
>> I have a script that was running perfectly for some time. It uses:
>> array = [elem for elem in output if 'CPU_TEMP' in elem]
>>
>> But because output has changed, I have to check for CPU_
On 12/4/17 4:36 AM, Cecil Westerhof wrote:
I have a script that was running perfectly for some time. It uses:
array = [elem for elem in output if 'CPU_TEMP' in elem]
But because output has changed, I have to check for CPU_TEMP at the
beginning of the line. What would be the best way to impl
On Monday, December 4, 2017 at 9:44:27 AM UTC, Cecil Westerhof wrote:
> I have a script that was running perfectly for some time. It uses:
> array = [elem for elem in output if 'CPU_TEMP' in elem]
>
> But because output has changed, I have to check for CPU_TEMP at the
> beginning of the line.
Respected Sir/Mam,
I am Dhananjay Singh,Student of IIIT Manipur. Sir/Mam when i am double
click in python program (Dhananjay.py),it is opening in Text Editor by Default
in Ubuntu.I want to run this program when i double click on it as any *.Exe
file executes as in Window.
Sir please help
Python for Engineers - Solve Problems by Coding Solutions
https://pythonforengineers.blogspot.in
--
https://mail.python.org/mailman/listinfo/python-list
I have a script that was running perfectly for some time. It uses:
array = [elem for elem in output if 'CPU_TEMP' in elem]
But because output has changed, I have to check for CPU_TEMP at the
beginning of the line. What would be the best way to implement this?
--
Cecil Westerhof
Senior Softwa
52 matches
Mail list logo