Vespair,

See it’s funny because we name things after other things

Crul,
unlawfulbooger,

Thanks!

wintermute,
@wintermute@feddit.de avatar

What’s the name of the Island, Java?

oce,
@oce@jlai.lu avatar

Snake island

dauerstaender,

The Python REPL is fucking good.

Andrew15_5,
GuybrushThreepwo0d,

That’s giving me a 404, captain

MightyGalhupo,

Not to me

Andrew15_5,

You can search it yourself. The PYPI package is ptpython.

quantenzitrone,

github.com/prompt-toolkit/ptpython

the dot at the end of your link breaks it

Andrew15_5,

On Sync it works fine. Moreover, it should work on other clients too. You better open a ticket.

https://mander.xyz/pictrs/image/ecbf3439-e098-40ef-8312-2acac23215e8.png

https://mander.xyz/pictrs/image/a64ffa19-2654-48bf-8125-8814ea788156.png

lukas,
@lukas@lemmy.haigner.me avatar

I see you’ve never used a Lisp REPL before.

sloppy_diffuser,

import gravity; gravity = None

edit: of course there is an xkcd: xkcd.com/353/.

MajorHavoc,

Incidentally, for anyone who hasn’t typed ‘import antigravity’ into an interactive Python terminal…you should - as Dr Seuss says, “These things are fun, and fun is good.”

0ops,

NO WAY

tetris11,
@tetris11@lemmy.ml avatar

I love how it contains exactly one function: from antigravity import geohash

Hell, this is the entire antigravity library:


<span style="color:#323232;">import webbrowser
</span><span style="color:#323232;">import hashlib
</span><span style="color:#323232;">
</span><span style="color:#323232;">webbrowser.open("https://xkcd.com/353/")
</span><span style="color:#323232;">
</span><span style="color:#323232;">def geohash(latitude, longitude, datedow):
</span><span style="color:#323232;">    '''Compute geohash() using the Munroe algorithm.
</span><span style="color:#323232;">
</span><span style="color:#323232;">    >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
</span><span style="color:#323232;">    37.857713 -122.544543
</span><span style="color:#323232;">
</span><span style="color:#323232;">    '''
</span><span style="color:#323232;">    # https://xkcd.com/426/
</span><span style="color:#323232;">    h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
</span><span style="color:#323232;">    p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
</span><span style="color:#323232;">    print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))
</span>

He literally gets a 32-bit hash, uses the first half of it as the latitude decimal, and the second half of it as the longitude decimal,

EmergMemeHologram,

“exit”

✈️: Use exit() or Ctrl-D (I.e. EOF) to exit

PlexSheep,
@PlexSheep@feddit.de avatar

I mean if they can see that we type exit and show us this message, why could they not just start the exiting when we type exit?

Zron,

Because exit might be a variable you use to determine if you should exit. exit() is a function that actually does the exiting.

It’s the difference between pointing at a jogger and saying “run” and actually running after them.

Bronco1676,

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.


<span style="color:#323232;">>>> exit=1
</span><span style="color:#323232;">>>> exit()
</span><span style="color:#323232;">Traceback (most recent call last):
</span><span style="color:#323232;">  File "<stdin>", line 1, in <module>
</span><span style="color:#323232;">TypeError: 'int' object is not callable
</span><span style="color:#323232;">>>>
</span>
peopleproblems,

wow it does do that. cool

EmergMemeHologram,

Reminds me of setting pi = 3 in my friends matlab subroutines in school.

Bronco1676, (edited )

This is the code (Github link):


<span style="font-weight:bold;color:#a71d5d;">class </span><span style="color:#0086b3;">Quitter</span><span style="color:#323232;">(</span><span style="color:#0086b3;">object</span><span style="color:#323232;">):
</span><span style="color:#323232;">    </span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#62a35c;">__init__</span><span style="color:#323232;">(self, name, eof):
</span><span style="color:#323232;">        self.name </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">name
</span><span style="color:#323232;">        self.eof </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">eof
</span><span style="color:#323232;">    </span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#62a35c;">__repr__</span><span style="color:#323232;">(self):
</span><span style="color:#323232;">        </span><span style="font-weight:bold;color:#a71d5d;">return </span><span style="color:#183691;">'Use </span><span style="color:#0086b3;">%s</span><span style="color:#183691;">() or </span><span style="color:#0086b3;">%s</span><span style="color:#183691;"> to exit' </span><span style="font-weight:bold;color:#a71d5d;">% </span><span style="color:#323232;">(self.name, self.eof)
</span><span style="color:#323232;">    </span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#62a35c;">__call__</span><span style="color:#323232;">(self, code</span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#0086b3;">None</span><span style="color:#323232;">):
</span><span style="color:#323232;">        </span><span style="font-style:italic;color:#969896;"># Shells like IDLE catch the SystemExit, but listen when their
</span><span style="color:#323232;">        </span><span style="font-style:italic;color:#969896;"># stdin wrapper is closed.
</span><span style="color:#323232;">        </span><span style="font-weight:bold;color:#a71d5d;">try</span><span style="color:#323232;">:
</span><span style="color:#323232;">            sys.stdin.close()
</span><span style="color:#323232;">        </span><span style="font-weight:bold;color:#a71d5d;">except</span><span style="color:#323232;">:
</span><span style="color:#323232;">            </span><span style="font-weight:bold;color:#a71d5d;">pass
</span><span style="color:#323232;">        </span><span style="font-weight:bold;color:#a71d5d;">raise </span><span style="color:#0086b3;">SystemExit</span><span style="color:#323232;">(code)
</span>

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.

WhiskyTangoFoxtrot,

Guessing at what the programmer wants instead of implementing consistent behaviour is what Javascript does. Do you want Python to become Javascript?

tetris11,
@tetris11@lemmy.ml avatar

Just once I want ‘1’ + ‘2’ to equal ‘3’. Is that so much to ask?

Metype,

You want to remove the string concatenation operator? Cause that’ll do it

tetris11,
@tetris11@lemmy.ml avatar

I think every language needs a please operator, which acts to enforce human expectation of a statement:


<span style="color:#323232;">'1'  + '1'            ## evaluates to '11'
</span><span style="color:#323232;">please '1' + '1' ## evaluates to '2'
</span>
PlexSheep,
@PlexSheep@feddit.de avatar

I kinda like that

wewbull,

Yes. Yes it is.

eluvatar,

Because python has strong opinions

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines