Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

How to document passing and returning date objects in Python as parameter documentation? [closed]

$
0
0

I'm working on a Python project where I'm handling dates, and I'd like to understand how to properly document functions or methods that accept and return date objects using datetime.date or date from the datetime library.

Specifically, I'm looking to understand how to document this correctly in the context of parameter typing and function/method return. Here are some examples of what I'm trying to achieve:we have two types of import:

from datetime import datetime

or

from datetime import date

how it works?

from datetime import datetimedef fuu(new_date: datetime.date)

or

from datetime import datedef baa(new_date: date)

and

def fuu(...) -> datetime.date:

or

ou baa(...) -> date:

My doubt is as follows: If the object that should be passed or returned is an object of type date. then should I usefrom datetime import datedef foo(new_date: date):to indicate that it is an object of type date or instead usefrom datetime import datetimedef baa(new_date: datetime)This is my doubt, since neither of the 2 start with a capital letter, as is conventional for a class. Which of the two is better to represent an object of type date? Especially one returned from pyodbc. its a date object or a datetime object??


Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>