Python Forum
Compiler fault or some kind of weird referencing bug?
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiler fault or some kind of weird referencing bug?
#11
(May-09-2017, 08:32 PM)volcano63 Wrote: return a new encoded list - instead of changing the argument list in place (which is side-effect - considered bad practice?! )
Yes, side-effects are generally-speaking not ideal, and don't gain anything here (sometimes modifying in-place is more efficient, but copies are being made here anyway).
Reply
#12
(May-08-2017, 12:07 AM)Joseph_f2 Wrote:
for x in range(0, 16):
    data.append(x)
I was planning to point it out - but got distracted. Those 2 lines are absolutely redundant
data = list(range(16))
does the trick. (One of the few things from Scala/Java I personally miss in Python - toList method  Huh )
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  When does Python need to use a compiler? JanOlvegg 5 2,927 Mar-09-2023, 04:24 PM
Last Post: snippsat
  What kind of list is this? jesse68 2 1,103 Jun-29-2022, 05:02 PM
Last Post: rob101
  make: *** [Makefile:29: all] Segmentation fault Anldra12 2 1,814 May-01-2022, 06:17 PM
Last Post: Anldra12
  name 'lblstatus' is not defined when referencing a label KatManDEW 4 1,471 Apr-21-2022, 12:33 PM
Last Post: KatManDEW
  Dictionary Referencing nickdavis2017 1 1,567 Nov-20-2021, 06:24 PM
Last Post: deanhystad
  Referencing string names in df to outside variables illmattic 1 1,329 Nov-16-2021, 12:47 PM
Last Post: jefsummers
  Segmentation fault (core dumped) hobbyist 1 10,352 Jun-07-2021, 12:56 PM
Last Post: supuflounder
  splitting lines, need to add element of same kind tester_V 6 3,072 Feb-20-2021, 11:51 PM
Last Post: tester_V
  What kind of object is this? Moris526 5 2,445 Dec-27-2020, 06:41 AM
Last Post: Gribouillis
  Referencing a fixed cell Mark17 2 2,020 Dec-17-2020, 07:14 PM
Last Post: Mark17

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020