|
accipter posted:You can create SVG files with matplotlib, which should work for you. Hmm I didn't notice this before. Thanks, I'll read up on it.
|
# ? Oct 11, 2017 14:55 |
|
|
# ? Jun 5, 2024 20:14 |
|
What are some good resources to learn GUI creation with PyQT5 and QT Designer? I'm not trying to do anything fancy, just a simple interface for a robot.
|
# ? Oct 15, 2017 16:47 |
|
Cockmaster posted:What are some good resources to learn GUI creation with PyQT5 and QT Designer? I'm not trying to do anything fancy, just a simple interface for a robot. There's a quick set-up guide for basic apps here: http://zetcode.com/gui/pyqt5/firstprograms/ As a general tip, when you're searching for documentation don't look for PyQt because you'll just get the C++ docs. Instead, look for PySide, which is basically the same thing, but has docs with Python examples. I've worked on several projects using PyQt5, so I can also answer specific questions.
|
# ? Oct 15, 2017 19:03 |
|
So if I was looking to make a "fast" version of some Python code (in the sense of writing the details in some lower-level language but keeping the API the same like cStringIO versus StringIO), what's the best way to go around it. Is it still using C? Use a helper library like Pyrex or Cython or Boost? Is all that Rust and Julia stuff viable?
|
# ? Oct 16, 2017 16:04 |
|
Rust or C are equally doable. For C you just compile to a DLL/so/dylib and for Rust you add the crate-type "cdylib" to the library and writing your library-level functions as #[no_mangle] pub extern "C" fn. C++ is only a little more complicated because you need to make a C wrapper over any C++ specific code. I'm not sure about how the Julia landscape looks anymore, I haven't used it in a while, but it should be doable with the right module. Of those options, I'd probably go with Rust just because Rust generally minimizes the OS-specific bullshit you need to deal with compared to C and C++ being somewhat fractured in that sense (especially around the Unix/GNU and Windows/MSVC boundaries). But if you're not using things that have to worry about that, anything is fine. C and C++ naturally have more mature landscapes as far as compiler optimizations go, and it'll also be easier to get low-level common libraries that have done the bulk of the optimization grunt work for you like BLAS or LAPACK in C (which, well... you probably shouldn't be wrapping BLAS or LAPACK yourself in Python given the numpy landscape but still it's an example).
|
# ? Oct 16, 2017 19:13 |
|
outlier posted:So if I was looking to make a "fast" version of some Python code (in the sense of writing the details in some lower-level language but keeping the API the same like cStringIO versus StringIO), what's the best way to go around it. Is it still using C? Use a helper library like Pyrex or Cython or Boost? Is all that Rust and Julia stuff viable? What is your fast code going to do? I haven't tried Cython yet, but I have had very good luck using Numba. The nice thing about Numba is that syntax is Python, but just compiled ahead of time.
|
# ? Oct 16, 2017 20:08 |
|
I haven't done much with it, but I found Cython very easy to get started with and got performance back to acceptable levels a few times I used it.
|
# ? Oct 16, 2017 20:12 |
|
Thanks all. The code is a set of clustering algorithms that need to be a lot more performant than currently. So it shouldn't need to do any OS stuff and will mainly be doing math. And it has to be done in a way that's maintainable and extensible and "tinker-able". My C is rusty but plausible, but I wanted to see if there was a "better way" and not get caught by any toolkit that initially seemed fine but turned out to be problematic.
|
# ? Oct 17, 2017 09:04 |
|
outlier posted:Thanks all. The code is a set of clustering algorithms that need to be a lot more performant than currently. So it shouldn't need to do any OS stuff and will mainly be doing math. And it has to be done in a way that's maintainable and extensible and "tinker-able". My C is rusty but plausible, but I wanted to see if there was a "better way" and not get caught by any toolkit that initially seemed fine but turned out to be problematic. Anything wrong with Scikit's clustering? It should've mostly done the Cython work for you.
|
# ? Oct 17, 2017 09:12 |
|
Linear Zoetrope posted:Anything wrong with Scikit's clustering? It should've mostly done the Cython work for you. We're developing a clustering algorithm, hence the need to make it perform.
|
# ? Oct 17, 2017 12:07 |
|
outlier posted:We're developing a clustering algorithm, hence the need to make it perform. Makes sense. Probably definitely go with C then, since if it ends up being competitive this will ease its inclusion into things like Scikit if you have a reference implementation ready to go and you don't want to force them to add extra dependencies like Julia or Rust.
|
# ? Oct 17, 2017 12:08 |
|
How have i not heard of pipenv before? It's even from the estimable Kenneth Reitz and the officially-recommended python packaging tool and I've still somehow missed it. It seems pretty awesome and addresses a lot of the problems i have with pip, requirements.txt and the like.
|
# ? Oct 17, 2017 16:02 |
|
Pipenv is lovely, and being able to specify dev dependencies reliably makes testing and deployment very painless. I can't wait for ansible to start supporting Pipfiles as an alternative to requirements files.
|
# ? Oct 17, 2017 16:18 |
|
Looks nice, but can't get it working due to this bug.
|
# ? Oct 18, 2017 09:27 |
|
Thermopyle posted:I haven't done much with it, but I found Cython very easy to get started with and got performance back to acceptable levels a few times I used it.
|
# ? Oct 18, 2017 21:58 |
|
What Python books (if any) do you all have? I'm thinking about picking up Fluent Python and Effective Python.
|
# ? Oct 21, 2017 19:46 |
|
Hughmoris posted:What Python books (if any) do you all have? I'm thinking about picking up Fluent Python and Effective Python. Are you just starting out? Automate the Boring stuff is a great starting point.
|
# ? Oct 21, 2017 21:14 |
Fluent Python is by far my favorite Python book.
|
|
# ? Oct 21, 2017 21:18 |
|
huhu posted:Are you just starting out? Automate the Boring stuff is a great starting point. Nah, I've been poking around Python for some time but I haven't really progressed from beginner -> intermediate. Automate The Boring Stuff is a great book.
|
# ? Oct 21, 2017 21:57 |
|
I'm in the same boat, but it doesn't seem like there are any books that are good for transitioning someone from beginner -> writing your own code. I think it's necessary to just start diving in and start doing projects - there are websites that have exercises with solutions, so I'm going to try doing those. Having said all that, I decided to get "Learn Python the Hard Way," but so far the title seems to be a bit misleading since the author handholds the reader through some very newbie stuff. Guess I'll see how it goes! Seventh Arrow fucked around with this message at 22:11 on Oct 21, 2017 |
# ? Oct 21, 2017 22:08 |
|
The only way I ever progressed from being a person who had read some programming books to someone who was making money doing cool stuff was to do projects that mattered to me....that solved problems I had. Struggling through those leveled me up more than I ever could have done by reading more books.
|
# ? Oct 21, 2017 22:16 |
|
Thermopyle posted:The only way I ever progressed from being a person who had read some programming books to someone who was making money doing cool stuff was to do projects that mattered to me....that solved problems I had. Struggling through those leveled me up more than I ever could have done by reading more books. Where did you look for projects?
|
# ? Oct 21, 2017 22:24 |
|
Seventh Arrow posted:Where did you look for projects? My life. I solved my own problems. Or "problems". I made a web scraper to create an RSS feed for a site that didn't have one. I created a thing that I could email commands to, to make things happen on my home server. Etc. I just progressed to more and more complex things and when it became obvious my CS background was too weak for some project I'd go take some (online) classes or read some books.
|
# ? Oct 22, 2017 01:32 |
|
Trying to build a basic website with Django or Flask is a good way to get into backend/full stack development if you're interested in that kind of thing. When you can hookup the stuff you build with Python to a website - a whole world of awesome possibilities opens up. For Flask I recommend this tutorial - https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world And the accompanying book. For Django I'd recommend - https://docs.djangoproject.com/en/1.11/intro/
|
# ? Oct 22, 2017 01:47 |
|
I can't speak for Hughmoris, but for myself I'm looking to get into data engineering so anything oriented towards ETL, batch, and data warehousing stuff is what I'm looking for. Still, I will look into the Flask and Django stuff, since it's probably not a good idea to be fussy while still learning - thanks for the links!
|
# ? Oct 22, 2017 01:54 |
|
I want to introduce a 7th grade student to coding, using Python. He's pretty good at math but I don't think he has any experience with programming languages. Is there any reasonably up-to-date book or curriculum for this?
|
# ? Oct 22, 2017 05:04 |
|
Think Like a Computer Scientist might be good at that level? It's been so long since I read it, though...
|
# ? Oct 22, 2017 06:20 |
|
Thermopyle posted:Think Like a Computer Scientist might be good at that level? That one looks pretty good. Amazon's top one is Python for Kids by Briggs; I don't know if it's any good though.
|
# ? Oct 22, 2017 06:31 |
|
FoiledAgain posted:There's a quick set-up guide for basic apps here: http://zetcode.com/gui/pyqt5/firstprograms/ As a general tip, when you're searching for documentation don't look for PyQt because you'll just get the C++ docs. Instead, look for PySide, which is basically the same thing, but has docs with Python examples. Thank you. I've also noticed this: https://www.tutorialspoint.com/pyqt/ How do you display a decimal point in the QLCDNumber display? I've run the setSmallDecimalPoint(True) method, but it doesn't seem to have any effect. Also, does anyone know where I can learn about bitwise operations in Python? Cockmaster fucked around with this message at 13:06 on Oct 23, 2017 |
# ? Oct 22, 2017 22:34 |
|
Cockmaster posted:Thank you. I've also noticed this: https://www.tutorialspoint.com/pyqt/ The function setSmallDecimalPoint() doesn't change whether the decimal point is displayed, it changes *how* it's displayed. If True, then the decimal point is small and squeezed between other numbers. If False then the decimal point takes up as much space as a digit does in the display. To get a decimal in the first place, you need to set the "number mode" to decimal, which you can do by calling setDecMode (note that this doesn't take any arguments). Try this out: code:
|
# ? Oct 23, 2017 19:12 |
|
Are there recommended techniques for preserving an exception call stack across a larger, multithreaded application? I'm finding I'm losing information about problems particularly when catching and reprocessing exceptions that are getting shot across threads using concurrent.futures.Future objects. I'll lose the stack trace when the problem first happened.
|
# ? Oct 25, 2017 17:36 |
|
Hi guys, I'm just now diving into python for scripting, and so far I am really enjoying the language. However, I am running into an issue where I am trying to run a specific query and email each line of the results tog a specific address. Python code:
and I am using the smtplib library for email sending. Is there a different SMTP library that works better for this type of operation? Alternatively, am I missing something with how I am preparing the information to be sent?
|
# ? Oct 26, 2017 16:23 |
|
Frank Viola posted:Hi guys, So what is the issue you're having?
|
# ? Oct 26, 2017 16:27 |
|
Thermopyle posted:So what is the issue you're having? The issue is that the email get's sent with no message body containing the line from the query, but it is printed to the output in the console when I am debugging
|
# ? Oct 26, 2017 16:29 |
|
I'm trying to learn unit testing in Python, I've only ever done small one-off things in it (python) so my 'pythonic' sensor is probably wrong; however looking online all the articles I see on doing mocks recommend using patch and it seems like a really bad and unmaintainable code smell. I'm coming from from c languages where dependency injection and injecting fakes is kosher, gmock, nsubstitute, etc. Can someone point me to a good article going over best practices with unit testing and if people really do recommend patching everywhere?
|
# ? Oct 26, 2017 18:01 |
|
Frank Viola posted:Hi guys, Are you using the MIMEText object from email.mime.text? Because the way you're sending msg, which is a concatenation of 2 strings, instead of a MIMEText looks odd to me.
|
# ? Oct 26, 2017 18:08 |
|
Mr. Crow posted:I'm trying to learn unit testing in Python, I've only ever done small one-off things in it (python) so my 'pythonic' sensor is probably wrong; however looking online all the articles I see on doing mocks recommend using patch and it seems like a really bad and unmaintainable code smell. The idea of a unit test is that you're testing a small piece of code in isolation. Think function level or smaller. Typically you're going to have several tests exercising a single function. Mock provides a good way to isolate or mock away unwanted side-effects of the function/code under test. If the unit you're testing has a lot of side-effects, then that might be a code smell, but not necessarily. If you're structuring your code well, then writing unit tests is usually fairly easy. 'Structured well' meaning: functions tend to have one or no side-effects. Functions are short and focus on accomplishing one goal.
|
# ? Oct 26, 2017 18:32 |
|
Symbolic Butt posted:Are you using the MIMEText object from email.mime.text? Because the way you're sending msg, which is a concatenation of 2 strings, instead of a MIMEText looks odd to me. I had considered using the MIMEtext library for this, I just wanted to try it this way. I will give that a try, and see if I can get the result I want.
|
# ? Oct 26, 2017 18:54 |
|
Frank Viola posted:The issue is that the email get's sent with no message body containing the line from the query, but it is printed to the output in the console when I am debugging Python code:
|
# ? Oct 26, 2017 19:11 |
|
|
# ? Jun 5, 2024 20:14 |
|
Mr. Crow posted:I'm trying to learn unit testing in Python, I've only ever done small one-off things in it (python) so my 'pythonic' sensor is probably wrong; however looking online all the articles I see on doing mocks recommend using patch and it seems like a really bad and unmaintainable code smell. As mentioned earlier, mocking can be a code smell, but it's not necessarily a code smell. You'll find mocks that only exist because someone wrote a 1200 line function, or mocks that mock away all the behavior you'd actually want to test. On the other hand they can make your code and your tests clearer. Sometimes you'll find yourself wanting to write your code in a way that only makes sense from the viewpoint of your tests. This is a good candidate to think about if mocking will help you. Maybe you can write your code in a clearer way and use a mock in your test. Just this morning I was writing a test for a Django view someone else wrote and it had a lot of logic and db queries in it. After struggling with figuring out what I wanted to do, I extracted a lot of its logic out into multiple functions and tested each one separately and then in the test for the view I mocked the new function out. As far as some reading goes, I'm not sure how good it is exactly, but I hear Test Driven Development With Python recommended pretty often. Link goes to page where you can read it online or it has links to buy it from amazon or wherever. Thermopyle fucked around with this message at 19:26 on Oct 26, 2017 |
# ? Oct 26, 2017 19:24 |