Categories
Mastering Development

‘list’ object has no attribute ‘fitness’ ERROR

import random class Individual(object): ”’ Class representing individual in population ”’ def __init__(self, chromosome): self.chromosome = chromosome self.fitness = self.fitness() @classmethod def mutate(chromosome): ”’ random change value of a random col ”’ # randomly choose mutation position col = random.randint(0, len(chromosome)-1) row = random.randint(0, len(chromosome)-1) chromosome[col] = row return chromosome @classmethod def create_chromosome(self,size): ”’ create […]

Categories
Mastering Development System & Network

how to print lists inside tuple in python

i got lists inside a tuple. At least i think thats what i have (i did not code it): nvts = {"high": [], "medium": [], "low": [], "log": []} I want to print the values inside "high", "medium" etc. i tried a for-loop: for a, *b in nvts: print(a, ‘ ‘.join(map(str, b))) but it gives […]

Categories
Development

python pass to C-API structure with a pointer to another structure as an element

What is the best way to pass from python 3.6.9 to C-API struct I have a C library, which I’m trying to create a Python interface for it, but the library expects to initialize a struct beforehand, the main problem is that one element of a struct is a pointer to another struct. The part […]

Categories
Development

Controlling website with Alexa voice commands

It is my first time asking the question here. I am completely new to Alexa. I wanted to know if it is possible to control website with Alexa voice commands? I have a website which makes appointments for car services where the users should be able to contol the website eg: Login to the website […]

Categories
Development

Ho do I change unicode u’\xb0C’ from SQL to string °C in python?

I SELECT data from SQL into temp_data dictionary but there is a unit value like “u’t_unit’: u’\xb0C'” which I can’t convert to string °C in python. Python Code: temp_data = [{u’thresh_id’: 508, u’app_guid’: u’7D83E6F8D879BE17C95D14879159973A’, u’override’: 1, u’thresh_guid’: u’BB8F3E8184783E0416EEA7D19D9C9FBC’, u’app_id’: 1102, u’edit_user’: 1, u’h_range’: Decimal(‘100.000′), u’t_type’: 1, u’t_value’: Decimal(‘0.000′), u’l_range’: Decimal(‘0.000′), u’t_unit’: u’\xb0C’, u’edit_date’: datetime.datetime(2019, 4, […]