Hi:
Can you please explain __getitem__? My understanding is that it brings back
dictionary's value. Is this correct? If so which value does it bring? Does it
look up this value by using a key? Where is this key specified in "
numbers.__getitem__" ?
The below supposedly brings back dictionary
Hi:
Can you please explain what is going on below? I do not understand how
numbermap.__getitem__ brings back month's key.
Does numbermap.__getitem__ bring back numbermap key or value? If key then it is
not consistent with my understanding of problem in my previous email. So month
is sorted by n
On 23/11/16 06:09, monik...@netzero.net wrote:
> Can you please explain __getitem__?
__getitem__ is the operator overload for indexing.
It is like the __add__() method which overloads the + operator.
So if you imple,ent __add__() in your class you can add two instances
together using + and Pytho
On 23/11/16 06:26, monik...@netzero.net wrote:
> I do not understand how numbermap.__getitem__ brings back month's key.
numbermap returns the integer corresponding to the key.
That number is then used by sorted as the basis for
sorting month. So for the first entry sorted receives
the value 1, fo
Hi,
I had a query regarding the code coverage for pyhton subprocess.I was
referring the below link
https://coverage.readthedocs.io/en/coverage-4.2/subprocess.html
I created a site customize file
./usr/lib/python2.7/site-packages/sitecustomize.py
with the coed snippet
import coveragecoverage.proc
Hi:
Thank you very much for your explanation. Just to confirm when using
__getitem__ sort will go thru every key in dict and get its value and then sort
according to it. Correct?
Also, you wrote:
">>> sorted(numbers, key = lambda ky: numbers[ky]) "
ky is input to lambda. Where does lambda get
Hi:
I have two questions in regards to below code:
1. largest is a list, not a list of lists.
[('deit', 4), ('acer', 3), ('aceilmr', 2), ('arst', 2)]
so why when I do largest[0] I get the whole list again, not just the first item
from the list. To get the first item I have to do largest[0][0].
So numbermap.__getitem__ brings back 1, then 2,then 3, then 4.
Then it looks up 1 ,2, 3, 4 in month but there is no key with value 1, 2, or
or in 4.
What am I missing?
Thank you very much
Monika
-- Original Message --
From: Alan Gauld via Tutor
To: tutor@python.org
Subject: Re
On 23/11/16 12:33, monik...@netzero.net wrote:
> So numbermap.__getitem__ brings back 1, then 2,then 3, then 4.
> Then it looks up 1 ,2, 3, 4 in month but there is no key with value 1, 2, or
> or in 4.
> What am I missing?
Your problem is not with getitem but with sorted.
You need to read up o
On 23/11/16 12:25, monik...@netzero.net wrote:
> I have two questions in regards to below code:
> 1. largest is a list, not a list of lists.
> [('deit', 4), ('acer', 3), ('aceilmr', 2), ('arst', 2)]
> so why when I do largest[0] I get the whole list again,
I don't know you will need to show us
10 matches
Mail list logo