|
Basically his port 80 and 443 were blocked by Comcast and those are the only ports the webhooks would work with so we spent a bunch of time, energy, (and he spent money) for naught which feels super bad (only because I wasted his time by not even thinking about this in the planning stages and telling him his little sign that lights up on a webhook won't work)
|
# ? May 23, 2017 02:04 |
|
|
# ? May 16, 2024 19:08 |
funny Star Wars parody posted:Basically his port 80 and 443 were blocked by Comcast and those are the only ports the webhooks would work with so we spent a bunch of time, energy, (and he spent money) for naught which feels super bad (only because I wasted his time by not even thinking about this in the planning stages and telling him his little sign that lights up on a webhook won't work) Ah bummer. I suppose you could use AWS or Heroku free tier to host something listening on :80 or :443 and then whatever message could get passed along to the raspberry pi by a number of other methods.
|
|
# ? May 23, 2017 02:38 |
|
fletcher posted:Ah bummer. I suppose you could use AWS or Heroku free tier to host something listening on :80 or :443 and then whatever message could get passed along to the raspberry pi by a number of other methods. Yeah probably, but that would be significantly more work than my pay grade (free) haha
|
# ? May 23, 2017 02:48 |
|
funny Star Wars parody posted:Yeah probably, but that would be significantly more work than my pay grade (free) haha Actually this bit would be super easy to do. apt-get install haproxy then drop in something like this code:
|
# ? May 23, 2017 04:00 |
|
I'm doing something relatively simple and Bottle seems like it's fully adequate for my uses. Is there some reason for using Flask over it if I don't need authentication or anything like that? In practice, I only need to serve an API with three distinct endpoints, one of which takes query parameters.
|
# ? May 23, 2017 06:10 |
|
Loezi posted:I'm doing something relatively simple and Bottle seems like it's fully adequate for my uses. Is there some reason for using Flask over it if I don't need authentication or anything like that? In practice, I only need to serve an API with three distinct endpoints, one of which takes query parameters. Bottle is fine.
|
# ? May 23, 2017 06:24 |
|
funny Star Wars parody posted:Yeah probably, but that would be significantly more work than my pay grade (free) haha Maybe ngrok might be helpful in this situation? https://ngrok.com/
|
# ? May 23, 2017 17:21 |
|
What's the preferred program to create an Windows executable from a Python script these days?
|
# ? May 26, 2017 00:30 |
|
I am looking for a python module to help me do some design/sim type of work. I want to build an object as a 3d array of points, and be able to interact with the object (zoom, rotate, etc). A 3D surface plot in matplotlib is almost exactly what I want, except when viewing the plot it's really clunky and hard to interact with. So basically something just like that, except less frustrating. There doesn't seem to be much out there for this. Any suggestions welcomed.
|
# ? May 26, 2017 03:58 |
|
My Rhythmic Crotch posted:I am looking for a python module to help me do some design/sim type of work. I want to build an object as a 3d array of points, and be able to interact with the object (zoom, rotate, etc). A 3D surface plot in matplotlib is almost exactly what I want, except when viewing the plot it's really clunky and hard to interact with. So basically something just like that, except less frustrating. There doesn't seem to be much out there for this. Any suggestions welcomed.
|
# ? May 26, 2017 12:05 |
|
I've never heard of Mayavi before but you might want to also check out Paraview. Both of them are built using the VTK library so should be quite similar. I'm pretty sure that everybody I know (including me) that would use a visualization software would use Paraview though. This might help: https://pyscience.wordpress.com/2014/09/06/numpy-to-vtk-converting-your-numpy-arrays-to-vtk-arrays-and-files/
|
# ? May 26, 2017 17:03 |
|
Is there a Python library for doing testing when my tests operate on large chunks of text, too large to just put in the code? Obviously I can just put the input and output into files and then read from them, but I know this is going to be bad when I have several hundred tests and dependencies on filenames. I think I'm going to need some kind of testing database- what's the least painful way to do this?
|
# ? May 29, 2017 02:12 |
|
a few DRUNK BONERS posted:Is there a Python library for doing testing when my tests operate on large chunks of text, too large to just put in the code? Obviously I can just put the input and output into files and then read from them, but I know this is going to be bad when I have several hundred tests and dependencies on filenames. I think I'm going to need some kind of testing database- what's the least painful way to do this? Dependencies on file names sounds like you've got them hard-coded somewhere, which is really bad practice. You can use magic mocks to over-write those file names for testing, but you're probably better off restructuring your code to make it more testable.
|
# ? May 29, 2017 17:41 |
|
I would like to debug JavaScript inside a PyCharm for Flask projects. I see that I can set breakpoints in the JS code but PyCharm always skips over them. The only tutorial I can find online involves debugging static HTML and not Jinja2 templates.
|
# ? May 30, 2017 16:13 |
|
huhu posted:I would like to debug JavaScript inside a PyCharm for Flask projects. I see that I can set breakpoints in the JS code but PyCharm always skips over them. The only tutorial I can find online involves debugging static HTML and not Jinja2 templates. I haven't debugged JS in a jetbrains IDE in years, but I seem to recall it was easier if I used an external js file included in my templates via a script tag.
|
# ? May 30, 2017 16:16 |
|
Thermopyle posted:I haven't debugged JS in a jetbrains IDE in years, but I seem to recall it was easier if I used an external js file included in my templates via a script tag. I might be explaining this poorly. Here's my structure: app/templates/input.html: code:
code:
Edit: The settings I think are relevent: huhu fucked around with this message at 16:26 on May 30, 2017 |
# ? May 30, 2017 16:22 |
|
huhu posted:stuff You'll probably get more help on StackOverflow. I will say this...the reason I haven't used the JetBrains JS debugger in years is that the chrome devtools debugger is superior in every way that I can think of. Depending on what you're doing you might be better off just using that.
|
# ? May 30, 2017 17:20 |
|
For those that work with Excel, what Python library do you use?
|
# ? May 31, 2017 22:21 |
|
Hughmoris posted:For those that work with Excel, what Python library do you use? i don't do anything complicated with excel but openpyxl suits me fine
|
# ? May 31, 2017 22:28 |
|
XLSXwriter can do pretty-much everything, but it's missing some useful abstractions. Ie the code will be kind of brute force, iterating over row indexes etc. The API and docs's nice. I don't know how it compares to OpenPyxl; they're both popular, full-featured libraries; after researching which to go with, I ended up neutral, and picked writer arbitrarily. Those are the only two full-featured, modern libraries.
Dominoes fucked around with this message at 11:58 on Jun 1, 2017 |
# ? May 31, 2017 23:00 |
|
Hughmoris posted:For those that work with Excel, what Python library do you use? I typically use openpyxl, but if there are charts as sheets then I might have to use xlwings. Note that xlwings opens up an Excel instance so it can be slow. If you are using tabular data, there is a function within pandas to also read excel. If you are mixing xls and xlsx, you might want to use pyexcel that has support for both.
|
# ? May 31, 2017 23:41 |
|
So I've been messing around with Python for a few months but I feel I'm stuck at a level slightly above complete beginner. I know how to work with lists/dicts/tuples and create loops/conditions. What would be a good resource to gain knowledge on working with concepts that are new to me? Things I regularly see and don't understand are __init__ or __main__ funtions, when I should use classes or how to create a decent structure in my code. Currently I create a few functions and below them I write loops/conditions which use them. When looking at code from others I usually see them split over multiple files. I'm working with python3.
|
# ? Jun 1, 2017 07:40 |
|
__init__ is boilerplate used in classes. Its most typical use is to convert arguments that are supplied when creating instances of the class into class-scope 'self' variables. Ie:Python code:
Python code:
Python code:
Python code:
Dominoes fucked around with this message at 12:18 on Jun 1, 2017 |
# ? Jun 1, 2017 12:09 |
LochNessMonster posted:So I've been messing around with Python for a few months but I feel I'm stuck at a level slightly above complete beginner. I know how to work with lists/dicts/tuples and create loops/conditions. You actually want to know two things: 0. How to write pythonic code; Solution: Read Fluent Python. It is by far the best intermediate-level book I know of. You don't have to read it cover to cover; read the first few chapters and then skip around to stuff that interests you. As you learn more, you can go back to the more advanced topics. Plus, it's an excellent reference. 1. How to organize your code in general. Solution: this is a little tougher! I would recommend Clean Code by Robert C. Martin. This is the best book I know of on the topic. It's about Java, but the concepts are universal. Honestly, though, it's just going to take a lot of practice. Eela6 fucked around with this message at 14:51 on Jun 1, 2017 |
|
# ? Jun 1, 2017 14:45 |
|
Probably sounds like faux outrage but I'm really just curious: is starting bullet lists for human consumption with element zero something programmers routinely do?
|
# ? Jun 1, 2017 15:04 |
pangstrom posted:Probably sounds like faux outrage but I'm really just curious: is starting bullet lists for human consumption with element zero something programmers routinely do? I do it, because otherwise my mind will snap back to one-based indexing and my code will start breaking on me. Years of MATLAB left permanent damage.
|
|
# ? Jun 1, 2017 15:15 |
|
pangstrom posted:Probably sounds like faux outrage but I'm really just curious: is starting bullet lists for human consumption with element zero something programmers routinely do?
|
# ? Jun 1, 2017 21:19 |
|
New to programming and python, and I made my first thing! Used Selenium to automate going into LexisNexis, then download all of the newspaper articles published that day from a few major newspapers that mention a couple different countries! It's janky, it's messy, but it actually does the thing I want it to which freaking owns. My low point was where I couldn't figure out how to deal with a few different frames on a page, and for a bit my workaround was send_keys((Keys.TAB * 57) + Keys.ENTER) to navigate to a button and click it yeeeesh. I feel like a lil kid and I wanna print it out and stick it on my refrigerator
|
# ? Jun 1, 2017 23:08 |
|
Has anybody dabbled with dependency injection with Python? I have reason to implement something like an API for getting implementations of APIs, and DI sounds like the way to go. I especially think back to how Angular managed stuff like this.
|
# ? Jun 2, 2017 06:20 |
|
Cingulate posted:I thought that's a thing people do to imply point zero is what you should have done already in the first place or something like that. Like, utter basics. That's how I'd use a 0th level bullet list too. I translate it in my head as "this is the pre requisite." Rocko Bonaparte posted:Has anybody dabbled with dependency injection with Python? I have reason to implement something like an API for getting implementations of APIs, and DI sounds like the way to go. I especially think back to how Angular managed stuff like this. I feel like people are gonna jump in and say "no don't do that," based on responses to other things I've asked about. But I don't really understand what you're asking though. LochNessMonster posted:So I've been messing around with Python for a few months but I feel I'm stuck at a level slightly above complete beginner. I know how to work with lists/dicts/tuples and create loops/conditions. Sup me from the past. Re: code organization, i think starting off with everything in a single file is the best way to go. That way everything is right there and easy to jump around to (I'm aware IDES and ctags makes this a nonissue but there's a physiological factor of knowing everything is right here that helps I think), and then splitting things off into their own files when the need arises.
|
# ? Jun 2, 2017 11:11 |
|
Dominoes posted:__init__ is boilerplate used in classes. Its most typical use is to convert arguments that are supplied when creating instances of the class into class-scope 'self' variables. Ie: The snake example makes it a bit more comprehensible but I have no clue on what use the __main__ boilerplate would be. Couldn't you just end your code with runall()? Eela6 posted:You actually want to know two things: Thanks for the suggestion. I'll pick up a copy and start reading and practising.
|
# ? Jun 2, 2017 12:31 |
|
Good point I missed: If you run_all() at the end without __main__, your code will run whenever it's imported. __main__ will only run if you load your script standalone.
|
# ? Jun 2, 2017 13:06 |
|
When you run a script, either directly or by importing it, it executes all the code in it from top to bottom. But suppose you wanted to import this as a module. If you had a runall() function defined and then called at the bottom, it would run when you import, which may not be the behavior you want. You might want to have different behavior if it's running as a script, or as a module.
|
# ? Jun 2, 2017 13:07 |
|
sugar free jazz posted:New to programming and python, and I made my first thing! Used Selenium to automate going into LexisNexis, then download all of the newspaper articles published that day from a few major newspapers that mention a couple different countries! It's janky, it's messy, but it actually does the thing I want it to which freaking owns. My low point was where I couldn't figure out how to deal with a few different frames on a page, and for a bit my workaround was send_keys((Keys.TAB * 57) + Keys.ENTER) to navigate to a button and click it yeeeesh. I feel like a lil kid and I wanna print it out and stick it on my refrigerator congrats. selenium can be finicky depending on the sites you're dealing with, so having hacks like tabbing to the thing and sending ENTER isn't that weird tbh. in some cases it's significantly faster than searching multiple xpaths or whatever, just make sure you're raising some kind of sensible error if the thing breaks at that point!
|
# ? Jun 2, 2017 13:29 |
|
Rocko Bonaparte posted:Has anybody dabbled with dependency injection with Python? I have reason to implement something like an API for getting implementations of APIs, and DI sounds like the way to go. I especially think back to how Angular managed stuff like this. Tom Christie talked about doing this for API development for his new API Star project.
|
# ? Jun 2, 2017 16:13 |
|
Rocko Bonaparte posted:Has anybody dabbled with dependency injection with Python? I have reason to implement something like an API for getting implementations of APIs, and DI sounds like the way to go. I especially think back to how Angular managed stuff like this. I've done some experiments in this direction, similar-ish to what Tom Christie talks about in that video MonkeyMaker just posted. I think it has a lot of potential. You'll find that a lot of DI/IoC stuff in Python is never called that because DI/IoC just comes naturally to python due to its dynamic nature with first class everything.
|
# ? Jun 2, 2017 16:28 |
|
Practical example question about working with functions. Say I want to talk to APIs and run a few calls against it. My idea would be to create a function with requests to set up a connection. After the connection would be established I'd like to use that to run several different functions I write for the different api calls I want to do. How would I go about setting something like that up?
|
# ? Jun 2, 2017 18:54 |
|
I think it depends on the protocols, IIRC. If you are using HTTP/S you have to make one request per connection, but if you are using TCP or UDP you could make something like that, but I wouldn't know how with requests, but it shouldn't be too hard.
|
# ? Jun 2, 2017 19:07 |
|
LochNessMonster posted:Practical example question about working with functions. Sounds like what you want is a Session. http://docs.python-requests.org/en/master/user/advanced/#session-objects quote:The Session object allows you to persist certain parameters across requests. It also persists cookies across all requests made from the Session instance, and will use urllib3's connection pooling. So if you're making several requests to the same host, the underlying TCP connection will be reused, which can result in a significant performance increase (see HTTP persistent connection). Tigren fucked around with this message at 22:26 on Jun 2, 2017 |
# ? Jun 2, 2017 22:23 |
|
|
# ? May 16, 2024 19:08 |
|
That sounds exactly like what I want, thank you!
|
# ? Jun 3, 2017 07:26 |