Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How does numpy do this?
#3
Ok let me explain it with a very simple example then.
I know the following doesn't work but it to shows what I am trying to do.

class Foo(object):
    
    def __new__(cls):
        cls.someVar = 5
        return cls.someVar
    
    def asList():
        return [cls.someVar]
               
f = Foo()   # Resutl: 5
f.asList()  # <-- I would like be able to do this and get: [5]
I get why it doesn't work, because f return an integer and it doesn't have that asList() method. So basically what I meant is if it possible to do what I intended in code above.
Reply


Messages In This Thread
How does numpy do this? - by rudihammad - Jun-19-2020, 06:08 AM
RE: How does numpy do this? - by ndc85430 - Jun-19-2020, 06:14 AM
RE: How does numpy do this? - by rudihammad - Jun-19-2020, 06:41 AM
RE: How does numpy do this? - by buran - Jun-19-2020, 06:43 AM
RE: How does numpy do this? - by buran - Jun-19-2020, 06:44 AM
RE: How does numpy do this? - by rudihammad - Jun-19-2020, 07:17 AM

Forum Jump:

User Panel Messages

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