|
Vivian Darkbloom posted:I'm finding how hard it is to make a cross-platform console interface that isn't horrible for a little strategy game project, so it's time to get a basic GUI framework set up. I just read the Python Wiki page on GUI programming and I am looking at pyjs as a possibility, since targeting web browsers might be easier than rolling my own GUI entirely. Not sure, though -- ideally I'd like something that's programmer-friendly and doesn't require a lot of setup for a user running my program. Any recommendations on what might be the best GUI choice? What are you envisioning in terms of the GUI?
|
# ¿ Apr 25, 2017 23:58 |
|
|
# ¿ Apr 29, 2024 01:47 |
|
What's the preferred program to create an Windows executable from a Python script these days?
|
# ¿ May 26, 2017 00:30 |
|
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 |
|
Boris Galerkin posted:My first instinct was that conda isn't in your $PATH or whatever the Windows equivalent is, but I just popped open a PowerShell (I don't have conda installed on this computer) and typed 'conda list' and it complained to me about conda not being a recognized command. So unless you trimmed that out of your post then I dunno. 10 years of vim isn't that impressive. I learned how to exit vim over 17 years ago and I still don't consider myself old. I too use PyCharm for most of my Python development, but also use Vim sometimes for standalone scripts.
|
# ¿ Jun 4, 2017 21:27 |
|
baka kaba posted:One day you'll reach a point where all the Google results are for 3.x docs no you won't You can with py3redirect!
|
# ¿ Jun 9, 2017 17:00 |
|
While we are on the subject of documentation, I also use http://devdocs.io from time to time. You can specify what documentation and version you want to search, and it even downloads the documentation for offline use.
|
# ¿ Jun 9, 2017 22:46 |
|
Cingulate posted:I think I need async/await ..? But I have never used either, nor understood the descriptions. What libraries are you using for this? Have you looked into using dask? Take a look at this and see if it will help: http://matthewrocklin.com/blog/work/2016/07/12/dask-learn-part-1
|
# ¿ Jun 15, 2017 16:33 |
|
VikingofRock posted:So I've been doing more python lately, and while I feel like I have a decent grasp on the language itself, I struggle with a lot of the idioms for structuring a program. For example, how should I layout the directory structure of my program, what is __init__.py, where do I list my dependencies, stuff like that. Does anyone have a good resource for learning that sort of stuff? Like the things that are necessary to use python effectively, but which are outside of the scope of the language itself. Here is the official documentation: https://docs.python.org/3/tutorial/modules.html#packages , and this is pretty good guide on how to package a Python module: https://python-packaging.readthedocs.io/en/latest/index.html . I would also recommend the setuptools documentation: https://setuptools.readthedocs.io/en/latest/index.html . However, it is a more focused on setuptools, rather than the organization of a package. How to organize a package depends on the scale of the package. If it is small enough, you can put everything in __init__.py. PEP8 is the recommended standard format for Python code. I use it because it is a standard, but there are people that complain about it (then again people always find something to complain about). I have also been used YAPF. When I am developing a package, I use py.test with flake8. This checks the format for all of my code, and if it violates PEP8 then I fix the code by hand. Depending on what you are working on and the OS, Python dependencies can be in conflict. A virtual environment is a way to create a project specific collection of Python packages. I used miniconda to develop packages that simultaneously support Python 2.7 and 3.6. I do this by having conda environmental for 2.7 and 3.6 installed simultaneously, and test against each one.
|
# ¿ Jun 23, 2017 16:18 |
|
Hughmoris posted:Are there any recommended articles/tutorials/blogs on working with sqlite in Python? I've just started learning a little bit about SQL and I'm trying to find best practices when incorporating it into a script. Do you want to work with sqlite directly? Or indirectly? If you want to work with it indirectly, look at Object Relational Mappers such as peewee or SQLAlchemy. Peewee is simpler, while SQLAlchemy is the standard (?) ORM for Python.
|
# ¿ Jun 24, 2017 17:27 |
|
Boris Galerkin posted:Well I just had a frustrating time figuring out what was wrong with a part of my code when it turns out it was numpy being weird. code:
|
# ¿ Jul 10, 2017 18:47 |
|
Boris Galerkin posted:Is it ok to do this? What about this? Python code:
|
# ¿ Jul 27, 2017 16:17 |
|
Loezi posted:Is there some reason @lru_cache doesn't work? Thanks, I never knew that existed.
|
# ¿ Jul 27, 2017 18:04 |
|
Eela6 posted:I completely forgot about singledispatch. I don't think I've ever used it, but maybe I should have. I feel like I need to review functools to re-learn all of it's cool features.
|
# ¿ Aug 7, 2017 16:05 |
|
duck monster posted:Ok, so I have a bit of a puzzle. Have you seen this: https://forums.unrealengine.com/showthread.php?54343-Communication-Between-UE4-and-a-Python-UDP-Server ?
|
# ¿ Aug 16, 2017 18:16 |
|
Seventh Arrow posted:I'm looking for a python tutor and not really sure how to go about it. I'm taking a data science course and my lack of proficiency with python is my biggest weakness. So obviously I want to focus on data science/data analysis concepts, but also not-quite-so-directly related things like web scraping and working with APIs. Have you tried the IRC #python channel on Freenode?
|
# ¿ Aug 22, 2017 04:09 |
|
Boris Galerkin posted:I don't have internet access on some of these machines. You could create a virtual environment on your host system, and then distribute that out.
|
# ¿ Sep 15, 2017 20:35 |
|
Seventh Arrow posted:Thanks for the suggestion. If I do "python meetup_data.py > meetup_data.csv", I just get a blank file. I think what you might be trying to do is pull "data" groups from the API, but the API only has a category for "tech." It's necessary - at least, as far as I can tell - to further filter the results from there. You have 8 spaces indent on your function definitions, and 4 spaces in other parts of the file. Use the same indent throughout. Did you search the file for tabs?
|
# ¿ Sep 20, 2017 19:15 |
|
Linear Zoetrope posted:What's the best tool for documenting Python 3 for an open source project (there are multiple languages in this project, but let's assume I'm gluing together the docs from different languages manually)? It looks like there are several options, and I'm not familiar enough with the Python open source world to know what's standard. I feel like I rarely see the builtin PyDoc, and see sphinx referenced more often, but I don't really know the tradeoffs and pros/cons of all the various tools. I would suggest Sphinx and ReadTheDocs. I am not sure how well that works for not automatic documentation.
|
# ¿ Sep 20, 2017 22:07 |
|
I am the author of two Python packages. The first package (pyrvt) provides a set of tools for working with type of motion, and provides a number of classes. The second package (pysra), uses pyrvt, but extends the capabilities of the pysra. I extend those cabilities, but inheriting from a class in pysra, however it feels like I am doing this in a clunky way. Is there a better way do this?Python code:
|
# ¿ Oct 11, 2017 04:09 |
|
creatine posted:Wondering if something like this exists in Python. You can create SVG files with matplotlib, which should work for you.
|
# ¿ Oct 11, 2017 14:52 |
|
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 |
|
Cingulate posted:"The Python default for dealing with tabular data." Exactly. I like DataFrames for quickly working with data in properly formatted CSV files -- especially when I need to work on groups of the data.
|
# ¿ Dec 6, 2017 19:12 |
|
Seventh Arrow posted:I have a comma-separated spreadsheet with a bunch of information about condos in my city, most importantly it has the latitude and longitude of these places. I want to be able to output these coordinates onto google maps but I'm not sure how to go about doing this. I looked at this link but none of the API's seem to quite provide what I'm looking for (at least, not with python). Any suggestions? Are you trying to create a map? Or load custom points on a Google Map? If you need to use Google, then I would create your own map (https://www.google.com/maps/d/), and then upload the CSV.
|
# ¿ Jan 2, 2018 15:00 |
|
Seventh Arrow posted:I need to put markers on a map, but since this is for a data science python course I need to find a ~*pythonic*~ way of doing it. The module that was linked to earlier was good, but I need to find around some of the details. Okay. For nearly all of my mapping needs I use basemap or cartopy, but these create static maps. If you want a slippy interactive map you could also consider Bokeh (https://bokeh.pydata.org/en/latest/docs/user_guide/geo.html).
|
# ¿ Jan 2, 2018 19:24 |
|
Do you know about getattr? Python code:
accipter fucked around with this message at 06:44 on Jan 13, 2018 |
# ¿ Jan 13, 2018 06:37 |
|
Portland Sucks posted:Got it, I guess this is pretty much how I was attempting to write my tests. I figured that Excel likely had precision loss in it as well and I know the guy who originally wrote the Excel workbook we're using put no thought into what he was doing regarding precision. I just want to make sure that what I'm producing isn't going to be wildly off the mark. Also take a look at numpy.testing.assert_allclose for testing all values in an array.
|
# ¿ Jan 29, 2018 05:06 |
|
Mrenda posted:Is there a particular setup I should have for developing with Python on windows? I would recommend a miniconda installation. https://conda.io/miniconda.html
|
# ¿ Jul 6, 2018 14:55 |
|
SurgicalOntologist posted:I'm doing a bunch of computations and saving them to a database. The following function is supposed to be committing to the database every 100 results (based on the variable commit_interval), and stopping after 10,000 (the value of total). But I'm not getting 10,000 results on each backtest_set, instead I'm getting 9,900. Can anyone spot the error? Am I making a basic off-by-one -ish mistake or do I have some weird race condition? I can't figure it out. Here's the code. You are testing that i == total, but on the last iteration i == (total - 1).
|
# ¿ Dec 8, 2018 02:57 |
|
unpacked robinhood posted:I'd like to "live-update" a geographical map with rectangular overlays, as soon as background processes bring up fresh data. You might want to consider Folium. I think it should work for you.
|
# ¿ Jan 24, 2019 01:48 |
|
Protocol7 posted:So what's the deal with multithreading in Qt? I believe that you send status updates back from the QThread using a signal().
|
# ¿ Apr 17, 2020 23:15 |
|
Would a relative import solve the issue? Instead of "import io", you would do "from . import io".
|
# ¿ Jul 23, 2020 20:22 |
|
I have used xlwings for work with Excel and it is quite nice when tools like pyexcel cannot handle it.
|
# ¿ Sep 4, 2020 16:39 |
|
QuarkJets posted:The general rule is that Python will not create a copy unless asked. Since you expect the output list to have all of the elements of the input list, except modified, you can copy it at the start of the function and then modify the elements in place. This will just create a copy of the list instance, you might need to also copy the objects held by the list.
|
# ¿ Jan 4, 2021 16:48 |
|
I have the structure below. Basically, p and m are both used by an instance of calc to perform a calculation. All of those components (calc, and p and m, which are stored within calc) are then used by outputs to compute a set of metrics of the calculation. This works great for a single threaded process, but I would like to move to use dask and convert the classes into immutable calculators. Or maybe just copy the calculator are return a new instance with the new parameters (p and m).Python code:
As I write this, I feel like the answer is to return a result from calc that is passed to outputs to be processed and turned into more results, which are eventually collected.
|
# ¿ Feb 18, 2021 06:51 |
|
Hughmoris posted:Anyone ever futz with extending Python using C or Rust to gain performance? I have used C and numba. For my problem, using numba was just a fast and much easier to implement.
|
# ¿ Apr 7, 2021 21:08 |
|
I recently discovered pyenv with virtual environments and it seems pretty amazing. It is pretty nice because you can configure directory specific environments. It also can mix conda and pip based environments. I found these two webpages helpful: - https://akrabat.com/creating-virtual-environments-with-pyenv/ - https://realpython.com/intro-to-pyenv/#virtual-environments-and-pyenv I should note that I am using linux and success on windows might be different.
|
# ¿ Sep 2, 2021 04:42 |
|
|
# ¿ Apr 29, 2024 01:47 |
|
SirPablo posted:Not sure that is quite what I'm aiming at. He's an example of one polygon that is rasterized at 0.01°x0.01°. I'd like to do this for hundreds of similar polygons, but the step I'm scratching my head on is counting them up grid by grid on a much larger domain, thus giving me a polygon density. Make a raster of the entire area with a value of zero. Loop over each polygon, and increment all points in it by one. You should be able to do this with rasterio.
|
# ¿ Sep 25, 2021 05:47 |