Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cleaner way to rewrite
#6
Lists don't store values; they store references to memory locations. Anything that returns an object (and everything in Python is an object) has a memory location. So, each index in a list can be conceptualized as a variable storing a reference to some object. Leveraging that, we can do things like the code above to store anonymous objects.

The same holds true for tuples, sets, and dicts as well, but they aren't necessarily as useful in this case as a list.
Reply


Messages In This Thread
Cleaner way to rewrite - by fakka - Dec-03-2019, 09:48 PM
RE: Cleaner way to rewrite - by michael1789 - Dec-03-2019, 09:58 PM
RE: Cleaner way to rewrite - by stullis - Dec-03-2019, 10:34 PM
RE: Cleaner way to rewrite - by buran - Dec-04-2019, 09:36 AM
RE: Cleaner way to rewrite - by fakka - Dec-04-2019, 04:16 PM
RE: Cleaner way to rewrite - by stullis - Dec-05-2019, 04:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  loop for dynamic cut string - cleaner way? korenron 4 1,950 Nov-22-2021, 02:30 PM
Last Post: korenron
  Optmized way to rewrite this very slow code liva28 0 1,499 Jul-18-2021, 12:16 PM
Last Post: liva28
  How do I rewrite this .bat file code onto Python? SteampunkMaverick12 4 2,857 Nov-02-2019, 11:28 PM
Last Post: snippsat
  Rewrite a function to make it work with 'bottle-pymysql' nikos 1 1,979 Feb-26-2019, 02:59 PM
Last Post: nikos
  piexif rewrite exif data yawstick 2 3,334 Oct-09-2018, 08:56 PM
Last Post: yawstick
  Not having to rewrite 'obj.' on each line beuaaa 4 3,162 Sep-30-2018, 02:21 AM
Last Post: micseydel
  How to rewrite image file name based on ocr data.txt kevinchr 0 3,650 Apr-16-2018, 07:09 PM
Last Post: kevinchr
  how do i rewrite this code to give me 10 outputs BlackPimpernel 2 2,677 Mar-29-2018, 11:29 AM
Last Post: BlackPimpernel
  Rewrite variable every n times andrea0913 0 2,610 Aug-20-2017, 05:54 PM
Last Post: andrea0913

Forum Jump:

User Panel Messages

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