On 27/07/17 03:22, C W wrote:
> Thank you very much, Steve!
>
> I think I got it. To get help() on a method, you have to somehow invoke an
> object first.
Or just use the class. In Steven's examples he included list.sort.
'list' is the class name for a list.
--
Alan G
Author of the Learn to Pro
On 27/07/17 03:22, boB Stepp wrote:
> use them. The idea of replacing a function with its decorated version
> sounds cool, but what types of problems would I want to use this
> approach on?
I'm sure others will have their own take on this but personally I view
them as primarily for building fram
Thank you very much, Steve!
I think I got it. To get help() on a method, you have to somehow invoke an
object first.
In your example, even an empty vector [] will do.
Thanks!
On Wed, Jul 26, 2017 at 10:16 PM, Steven D'Aprano
wrote:
> On Wed, Jul 26, 2017 at 10:03:59PM -0400, C W wrote:
> > Th
Thank you very much, all!
One other question: how do you look up a method?
>help(sort)
Traceback (most recent call last):
File "", line 1, in
help(sort)
NameError: name 'sort' is not defined
Back to function vs method, I came from R:
aList = sort(aList)
There was never aList.sort(),
On Mon, Jul 24, 2017 at 11:01 AM, Steven D'Aprano wrote:
>
> There's more to decorators than that, but hopefully that will
> demonstrate some of the basic concepts. Feel free to ask any more
> questions on the mailing list, and we will answer if we can.
>
I hope I can ask questions, too! ~(:>))
On Wed, Jul 26, 2017 at 10:03:59PM -0400, C W wrote:
> Thank you very much, all!
>
> One other question: how do you look up a method?
Any of these will work:
help(list.sort)
help([].sort)
alist = [1, 2, 3, 99]
help(alist.sort)
--
Steve
___
Tutor
On Wed, Jul 26, 2017 at 02:40:17PM -0400, C W wrote:
> sorted(aList)
> > [2, 3, 4, 5]
sorted() makes a copy of whatever you give it, as a list, and sorts the
copy. It doesn't have to be a list to start with:
py> sorted("alphabet")
['a', 'a', 'b', 'e', 'h', 'l', 'p', 't']
> aList.sort()
> aLis
On 26/07/17 19:40, C W wrote:
> My understanding of each is:
> 1) function(variable) is manipulating a vector, I can do bList =
> sorted(aList)
> 2) object.method() is permanently changing it, I don't even need to assign
> it in #1.
>
> Why is there both? They do the same thing.
As you have just
On Wed, Jul 26, 2017 at 2:40 PM, C W wrote:
> Dear Python experts,
>
> I suppose I have the following Python code:
>
> aList = [3, 5, 2, 4]
>
> sorted(aList)
> > [2, 3, 4, 5]
>
> aList.sort()
>
> aList
> > [2, 3, 4, 5]
>
> My understanding of each is:
> 1) function(variable) is manipulating a vec
Dear Python experts,
I suppose I have the following Python code:
aList = [3, 5, 2, 4]
sorted(aList)
> [2, 3, 4, 5]
aList.sort()
aList
> [2, 3, 4, 5]
My understanding of each is:
1) function(variable) is manipulating a vector, I can do bList =
sorted(aList)
2) object.method() is permanently ch
On 7/25/2017 12:43 AM, Alan Gauld via Tutor wrote:
On 25/07/17 04:58, N6Ghost wrote:
this code works
f = open("C:/coderoot/python3/level1/inputfile.txt", 'r')
for line in f:
for line in f:
#print(line.rstrip())
print(line)
f.close()
the out put skips the first line
11 matches
Mail list logo