Bronco1676

joined 11 months ago
[–] Bronco1676@lemmy.ml 17 points 11 months ago (2 children)

If you have a variable called exit you've overwritten the function in that scope, and won't be able to execute it.

e.g.

>>> exit=1
>>> exit()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not callable
>>>
[–] Bronco1676@lemmy.ml 7 points 11 months ago* (last edited 11 months ago)

This is the code (Github link):

class Quitter(object):
    def __init__(self, name, eof):
        self.name = name
        self.eof = eof
    def __repr__(self):
        return 'Use %s() or %s to exit' % (self.name, self.eof)
    def __call__(self, code=None):
        # Shells like IDLE catch the SystemExit, but listen when their
        # stdin wrapper is closed.
        try:
            sys.stdin.close()
        except:
            pass
        raise SystemExit(code)

What happens is that the python repl calls __repr__ automatically on each variable/statement that you type into the repl (except assignments e.g. x = 1). But this basically only happens in the repl. So "executing" only exit wouldn't work in a python script as it is not calling __repr__ automatically, so better you learn how to do it right than using just exit in your python scripts and scratching your head why it works in the repl but not in your code.

[–] Bronco1676@lemmy.ml 2 points 11 months ago

No worries, awesome that you were able fix it!

[–] Bronco1676@lemmy.ml 2 points 11 months ago (2 children)

This sounds like your clock may be out of sync?

Have a look at timesyncd https://wiki.archlinux.org/title/Systemd-timesyncd#Usage

[–] Bronco1676@lemmy.ml 2 points 11 months ago (1 children)

How long did it take to count them

[–] Bronco1676@lemmy.ml 1 points 11 months ago

But dopamine🥺

[–] Bronco1676@lemmy.ml 23 points 11 months ago (1 children)

That's mineblowing

[–] Bronco1676@lemmy.ml 2 points 11 months ago (4 children)

Weird and what's in it?

Open with a text editor or execute cat /etc/localtime

[–] Bronco1676@lemmy.ml 3 points 11 months ago (1 children)

You didn't specify the calendar used 🤓, so I'll go to the year 1401 in the hijri calendar (1980 in the gregorian calendar)

view more: ‹ prev next ›