Issue is your logic
prod_location = location.id
Then the following if statement is never entered, and you move to
val['location_id'] = prod_location.id
And the error is thrown
Answer from OneCricketeer on Stack Overflowint object has no attribute 'num_die'
AttributeError: 'int' object has no attribute 'id'
python - 'int' object has no attribute 'id' - Stack Overflow
AttributeError: 'int' object has no attribute 'id' on odoo 9
Videos
Issue is your logic
prod_location = location.id
Then the following if statement is never entered, and you move to
val['location_id'] = prod_location.id
And the error is thrown
Yes correct. Some location don't exist on the system. That's it throws error. To avoid such error, you can use following trick.
prod_location = self.location and self.location.id or False
Means if system has location then prod_location variable set value with id of location otherwise False
NOTE:
In model declaration, location_id field set with required=False otherwise you can not create record with location_id=False It will give you integrity error.
As time = 3 is declared as an integer,
time.time doesn't have any sense since time is int variable (that isn't a class but a primitive data type). I suppose that you expected to call time (module) writing time but, since you're redefining it as an integer, this last definition shadows the time module
Change time variable name to something else, like myTime
Error messages are usefull, you should read them. Often the answer is contained directly into this errors/warning messages
You have variable time:
time = 3
and you have previously imported package time:
import time
When you try to do
time.time()
it seems that you try to call method time() of variable time (that contains int).
You should rename it and it will figure out conflicts with package name.
Assuming category is the category id. You need to get the CategoryChannel object from ctx.guild.categories and pass that as category in create_text_channel().
category_channel = discord.utils.get(ctx.guild.categories, id=category)
await ctx.guild.create_text_channel("~ " + user.name +" ~", category=category_channel, overwrites = perms)
try
await ctx.guild.create_text_channel('~ " + user.name +" ~', category=category, overwrites = perms)
I'm creating frequency dicts of lemmas and words, but have encountered this error and have no clue on what's going on, can anyone help me make sense of this?
If there's a better way of doing this please do tell!
https://imgur.com/a/sUR7DEJ
freq = defaultdict(dict)
def spcy(content, dir):
code = str(dir.lower())
model = code + "_core_news_sm"
models = spacy.util.get_installed_models()
if model in models:
#try:
nlp = spacy.load(model)
#print(model)
spcy = nlp(content)
for word in spcy:
if word.text.isalpha():
print(word)
print(type(freq.get(word.lemma_,{})))
freq[word.lemma_][word.text] = freq.get(word.lemma_,{}).get(word.text, 0) + 1
#except:
#print("exception")
#print(freq)
elif not model in models:
nlp = spacy.blank(code)
spcy = nlp(content)
for word in spcy:
if word.text.isalpha():
#does work...
freq[word.text] = freq.get(word.text, 0) + 1 # type: ignore
print(freq)So I was watching a tutorial on how to make a snake game in python but I got the error AttributeError: 'int' object has not attribute '_speed'. I can't understand what is wrong. This is the program (it's not finished):
#imports
import turtle
import time
import random
#variables
delay = 0.1
score = 0
high_score = 0
#Creating a window screen
wn = turtle.Screen()
wn.title("Snake Game")
wn.bgcolor("yellow")
#the width and height can be put as user's choice
wn.setup(width=600, height=600)
wn.tracer(0)
#head of the snake
head = turtle.Turtle()
head.shape("square")
head.color("white")
head.penup
head.goto(0, 0)
head.direction = "Stop"
#food in the game
food = turtle.Turtle
colors = random.choice(['red', 'green', 'black'])
shapes = random.choice(['square', 'triangle', 'circle'])
food.speed(0)
food.shape(shapes)
food.color(colors)
food.penup()
food.goto(0, 100)
pen = turtle.Turtle()
pen.speed(0)
pen.shape("square")
pen.color("white")
pen.penup()
pen.hideturtle()
pen.goto(0, 250)
pen.write("Score : 0 High Score : 0", align="center",
font=("candara", 24, "bold"))
# assigning key directions
def goup():
if head.direction != "up":
head.direction = "down"
def godown():
if head.direction != "down":
head.direction = "up"
def goleft():
if head.direction != "right":
head.direction = "left"
def goright():
if head.direction != "left":
head.direction = "right"
def move():
if head.direction == "up":
y = head.ycor()
head.sety(y+20)
if head.direction == "down":
y = head.ycor()
head.sety(y-20)
if head.direction == "left":
x = head.xcor()
head.setx(x-20)
if head.direction == "right":
x = head.xcor()
head.setx(x+20)
wn.listen()
wn.onkeypress(goup, "w")
wn.onkeypress(godown, "s")
wn.onkeypress(goleft, "a")
wn.onkeypress(goright, "d")
row[field.type]
field is just a simple integer counter and has no type property.
if rowU[field] == None and type(row[field]) == "String":
You need the built-in type() function so try the above instead.
Convert
if rowU[field] == None and row[field.type] == "String"
into
if rowU[field] == None and type(row[field]) == str