[Tutor] SLICING

2018-06-15 Thread kenneth yashim
please im new to python or any other programming language. please i want to
understand how slicing works

[start,stop,step]

>>> 'abc'[0:3]
'abc'

>>>'abc'[0:-1]
'ab'

why does 'abc'[2:1]  or 'abc'[2:1] print ' ' instead of 'c'???
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] In matplotlib, why are there axes classes vs. axes API? Why not list them under one documentation?

2018-06-15 Thread C W
I read through some documentations yesterday after posting.

I will share what I think. There are three parts to matplotlib: backend,
artist, and scripting. The artist layer is the only one that really matters
for matplotlib users.

Why haven't the developers fixed the problem? Considering Python's growing
popularity, hasn't anyone brought this up before me? Was there a plan?

Thanks!





On Thu, Jun 14, 2018 at 9:39 PM, Steven D'Aprano 
wrote:

> On Thu, Jun 14, 2018 at 12:31:44PM -0400, C W wrote:
> > Hello everyone,
> >
> > I'm working on matplotlib, could someone explain the difference between
> > these two?
> >
> > Axes class: https://matplotlib.org/api/axes_api.html#matplotlib.axes.
> Axes
> > Axes and tick API: https://matplotlib.org/api/axis_api.html
> >
> > I began at reading axes class, but discovered axes API by accident. Why
> are
> > there two documentations on the same thing? Why not merge? I mean, one is
> > already confusing enough. ;)
>
> *shrug*
>
> Because the designers of matplotlib suck at designing a good, easy to
> use, easy to understand, simple API? Because they're not good at writing
> documentation? I dunno.
>
> It is hard to write an API which is both *obvious* and *powerful*, but
> the few times I tried using matplotlib I found it baroque and confusing.
>
>
>
> --
> Steve
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] In matplotlib, why are there axes classes vs. axes API? Why not list them under one documentation?

2018-06-15 Thread Mats Wichmann
many systems are constrained by history. matplotlib started when the vile (yes, 
thats just a personal opinion) matlab proved too cumbersome and someone decided 
to try again in python... but knowing matlab, he picked up ideas from there. 
since then all kinds of stuff has been bolted on. it's powerful but awkward and 
not very modern and has a steep learning curve. there are other options if you 
don't like it.  try a search engine: you are certainly not the first complainer

On June 15, 2018 10:35:36 AM MDT, C W  wrote:
>I read through some documentations yesterday after posting.
>
>I will share what I think. There are three parts to matplotlib:
>backend,
>artist, and scripting. The artist layer is the only one that really
>matters
>for matplotlib users.
>
>Why haven't the developers fixed the problem? Considering Python's
>growing
>popularity, hasn't anyone brought this up before me? Was there a plan?
>
>Thanks!
>
>
>
>
>
>On Thu, Jun 14, 2018 at 9:39 PM, Steven D'Aprano 
>wrote:
>
>> On Thu, Jun 14, 2018 at 12:31:44PM -0400, C W wrote:
>> > Hello everyone,
>> >
>> > I'm working on matplotlib, could someone explain the difference
>between
>> > these two?
>> >
>> > Axes class:
>https://matplotlib.org/api/axes_api.html#matplotlib.axes.
>> Axes
>> > Axes and tick API: https://matplotlib.org/api/axis_api.html
>> >
>> > I began at reading axes class, but discovered axes API by accident.
>Why
>> are
>> > there two documentations on the same thing? Why not merge? I mean,
>one is
>> > already confusing enough. ;)
>>
>> *shrug*
>>
>> Because the designers of matplotlib suck at designing a good, easy to
>> use, easy to understand, simple API? Because they're not good at
>writing
>> documentation? I dunno.
>>
>> It is hard to write an API which is both *obvious* and *powerful*,
>but
>> the few times I tried using matplotlib I found it baroque and
>confusing.
>>
>>
>>
>> --
>> Steve
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>>
>___
>Tutor maillist  -  Tutor@python.org
>To unsubscribe or change subscription options:
>https://mail.python.org/mailman/listinfo/tutor

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SLICING

2018-06-15 Thread Alan Gauld via Tutor
On 15/06/18 14:57, kenneth yashim wrote:
> please im new to python or any other programming language. please i want to
> understand how slicing works
> 
> [start,stop,step]
> 
 'abc'[0:3]
> 'abc'
> 
 'abc'[0:-1]
> 'ab'
> 
> why does 'abc'[2:1]  or 'abc'[2:1] print ' ' instead of 'c'???

Because stop is lower than start and the step is implicitly +1,
so the slice doesn't include anything.

'abc'[2:]

will yield 'c' because it implicitly specifies stop as the
end of the string.

'abc'[2:1:-1]

will also yield 'c' because the -1 step value reverses the
direction.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] In matplotlib, why are there axes classes vs. axes API? Why not list them under one documentation?

2018-06-15 Thread Alan Gauld via Tutor
On 15/06/18 17:35, C W wrote:

> Why haven't the developers fixed the problem? 

This is open source, developed by volunteers to
meet their own needs primarily and others by
happy coincidence.

If the existing solution meets the needs of the
developers they have no incentive to spend time
to  "fix" it.

You(*) may want it fixed and if you submit a patch
they may well incorporate it. That's how open
source works.

(*)You or anyone else who is sufficiently irritated
or motivated to spend their time fixing it...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SLICING

2018-06-15 Thread Steven D'Aprano
On Fri, Jun 15, 2018 at 04:57:47PM +0300, kenneth yashim wrote:
> please im new to python or any other programming language. please i want to
> understand how slicing works
> 
> [start,stop,step]
> 
> >>> 'abc'[0:3]
> 'abc'
> 
> >>>'abc'[0:-1]
> 'ab'
> 
> why does 'abc'[2:1]  or 'abc'[2:1] print ' ' instead of 'c'???

They don't return a space. They return an empty string, because the 
starting point comes AFTER the ending point.

The slice from 2 to 1 means:

- move to the right;
- start at position number two
- stop when you get to, or pass, position number one

Since you have already passed position number one, the slice stops 
collecting immediately, and you have an empty slice.

Slices cut the string at positions *between* the characters. If you have 
the string s="abcdef", imagine marking the gaps between the characters 
like this:

|a|b|c|d|e|f|

and numbering the gaps 0, 1, 2, 3, 4, 5, 6.

So the slice s[2:5] cuts at the gaps numbered 2 and 5:

|a|b||c|d|e||f|

giving you 'cde' as the returned slice.

If the ending position is to the left of the starting position, an 
empty slice is returned.


-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] In matplotlib, why are there axes classes vs. axes API? Why not list them under one documentation?

2018-06-15 Thread Steven D'Aprano
On Fri, Jun 15, 2018 at 12:35:36PM -0400, C W wrote:

> Why haven't the developers fixed the problem?

matplotlib is free, open source software. If volunteers don't "fix the 
problem", who is paying for the work to be done?

Are you volunteering?

Or willing to pay somebody to do the work? $30,000 - $50,000 would 
probably pay for one developer to work on mathplotlib full time for 
three months.

Or maybe the developers don't think it is a problem that needs fixing. 
Maybe they're happy with it the way it is.

Or they don't like it any more than you do, but they are constrained by 
the need to keep backwards compatibility.


-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor