|
I'm currently in my second week of learning how to program in Python using Learn Python The Hard Way. So far I understand all the code that is thrown at me. Should I use more than one learning source or multiple? I've had several people tell me that you need to be learning by getting started on a big project you want to do. How am I suppose to start a big project and don't even know how to program. This my first programming language by the way. And I want to learn how to program, not learn how to program a big project and that's all I learn to do.
|
# ? Jul 30, 2013 14:41 |
|
|
# ? Jun 11, 2024 17:35 |
|
Suspicious Dish posted:I actually recommend you check out JS. For all you may have heard otherwise, it's actually fairly Python-like and I often feel like I'm writing Python in JavaScript. Yeah and then it goes and does something stupid like telling you that 2 + 2 = 22 requiring one to bounce a chair off a wall in a fit of rage. Its a pale immitation at best, albeit one with some neat chops for closures and prototype OO
|
# ? Jul 30, 2013 14:46 |
|
digitalcamo posted:I'm currently in my second week of learning how to program in Python using Learn Python The Hard Way. So far I understand all the code that is thrown at me. Should I use more than one learning source or multiple? I've had several people tell me that you need to be learning by getting started on a big project you want to do. How am I suppose to start a big project and don't even know how to program. This my first programming language by the way. And I want to learn how to program, not learn how to program a big project and that's all I learn to do. Hello fellow python 2nd-weeker! I've been following a beginners book along side using codecademy and I've found that the web learning is pretty good as a supplement, I'd recommend it.
|
# ? Jul 30, 2013 15:04 |
|
digitalcamo posted:I'm currently in my second week of learning how to program in Python using Learn Python The Hard Way. So far I understand all the code that is thrown at me. Should I use more than one learning source or multiple? I've had several people tell me that you need to be learning by getting started on a big project you want to do. How am I suppose to start a big project and don't even know how to program. This my first programming language by the way. And I want to learn how to program, not learn how to program a big project and that's all I learn to do. Considering you're only in your second week, i'd recommend a small project over a big one. But it is definitely good to have something outside of just the practice examples in a a book. If you can't think of any ideas, there's always these ones: http://www.python-forum.org/viewtopic.php?f=10&t=378
|
# ? Jul 30, 2013 15:05 |
|
Which book are you following? I have looked at codecadmy and liked what I saw. And unfortunately like I do everything I looked to see what other people thought about it. Most of what I read about codecadmy was negative. But that might have been the opinions of programmers that believe they know everything. I might give that site a shot. I would like to think any resource I can get my hands on would be beneficial either way.
|
# ? Jul 30, 2013 15:17 |
|
digitalcamo posted:I'm currently in my second week of learning how to program in Python using Learn Python The Hard Way. So far I understand all the code that is thrown at me. Should I use more than one learning source or multiple? I've had several people tell me that you need to be learning by getting started on a big project you want to do. How am I suppose to start a big project and don't even know how to program. This my first programming language by the way. And I want to learn how to program, not learn how to program a big project and that's all I learn to do.
|
# ? Jul 30, 2013 15:26 |
|
digitalcamo posted:I'm currently in my second week of learning how to program in Python using Learn Python The Hard Way. So far I understand all the code that is thrown at me. Should I use more than one learning source or multiple? I've had several people tell me that you need to be learning by getting started on a big project you want to do. How am I suppose to start a big project and don't even know how to program. This my first programming language by the way. And I want to learn how to program, not learn how to program a big project and that's all I learn to do. I'm probably two weeks ahead of you in my Python/programming adventure, and I've been alternating between Learn Python the Hard Way and the Udacity CS101 course. I feel like they complement each other pretty well - the Udacity course is pretty bad having you get really familiar with the concepts it introduces, but I don't think I would have gotten a decent grasp on classes (and especially inheritance) without having it explained to me in small bites. I might be a little biased towards things that function like university courses though, since I'm a humanities grad student and I'm better at structured learning. Over the course of the Udacity course you design a rudimentary search engine, which helped me see how "real" (parts of it are pretty contrived but whatever) programs get made. The instructor is also really good, I'd at least check it out and see if it works for you.
|
# ? Jul 30, 2013 15:44 |
|
I learned from Think Python and I feel like this is a book that should deserve far more praise than The Hard Way. I also like how it seems to be always changing and updating things (back when I read it was called How to Think Like a Computer Scientist)
|
# ? Jul 30, 2013 15:45 |
|
Symbolic Butt posted:I learned from Think Python and I feel like this is a book that should deserve far more praise than The Hard Way. I agree with this. Not that Hard Way is bad, but I like Think Python more. Anyway, I typed up a list like this in this thread years ago, but off the top of my head, here's some projects a beginner might like to tackle:
|
# ? Jul 30, 2013 20:25 |
|
duck monster posted:Yeah and then it goes and does something stupid like telling you that 2 + 2 = 22 requiring one to bounce a chair off a wall in a fit of rage. Its a pale immitation at best, albeit one with some neat chops for closures and prototype OO There's only a few times that a bug like that has bit me, and I've never felt rage like that. "use strict"; (which is on by default in the JS framework we wrote) handles most of the bigger annoyances.
|
# ? Jul 30, 2013 20:53 |
|
Well I'll try out Think Python too and see how that is. And the program ideas for a beginner you listed, I don't even know where I would start with that. Are those programs I should at least have an idea on where to start? So far I've only learned about Variables, learning Functions right now, printing, and a little bit of importing. But, I don't know maybe it will all just click one day like anything else you learn. I'm anxious to start making programs that look like a program and not something I have to type into a command line. Or is that how all Python programs are? I'm hoping I'm on track with my learning because learning how to program is definitely something I have to learn how to do.
|
# ? Jul 30, 2013 22:09 |
|
digitalcamo posted:Well I'll try out Think Python too and see how that is. And the program ideas for a beginner you listed, I don't even know where I would start with that. That's kind of the idea with tackling projects as a beginner. Inevitably, you'll not know how to do something so you go figure out how to do it. Like, think about the project to organize files in your downloads directory. You'll need to know how to get a list of files in a directory, so google "python list files in directory". Be sure to read more than one source, because there will inevitably be people recommending stupid things. digitalcamo posted:Are those programs I should at least have an idea on where to start? So far I've only learned about Variables, learning Functions right now, printing, and a little bit of importing. It's still early days for you, just keep plugging along. digitalcamo posted:But, I don't know maybe it will all just click one day like anything else you learn. I'm anxious to start making programs that look like a program and not something I have to type into a command line. Or is that how all Python programs are? What you're talking about is a a program with a GUI. A program that involves you typing at the command line is just as much a program as something with a graphical user interface. A GUI is a more advanced thing to do, but you can definitely make them with Python. There is some advanced, complicated GUI programs out there written in Python. However, depending on who the audience for your programs are, you'll likely find yourself less and less worried about whether or not you have to type something at the command line.
|
# ? Jul 30, 2013 22:27 |
|
Well I didn't know if looking up how to do this or do that in a program would be considered cheating and being lazy. Wasn't sure if that's a good way to learn or if I should be able to figure it out myself. Guess that is a little ignorant way of thinking though because I didn't simply figure out how to do electric work, someone had to teach me how to bend pipe, how to make up this motor or transformer so it doesn't blow up. Guess the same thing applies to learning how to program.
|
# ? Jul 30, 2013 22:39 |
|
digitalcamo posted:Well I didn't know if looking up how to do this or do that in a program would be considered cheating and being lazy. Wasn't sure if that's a good way to learn or if I should be able to figure it out myself. Guess that is a little ignorant way of thinking though because I didn't simply figure out how to do electric work, someone had to teach me how to bend pipe, how to make up this motor or transformer so it doesn't blow up. Guess the same thing applies to learning how to program. Well, maybe some programmers are able to figure stuff out from the first principles of computing, but to the rest of us Google is a godsend.
|
# ? Jul 30, 2013 22:43 |
|
A python IRC bot is what made me finally "get" programming after having messed around in various languages for years.
|
# ? Jul 31, 2013 01:40 |
|
Well didn't take long for me to get confused about functions. def do_twice(f, arg): f(arg) f(arg) def print_twice(arg): print arg print arg do_twice(print_twice, 'spam') print '' I understand that arg gets replaced with 'spam' but why does it print spam four times? Seems like it should only print twice. Why would it not be print f (arg)?
|
# ? Jul 31, 2013 02:26 |
|
1) Use code tags:Python code:
|
# ? Jul 31, 2013 02:52 |
|
Well, I had no idea you could pass functions as arguments.
|
# ? Jul 31, 2013 03:09 |
|
How do you usually pass functions? That code is from the Think Python book. The examples in Learn Python The Hard Way are a little bit different and a little easier to understand. But I like seeing how other people do it.
|
# ? Jul 31, 2013 03:24 |
|
digitalcamo posted:How do you usually pass functions? That code is from the Think Python book. The examples in Learn Python The Hard Way are a little bit different and a little easier to understand. But I like seeing how other people do it. That's how you do it. I think Dominoes is just saying he didn't know you could do it at all. Being able to pass a function to a function isn't a necessary requirement to being able to write programs, so I can see how someone fairly new (IIRC, you're fairly new, Dominoes...I hope I'm not putting my foot in my mouth!) wouldn't realize it was A Thing You Can Do. It's kind of a fundamental part of the way Python works, though.
|
# ? Jul 31, 2013 03:27 |
|
digitalcamo posted:How do you usually pass functions? That code is from the Think Python book. The examples in Learn Python The Hard Way are a little bit different and a little easier to understand. But I like seeing how other people do it. Exactly the way you did it. I believe that functions are just objects in Python (as in I think you can just make a class that has a __call__ method and it's a function). You can pass objects to functions, so there's no reason you can't pass objects that are also functions. Another functional thing that's useful is closures, where you can save some state along with your function. Here's a contrived example: Python code:
|
# ? Jul 31, 2013 03:38 |
|
Thermopyle posted:That's how you do it. e: Nested functions too. Dominoes fucked around with this message at 03:42 on Jul 31, 2013 |
# ? Jul 31, 2013 03:39 |
|
This is because functions are "first class" in Python. For more information: http://en.wikipedia.org/wiki/First-class_function It's neat.
|
# ? Jul 31, 2013 07:20 |
|
I'm having trouble understanding how to get a thread to stop running. It appears from some googling that there's no general way to do this (i.e. no such thing as thread.quit()). In my case, I have a simulation GUI (written with Tkinter) and I want the user to be able to click a "cancel" button if they need to stop a simulation for some reason. How do I accomplish this? I set it up so that clicking the button sets stop_thread to True. This in turn is supposed to cause a change in a similar variable inside the simulation, which results in the simulation calling sys.exit(). But nothing actually happen. The simulation keeps on running until it's finished, as though the change in variable is not happening. What's the correct way to communicate between threads here? Psuedo-code: code:
|
# ? Jul 31, 2013 07:40 |
|
Use a threading.Event object. It does basically what you are trying to do, but it will actually work.
|
# ? Jul 31, 2013 08:07 |
|
evensevenone posted:Use a threading.Event object. It does basically what you are trying to do, but it will actually work. I read about these, but I don't really get how they work. (I've been working with threading for maybe three days nows, so not everything is clear yet.) I assume that I want to set the Event flag to True when the user clicks the cancel button, but then I'm in the same place of not knowing how to communicate this information to the other thread. FoiledAgain fucked around with this message at 09:05 on Jul 31, 2013 |
# ? Jul 31, 2013 08:19 |
|
Could you use a while statement with a break statement, or is that too simplistic in this context?
|
# ? Jul 31, 2013 09:05 |
|
Am I making things hard on myself by using X11 to hook keyboard input to monitor for global key presses on Ubuntu? I basically just need this script to run in the background and call one function when I press ctrl+c and another when I press ctrl+v. I got it working in Windows using pythoncom and pyhook, but Linux is a bit tougher than that.
|
# ? Jul 31, 2013 14:36 |
|
May I ask exactly what your program wants to do here? I assume something to do with the clipboard? It's likely there are simpler ways under X11, because X11 can't snoop key events globally.
|
# ? Jul 31, 2013 14:50 |
|
duck monster posted:That I doubt. Cocos2d for ios has the lionshare of the market, is conceptually multiplatform via cocos2s-x and its html5 spin-off and has zynga as the 700lb gorilla backing it. Zynga is dying fast,but that's besides the point. For iOS (again, I'm being specific to iOS here) cocos2D is going to all but vanish. This does not mean cocos2D is going away. I was pointing out that it's heavy focus on iOS will be going away most likely, as that was one of the original poster's concerns: that so much of it's tutorials / samples were iOS related. I'm simply pointing out that the focus of cocos2D will shift away from iOS, and has been slowly for a little while, but that trend will accelerate since Apple's new 2D game API will likely be getting a large dev mind-share in iOS-land.
|
# ? Jul 31, 2013 15:07 |
|
FoiledAgain posted:I read about these, but I don't really get how they work. (I've been working with threading for maybe three days nows, so not everything is clear yet.) I assume that I want to set the Event flag to True when the user clicks the cancel button, but then I'm in the same place of not knowing how to communicate this information to the other thread. The other thread can check the state of the event with is_set(). So it would basically just replace that simulation.stop_thread Boolean.
|
# ? Jul 31, 2013 16:18 |
|
I want a lightweight graphing library to integrate with wxPython that can do simple but nice looking and fast 2D line graphs that allows the user to pan and zoom. Matplotlib is okay but it's very heavy and slow. The annotation support is nice though. If there's no library like this existing, would it be better to make one in PyGame or some kind of canvas? My requirement is only a simple 2D line graph with 500-5k data points. Just want lots of control over the design of it. I have minimal desktop GUI experience, but some frame drawing experience via XNA, processing, and html5 canvas.
|
# ? Jul 31, 2013 18:47 |
|
MeruFM posted:I want a lightweight graphing library to integrate with wxPython that can do simple but nice looking and fast 2D line graphs that allows the user to pan and zoom. Chaco? Relatively simple to make 2D plots, interactive, integrates with wxPython.
|
# ? Jul 31, 2013 19:01 |
|
OnceIWasAnOstrich posted:Chaco? Relatively simple to make 2D plots, interactive, integrates with wxPython. Thanks. Is there an easier way to install this than do infinite recurse package installation? I tried installing with easy_install which gives me a trait.api error so i install traits and I get an enable.api error and I try to install enable and I get a swig error which is not a python package? I tried installing the EDP https://www.enthought.com/products/epd/free/, but apparently it's now the Canopy Express standalone python distribution instead of just a package? Wow.
|
# ? Jul 31, 2013 20:06 |
|
MeruFM posted:I want a lightweight graphing library to integrate with wxPython that can do simple but nice looking and fast 2D line graphs that allows the user to pan and zoom. Have you checked out sage? It has multiple backends and has been incredibly fast and easy to use for my needs. Reference for 2D plotting: http://www.sagemath.org/doc/reference/plotting/ Some cool poo poo that probably is completely irrelevant for your needs: http://wiki.sagemath.org/pics and http://www.sagemath.org/tour-graphics.html edit: further investigation yields that sage uses matplotlib for 2D graphing, so this might be a moot point salisbury shake fucked around with this message at 23:04 on Jul 31, 2013 |
# ? Jul 31, 2013 20:07 |
|
So I needed something that could execute commands on multiple Linux systems and bring the data back to me for parsing. So using Python and Pexpect I wrote the following and I just wanted to share as this is the very first project I've ever undertaken in Python let alone Pexpect. The only thing the script doesn't ask for is the file with the IP addresses or hostnames instead it's hard coded to read a targets.txt file in the directory it's executed from. Eventually I'll update it so it has a help function and ask for a custom file with a list of hosts and maybe sanitize user input etc.... But I was stoked I got this far and I just want to share! Python's pretty cool. edit* also it writes an error log with a best guess as to why it couldn't log into a server. code:
|
# ? Jul 31, 2013 20:21 |
|
evensevenone posted:The other thread can check the state of the event with is_set(). So it would basically just replace that simulation.stop_thread Boolean. It works perfectly now. Thanks!
|
# ? Jul 31, 2013 21:31 |
|
Suspicious Dish posted:May I ask exactly what your program wants to do here? I assume something to do with the clipboard? It's likely there are simpler ways under X11, because X11 can't snoop key events globally. Yeah sure, I'm just making a small script to monitor my different computers for copy/paste events in order to enable a big shared clipboard and clipboard history through a django app. I've got the django app built with a little API all set up to handle the clipboard data, and I basically want the script to globally monitor for key combinations. On ctrl+c I want it to take the data currently in the clip board and blip it on over to the django app, and then on a separate keypress (not actually ctrl+v) I would like it to pull down the most recent entry under a certain user from the django app and store that information to the clipboard. I've got all of the rest of this stuff working, the Django app is built, I've got clipboard reading and writing working across osx, ubuntu, and windows and I have global keyboard monitoring working on windows -- but osx and ubuntu are a bit tougher to do it on since they are real operating systems. I had found some code that used xlib that seems like it might work, but if you are saying that it can't hook globally then I guess I should ask for an opinion on a solution that will work.
|
# ? Aug 1, 2013 00:36 |
|
MeruFM posted:Thanks. Is there an easier way to install this than do infinite recurse package installation? I used to work on chaco. It's not especially lightweight, it's geared towards interactive and high frequency streaming plotting. It depends on alot of other machinery as you have discovered. As an alternative to EPD (since it is no longer available, AFAIK) I would suggest Anaconda, which is free and self-contained. Not sure if Chaco is part of the default install but if not just run "conda install chaco" afterwards and it will fetch chaco as well as any necessary dependencies for you. [disclaimer: I work for Continuum]
|
# ? Aug 1, 2013 05:31 |
|
|
# ? Jun 11, 2024 17:35 |
|
Part generic programming and part pythonic question: I'm currently grinding through a weird project at work and reverse engineering a lovely piece of software through wireshark dumps. I have a bunch of data that I can only describe as "inverted hex"? I don't think it's an endian issue because array.byteswap doesn't give the same result. code:
Am I doing something wrong, and if not, what's the quickest way to perform the inversion on each byte in a string in Python?
|
# ? Aug 1, 2013 11:32 |