Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
Jason Novinger ( jnovinger@programming.dev ) M to Python@programming.dev · 3 years ago

[Meme] Swapping integers in Python

lemmy.world

message-square
17
link
fedilink
  • cross-posted to:
  • bumba@boomer.casino
  • programmerhumor@lemmy.ml
37

[Meme] Swapping integers in Python

lemmy.world

Jason Novinger ( jnovinger@programming.dev ) M to Python@programming.dev · 3 years ago
message-square
17
link
fedilink
  • cross-posted to:
  • bumba@boomer.casino
  • programmerhumor@lemmy.ml

Yay or nay, memes should be allowed in !python@programming.dev ?

alert-triangle
You must log in or # to comment.
  • Vahtos ( vahtos@programming.dev ) 
    link
    fedilink
    arrow-up
    12
    ·
    3 years ago

    Isn’t c/Programmer Humor already for memes?

    • ruffsl ( ruffsl@programming.dev ) 
      link
      fedilink
      arrow-up
      6
      ·
      3 years ago

      Hear, hear!

      I’d prefer to keep all lang communities on topic. E.g. I occasionally block and unblock !c/programmer_humor when I want to read technical news or just have a laugh. If memes crossed into all local subs, then the noise-to-news ratio couldn’t be customized as easily.

      Although I suppose tagging posts would be a better compromise.
      Does Lemmy support tagging posts, or filtering feeds by tag yet?

      • Vahtos ( vahtos@programming.dev ) 
        link
        fedilink
        arrow-up
        4
        ·
        3 years ago

        My thoughts exactly. Tagging them (if possible) is OK, but kind of annoying to need to go to all these different communities and filter memes when there is already a dedicated community for programming memes.

        It also may turn off new arrivals that may be looking for a more serious community, and think all/most of the content is memes.

      • LaggyKar ( LaggyKar@programming.dev ) 
        link
        fedilink
        arrow-up
        4
        ·
        3 years ago

        Agreed, let’s keep memes separate from serious posts

      • snowe ( snowe@programming.dev ) 
        link
        fedilink
        arrow-up
        3
        ·
        3 years ago

        @Ategon@programming.dev is working on tagging, but I wouldn’t expect it anytime soon. It’s a big feature.

      • Jakob ( Jakob@programming.dev ) 
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        Tagging would make sense if the community becomes larger and naturally people start requesting it. For now, I think memes should stay in Pr. Humor

      • pythonoob ( pythonoob@programming.dev ) 
        link
        fedilink
        arrow-up
        1
        ·
        3 years ago

        I didn’t care before but you make a good point. I vote keep them separate.

  • ActuallyRuben ( ActuallyRuben@actuallyruben.nl ) 
    link
    fedilink
    arrow-up
    3
    ·
    3 years ago
    a ^= b
    b ^= a
    a ^= b
    
    • Hammerheart ( Hammerheart@programming.dev ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      I’m gonna need you to elaborate on this one

      • dmad ( dmad@programming.dev ) 
        link
        fedilink
        arrow-up
        5
        ·
        3 years ago

        xor has the property x ^ x = 0, and x ^ 0 = x. So, x ^ x ^ y = y

        a' = a ^ b
        b' = b ^ a' = b ^ (a ^ b) = a
        a'' = (a ^ b) ^ a = b
        

        This is pretty clever, I’ve never seen this for a swap.

        • ActuallyRuben ( ActuallyRuben@actuallyruben.nl ) 
          link
          fedilink
          arrow-up
          2
          ·
          3 years ago

          Couldn’t have explained it better myself. I don’t remember where exactly I first read about this trick, but it’s mainly useful in C or Assembly, as you don’t have to resort to using a third variable/register.

  • sociablefish ( sociablefish@programming.dev ) 
    link
    fedilink
    arrow-up
    2
    ·
    3 years ago

    yay

  • Jason Novinger ( jnovinger@programming.dev ) OP
    link
    fedilink
    arrow-up
    2
    ·
    3 years ago

    I used Lemmy’s cross-post functionality, but it doesn’t seem to have marked it?! Original post is https://lemmy.ml/post/1213162

    • Ategon ( Ategon@programming.dev ) 
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      It looks like it marked it on my end. Lemmy has two different cross post functionalities based on how you cross post, one where it shows the original post in the text and one where it shows up as a link under the new post

      • Jason Novinger ( jnovinger@programming.dev ) OP
        link
        fedilink
        arrow-up
        1
        ·
        3 years ago

        Ah, I am seeing that now, thanks!

        I’m not sure if that was there originally and I just missed it or if Lemmy added it later when it got around to it.

Python@programming.dev

python@programming.dev

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: !python@programming.dev

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events
Past

November 2023

  • PyCon Ireland 2023, 11-12th
  • PyData Tel Aviv 2023 14th

October 2023

  • PyConES Canarias 2023, 6-8th
  • DjangoCon US 2023, 16-20th (!django 💬)

July 2023

  • PyDelhi Meetup, 2nd
  • PyCon Israel, 4-5th
  • DFW Pythoneers, 6th
  • Django Girls Abraka, 6-7th
  • SciPy 2023 10-16th, Austin
  • IndyPy, 11th
  • Leipzig Python User Group, 11th
  • Austin Python, 12th
  • EuroPython 2023, 17-23rd
  • Austin Python: Evening of Coding, 18th
  • PyHEP.dev 2023 - “Python in HEP” Developer’s Workshop, 25th

August 2023

  • PyLadies Dublin, 15th
  • EuroSciPy 2023, 14-18th

September 2023

  • PyData Amsterdam, 14-16th
  • PyCon UK, 22nd - 25th
🐍 Python project:
  • Python
  • Documentation
  • News & Blog
  • Python Planet blog aggregator
💓 Python Community:
  • #python IRC for general questions
  • #python-dev IRC for CPython developers
  • PySlackers Slack channel
  • Python Discord server
  • Python Weekly newsletters
  • Mailing lists
  • Forum
✨ Python Ecosystem:
  • pyvideo
  • Awesome Python
  • PyCon US 2023 and videos!
🌌 Fediverse
Communities
  • #python on Mastodon
  • c/django on programming.dev
  • c/pythorhead on lemmy.dbzer0.com
Projects
  • Pythörhead: a Python library for interacting with Lemmy
  • Plemmy: a Python package for accessing the Lemmy API
  • pylemmy pylemmy enables simple access to Lemmy’s API with Python
  • mastodon.py, a Python wrapper for the Mastodon API
Feeds
  • Active c/Python posts
  • New c/Python posts
Visibility: Public
globe

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

  • 1 user / day
  • 14 users / week
  • 93 users / month
  • 276 users / 6 months
  • 104 local subscribers
  • 8.06K subscribers
  • 632 Posts
  • 1.96K Comments
  • Modlog
  • mods:
  • Erlingur ( erlingur@programming.dev ) 
  • Jason Novinger ( jnovinger@programming.dev ) 
  • Luis Norambuena ( norambna@programming.dev ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code