Skip to main content
added 29 characters in body
Source Link
POV
  • 12.1k
  • 40
  • 130
  • 229

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 

My final code is:

import controller.api

apiClass = controller.api.API()

When I try to set:

apiClass.api_key = 'NEW VALUE'

It gives me :

'NoneType' object has no attribute 'api_key'

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 

My final code is:

apiClass = controller.api.API()

When I try to set:

apiClass.api_key = 'NEW VALUE'

It gives me :

'NoneType' object has no attribute 'api_key'

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 

My final code is:

import controller.api

apiClass = controller.api.API()

When I try to set:

apiClass.api_key = 'NEW VALUE'

It gives me :

'NoneType' object has no attribute 'api_key'

added 193 characters in body
Source Link
POV
  • 12.1k
  • 40
  • 130
  • 229

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 

My final code is:

apiClass = controller.api.API()

When I try to set:

apiClass.api_key = 'NEW VALUE'

It gives me :

'NoneType' object has no attribute 'api_key'

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 

My final code is:

apiClass = controller.api.API()

When I try to set:

apiClass.api_key = 'NEW VALUE'

It gives me :

'NoneType' object has no attribute 'api_key'

added 10 characters in body
Source Link
POV
  • 12.1k
  • 40
  • 130
  • 229

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(api_key) 

I have class in file api.py that contains property:

class API(object):
    api_key = ''
    def add_advert(self):
        print(self.api_key)

In another class I use import class above:

import api
api = api.API()

Then in class I try to write value into property api_key:

api.api_key = 'NEW VALUE'

So, when I call another method from api class:

api.add_advert()

It does not return me new value for api_key:

def add_advert(self):
    print(self.api_key) 
Source Link
POV
  • 12.1k
  • 40
  • 130
  • 229
Loading