This profile is from a federated server and may be incomplete. View on remote instance

decivex , to Python in Why can't I append to list inside of a list comprehension?

I know I'm being somewhat pedantic but range() returns an iterable range type, not a list, in python 3.

decivex , to Today I Learned in TIL about Roko's Basilisk, a thought experiment considered by some to be an "information hazard" - a concept or idea that can cause you harm by you simply knowing/understanding it

Make your own rules.

decivex , to Python in Why can't I append to list inside of a list comprehension?
  1. list.append returns None so what you've actually got is a list comprehension that generates a list containing the value None 19 times. (using functions with side effects, such as list.append, in list comprehensions are generally bad style so you should avoid this)
  2. The list[...] syntax retrieves elements from the list, which is not what you're trying to do here. (and it is actually invalid syntax in this case)
  3. You should generally avoid calling lists list, because list is already a builtin.

If you want to append the numbers 1 to 19 to a list as you're trying to do you can call the list.extend function with the list comprehension [value for value in range(1, 20)] as the argument. (Although in this case you can also just use the range directly.) To do it without list comprehensions you can simply loop over the range and repeatedly call the append function.

decivex , to Today I Learned in TIL about Roko's Basilisk, a thought experiment considered by some to be an "information hazard" - a concept or idea that can cause you harm by you simply knowing/understanding it

Thanks! I just won the game!

decivex , to Technology in I Will Fucking Piledrive You If You Mention AI Again — Ludicity

It's not a paper, it's a stream-of-consciousness style blog post.

decivex , (edited ) to Piracy: ꜱᴀɪʟ ᴛʜᴇ ʜɪɢʜ ꜱᴇᴀꜱ in Why do some peers have unusual client names

You can also use & to get &.

Edit: Fuck, I meant &

Edit 2: &

Okay nevermind, either lemmy or sync resolves html entities recursively apparently.

Edit 3: &

decivex , to ADHD memes in If I don't overshoot my planned sleeping time by 1 hour doomscrolling, I'm usually sick.

I've taken to listening to the Cobalt Core soundtrack, I never remember getting very far so I guess it works.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • kbinchat
  • All magazines