Search results

  1. didlly

    Python Encapsulation in Python

    I recently learned about encapsulation in Python, and how you could specify private variables in classes that can't be accessed outside of the class (by prefacing the variable with '__'). However, this actually only mangles the name of the variable to...
  2. didlly

    Python How to kill a thread?

    @Sigma Example using a global variable to tell the thread to stop. Please note that there will be a time after 'thread_stop' is set to 'True' while the thread is still running as we have to wait for the thread to get to the code which checks the variable's value. from threading import Thread...
  3. didlly

    Python How to kill a thread?

    Threads are non-killable (or at least Python doesn't have a thread kill implementation by default). You could use global variables or variables in a specific file and have the thread periodically check the value of that variable. Or you can use processes if you don't mind separate processes, and...
  4. didlly

    Python What is this feature called and what other languages have it?

    TL;DR: `exec` is a function in interpreted programming languages that execute the code passed to them. They are not found in compiled programming languages because the code has already been compiled to machine code. `exec` is a function in Python used for dynamic execution of Python code. It...
  5. didlly

    C Feedback on hash table implementation.

    Ah sorry, I didn't realize that, since I added those keys especially for the posting the code here.
  6. didlly

    C Feedback on hash table implementation.

    As C programmers will know, C doesn't have a implementation for dictionaries, and so you have to implement your own using hash maps. I am new to C, and created a hash map implementation, and would be grateful for any feedback. The program also uses a custom list implementation to allow easy...
  7. didlly

    Python Military Time Converter Assignment

    @menator01 Yep, they don't work.
  8. didlly

    Python Military Time Converter Assignment

    I'm not sure if those will work on Windows, here's a file of all the ANSI Escape Sequences I have that are cross platform. Please note that the old windows terminal doesn't support these (the new one does though). https://github.com/splewdge/Python-ANSI-Escape-Sequences...
  9. didlly

    Python Military Time Converter Assignment

    This should work: military_time = input("Enter the military time: ") military_hour, minute = military_time[:2], military_time[2:] if military_hour == "00": hour = "12" state = "AM" elif int(military_hour) > 12: hour = int(military_hour) - 12 state = "PM" else: hour = military_hour...
  10. didlly

    Python Removing a character from a string using user input

    Why are you using an if statement to check if the char is in the string? Even if the char isn't in the string `.replace` won't raise an error.
  11. didlly

    PDF to Images

    Try: python -m ensurepip Then, install each of the modules by doing the following: python -m pip install [package]
  12. didlly

    Creepy Hugs

    Hmmmmmm...
  13. didlly

    PHP Why does ../ work but not / for relative file paths?

    We are not talking about the difference between how OSes handle `/`, we are talking about the difference in how HTML and PHP handle the `/` character. HTML handles it as go to the root of the directory being served. PHP handles it as go to the root of the drive.
  14. didlly

    PDF to Images

    @Johna Did you have the `Install Pip` option selected when installing Python?
  15. didlly

    Python Floating point numbers subtracting incorrectly

    Rounding by the highest amount of decimals out of the two numbers should work @Johna.
  16. didlly

    Python Floating point numbers subtracting incorrectly

    If you want the exact output, 2 - 1.23456789
  17. didlly

    Python Floating point numbers subtracting incorrectly

    That won't work for all subtractions.
  18. didlly

    Python Floating point numbers subtracting incorrectly

    This is due to limitations in Binary. You can't practically represent decimals in Binary. For computer purposes `2.5199999999999996` is close enough to `2.52`. See this post.
  19. didlly

    PHP Why does ../ work but not / for relative file paths?

    @Johna Have a look at this.
  20. didlly

    What Linux-Distro Are You Using?

    I dual boot between Windows and Zorin OS 16 Professional.
Top