0

I know in python, you can use, say dir(list)to find out all the methods of listobject, and then use help(list.pop) to look more of the details.

but when I came across datetimelibrary, so there is a timedeltamethod which has the following attributes

datetime.timedelta(days = 1)

datetime.timedelta(1)

datetime.timedelta(hours = 1)

datetime.timedelta(0, 3600)

datetime.timedelta(seconds = 1)

datetime.timedelta(0, 1)

but I looked all over the help(datetime.timedelta) documents, it only lists days, seconds in the library, there's nowhere to find hours attribute.

just in general, how do you find all the attributes of a method?

1 Answer 1

1

In general, you're better off bookmarking the Python documentation than using help(some_function): help() shows you the function's __doc__ attribute, which is usually a short reference to the function. Instead, if you'd gone to:

https://docs.python.org/3/library/datetime.html#timedelta-objects

you would have found the hours parameter (and several others) that you were looking for.

Sign up to request clarification or add additional context in comments.

2 Comments

If it's not in the standard library, and if the documentation is not on readthedocs.org, an alternate method is to just read the source code. (Unless it's an extension in C like numpy, in which case you will need to rely on the documentation.)
Thank you rmunn. I'm used to use the function in R which gives all the documents you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.