tchncs
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
hairinmybellybutt@lemmy.world to Programmer Humor@lemmy.mlEnglish · vor 2 Jahren

would you write web app with this?

lemmy.world

message-square
54
link
fedilink
250

would you write web app with this?

lemmy.world

hairinmybellybutt@lemmy.world to Programmer Humor@lemmy.mlEnglish · vor 2 Jahren
message-square
54
link
fedilink
  • Gebruikersnaam@lemmy.ml
    link
    fedilink
    arrow-up
    27
    ·
    vor 2 Jahren

    Python is strongly typed, but it is also dynamically typed.

    • CanadaPlus@futurology.today
      link
      fedilink
      English
      arrow-up
      10
      arrow-down
      1
      ·
      vor 2 Jahren

      TIL. Obviously I’ve avoided using it much.

      So how does that work? Is there a few implicit conversions that are allowed, but if you really write something weird it will complain?

      • Gebruikersnaam@lemmy.ml
        link
        fedilink
        arrow-up
        11
        ·
        vor 2 Jahren

        Yes, it has no implicit conversions like JS or R. It does, however, allow you to not specify the type of a variable and even change it without complaining. Even if you add types these are only hints that won’t generate errors unless you use external type checking (e.g. mypy).

        • tryptaminev 🇵🇸 🇺🇦 🇪🇺@feddit.de
          link
          fedilink
          arrow-up
          9
          ·
          vor 2 Jahren

          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
            link
            fedilink
            arrow-up
            2
            ·
            vor 2 Jahren

            Isn’t // integer division?

            • Gebruikersnaam@lemmy.ml
              link
              fedilink
              arrow-up
              3
              ·
              vor 2 Jahren

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

              • Chrobin
                link
                fedilink
                arrow-up
                2
                ·
                vor 2 Jahren

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

                • Gebruikersnaam@lemmy.ml
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  vor 2 Jahren

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

          • dzervas@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            vor 2 Jahren

            you can do i: int to make this error out

            • Gebruikersnaam@lemmy.ml
              link
              fedilink
              arrow-up
              6
              ·
              vor 2 Jahren

              No, type hints are not enforced.

              • dzervas@lemmy.world
                link
                fedilink
                arrow-up
                1
                ·
                vor 2 Jahren

                damn

      • HappyRedditRefugee@lemm.ee
        link
        fedilink
        arrow-up
        6
        ·
        vor 2 Jahren

        In python you always have the right type, cause everything is an object

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: !programmerhumor@lemmy.ml

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.

  • 395 users / day
  • 288 users / week
  • 1.43K users / month
  • 5.81K users / 6 months
  • 851 local subscribers
  • 42K subscribers
  • 2.01K Posts
  • 41.2K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.mldeleted by creator
  • cat_programmer@lemmy.ml
  • BE: 0.19.18
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org