Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

fizzlesticks

Member
  • Content Count

    1,194
  • Joined

  • Last visited

Everything posted by fizzlesticks

  1. fizzlesticks

    List Comprehension Help- Python

    You can use anything you would would use in a normal if statement. if wkd[1] == 'Sunday' or wkd[1] == 'Saturday' or if wkd[1] in ('Sunday', 'Saturday')
  2. fizzlesticks

    why am i getting this error in PYTHON 3

    You're missing a ).
  3. fizzlesticks

    Function

    Lambdas mostly.
  4. fizzlesticks

    Function

    You use things that don't need indenting. For example here's elpiops answer in 1 line: print(dict((lambda d: (d, [d[name].add(item) for name, item in [("Thomas", "pen"), ("Mike", "pencilcase"), ("Thomas", "rubber"), ("Tom", "scissors")]])[0])(__import__('collections').defaultdict(set))))
  5. fizzlesticks

    Function

    Anything that can be written in Python can be written in 1 line, it might look silly sometimes though.
  6. Hashed, not encrypted. It could be encrypted, though that's almost as bad as plain text. Yes, many website store your last X passwords so you can't reuse them. They're still hashed and if they're not your current password that shouldn't be a problem.
  7. fizzlesticks

    Calculate math from string // c++

    std::deques have tons of overhead and are inefficient in how they store data compared to a std::vector. For a smallish program like you'll never be able to notice the difference but it's something to keep in mind for other things. std containers have constructors that can do this work for you. std::deque<std::string> uMathCont(std::cbegin(uMathInput), std::cend(uMathInput)); However when you iterate over the input string you're iterating over characters not strings, so it should really be std::deque<char>. edit: if you're using a c++17 compatible compiler (which you should be!) you can let the compiler figure that out for you and just write std::deque deq(std::cbegin(uMathInput), std::cend(uMathInput)); std::endl isn't just a way to write a newline character, it also forces a flush which can have a huge impact on performance (again not really noticeable in a small program like this.) For more a bit more info on that you can check out these 2 videos https://www.youtube.com/watch?v=GMqQOEZYVJQ https://www.youtube.com/watch?v=lHGR_kH0PNA Lastly when posting code please copy/paste into code tags instead of taking a picture.
  8. fizzlesticks

    Calculate math from string // c++

    std::getline Should pretty much not be used. Unless you plan on allowing equations that are millions of characters long std::vector will be better in every way (even push_front.)
  9. fizzlesticks

    N00b Python question

    Check out java.util.function, they have ways of doing the same thing. There's not really anything "non OOP" about storing then calling a function pointer.
  10. fizzlesticks

    N00b Python question

    What language do you usually use? Pretty much every popular language has some kind of function pointer like thing that works just like this.
  11. fizzlesticks

    N00b Python question

    object.bar is just a normal object. It has a __call__ member function that gets invoked when you call object.bar(). So object.bar() calls the object.bar object. Libraries like pyqt need the reference to the object so they are able to invoke it whenever they need to. If you try passing object.bar() to set a listener your giving qt whatever the bar() method returns instead of the bar object itself.
  12. fizzlesticks

    Writing file in c++

    You can get the input as a string and convert it yourself using the stoi function or using a stringstream to convert it in a way similar to cin.
  13. fizzlesticks

    Writing file in c++

    Don't mix input methods. Use getline everywhere.
  14. fizzlesticks

    Writing file in c++

    Without seeing your code we can't really help. But I'm guessing you're using std::cin >> for input which will only read input up to a space character. You can use std::getline to get around that.
  15. fizzlesticks

    Python

    list(set(s) ^ set(t))
  16. You could either pipe the output from the program to a python script or use the subprocess module to run the program from the python script and capture the output that way. To pipe the output, from the command line you would run BarcodeReader.exe | py my_python_script.py where my_python_script.py is using the input() function to get input. Or using the subprocess module make a script that does something like: import subprocess as sp proc = sp.Popen(['path/to/barcodereader.exe'], stdout=sp.PIPE) out = proc.stdout.read() print(out)
  17. fizzlesticks

    Don't know what's wrong with tip calculator. (Python)

    You need to import time. If you open a command window / terminal and run it from there the window will stay open and you can see what error you're getting.
  18. fizzlesticks

    C++ help - shouldn't be too hard.

    The eof flag gets set when something tries to read past the end of file, because of how the getline and >> functions work this will never happen. You need to use .good() or cast to bool instead of .eof().
  19. fizzlesticks

    Python: Merge Sort Error

    The sample code is written in Python 2 where '/' is integer division. To accomplish the same thing in Python 3 you can use '//'.
  20. fizzlesticks

    Compiler choices & linking APIs for C++

    If you use vcpkg you shouldn't need to do anything but the last step from that tutorial to set the subsystem (if you want something besides the default.) And I use dark theme so purple is just a normal color for me so I have no idea what that might mean.
  21. fizzlesticks

    Compiler choices & linking APIs for C++

    I just followed the quick start section on the github page then googled if I couldn't figure something out. There is no linking to VS, the program edits some internal VS files to make things available in any project (if you did the integrate step in the guide.) vcpkg install sdl2 curl installs the 32bit dynamically linked versions of the libraries so make sure your project is set to x86 if you want to get the 64 bit version use vcpkg install sdl2:x64-windows and for statically linked (if the library supports it, I don't know if sdl or curl do) vcpkg install sdl2:x86-windows-static for 32bit or vcpkg install sdl2:x64-windows-static for 64bit After installing you should be able to just #include <SDL2/sdl.h> and everything should work automatically.
  22. fizzlesticks

    Compiler choices & linking APIs for C++

    For using 3rd party libraries like SDL in Visual Studio you can use VCPKG. You tell it which version of the library to install (32 or 64 bit, static or dynamically linked) and it will automatically download, build and add the proper compiler and linker options for you to use the libraries in your projects. Not every library will be available but a ton are.
  23. fizzlesticks

    New to Hardcore programming

    Visual Studio's compiler doesn't support standard C and it never will. If you want to write straight C code you shouldn't be using VS.
  24. Nope, I just used the docs when I was messing around with it.
  25. This is a problem with the SDL library. SDL defines its own entry point so must either tell VS where that entry point is by setting the subsystem to console then in project properties > linker > advanced, setting the entry point to whatever SDL calls its main function (I can't remember the name sorry.) Or add a define for SDL_MAIN_HANDLED before #including SDL.h to tell SDL you want to use your own entry point.
×