|
Ghost of Reagan Past posted:a fancy way to do it with a generator or something Well, you can do this code:
|
# ? Jul 22, 2015 21:05 |
|
|
# ? Jun 1, 2024 00:21 |
|
I'm trying my hand at python now for the first time by making a game of life clone in pygame. I can't for the life of me figure out whats wrong with my code, Most parts works and the games logic is fine when there is no updating required, like basically when the patterns are 'still life', oscillators and everything else behaves very strangely and also behaves differently on the rows and columns. It feels like I'm just within grasp of a functioning game but I can't wrap my head around what's wrong with it. Here is my code: http://pastebin.com/RxeuBx89
|
# ? Jul 23, 2015 17:55 |
|
Curdy Lemonstan posted:I'm trying my hand at python now for the first time by making a game of life clone in pygame. I can't for the life of me figure out whats wrong with my code, code:
As an exercise, try typing this in the Python interactive interpreter: code:
code:
|
# ? Jul 23, 2015 20:14 |
|
Hammerite posted:
Wow thanks! I see now the error of my ways. thank you so much!
|
# ? Jul 23, 2015 20:26 |
|
Other thoughts - in getCellList() you explicitly enumerate the eight squares surrounding the cell under consideration (taking care not to query cells that are outside the edge of the board), and then you return a list of them. But all you care about is how many of them are "alive". I would be tempted to reduce the amount of code by doing something like this:Python code:
This could be even further condensed if you wanted, but I resisted the urge to do that because I only want to illustrate the general approach I am suggesting. Also, you have a global Board object which is just a list of lists. The object oriented approach would be to have a class Board and have most of your free-standing functions be methods on that class.
|
# ? Jul 23, 2015 20:32 |
|
Awesome! *cracks knuckles* Lets code!
|
# ? Jul 23, 2015 22:06 |
|
Welp. https://news.ycombinator.com/item?id=9936295 If there's things you want to see in Anaconda, let us know, we are moving ahead full bore
|
# ? Jul 23, 2015 22:12 |
|
BigRedDot posted:Welp. https://news.ycombinator.com/item?id=9936295 Qt5 support.
|
# ? Jul 23, 2015 22:18 |
|
Is there a not terrible/easy ocr library for python? I'm thinking about trying to pull serial numbers from a batch of photos.
|
# ? Jul 23, 2015 22:50 |
|
BigRedDot posted:Welp. https://news.ycombinator.com/item?id=9936295 Easier/more user friendly offline package management. Some of us don't have luxuries like internet access on our work machines, and updating/installing new packages in an Anaconda environment without internet access can be confusing if you've never done it before.
|
# ? Jul 23, 2015 22:57 |
|
BigRedDot posted:Welp. https://news.ycombinator.com/item?id=9936295
|
# ? Jul 23, 2015 23:27 |
|
BigRedDot posted:Welp. https://news.ycombinator.com/item?id=9936295 Actual Python question: I've been wanting to build a UI for this data tool I've been building, but I'm torn on whether I should just use Tkinter, Qt, something else, or just build a web interface with Django and learn how to smash JSON files into an SQL database. If you were going to build a UI for a tool to collect and sift through hundreds of thousands of tweets, what would you use, Python thread? Ghost of Reagan Past fucked around with this message at 02:19 on Jul 24, 2015 |
# ? Jul 24, 2015 02:14 |
|
If you want it to be easily accessible by other people, use Django or Flask for the UI. It sounds like Flask would be more appropriate. Qt's nice if you want to run it on your own computer as a desktop app. Keep in mind, learning Qt and web development are both a pain in the nuts if you're not familiar. Qt's challenge is lack of tutorials and non-userfriendly documentation. Web development's challenge is learning how each component (database, html, css, js, servers, front-end-frameworks, deployment etc) works before trying to put them together. Dominoes fucked around with this message at 03:13 on Jul 24, 2015 |
# ? Jul 24, 2015 03:02 |
|
BigRedDot posted:Welp. https://news.ycombinator.com/item?id=9936295 pylint (for spyder integration) and additional neural network tools in the default distribution, please! also, congrats
|
# ? Jul 24, 2015 03:44 |
|
Dominoes posted:If you want it to be easily accessible by other people, use Django or Flask for the UI. It sounds like Flask would be more appropriate. Qt's nice if you want to run it on your own computer as a desktop app. I'd rather read the Django or Flask docs than try to figure out how to make Qt bend to your will if you've never done UI development before.
|
# ? Jul 24, 2015 14:31 |
|
If you're not familiar, both native and web UI development will seem daunting. However, I think web development knowledge will be more widely useful going forward so if you're just going to learn one do that.
|
# ? Jul 24, 2015 15:37 |
|
Having been there and going down both routes, I'll echo the Flask/Django sentiment. With Qt you'll be using a wrapper over the C++ library and the documentation is for C++. You'll have to learn a lot that is only applicable to that library or building desktop GUIs. It isn't very portable. Then there is the whole QML layer which is a language unto itself. I'd say go with Flask. You won't have everything Django provides out of the box, but in this case it might be enough. Figure out how to write a function that can inject and render what you need into you view, display it in your Jinja template, run the Flask server and you're set.
|
# ? Jul 24, 2015 16:12 |
|
Alright, Flask it is.
|
# ? Jul 24, 2015 17:48 |
|
Dominoes posted:Qt5 support. pmchem posted:pylint (for spyder integration) and additional neural network tools in the default distribution, please! QuarkJets posted:Easier/more user friendly offline package management. Some of us don't have luxuries like internet access on our work machines, and updating/installing new packages in an Anaconda environment without internet access can be confusing if you've never done it before. Cingulate posted:Does that mean Travis Oliphant is rich now
|
# ? Jul 24, 2015 19:10 |
|
You can also sort of make desktop apps using web development stuff now that chromium and node etc. all exist. Atom.io is built using HTML/CSS/JS, as is Brackets.
|
# ? Jul 24, 2015 19:27 |
|
BigRedDot posted:Planned, probably Q1 2016.
|
# ? Jul 24, 2015 19:34 |
|
I really tried to think of some way to improve, but I really couldn't think of anything but for "just do what you're doing now, but harder". Which is lame. I'm really happy with conda. I have something extra lame though. Make installing packages from binstar easier. Right now, you have to manually copy lines and poo poo, multiple lines. Just give me another flag for conda install to automatically check binstar if there is nothing in the main repo/my channels, and if something is found, prompt me asking if I want to install it.
|
# ? Jul 24, 2015 19:58 |
|
I'm hoping at least one other person here is at this PyData conference.
|
# ? Jul 24, 2015 21:29 |
|
Captain Capacitor posted:I'm hoping at least one other person here is at this PyData conference. I'm on the conference organizing committee, around the registration table most of the time.
|
# ? Jul 25, 2015 07:20 |
|
BigRedDot posted:I'm on the conference organizing committee, around the registration table most of the time. Well dang here I was killing time around the continuum table thinking I could find someone else. At least I didn't completely embarrass myself by bringing up some obscure reference. The continuum shirts are hella comfy, as it happens.
|
# ? Jul 25, 2015 08:44 |
|
BigRedDot posted:Do you mean in the installer? It's always a tradeoff what goes in the installer, it would be easy to balloon it to 1GB download. However conda install pylint should grab it from the repo super fast. But, you also just gave me an interesting idea, which is that perhaps the installers could offer additional optional packages that user's could check/uncheck at install (they would have to be downloaded separately from the installer, but the installer could do it for you, right at install time). I will toss the idea to the team and see what they think. yup, I meant the installer, with some of the same motivation as quarkjets' post. I'd like to be able to get all the packages I desire at once, since the combination of administrator+network access is rare and painful.
|
# ? Jul 25, 2015 15:19 |
|
Captain Capacitor posted:Well dang here I was killing time around the continuum table thinking I could find someone else. At least I didn't completely embarrass myself by bringing up some obscure reference. quote:The continuum shirts are hella comfy, as it happens.
|
# ? Jul 25, 2015 23:31 |
|
iPython question: I have a self-installed module available, but I have no idea how I am making it available. It's not in my PYTHONPATH, it's not in my anaconda directory, it's not in the directory I'm calling Python from. Can I somehow check what other paths Python checks?
|
# ? Jul 29, 2015 01:32 |
|
Cingulate posted:iPython question: I have a self-installed module available, but I have no idea how I am making it available. It's not in my PYTHONPATH, it's not in my anaconda directory, it's not in the directory I'm calling Python from. Can I somehow check what other paths Python checks?
|
# ? Jul 29, 2015 01:45 |
|
KICK BAMA KICK posted:This might be way too simple but have you looked at sys.path?
|
# ? Jul 29, 2015 02:03 |
|
I have a bunch of values stored in seperate objects. Is there a quick way to put them all in a neat JSON string?
|
# ? Jul 29, 2015 09:13 |
|
Michaellaneous posted:I have a bunch of values stored in seperate objects. Is there a quick way to put them all in a neat JSON string? Python code:
|
# ? Jul 29, 2015 13:10 |
|
Hello, I'm taking a MOOC about machine learning which has python based lab exercises. My knowledge of python is quite basic, but I'm not having big trouble with the language. Actually, I like what I've seen... The labs are done using iPython notebooks, against a configured virtual machine, so it is a "black box" for me: I just open the browser, point to the VM and start coding. My question is if there is some way to debug the code using iPhyton without resorting to the old and ugly practice of spamming the code with "print" statements. I've done some googling, but found nothing (I admit I haven't gone beyond the basic searchs). Could anyone point me to any doc/tutorial/example to teach myself how to do it?
|
# ? Jul 30, 2015 22:02 |
|
Amberskin posted:Hello, I'd recommend starting by reading about the python debugger: https://docs.python.org/2/library/pdb.html It works just fine in iPython notebooks.
|
# ? Jul 30, 2015 22:11 |
|
Also if you just want a more sensible version of spamming prints, check out the logging module. Use logger.debug statements in place of those prints; overhead consists of logging.basicConfig() near the start of your code and a logger = logging.getLogger(__name__) at the top of each module that wants to log anything. That'll automatically give you timestamps and the name of module that the entry came from. Set the level argument to basicConfig to logging.DEBUG when you want to see the logs, logging.INFO when you don't, no need to comment out all your logging statements. (Off the top of my head, may have gotten a detail wrong.)
|
# ? Jul 30, 2015 22:57 |
|
vikingstrike posted:I'd recommend starting by reading about the python debugger: https://docs.python.org/2/library/pdb.html It works just fine in iPython notebooks. KICK BAMA KICK posted:Also if you just want a more sensible version of spamming prints, check out the logging module. Use logger.debug statements in place of those prints; overhead consists of logging.basicConfig() near the start of your code and a logger = logging.getLogger(__name__) at the top of each module that wants to log anything. That'll automatically give you timestamps and the name of module that the entry came from. Set the level argument to basicConfig to logging.DEBUG when you want to see the logs, logging.INFO when you don't, no need to comment out all your logging statements. (Off the top of my head, may have gotten a detail wrong.) Thanks! I'll try both things.
|
# ? Jul 31, 2015 10:44 |
I tried to install the latest version of django-after-response and got:code:
|
|
# ? Jul 31, 2015 11:32 |
|
I don't have a solution, but it's doing the same when I try.
|
# ? Jul 31, 2015 12:18 |
|
KICK BAMA KICK posted:Also if you just want a more sensible version of spamming prints, check out the logging module. Use logger.debug statements in place of those prints; overhead consists of logging.basicConfig() near the start of your code and a logger = logging.getLogger(__name__) at the top of each module that wants to log anything. That'll automatically give you timestamps and the name of module that the entry came from. Set the level argument to basicConfig to logging.DEBUG when you want to see the logs, logging.INFO when you don't, no need to comment out all your logging statements. (Off the top of my head, may have gotten a detail wrong.) I'm slowly weening myself off of relying on prints (by using PyCharm's debugger), and this is amazing, thank you!
|
# ? Jul 31, 2015 21:07 |
|
|
# ? Jun 1, 2024 00:21 |
|
oxidation posted:I'm slowly weening myself off of relying on prints (by using PyCharm's debugger), and this is amazing, thank you!
|
# ? Aug 1, 2015 06:52 |