|
Got started with Python with this book: this book (think python) and i really like it so far. What's a good book to continue learning? I'm using 2.7, but wouldn't mind advancing to 3. I'm mostly interested in learning to make GUIs, maybe some web stuff or games, and some light mathematical use.
|
# ? Dec 17, 2012 12:16 |
|
|
# ? May 8, 2024 06:40 |
|
Thanks for the input guys, I'm still not entirely clear though why I'd use (or import) the copy module rather than just keep a loop like before, i.e.:code:
Also, thanks for the explanation as to why Python was setting ALL instance of x to the same value. That kinda seems like a 'gotcha' to me, but I guess I need to think more like a programmer ? It makes sense to me now, it's just a little counter-intuitive.
|
# ? Dec 17, 2012 16:16 |
|
JetsGuy posted:Thanks for the input guys, I'm still not entirely clear though why I'd use (or import) the copy module rather than just keep a loop like before, i.e.: You don't. It's bad. But we told you why putting d_set outside the loop didn't work, and how to fix that if you somehow had to do it that way.
|
# ? Dec 17, 2012 16:21 |
|
KetchupYEAH! posted:Got started with Python with this book: this book (think python) and i really like it so far. Personally speaking, I stick to 2.7 for a lot of reasons, not the least of which is that it is the 'consensus' Python for astrophysics right now. While some modules exist for 3, not ALL astro python libraries have been re-written for 3. A lot of this is for the simple fact that "this works", and why bother to rewrite it until there is a clear advantage in doing so? I don't remember where the exact hiccup is but I think a lot of it was in matplotlib for a long time. It doesn't help that a lot of people coded a lot of their processing codes for their own work in 2.* and the differences between Py2.* and Py3 are big enough to actually matter. So a lot of people in my field are kinda stuck with 2.* for a long time simply because it's a pain in the rear end to rewrite routines we know to work. So my suggesting here is to determine what you *really* want to do with Python and then settle on a version. If you're just screwing around with it for your own purposes, go to 3. I literally know people that still run FORTRAN code that they wrote on punch cards. There is a LOT of sentiment in the astro community of "I know this works, so I will use this". Even today, I know a lot of young physicists who are taught to use F90 because they have to in order to read all the bullshit code that their advisers write. NASA data still has a ton of FORTRAN code used to analyze the data. Jewel posted:You don't. It's bad. But we told you why putting d_set outside the loop didn't work, and how to fix that if you somehow had to do it that way. Ahhhh. Ok. Thanks again! JetsGuy fucked around with this message at 16:36 on Dec 17, 2012 |
# ? Dec 17, 2012 16:26 |
|
JetsGuy posted:NASA data still has a ton of FORTRAN code used to analyze the data. I taught several python classes at JSC earlier this year. All the obscure and impenetrable initialisms reminded me of when I worked for Navy research lab...
|
# ? Dec 17, 2012 17:05 |
|
Haystack posted:No, your question makes perfect sense. Oh, thanks. I forgot I read that part of the documentation! Sometimes I get too immersed in my reading and with 30 tabs open kind of forget where I'm at. But yeah, I get it now and I bet your solution works when I test it out later today.
|
# ? Dec 17, 2012 18:09 |
|
JetsGuy posted:Also, thanks for the explanation as to why Python was setting ALL instance of x to the same value. That kinda seems like a 'gotcha' to me, but I guess I need to think more like a programmer ? It makes sense to me now, it's just a little counter-intuitive. Different programming languages handle assignment operations in different ways. Python's way of doing things is at least very consistent; assignment operations always create a reference to the object being assigned. This goes for mutable and immutable types alike (although you obviously don't care for immutable ones). One of the appealing things about Python is that the way it behaves is very thoroughly thought-out and consistent. But yes it can be a bit of "gotcha" if you are not used to it.
|
# ? Dec 17, 2012 18:52 |
|
Can I get some opinions on some code I wrote? To give some background, I'm developing automated tests using Robot Framework, which lets you write libraries in Python (or Java). One of the libraries I'm working on is a wrapper for a product's REST API. I've never worked with REST before, or remote function calls in general, but the product's implementation is awful as far as I can tell. I've found that every function seems to handle authentication/data input in one of seven different ways. To work around this, I wrote the following (some names and documentation removed/changed to avoid identifying the product or company):Python code:
Python code:
|
# ? Dec 17, 2012 22:39 |
|
[quote="BeefofAges" post="410668431"]Python code:
|
# ? Dec 18, 2012 01:43 |
|
Captain Capacitor posted:[quote="BeefofAges" post="410668431"] Oh, I don't actually have a good reason for that anymore. It was left over from when I was trying to figure out a stupid mistake I made (I had a module named TestLibrary but it turned out Robot Framework has it's own module named TestLibrary, and the conflict manifested strangely so it took me a while to figure it out).
|
# ? Dec 18, 2012 01:52 |
|
BeefofAges posted:Can I get some opinions on some code I wrote? To give some background, I'm developing automated tests using Robot Framework, which lets you write libraries in Python (or Java). One of the libraries I'm working on is a wrapper for a product's REST API. I've never worked with REST before, or remote function calls in general, but the product's implementation is awful as far as I can tell. From the looks of the api you're having to wrap, they don't seem to have much experience with REST.
|
# ? Dec 18, 2012 02:40 |
|
JetsGuy posted:I literally know people that still run FORTRAN code that they wrote on punch cards. There is a LOT of sentiment in the astro community of "I know this works, so I will use this". Even today, I know a lot of young physicists who are taught to use F90 because they have to in order to read all the bullshit code that their advisers write. Some big part of the numpy stack is fortran. Writing that kind of code is hard, and it works, and other languages can interface with it, and it works, so why would anybody want to re-do it?
|
# ? Dec 18, 2012 02:47 |
|
tef posted:From the looks of the api you're having to wrap, they don't seem to have much experience with REST. Yeah... I think they pretty much settled on a cool sounding buzzword and didn't bother to actually read up on what it means or how to properly use it. I'm just trying to build a decent way to interact with their crappy API so I can test the software behind it.
|
# ? Dec 18, 2012 02:52 |
|
tef posted:From the looks of the api you're having to wrap, they don't seem to have much experience with REST. "Oh, so we just put our function name in the URL? That's easy, then"
|
# ? Dec 18, 2012 03:02 |
|
Given the following SQLAlchemy models how can I query for Tenants in a specific Complex? Is there a better way to model this to allow for such queries? I think I got this stripped down to the bare essentials. Python code:
|
# ? Dec 19, 2012 04:52 |
|
Python code:
|
# ? Dec 19, 2012 05:09 |
|
If I were to write something that uses non-blocking sockets would it potentially be a bad idea to completely ignore WOULDBLOCK exceptions? Like this: Python code:
Optimus Prime Ribs fucked around with this message at 11:28 on Dec 19, 2012 |
# ? Dec 19, 2012 11:22 |
|
Suspicious Dish posted:
Ahh yes, thank you. quote:There may be some way to use the Complex class instead of the ID: I'd expect Unit.complex == my_complex to work, but I haven't tried it. Yeah, I'd expect so too...but it doesn't work.
|
# ? Dec 19, 2012 18:44 |
|
Optimus Prime Ribs posted:If I were to write something that uses non-blocking sockets would it potentially be a bad idea to completely ignore WOULDBLOCK exceptions? Might want to leave it in as defensive code (With a comment, and possibly a log/error)
|
# ? Dec 19, 2012 19:19 |
|
tef posted:Might want to leave it in as defensive code (With a comment, and possibly a log/error) I don't think it's really defensive coding since if the exception isn't handled the program blows up; don't really have any choice about doing something with the exception (even if I just end up silencing it). And writing to a log every time that occurs would probably be a bad idea. I just ran a non-blocking socket script for 5 seconds, counted the number of exceptions I received, and then extrapolated that to an hour and got 259.2 million. So I guess then just stick to silencing it and maybe add a comment?
|
# ? Dec 19, 2012 22:04 |
|
Leave a comment, move on
|
# ? Dec 19, 2012 22:11 |
|
Keepin' calm and carryin' on.
|
# ? Dec 19, 2012 22:23 |
|
Can someone point me to a basic "Babby's first app packaging guide"? For example, assuming I want to install my thing on a computer that only has python but nothing else, and that my app has one or two third party libraries? I'm not finding anything really easily understandable as a newbie.
|
# ? Dec 20, 2012 11:27 |
|
Daynab posted:Can someone point me to a basic "Babby's first app packaging guide"? http://stackoverflow.com/questions/5360873/how-do-i-package-a-python-application-to-make-it-pip-installable
|
# ? Dec 20, 2012 17:09 |
|
Pycharm, the Python IDE that people are always raving about is $25 instead of $100 for individual developers for the rest of the day. http://www.jetbrains.com/specials/index.jsp
|
# ? Dec 20, 2012 18:58 |
|
Thermopyle posted:Pycharm, the Python IDE that people are always raving about is $25 instead of $100 for individual developers for the rest of the day. Sweet. Thanks for the heads up, I wasn't going to but then I noticed licenses are permanent, which is awesome. BeefofAges posted:http://stackoverflow.com/questions/5360873/how-do-i-package-a-python-application-to-make-it-pip-installable That... sound as if I would need pip installed in the first place on that computer, no?
|
# ? Dec 20, 2012 22:54 |
|
Thermopyle posted:Pycharm, the Python IDE that people are always raving about is $25 instead of $100 for individual developers for the rest of the day. I'm kind of on the fence about this. Is it worth it?
|
# ? Dec 21, 2012 01:49 |
|
MeramJert posted:I'm kind of on the fence about this. Is it worth it? Download it and dick around. 30 day free trial. There's also videos and documentation on their site.
|
# ? Dec 21, 2012 01:52 |
|
Thanks for letting us know, Thermopyle. I guess I only thought it worked on a Mac before since I only saw Mac screenshots. Snatched it up for 1.25
|
# ? Dec 21, 2012 04:50 |
Perfect timing for the sale! My PyCharm trial was just about to run out.
|
|
# ? Dec 21, 2012 04:56 |
|
MeramJert posted:I'm kind of on the fence about this. Is it worth it? I dont use it because i've found it unstable. However I havent actually used it since it first came out (and it DID undeniably explode alot back them). Perhaps its more stable now. When it worked, it worked well and its code completions actually frigging worked.
|
# ? Dec 21, 2012 05:31 |
|
Hed posted:Thanks for letting us know, Thermopyle. I guess I only thought it worked on a Mac before since I only saw Mac screenshots. Snatched it up for 1.25 did you get the confirmation email and a key and everything?
|
# ? Dec 21, 2012 07:31 |
|
duck monster posted:I dont use it because i've found it unstable. However I havent actually used it since it first came out (and it DID undeniably explode alot back them). Perhaps its more stable now. However, if you're using any relatively modern PC, it's brilliant. I picked up a personal license for it, but I've not yet had the license through, I think because of the huge backlog jetbrains didn't anticipate.
|
# ? Dec 21, 2012 13:43 |
|
Yes it probably took about 30 minutes but I got an email from sales@jetbrains.com with all of the information.
|
# ? Dec 21, 2012 14:55 |
|
So, I migrated a program I wrote from PyGTK to PyGObject. Afterwards I noticed that it was noticeably slower when doing the following: User selects data -> TreeView is filled with data. So I wrote small test programs for PyGTK and PyGObject where a single TreeView with a ListStore model and six columns is filled with 100 rows of random 8 character strings.Python code:
code:
|
# ? Dec 21, 2012 20:24 |
|
For some reason my brain is not working today and I'm getting impatient with myself. I can't seem to figure out how to get a list of the datetime.date's between two dates. So, I'm wanting something like: Python code:
I'm quite irritated that I can't come up with a function to do this right now, so I'm going to go watch Homeland. edit: Nevermind. Used python-dateutil. It came to me right after I started watching Homeland. Python code:
Thermopyle fucked around with this message at 23:05 on Dec 21, 2012 |
# ? Dec 21, 2012 22:37 |
|
loose-fish posted:So, I migrated a program I wrote from PyGTK to PyGObject. Afterwards I noticed that it was noticeably slower when doing the following: User selects data -> TreeView is filled with data. So I wrote small test programs for PyGTK and PyGObject where a single TreeView with a ListStore model and six columns is filled with 100 rows of random 8 character strings.
|
# ? Dec 21, 2012 22:52 |
|
Plorkyeran posted:Have you tried freezing the TreeView while updating the model? It may be updating the UI on every append/insert, which would be pointless and slow. You're right, I thought detaching the model was enough to keep the UI from updating. However PyGObject is still ten times slower than PyGTK: code:
|
# ? Dec 21, 2012 23:45 |
|
Can you give full complete programs for both?
|
# ? Dec 22, 2012 01:32 |
|
|
# ? May 8, 2024 06:40 |
|
Sure: PyGObject PyGTK
|
# ? Dec 22, 2012 02:20 |