programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
hairinmybellybutt@lemmy.world to Programmer Humor@lemmy.mlEnglish · 2 years ago

would you write web app with this?

lemmy.world

message-square
56
link
fedilink
257

would you write web app with this?

lemmy.world

hairinmybellybutt@lemmy.world to Programmer Humor@lemmy.mlEnglish · 2 years ago
message-square
56
link
fedilink
  • tryptaminev 🇵🇸 🇺🇦 🇪🇺@feddit.de
    link
    fedilink
    arrow-up
    9
    ·
    2 years ago

    example:

    i = 5.0//2

    list[i]

    throws an error because i is double and the list-index expects an integer.

    so for it to work the code needs to look like this:

    i = int(5.0//2)

    list[i]

    meanwhile this works:

    i=5

    i= ‘abcde’

    • Chrobin@discuss.tchncs.de
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      Isn’t // integer division?

      • Gebruikersnaam@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        2 years ago

        It is but if you start with a float you get a float back.

        • Chrobin@discuss.tchncs.de
          link
          fedilink
          arrow-up
          2
          ·
          2 years ago

          You’re right, I did not know that. Thanks!

          • Gebruikersnaam@lemmy.ml
            link
            fedilink
            arrow-up
            1
            ·
            2 years ago

            Was really surprised by this too, because iirc Python 2 did not do this.

    • dzervas@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      you can do i: int to make this error out

      • Gebruikersnaam@lemmy.ml
        link
        fedilink
        arrow-up
        6
        ·
        2 years ago

        No, type hints are not enforced.

        • dzervas@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          2 years ago

          damn

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 23 users / day
  • 324 users / week
  • 2.37K users / month
  • 9.7K users / 6 months
  • 732 local subscribers
  • 35.8K subscribers
  • 1.75K Posts
  • 38.5K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org