Python Forum
Why does this hang the system up
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does this hang the system up
#11
(Jun-09-2017, 12:16 AM)nilamo Wrote: Just because we know python, doesn't mean we know all of the 3rd party packages that have ever been written for it :p

I am so, so, so Sorry. Not meant the way I wrote it. Thanks so much for your very kind patience. Because of it, I have now learned some new things. Please do not leave me. I can not even get the simplest of Python programs to work right now.

The program I am trying to adapt, not written by me, has some serious flaws, as I see it, and my knowledge of Python is so limited it has been quite a struggle. We are getting there.

The code I have, the way it is now, does seem to work as is. In view of this, for now, it is my intent to just make the changes needed if possible.

In my very humble opinion, raising an exception is not a good way to end a program. I would like to do it a different way other than raising an exception and do not know how. If you can think of anything, please let me know otherwise I will move on to other issues not yet addressed in code.

Thanks again to all here. You are a life saver for me.
Reply
#12
(Jun-09-2017, 08:29 AM)Able98 Wrote: my knowledge of Python is so limited it has been quite a struggle

Seems to me that with limited knowledge, trying to 'adapt' someone else's code, would indeed be quite a struggle, particularly if you do not completely understand what the original author is trying to accomplish with a certain segment of code, if not the entire script. My advice would be to set this project aside for the time being until you become more proficient at Python, or start your own script, adding to it as your proficiency grows. Personally, I think the later would be of greater benefit to you. If you wish to continue with your current path, you should post a link to the code, in it's entirety, and what it is that you are hoping to 'adapt' it to do. Be warned though, that continuing to follow this line of action is going to lead to more struggles, disappointment and frustration above and beyond what you're normally going to encounter as a new programmer in Python.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#13
You can end the program by calling sys.exit
import sys

# the rest of the program

sys.exit('some message or nothing')
Usually I put in sys.exit main function so the system gets the exit code of the program this way.

sys.exit(main())
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#14
(Jun-09-2017, 01:03 PM)sparkz_alot Wrote: If you wish to continue with your current path, you should post a link to the code, in it's entirety, and what it is that you are hoping to 'adapt' it to do.

The original program is here: https://github.com/danielchalef/pyethrecoverv3

It needs a few changes for Python3.

The major thing that needs adaption I feel is replacing this:

def generate_all(el, tr): #taken from pyethrecover
    if el:
        for j in range(len(el[0])):
            for w in generate_all(el[1:], tr + el[0][j]):
                # print(w)
                yield w
    else:
        yield tr
The number of possibilities for me will be in the millions and so instead want to generate them one by one in sequence as needed.
I know roughly how I would do it in C but not in Pyhon.

Another thing that shoud be added to the program is some means of recording the last sequence tested to file in case of a computer crash so we can restart at the point left off.

Those are the two main things I can think of now. That would add two more items to this topic and be confusing, so perhaps starting a new topic for each may be better. Thanks.
Reply
#15
Hi Able98
Unfortunately I'm in the exact same situation as you are...
Did you manage to solve code issues?
A bit of help will truly assist here.
Thanks
Reply
#16
(Sep-01-2017, 11:40 AM)Gil77 Wrote: Hi Able98
Unfortunately I'm in the exact same situation as you are...
Did you manage to solve code issues?
A bit of help will truly assist here.
Thanks

Very few things in life are exactly the same as something else.  This thread hasn't been replied to in more than two months, and the original poster is not likely to return (statistically speaking).  Your best bet would be to start a new thread, with details about your specific situation.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,492 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  multiprocess hang when certain number is used in the program esphi 7 3,113 Nov-06-2020, 03:49 PM
Last Post: esphi
Question Difference between Python's os.system and Perl's system command Agile741 13 6,651 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Hang man game supermane 2 2,218 Aug-15-2018, 12:07 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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