On Fri, Jan 15, 2016 at 10:20:41PM -0600, boB Stepp wrote:
> At
> https://docs.python.org/3.4/library/stdtypes.html#sequence-types-list-tuple-range
> it states:
>
> "s.insert(i, x) inserts x into s at the index given by i (same as s[i:i] =
> [x])"
>
> I find this confusing.
That's because it i
Steven D'Aprano wrote:
> But slices are slightly different. When you provide two indexes in a
> slice, they mark the gaps BETWEEN items:
The other explanation that Python uses half-open intervals works for me.
> Now, what happens with *negative* indexes?
>
> mylist = [ 100, 200, 300, 400, 500
def get_(loc, thing):
if loc==[]: return thing
return get_(loc[1:], thing[loc[0]])
Hi I am new to Python and I would like to learn about these uses of square
brackets. I know that loc[1:] means loc list without the first element but
I do not know the meanings of loc==[] and thing[loc[0]].
On 16/01/16 15:51, Ege Berkay Gülcan wrote:
> def get_(loc, thing):
> if loc==[]: return thing
> return get_(loc[1:], thing[loc[0]])
>
> Hi I am new to Python and I would like to learn about these uses of square
> brackets. I know that loc[1:] means loc list without the first element but
>
On 16 January 2016 at 16:51, Ege Berkay Gülcan wrote:
> def get_(loc, thing):
> if loc==[]: return thing
> return get_(loc[1:], thing[loc[0]])
>
> Hi I am new to Python and I would like to learn about these uses of square
> brackets. I know that loc[1:] means loc list without the first ele
On Sat, Jan 16, 2016 at 1:00 PM, Alan Gauld wrote:
> As a side note, this function looks very fragile since
> it depends on thing having nested data structures that
> match the indexes provided by loc.
As Alan's response arrived, I was in the interpreter trying out this
function with a set of va
On Sat, Jan 16, 2016 at 1:14 PM, boB Stepp wrote:
>
> While learning I find it very helpful to either use IDLE or invoke the
> Python interpreter in the shell and try these things out. Once I get
> it to work, then I play around with the syntax and deliberately try to
> break things and see what
On 16/01/16 19:35, boB Stepp wrote:
> And so on. Until you (and I) can understand why the function produces
> these outputs with the given values of loc and thing, then we cannot
> claim we understand what is going on. So I encourage you to
> thoroughly explore your sample code!
The function pl
On Sat, Jan 16, 2016 at 6:19 AM, Peter Otten <__pete...@web.de> wrote:
> Steven D'Aprano wrote:
>
>> But slices are slightly different. When you provide two indexes in a
>> slice, they mark the gaps BETWEEN items:
>
> The other explanation that Python uses half-open intervals works for me.
>
>> Now
On Sat, Jan 16, 2016 at 2:33 PM, Alan Gauld wrote:
> On 16/01/16 19:35, boB Stepp wrote:
>
>> And so on. Until you (and I) can understand why the function produces
>> these outputs with the given values of loc and thing, then we cannot
>> claim we understand what is going on. So I encourage you
Hi, i don't have any clue how to write a console program that shows a list
of options which could be chosen with keyboard and when one item was
selected, a text shows there.
I want to know, which things i need to write a program like that?
Input() , print, and What? :(
__
Hi, i wrote a small APP to execute MySQL commands and retrieve to a Treeview
http://pastebin.com/v2C8kAu1
Share your comments and upgrades.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/ma
On 16/01/16 22:39, boB Stepp wrote:
> So in this model of understanding negative list indexing, should it be:
>
> mylist = [ 100, 200, 300, 400, 500 ]
> ^^^^^ ^
> -5 -4 -3 -2 -1 ?
>
> Well, it has to be this; otherwise, the off-by-one error exist.
boB Stepp writes:
> So in this model of understanding negative list indexing, should it be:
>
> mylist = [ 100, 200, 300, 400, 500 ]
> ^^^^^ ^
> -5 -4 -3 -2 -1 ?
For completeness, let's use the rest of the integers also::
012
Ricardo Martínez writes:
> Hi, i wrote a small APP to execute MySQL commands and retrieve to a Treeview
>
> Share your comments and upgrades.
You're addressing this to the wrong forum. If you want to discuss code,
please post *small, complete* samples of code directly here in the forum
and ask s
On 16/01/16 22:53, boB Stepp wrote:
>> The function plumbs the depths of thing according to the indices
>> supplies in loc. The shape of thing must match the length of loc.
>
> The interesting part of this function for me was not the OP's original
> questions, but why this particular use of a rec
Ali Moradi writes:
> Hi, i don't have any clue how to write a console program that shows a
> list of options which could be chosen with keyboard and when one item
> was selected, a text shows there.
A text shows where? Shows at the point of input, at the point of the
option, at some other point?
On 16/01/16 23:56, Alan Gauld wrote:
> On 16/01/16 22:39, boB Stepp wrote:
>
>> So in this model of understanding negative list indexing, should it be:
>>
>> mylist = [ 100, 200, 300, 400, 500 ]
>> ^^^^^ ^
>> -5 -4 -3 -2 -1 ?
>>
>> Well, it has to be
On 16/01/16 21:18, Ali Moradi wrote:
> Hi, i don't have any clue how to write a console program that shows a list
> of options which could be chosen with keyboard and when one item was
> selected, a text shows there.
>
> I want to know, which things i need to write a program like that?
>
> Input(
On 17/01/16 00:04, Ben Finney wrote:
> Ricardo Martínez writes:
>
>> Hi, i wrote a small APP to execute MySQL commands and retrieve to a Treeview
>>
>> Share your comments and upgrades.
>
> You're addressing this to the wrong forum. If you want to discuss code,
> please post *small, complete* sa
On 2016-01-16 16:08, Alan Gauld wrote:
On 16/01/16 23:56, Alan Gauld wrote:
On 16/01/16 22:39, boB Stepp wrote:
So in this model of understanding negative list indexing, should it
be:
mylist = [ 100, 200, 300, 400, 500 ]
^^^^^ ^
-5 -4 -3 -2 -1 ?
Alex sent me this off-list. I hope he does not mind me sharing part
of what he wrote on-list!
On Sat, Jan 16, 2016 at 4:57 PM, Alex Kleider wrote:
> On 2016-01-16 14:39, boB Stepp wrote:
>
>
> mylist[:0 or None]
>>
>> [100, 200, 300, 400, 500]
>>
>> The critical portion of the for loop for m
On 16Jan2016 18:43, boB Stepp wrote:
This led me to try:
mylist[:None]
[100, 200, 300, 400, 500]
So, in effect, None is acting as a place holder for that final
position in slices. Also, I would never have thought to be able to
use a logical "or" inside an index in Peter's "[:-i or None]".
On 2016-01-16 18:02, Cameron Simpson wrote:
On 16Jan2016 18:43, boB Stepp wrote:
This led me to try:
mylist[:None]
[100, 200, 300, 400, 500]
So, in effect, None is acting as a place holder for that final
position in slices. Also, I would never have thought to be able to
use a logical "or"
On Sat, Jan 16, 2016 at 01:19:16PM +0100, Peter Otten wrote:
> Steven D'Aprano wrote:
>
> > But slices are slightly different. When you provide two indexes in a
> > slice, they mark the gaps BETWEEN items:
>
> The other explanation that Python uses half-open intervals works for me.
Half-open a
25 matches
Mail list logo