Python Forum
Attibute Error: Two methods in a class, one I can reach, the other not (phantom file?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attibute Error: Two methods in a class, one I can reach, the other not (phantom file?
#1
This is my first post so ... forgive any faux pas.
Error:
AttributeError: 'DatabaseProcess' object has no attribute 'update_card_in_information_from_card_number'
Python3.6 asyncio

This seems straightforward, right? The name must be wrong:

The calling program: Note that the first line causes a problem. If that line is commented the second line succeeeds.

import asyncio
import logging
import json
from Database.database import Database
from Database.database_processes import DatabaseProcess
...
        self.dbprocess = DatabaseProcess(self.log, self.database)
---
        await self.dbprocess.update_card_in_information_from_card_number(request.requestor, request.card_number)
        request.card_record = await self.dbprocess.get_card_record_from_card_number(request.card_number)
Here is the class(callee):

import asyncio
import logging

class DatabaseProcess(object):
    def __init__(self, log, database):
        self.database = database

...
    async def get_card_record_from_card_number(self, card_number):
        stmt = "select * from cards where card_number = '{}' and dt_inactivated is null".format(card_number)

...
    async def update_card_in_information_from_card_number(self, machine_id, card_number):
        exec_stmt = "update cards set dt_last_inserted = now(), last_machine_id = %s where card_number = %s"
...
Here is where it goes bonkers: if I go to the file database_processes.py which contains the DatabaseProcess class and mangle the second name, the one that works, it keeps working.

Aha! we say, must be a duplicate file somewhere in teh path where this class is defined as well ...

It seems not!

grep 'class DatabaseProcess' find / -name 'database*.py'

grep 'a' find . -name 'database*.py'


root@glaptop:/home/.../Database# grep 'class DatabaseProcess' find .../projects/ -name '*.py*'
/home/gary/projects/Brix/Database/database_processes.py:class DatabaseProcess(object):

FINDS IT, that is where I expect it to be. The search starts very high in the directory tree, high enough to find it anywhere.

But this finds nothing in dist-packages (and I wuld not exepct it to becasue this is a dev box)
root@gary-laptop:/home/.../Database# grep 'class DatabaseProcess' find /usr/lib/python3/dist-packages/ -name '*.py*'

What am I missing? Thanks for helpting!
Reply


Messages In This Thread
Attibute Error: Two methods in a class, one I can reach, the other not (phantom file? - by GaryKuipers - Aug-27-2018, 07:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Class test : good way to split methods into several files paul18fr 5 3,885 Jul-17-2024, 11:12 AM
Last Post: felixandrea
  [split] Class and methods ebn852_pan 15 3,440 May-23-2024, 11:57 PM
Last Post: ebn852_pan
  Class and methods Saida2024 2 1,139 May-13-2024, 04:04 AM
Last Post: deanhystad
  error occuring in definition a class akbarza 3 2,310 Nov-26-2023, 09:28 AM
Last Post: Yoriz
  Structuring a large class: privite vs public methods 6hearts 3 1,953 May-05-2023, 10:06 AM
Last Post: Gribouillis
  "<class 'typeerror'>: don't know how to convert" error GiggsB 3 5,504 Feb-28-2022, 06:45 PM
Last Post: GiggsB
  access share attributed among several class methods drSlump 0 1,576 Nov-18-2021, 03:02 PM
Last Post: drSlump
  a function common to methods of a class Skaperen 7 4,062 Oct-04-2021, 07:07 PM
Last Post: Skaperen
  Helps with reading csv file - 3 methods hhchenfx 4 5,098 May-13-2021, 04:15 AM
Last Post: buran
  Listing All Methods Of Associated With A Class JoeDainton123 3 3,104 May-10-2021, 01:46 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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