|
The Gripper posted:For me as an old (young, but old at heart) and jaded programmer the only thing that keeps me interested is finding a new idea to work on. Most of my day-to-day work is maintenance, retrofitting, and tool design which isn't all that interesting or compelling any more. Pick up a new hobby rather than practicing your day job in your free time. Learn to play an instrument perhaps. quote:Outside of work I just have an amazing case of writers block so I spend a lot of time reading about languages and design look for anything that is going to take some actual, solid research Writers block is the process of editing the text before you've written it. Try writing stupid code instead of worrying what's right. quote:that isn't just referring to an API or picking up a new language without making something from it. 90% of the time I just want to sit down and code something but don't have the faintest idea of where to start. This is probably because 90% of starting something new is playing with an api. quote:Currently that journey has taken me into the depths of 3D graphics/game engines, and I can't see myself coming out of this as a whiz-kid any time soon. Does it matter what you learn now? If you're doing this in your free time, shouldn't it just be fun instead?
|
# ? Dec 11, 2012 15:04 |
|
|
# ? May 30, 2024 12:53 |
|
I do play instruments! It's not so much that I'm mentally writing something and tossing it out before it's down on paper, it that I get to the point where there's just nothing rattling around in there that I want to even start on. I've written a lot of stupid code and my github is scattered with small finished projects based on it, but that's mostly because I find it's the easiest way to pick up a new language or API (because it is!) and not because I've found some long-term engaging thing to work on more generally. It's a lot of fun picking up new languages but at some point it feels like I should find something more constructive to do! tef posted:Does it matter what you learn now? If you're doing this in your free time, shouldn't it just be fun instead?
|
# ? Dec 11, 2012 15:38 |
|
tef posted:https://gist.github.com/295200 you can use ctypes to monkeypatch cpython OH MAN I'm going to use this to monkeypatch the pygame joystick code to work with 360 controller triggers properly.
|
# ? Dec 11, 2012 16:37 |
|
BeefofAges posted:Are you sure you're passing it the right path? Are you giving it a relative path or an absolute path?
|
# ? Dec 11, 2012 17:34 |
|
Bunny Cuddlin posted:OH MAN I'm going to use this to monkeypatch the pygame joystick code to work with 360 controller triggers properly. Er, use the example I gave. What makes tef's example interesting is that your not *supposed* to be able to monkey patch builtin types.
|
# ? Dec 11, 2012 19:13 |
|
duck monster posted:Er, use the example I gave. What makes tef's example interesting is that your not *supposed* to be able to monkey patch builtin types. The joystick class in pygame is a C extension so you can't monkey patch it the normal way.
|
# ? Dec 11, 2012 20:48 |
|
Jewel posted:Did someone say, weird obtuse code that tests the boundaries of python and still works? http://paste.pound-python.org/show/chatserver/
|
# ? Dec 11, 2012 20:55 |
|
everyone posted:
Heh, thanks for the tips. I'll keep trying and hopefully it will click soon.
|
# ? Dec 11, 2012 22:29 |
|
The Gripper, I was also going to suggest getting yourself a not programming hobby like tef said. Perhaps a not programming hobby will inspire you to write some apps to assist you with your hobby.
|
# ? Dec 11, 2012 23:12 |
|
The Gripper, doing this sort of maintenance work will kill a person's soul. You're not being challenged, intellectually. What helped me a lot was visiting users of the software in the wild, and looking at their problems they have with the software (not just bugs, but workflow issues, places that looked inefficient), and solving their problems. I felt good about being a programmer that helped other people by applying his skills, and I stopped looking at it as "it's maintenance work", but "I'm helping all these people do their jobs, and without me, they couldn't work!"
|
# ? Dec 11, 2012 23:22 |
|
Suspicious Dish posted:"I'm helping all these people do their jobs, and without me, they couldn't work!" Sure they could
|
# ? Dec 11, 2012 23:37 |
|
What's the fashionable way to do something like the following? I have a class A, and I want to wrap functionality of a class B. I can do something like:code:
Should I have something like code:
|
# ? Dec 12, 2012 00:52 |
|
GrumpyDoctor posted:Yep, because it works in the majority of cases. Inevitably, though, one of the deletions will fail, bringing the whole program down, which is doubly annoying because the "failure" actually successfully deletes the directory - it just thinks it didn't. Which is why I thought ignoring the error would be helpful. That's an odd problem. This sounds messy, but try catching the exception, checking to see if the delete actually worked, and only re-raising the exception if the delete failed? Can you post a bit of your code so we can see what you're doing?
|
# ? Dec 12, 2012 05:43 |
|
BeefofAges posted:That's an odd problem. This sounds messy, but try catching the exception, checking to see if the delete actually worked, and only re-raising the exception if the delete failed? I think I actually figured it out. I was using a third-party component that wasn't behaving the way I thought it was: It was doing its own shutil shenanigans that were fighting with mine. I didn't see the problem because I don't know how to get exceptions usefully across the multiprocessing process boundary so all I knew was that shutil was involved somehow. I really need a way to effectively debug code that uses multiprocessing.
|
# ? Dec 12, 2012 06:03 |
|
fritz posted:What's the fashionable way to do something like the following? I have a class A, and I want to wrap functionality of a class B. I can do something like: Python code:
Basically you decorate your function in the body of A with your wrapper, which performs any of the pre and post-wrapped logic and calls the wrapped function where needed. It's more complicated in general but it means you can wrap whatever you want by just decorating methods in other classes. If you wanted you could set the wrapper to take additional arguments like pre and post-run functions, if the logic isn't always the same for some flexibility. Edit; i've heard bad things about decorator classes though, so it might be better to use a regular decorator method. Holy lord why did I just write out that giant class decorator one when a regular one is way more concise Python code:
Python code:
The Gripper fucked around with this message at 06:56 on Dec 12, 2012 |
# ? Dec 12, 2012 06:16 |
|
Any recommendation for a GUI to use with pygame? The pygame wiki has some suggestions, but based on these reviews nothing seems very mature. e: The stuff I want to do includes buttons, text boxes (preferably with scrolling), windows within the pygame window, etc. I could do this myself, I guess.. Vivian Darkbloom fucked around with this message at 08:57 on Dec 12, 2012 |
# ? Dec 12, 2012 08:54 |
|
Dren posted:The Gripper, I was also going to suggest getting yourself a not programming hobby like tef said. Or even download pygame or cocos2d - python, do some tutorials and try making some nutty space invader game or something. Games are fun, just dont get too ambitious (the big games are in fact really big). Incidently heres whats fun;- http://kivy.org/ Python;- check. Gods own language. loving easy to use UI framework;- check. Easiest non RAD framework I've seen. Looks good;- check. You could portfolio stuff from this with just the defaults. Cross platform;- double check. Toolkit will compile to IOS and Android. For added fun, you can hatchet Panda3D into a widget for gaaaaames. Probably pygame too with a bit of twangling. duck monster fucked around with this message at 12:12 on Dec 12, 2012 |
# ? Dec 12, 2012 12:08 |
|
Is there a cleverer way of representing grids in Python instead of just a 2D array/list? I want to store data and be able to do something simple like grid[1][5] returns whatever value is at coordinate x:1,y:5 in my model. The next thing I need is a quick way to return the surrounding points in the grid. So a point like the one above has 8 neighboring points surrounding it at (0,4),(1,6) etc. I can do this using multi-dimensional arrays but if there is a module that deals specifically with grids like this and can do other things I could use that instead.
|
# ? Dec 12, 2012 17:27 |
|
Sylink posted:Is there a cleverer way of representing grids in Python instead of just a 2D array/list? Doesn't numpy have a fairly versatile n-dimensional array?
|
# ? Dec 12, 2012 17:33 |
|
Sylink posted:Is there a cleverer way of representing grids in Python instead of just a 2D array/list? There's numpy arrays and if you want even more fancy functionality (that also uses numpy arrays) you can try pandas dataframes.
|
# ? Dec 12, 2012 17:45 |
|
I ended up making my own class for it:code:
|
# ? Dec 12, 2012 19:25 |
|
Oh man, after 2-3 days of struggling, not really being able to absorb any information or understanding, it clicked. I can make a basic GUI app, and self, inits, inheritence and all that stuff just kind of fell into place in my mind.
|
# ? Dec 13, 2012 03:16 |
|
Daynab posted:Oh man, after 2-3 days of struggling, not really being able to absorb any information or understanding, it clicked. I can make a basic GUI app, and self, inits, inheritence and all that stuff just kind of fell into place in my mind. Coding seems to do that! The feeling of things suddenly just.. clicking, is fantastic. Really gives you a good high, which you can then use for just coding nonstop for 8 hours hahah.
|
# ? Dec 13, 2012 10:44 |
|
Daynab posted:and self Having to pass self to instance methods is probably what tripped me up the most while learning Python, but when I figured out why you actually do that it certainly helped. Now it just makes perfect sense and I don't even think about it when writing Python.
|
# ? Dec 13, 2012 11:03 |
|
Daynab posted:Oh man, after 2-3 days of struggling, not really being able to absorb any information or understanding, it clicked. I can make a basic GUI app, and self, inits, inheritence and all that stuff just kind of fell into place in my mind. Like falling off a bike. You might forget syntax (Hell I forget syntax minutes after learning it, always), or how a certain thing works but the basic concept of programming once learned is never forgotten. Welcome to the club.
|
# ? Dec 13, 2012 11:49 |
|
One of us One of us One of us
|
# ? Dec 13, 2012 12:16 |
|
I could use some advice on project structure so I'm not kicking myself later. I'm about to migrate to new machine and start a large personal project "for reals" with versioning, proper classes, etc. instead of the folder of hodgepodge scripts I've been using to learn. When I've done development in other languages, all the code and assets were contained within a single \\dev\projectname path. It was easy to manage dependencies because third-party scripts, modules, frameworks, etc. were revisioned along with the rest of the code. This project will require some third-party modules (numpy, etc.). Since these get installed to Python's directory, how should I manage dependencies on these modules so I can re-create the development environment when I have to move machines, restore from backup, etc.? I can just keep copies of the module installation packages, but I'm guessing there are better ways to go about it.
|
# ? Dec 13, 2012 18:45 |
|
onionradish posted:This project will require some third-party modules (numpy, etc.). Since these get installed to Python's directory, how should I manage dependencies on these modules so I can re-create the development environment when I have to move machines, restore from backup, etc.? I can just keep copies of the module installation packages, but I'm guessing there are better ways to go about it. Combining that with `pip freeze > requirements.txt` will let you save a list of modules installed (and versions) for that project and reinstall those same modules wherever you go with `pip install -r requirements.txt`.
|
# ? Dec 13, 2012 19:04 |
|
onionradish posted:This project will require some third-party modules (numpy, etc.). Since these get installed to Python's directory, how should I manage dependencies on these modules so I can re-create the development environment when I have to move machines, restore from backup, etc.? I can just keep copies of the module installation packages, but I'm guessing there are better ways to go about it. Before anything, get virtualenv. One easy option is pip freeze. Install everything you need, call freeze, get a requirements file. You can later feed it to pip to reinstall everything in the exact same versions. Or write requirements file yourself. If you use distribute for you projects, you can also just specify dependencies in setup.py and simply install it to get everything. There's also buildout, but I've never really used it, so can't tell you how easy it is to setup/use.
|
# ? Dec 13, 2012 19:06 |
|
What you want is virtualenv to isolate your dependencies and pip to download your dependencies. Generally speaking, you want to keep your dependencies out of your version control. I usually have a folder for virtualenvs, and a folder for my projects. Each project in the projects folder has an outer directory (e.g. "FooProject") that contains a requirements text file (look up "pip freeze"), any other project metadata, and the actual python package that I'm developing (which is another directory with an __init__.py and my actual python code). It looks roughly like this code:
Haystack fucked around with this message at 22:22 on Dec 13, 2012 |
# ? Dec 13, 2012 19:11 |
|
Thanks for the advice; and, the sample dirtree is a big help, so thanks for that detail, Haystack! I'll need to do some more reading and testing on virtualenv as soon as I finish uninstalling all the bloatware that came with the new system. In the example usage given in the docs: code:
Also, when I'm installing modules/packages, do I install to a project's particular virtualenv, to the native Python directory or both? For example, if I want a module like numpy or PIL to be available to every script, I'm assuming that I install it to native Python directory. For my actual project, I'm assuming I'll also need to install it to its particular virtualenv so that version is the one that will run.
|
# ? Dec 13, 2012 21:44 |
|
onionradish posted:Is ENV representative of a full path (C:\my_python_files\), a subdirectory of c:\Python27, or some alias that refers to a full path? It can be absolute or relative path to wherever you want create the environment. If you're in C:\my_python_files, virtualenv test will create C:\my_python_files\test and put all the stuff inside. Generally you don't make it a subdirectory of Python installation. onionradish posted:Also, when I'm installing modules/packages, do I install to a project's particular virtualenv, to the native Python directory or both? For example, if I want a module like numpy or PIL to be available to every script, I'm assuming that I install it to native Python directory. For my actual project, I'm assuming I'll also need to install it to its particular virtualenv so that version is the one that will run. Usually you want to install to just the virtualenv (after you activate it, pip install X will do the right thing). If you want something to be available from global site-packages, you need to create virtualenv with --site-packages argument. Then you don't have to install it again to the virtualenv.
|
# ? Dec 13, 2012 22:46 |
|
Awesome! Thanks, everybody. Glad I asked!
|
# ? Dec 13, 2012 22:57 |
|
The Gripper posted:I have no idea what the fashionable thing would be to do, but it can be done with decorators if the wrapper code is always going to be the same, through something like: Dang, I hadn't even thought about decorators. Hmm. (Thanks!)
|
# ? Dec 14, 2012 07:15 |
|
So, working with wxPython to make an interface... are you supposed to create the whole UI completely within the __init__? That's how the tutorials show it http://wiki.wxpython.org/Getting%20Started but it seems a bit... weird to do that.
|
# ? Dec 14, 2012 07:20 |
|
Daynab posted:So, working with wxPython to make an interface... are you supposed to create the whole UI completely within the __init__? That's how the tutorials show it http://wiki.wxpython.org/Getting%20Started but it seems a bit... weird to do that. I can't speak for wx specifically, but in PyQt you have a class for each window (So one for the main window, another one for say, an options dialog, and then another for something else, etc.) and you do indeed put everything you want for that window in __init__ for that class.
|
# ? Dec 14, 2012 07:34 |
|
Daynab posted:So, working with wxPython to make an interface... are you supposed to create the whole UI completely within the __init__? That's how the tutorials show it http://wiki.wxpython.org/Getting%20Started but it seems a bit... weird to do that. Use this thing: http://kivy.org/ It makes incredibly cool UIs.
|
# ? Dec 14, 2012 09:33 |
|
Following up on virtualenv, I'm having failures when trying to install packages, and I'm not sure what I'm doing wrong. I'm on Windows, and using CMD as the shell. I'm able to create a project folder: "virtualenv test". After I do that, I'm navigating to the test directory (D:\test\project) and entering "scripts\activate". Then I'm trying "pip install lxml" as an example. A bunch of stuff scrolls by and results in "failed with error code 1". I'm not sure what this means: code:
|
# ? Dec 14, 2012 20:20 |
|
You have just run into the bane of windows python programmers everywhere: compiler issues. Lots of python libraries have have c extensions that pip tries to compile. Installing the visual studio 2008 redistributable will solve 90% of your issues. Unfortunantely, lxml is in the 10% . The easiest way I know of getting it is to use the binaries from here to install lxml to your base python directory, and then copying the goddamn lxml folder to your virtualenv (as detailed on this stackoverflow page)
|
# ? Dec 14, 2012 21:53 |
|
|
# ? May 30, 2024 12:53 |
|
Haystack posted:You have just run into the bane of windows python programmers everywhere: compiler issues. Lots of python libraries have have c extensions that pip tries to compile. Installing the visual studio 2008 redistributable will solve 90% of your issues. Compiler and linking issues in general are absolutely rediculous. Just to link a library to a new project in Visual Studio I shouldn't have to go through hundreds of scattered options to find the right three or four, and then hope everything works on the exact version of windows I have with the exact dependencies I have and also work on other peoples'.
|
# ? Dec 14, 2012 22:10 |