Skip to content

Instantly share code, notes, and snippets.

@nicomen
Last active April 9, 2019 20:31
Show Gist options
  • Save nicomen/56c82122b1d6845d464d to your computer and use it in GitHub Desktop.
Save nicomen/56c82122b1d6845d464d to your computer and use it in GitHub Desktop.
why python is not for me
nicolasm@merry:~$ python -c 'datetime.isoformat()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'datetime' is not defined
nicolasm@merry:~$ python -c 'import datetime; datetime.isoformat()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'isoformat'
nicolasm@merry:~$ python -c 'import isoformat from datetime; datetime.isoformat()'
File "<string>", line 1
import isoformat from datetime; datetime.isoformat()
^
SyntaxError: invalid syntax
nicolasm@merry:~$ python -c 'import datetime; datetime.isoformat()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'isoformat'
nicolasm@merry:~$ python -c 'import datetime; datetime.isoformat('')'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'isoformat'
nicolasm@merry:~$ python -c 'import datetime; datetime.isoformat("")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'isoformat'
nicolasm@merry:~$ python -c 'from datetime import isoformat; datetime.isoformat("")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name isoformat
nicolasm@merry:~$ python -c 'import datetime; datetime.isoformat("")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'isoformat'
nicolasm@merry:~$ python -c 'import datetime; print datetime.isoformat("")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'isoformat'
nicolasm@merry:~$ python -c 'from datetime import date; print date.isoformat("")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: descriptor 'isoformat' requires a 'datetime.date' object but received a 'str'
nicolasm@merry:~$ python -c 'from datetime import date; print date.isoformat()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: descriptor 'isoformat' of 'datetime.date' object needs an argument
nicolasm@merry:~$ python -c 'from datetime import date; import time; print date.isoformat(time.time)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: descriptor 'isoformat' requires a 'datetime.date' object but received a 'builtin_function_or_method'
nicolasm@merry:~$ python -c 'from datetime import date; import time; print date.isoformat(time.time())'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: descriptor 'isoformat' requires a 'datetime.date' object but received a 'float'
nicolasm@merry:~$ python -c 'from datetime import date; import time; print date(time.time()).isoformat()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: integer argument expected, got float
nicolasm@merry:~$ python -c 'from datetime import date; import time; print date(time.time()).isoformat()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: integer argument expected, got float
nicolasm@merry:~$ python -c 'import datetime; datetime.tzname()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'tzname'
nicolasm@merry:~$ python -c 'import datetime; d = datetime.new(); d.tzname()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'new'
nicolasm@merry:~$ python -c 'import datetime; d = new datetime; d.tzname()'
File "<string>", line 1
import datetime; d = new datetime; d.tzname()
^
SyntaxError: invalid syntax
nicolasm@merry:~$ python -c 'from datetime import date; datetime(date.today).tzname()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'datetime' is not defined
nicolasm@merry:~$ python -c 'import datetime; from datetime import date; datetime(date.today).tzname()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'module' object is not callable
nicolasm@merry:~$ python -c 'from datetime import date, datetime; datetime(date.today).tzname()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: an integer is required
nicolasm@merry:~$ python -c 'from datetime import date, datetime; datetime(date.today)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: an integer is required
nicolasm@merry:~$ python -c 'from datetime import date, datetime; datetime.today'
nicolasm@merry:~$ python -c 'from datetime import date, datetime; print datetime.today'
<built-in method today of type object at 0x964800>
nicolasm@merry:~$ python -c 'import datetime; print datetime.today.tzname'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'today'
nicolasm@merry:~$ python -c 'import datetime; print datetime.today().tzname'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'today'
nicolasm@merry:~$ python -c 'import datetime; print datetime.today()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'today'
nicolasm@merry:~$ python -c 'from datetime import date, datetime; print datetime.today'
<built-in method today of type object at 0x964800>
nicolasm@merry:~$ python -c 'from datetime import date, datetime; print datetime.today.tzname'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'builtin_function_or_method' object has no attribute 'tzname'
nicolasm@merry:~$ python -c 'from datetime import date, datetime; print datetime.today.tzname()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'builtin_function_or_method' object has no attribute 'tzname'
nicolasm@merry:~$ python -c 'from datetime import date, datetime; print datetime.today().tzname()'
None
nicolasm@merry:~$ python -c 'from datetime import date, datetime; d = datetime.today(); print d.tzname()'
None
nicolasm@merry:~$ python -c 'from datetime import date, datetime; d = datetime.today(); print d.tzname(); d.tzname("UTC"); print d'
None
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: tzname() takes no arguments (1 given)
nicolasm@merry:~$ python -c 'from datetime import date, datetime; d = datetime.today(); print d.tzname(); print d.astimezone'
None
<built-in method astimezone of datetime.datetime object at 0x7ff00c171828>
nicolasm@merry:~$ python -c 'from datetime import date, datetime; d = datetime.today(); print d.tzname(); print d.astimezone()'
None
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: Required argument 'tz' (pos 1) not found
nicolasm@merry:~$ python -c 'from datetime import date, datetime; d = datetime.today(); print d.tzname(); print d.astimezone(UTC)'
None
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'UTC' is not defined
nicolasm@merry:~$ python -c 'from datetime import date, datetime; d = datetime.today(); print d.tzname(); print d.astimezone("UTC")'
None
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: astimezone() argument 1 must be datetime.tzinfo, not str
nicolasm@merry:~$ python -c 'from datetime import date, datetime; d = datetime.today(); print d.tzname(); print d.astimezone(datetime.tzinfo("UTC"))'
None
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'getset_descriptor' object is not callable
# yeah whatevvs...
$ perl -wlE 'use DateTime; print join " @ ", (DateTime->now->iso8601, DateTime->now->time_zone->name)'
2015-07-17T11:03:43 @ UTC
$ php5 -r '$d = new DateTime("NOW"); print $d->format(DateTime::ISO8601) . "\n";'
2015-07-17T13:09:57+0200
javascript:alert((new Date).toISOString())
@pije76
Copy link

pije76 commented Aug 9, 2017

python -c 'from datetime import datetime; whatevvs = datetime.now(); print(whatevvs)'

@joshi1983
Copy link

joshi1983 commented Apr 9, 2019

It is pretty annoying to me also. Printing a formatted date shouldn't be difficult in any good programming language. This annoyance with Python reminds me of the excessively long chains of factory classes required to do simple things like reading a file in Java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment