Python execution problem from cpp shared object /u/Rough_Metal_9999 Python Education

Python execution problem from cpp shared object /u/Rough_Metal_9999 Python Education

I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program

everything works fine when i run cpp program it executes and prints hello world

when i make so file , and call the same function from .py file and run the py file it gives me error of

<code>

free(): invalid pointer
zsh: IOT instruction (core dumped) python3 main.py

</code>

i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method

itry to execute the function call with another thread same error occour

Why this happend and how i solve it

submitted by /u/Rough_Metal_9999
[link] [comments]

​r/learnpython I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program everything works fine when i run cpp program it executes and prints hello world when i make so file , and call the same function from .py file and run the py file it gives me error of <code> free(): invalid pointer zsh: IOT instruction (core dumped) python3 main.py </code> i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method itry to execute the function call with another thread same error occour ​ Why this happend and how i solve it submitted by /u/Rough_Metal_9999 [link] [comments] 

I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program

everything works fine when i run cpp program it executes and prints hello world

when i make so file , and call the same function from .py file and run the py file it gives me error of

<code>

free(): invalid pointer
zsh: IOT instruction (core dumped) python3 main.py

</code>

i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method

itry to execute the function call with another thread same error occour

Why this happend and how i solve it

submitted by /u/Rough_Metal_9999
[link] [comments]  I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program everything works fine when i run cpp program it executes and prints hello world when i make so file , and call the same function from .py file and run the py file it gives me error of <code> free(): invalid pointer zsh: IOT instruction (core dumped) python3 main.py </code> i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method itry to execute the function call with another thread same error occour ​ Why this happend and how i solve it submitted by /u/Rough_Metal_9999 [link] [comments]

Read more

I’m struggling with learning python /u/Affectionate_Play180 Python Education

I’m struggling with learning python /u/Affectionate_Play180 Python Education

So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated.

submitted by /u/Affectionate_Play180
[link] [comments]

​r/learnpython So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated. submitted by /u/Affectionate_Play180 [link] [comments] 

So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated.

submitted by /u/Affectionate_Play180
[link] [comments]  So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated. submitted by /u/Affectionate_Play180 [link] [comments]

Read more

Can you filter pandas dataframes by Day/Month date without year? Writing a generalised function for between date that is year agnostic is proving difficult. /u/Statnamara Python Education

Can you filter pandas dataframes by Day/Month date without year? Writing a generalised function for between date that is year agnostic is proving difficult. /u/Statnamara Python Education

Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write

df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15)

This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc.

A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic.

submitted by /u/Statnamara
[link] [comments]

​r/learnpython Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15) This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc. A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic. submitted by /u/Statnamara [link] [comments] 

Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write

df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15)

This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc.

A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic.

submitted by /u/Statnamara
[link] [comments]  Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15) This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc. A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic. submitted by /u/Statnamara [link] [comments]

Read more

Issue raising exceptions – Beginner project /u/benmilesrocks Python Education

Issue raising exceptions – Beginner project /u/benmilesrocks Python Education

Hi everyone!

Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code:

def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v)

v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10)

print(“The number is:”, v)

I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!!

submitted by /u/benmilesrocks
[link] [comments]

​r/learnpython Hi everyone! Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code: def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!! submitted by /u/benmilesrocks [link] [comments] 

Hi everyone!

Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code:

def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v)

v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10)

print(“The number is:”, v)

I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!!

submitted by /u/benmilesrocks
[link] [comments]  Hi everyone! Trying to make a simple code to handle exceptions. The task is to make a piece of code that checks if an inputted number is between a specified range (in this case -10 to 10). I can make it handle an exception if it falls out of the range, no problem. But I also need a ValueError exception if somebody inputs non numeric values. But I can’t make the ValueError exception work for some reason. Here’s the code: def read_int(prompt, min, max): try: if prompt in range(min, max): return str(prompt) if prompt not in range(min, max): raise IndexError except IndexError: return “Error: Value not in range ” + str(min) + “, ” + str(max) except ValueError: return “Error: Wrong input” v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) v = read_int(int(input(“Enter a number from -10 to 10: “)), -10, 10) print(“The number is:”, v) I’m certain that it’s something REALLY basic that I’m missing here, but I can’t figure it out for the life of me. Please help!! submitted by /u/benmilesrocks [link] [comments]

Read more

Problems with using list /u/Easy-Paramedic-5611 Python Education

Problems with using list /u/Easy-Paramedic-5611 Python Education

Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead

submitted by /u/Easy-Paramedic-5611
[link] [comments]

​r/learnpython Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead submitted by /u/Easy-Paramedic-5611 [link] [comments] 

Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead

submitted by /u/Easy-Paramedic-5611
[link] [comments]  Alright, basically. I am working on a random script to “find clothes” and clothes are in a list. So we got shoes and all such, in a list. All though i can’t seem to figure out how to print only one of the elements in the list. I originally used “` random.choice(clothes) “` but then i couldn’t figure out how to remove that option from the list, because if that is a choice i’d do that instead submitted by /u/Easy-Paramedic-5611 [link] [comments]

Read more

Ask Anything Monday – Weekly Thread /u/AutoModerator Python Education

Ask Anything Monday – Weekly Thread /u/AutoModerator Python Education

Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread

Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread.

* It’s primarily intended for simple questions but as long as it’s about python it’s allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban.

That’s it.

submitted by /u/AutoModerator
[link] [comments]

​r/learnpython Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread. * It’s primarily intended for simple questions but as long as it’s about python it’s allowed. If you have any suggestions or questions about this thread use the message the moderators button in the sidebar. Rules: Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban. That’s it. submitted by /u/AutoModerator [link] [comments] 

Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread

Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread.

* It’s primarily intended for simple questions but as long as it’s about python it’s allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban.

That’s it.

submitted by /u/AutoModerator
[link] [comments]  Welcome to another /r/learnPython weekly “Ask Anything* Monday” thread Here you can ask all the questions that you wanted to ask but didn’t feel like making a new thread. * It’s primarily intended for simple questions but as long as it’s about python it’s allowed. If you have any suggestions or questions about this thread use the message the moderators button in the sidebar. Rules: Don’t downvote stuff – instead explain what’s wrong with the comment, if it’s against the rules “report” it and it will be dealt with. Don’t post stuff that doesn’t have absolutely anything to do with python. Don’t make fun of someone for not knowing something, insult anyone etc – this will result in an immediate ban. That’s it. submitted by /u/AutoModerator [link] [comments]

Read more