|
code:
|
# ? Nov 5, 2010 00:08 |
|
|
# ? May 30, 2024 05:51 |
|
Spime Wrangler posted:Heh, guess I haven't updated for some time now. Its working fine at home under 2.6.6 so nvm I guess. It's numpy. If you have an different version of numpy installed than the one matplotlib was coded against it blows the hell up on windows xp. It took me a while to figure out why as well.
|
# ? Nov 5, 2010 01:41 |
|
OK guys, I'm trying to access a number of HTTP APIs that are sitting behind HTTP authentication using httplib.HTTPConnection I tried to format the URL to pass the auth information through (bad practice, probably, but I'm just trying to get this thing to work - it's a proof of concept anyway), but it's still sending the HTTP challenge back. I have something like this: code:
Anyway, I need to know how to pass the auth details through correctly. I'm on Python 2.6, if that helps
|
# ? Nov 5, 2010 06:48 |
|
bobthecheese posted:OK guys, I'm trying to access a number of HTTP APIs that are sitting behind HTTP authentication using httplib.HTTPConnection AFAIK httplib does not do authentication. Check out httplib2: http://code.google.com/p/httplib2/ And here's your code (with anal retentive changes included). code:
In so far as APIs go, two-legged OAuth is becoming the standard protocol for API security, it's fairly straightforward and can accomodate varied deployments, including federation. deimos fucked around with this message at 09:16 on Nov 5, 2010 |
# ? Nov 5, 2010 08:26 |
|
So the DBAPI is pissing me off. I'm using PyODBC to write to an SQL Server DB through a stored procedure. The PyODBC driver does not support callproc, so the only way to call the proc is via cursor.execute("EXEC write_to_db ?, ?, ...", (arg1, arg2, ...). This causes the following to occur on the db:
Any ideas anyone?
|
# ? Nov 5, 2010 12:25 |
|
deimos posted:AFAIK httplib does not do authentication. I guess it depends on what you mean for authentication but you do have an HTTPSConnection that can use certificates: http://docs.python.org/library/httplib.html#httplib.HTTPSConnection The trick is that there's no validation of the server's certificate, which may or may not be a big deal depending on your needs.
|
# ? Nov 5, 2010 14:24 |
|
Some interesting news from the web framework front: Repoze.bfg has become Pyramid, part of the Pylons Project Pyramid info and documentation Highlights:
|
# ? Nov 6, 2010 02:08 |
|
Lurchington posted:I guess it depends on what you mean for authentication but you do have an HTTPSConnection that can use certificates: Authentication is authentication. If there's no validation of the server cert then there's no authentication. What he's trying to do is Basic Auth (part of the http standard) and uses the Authentication headers (which I guess he could build manually).
|
# ? Nov 6, 2010 02:45 |
|
deimos posted:Authentication is authentication. If there's no validation of the server cert then there's no authentication. What he's trying to do is Basic Auth (part of the http standard) and uses the Authentication headers (which I guess he could build manually). The example was talking about passing a username and password over an HTTPConnection as well as an HTTPS, so I think the tautology is a bit misplaced. Anyway, here's a reasonable looking subclassed-HTTPSConnection for the server cert validation. Lurchington fucked around with this message at 03:57 on Nov 6, 2010 |
# ? Nov 6, 2010 03:23 |
|
All right, I have a beginner question. I want to fill a 200x200 bitmap using Tkinter but I am kind of struggling using the "put" method in PhotoImage; they recommend building a list of colors and positions for each row so that you can call the put method only once. So, I guess my question is how can I create the lists correctly? Here's my code: code:
|
# ? Nov 7, 2010 00:06 |
|
So I need to use SciPy, but I'm running Python 2.7 under Windows, and the SciPy installer complains that it can't find 2.6. Can anybody offer me any tips on getting it working with my setup?
|
# ? Nov 7, 2010 02:13 |
|
>>> help(PhotoImage.put) Help on method put in module Tkinter: put(self, data, to=None) unbound Tkinter.PhotoImage method Put row formated colors to image starting from position TO, e.g. image.put("{red green} {blue yellow}", to=(4,6))
|
# ? Nov 7, 2010 02:52 |
|
Rohaq posted:So I need to use SciPy, but I'm running Python 2.7 under Windows, and the SciPy installer complains that it can't find 2.6. Can anybody offer me any tips on getting it working with my setup? Install 2.6?
|
# ? Nov 7, 2010 06:05 |
|
BeefofAges posted:Install 2.6? EDIT:- Never mind, found this, and going to give it a go: http://www.lfd.uci.edu/~gohlke/pythonlibs/ Rohaq fucked around with this message at 16:23 on Nov 7, 2010 |
# ? Nov 7, 2010 15:38 |
|
I ended up (after much more googling, and mashing several different tutorials together) with this:code:
|
# ? Nov 7, 2010 23:19 |
|
Stabby McDamage posted:2. Is there any way to ask for the old print statement in python 3? I'd never use it in code, but it might be nice on the command line. Unfortunately, it doesn't look like there's a "__past__" module. This was already answered, but I wanted to mention that ipython does pretty much exactly this, but for all functions. code:
|
# ? Nov 9, 2010 06:51 |
|
I'm pretty amateur when it comes to coding, I'm trying to make a program with evolutionary principles. Anyway, I'm running into problems which make no sense to me. I'm trying to make a class, but it's spitting the dummy, code:
If I hack it so that plant.init is meant to take 2 arguments I get around that problem but now it's telling me that the for loop in the class has a "TypeError: 'plant' object is not iterable" I don't understand, I'm not trying to iterate the object, just through my genome list. This probably seems like the most retarded questions to you pros but..
|
# ? Nov 9, 2010 09:10 |
|
You are passing it two and it only accepts one. The first parameter of a method is the object so a.b() is the same as b(a) so a.b(c) is b(a, c). So you need to change your method to take (self, genome). also it's __init__ not init so it should be __init__(self, genome)
|
# ? Nov 9, 2010 09:17 |
|
Thanks man, that was really confusing the hell out of me
|
# ? Nov 9, 2010 09:18 |
|
I have only just started with python and I am not very good but I have a question if someone could assist or if its really bad someone can just tell me to go right away. Ive been working on a small thing just to get the hang of it take that takes a series of inputs including time and then is used to calculate my TOIL from work. Oddly I was able to get that to all work first go and it calculates it and what not and multiplies it correctly and then writes it to file, well after I figured out that you cant write a float to the file so I had to convert it all to strings first. I am now at the point however where I want to be able to do one of two things based on the users input which I know I would use a series of if statements for which I already did earlier in the code to decide how to multiply a variable I had based on their input. I dont know how to do the same though to decide how to execute a different action based on the choice. As I said I am not very good but I would assume that I need to "mark/define" my sections of code and then call that "section" based on the answer? Sorry if I am being rather simple with this all but I am trying to get as much done myself without having to bug people.
|
# ? Nov 9, 2010 23:01 |
|
insidius posted:I have only just started with python and I am not very good but I have a question if someone could assist or if its really bad someone can just tell me to go right away. I'm not entirely sure what you mean by "mark/define", but it sounds like you're asking how to use functions. Have you done any programming before? The python tutorial is pretty solid, but I'm not sure how useful it is for someone with no programming experience at all.
|
# ? Nov 9, 2010 23:26 |
|
Sailor_Spoon posted:I'm not entirely sure what you mean by "mark/define", but it sounds like you're asking how to use functions. Have you done any programming before? The python tutorial is pretty solid, but I'm not sure how useful it is for someone with no programming experience at all. Ahh yes that makes sense Move my current code into two sets of functions then call the one I need. Why do I fail at things that are so simple even after I re-read through the function page. Thank you good sir for pointing out my obvious failure.
|
# ? Nov 9, 2010 23:32 |
|
echinopsis posted:I'm pretty amateur when it comes to coding, I'm trying to make a program with evolutionary principles. Anyway, I'm running into problems which make no sense to me. I'm trying to make a class, but it's spitting the dummy, Quick question, why are you making a class here? Seems like an unnecessary level of complexity unless you're going to be working with a bunch of different kinds of plants who use completely different ways of stripping out gene sequences from genomes. Anyway, something to think about. code:
RobotEmpire fucked around with this message at 06:05 on Nov 10, 2010 |
# ? Nov 10, 2010 06:03 |
|
RobotEmpire posted:Quick question, why are you making a class here? Seems like an unnecessary level of complexity unless you're going to be working with a bunch of different kinds of plants who use completely different ways of stripping out gene sequences from genomes. Anyway, something to think about. This is precisely how 99% of scientific software becomes total garbage. If you're going to the trouble of writing software to solve a problem, build a good foundation of software development skills and code it right. It'll be more maintainable and thereby more useful to other scientists down the road, and you'll have learned a valuable skill. Without even bothering to speculate whether an object-oriented approach is suitable for this problem, I can say that "getting the core logic working before worrying about [anything else" is the wrong attitude.
|
# ? Nov 10, 2010 06:30 |
|
RobotEmpire posted:Quick question, why are you making a class here? Seems like an unnecessary level of complexity unless you're going to be working with a bunch of different kinds of plants who use completely different ways of stripping out gene sequences from genomes. Anyway, something to think about. Thanks for the tips. I've changed it a bit since then. Reading "how-tos" in coding doesn't tell you much about theory, like don't repeat yourself etc. Yeah that plant class is going to be used many many times, it's going to simulate plants growing, in my mind a instance of the class for each plant seems the easiest way to maintain it. Should only the things that absolutely necessary be in an class be in one? Should everything else just be functions? MaberMK posted:This is precisely how 99% of scientific software becomes total garbage. If you're going to the trouble of writing software to solve a problem, build a good foundation of software development skills and code it right. It'll be more maintainable and thereby more useful to other scientists down the road, and you'll have learned a valuable skill. Well this isn't really scientific software or anything, it's me loving around on my holidays based on an idea of trying to make entities evolve towards an ecosystem, incorporating an emerging system of families/species etc Part of this is to also learn how to learn fundamentals anyway, I have little background in coding. quote:Without even bothering to speculate whether an object-oriented approach is suitable for this problem, I can say that "getting the core logic working before worrying about [anything else" is the wrong attitude. Interesting, that is exactly what I am doing.. What's a better approach (generally)?
|
# ? Nov 10, 2010 07:47 |
Nitpicky question, but which is the preferred way to comment? The PEP guide wasn't clear on this....code:
code:
code:
|
|
# ? Nov 10, 2010 12:11 |
|
MaberMK posted:This is precisely how 99% of scientific software becomes total garbage. If you're going to the trouble of writing software to solve a problem, build a good foundation of software development skills and code it right. It'll be more maintainable and thereby more useful to other scientists down the road, and you'll have learned a valuable skill. Without even bothering to speculate whether an object-oriented approach is suitable for this problem, I can say that "getting the core logic working before worrying about [anything else" is the wrong attitude. Right I totally get this 100%, but this is a dude's hobby project, and dude has zero background programming. From a motivational perspective -- speaking from first-hand experience -- there's nothing that will make you say "gently caress it" more than not being able to get a single thing working.
|
# ? Nov 10, 2010 12:19 |
|
echinopsis posted:Thanks for the tips. I've changed it a bit since then. Reading "how-tos" in coding doesn't tell you much about theory, like don't repeat yourself etc. Well, I dunno about all that. But have you read Dive Into Python? It's an excellent resource. For just an introduction to classes: http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm
|
# ? Nov 10, 2010 12:25 |
|
oiseaux morts 1994 posted:Nitpicky question, but which is the preferred way to comment? The PEP guide wasn't clear on this.... Do what you like best, there's no single right way and there's no reason to follow a guideline from PEP8 if you have an alternative that's reasonable.
|
# ? Nov 10, 2010 14:46 |
|
oiseaux morts 1994 posted:
|
# ? Nov 10, 2010 15:01 |
|
RobotEmpire posted:Well, I dunno about all that. NO NO DO NOT DO THIS
|
# ? Nov 10, 2010 15:35 |
|
tripwire posted:NO In fairness, DIP is still prominently featured on the first post, so it's not surprising we're seeing these still. For a bit more content, since PEP8 was mentioned, I have determined where I personally deviate from it: I got tired of staying at 79 character lines for exception/assert raising output. Especially with assertions being a statement instead of a function. Seriously, nothing more annoying than seeing the stacktrace only show the last 1/3 of the statement and having to physically go to the line and see what the hell you were asserting on. Yes, the text should be descriptive, but it's a kick in the teeth to break a nice grammatically-correct sentence over 5 lines and be rewarded with slightly less output. Lurchington fucked around with this message at 15:48 on Nov 10, 2010 |
# ? Nov 10, 2010 15:42 |
|
RobotEmpire posted:Right I totally get this 100%, but this is a dude's hobby project, and dude has zero background programming. From a motivational perspective -- speaking from first-hand experience -- there's nothing that will make you say "gently caress it" more than not being able to get a single thing working. I suppose I kinda jumped before I really thought carefully about his situation. I will most certainly agree that fundamentals come before higher-level design principles. (I work with the abominations scientists produce every day so I'm a little sensitive to "how I do program" and "<insert scientific principle or problem>" appearing in the same statement) Lurchington posted:In fairness, DIP is still prominently featured on the first post, so it's not surprising we're seeing these still. Use a line span and you can stay under the 79 character limit and get the whole string. code:
|
# ? Nov 10, 2010 16:05 |
|
tripwire posted:NO What's wrong with Dive Into Python?
|
# ? Nov 10, 2010 16:30 |
qntm posted:What's wrong with Dive Into Python? http://oppugn.us/posts/1272050135.html
|
|
# ? Nov 10, 2010 17:52 |
|
oiseaux morts 1994 posted:http://oppugn.us/posts/1272050135.html I had never read Dive Into Python before. I read your link followed by the first chapter of the book.... wow. I had no idea.
|
# ? Nov 10, 2010 18:32 |
|
I'm trying to use Tkinter's Canvas to produce a vector map of Great Britain that you can pan around in, and zoom into. It's working great so far, using .move and .scale from the Canvas class for the panning and zooming, respectively. These methods actually directly manipulate the coordinates of each object on the canvas, so you aren't moving the 'viewport', you're just moving everything around on the canvas to simulate that effect. This is all well and good until I want to draw something new, like a line from London to Manchester. I essentially need a function that will get my old coordinates to the 'new' coordinates. If I only implemented panning and forgot zooming, this would be easy since I can update a variable with every panning transformation and then run that against any 'old' coordinate to get it into the right place e.g. code:
The canvas.scale method is this (for x and y but shown only for x): code:
I don't even know what mathematics this involves, or the name of it, so even that would be helpful. I posted this question in here in the hopes that maybe somebody has had to do the same thing, as it seems to be a byproduct of the tkinter canvas not having a viewport.
|
# ? Nov 10, 2010 18:46 |
|
MaberMK posted:Use a line span and you can stay under the 79 character limit and get the whole string. Breaking a string inside parentheses is preferred. Like so: code:
|
# ? Nov 10, 2010 19:28 |
|
MaberMK posted:Use a line span and you can stay under the 79 character limit and get the whole string. Well, your answer caused me to think about it a bit more: here's all 1 string and not broken up: pre:def wrap(num): assert num<10, 'asdfsadfsadfsadfasdfa<snip for tables>ffffffffffffffff' return wrap(num+1) yields Traceback (most recent call last): File "assert_test.py", line 19, in <module> wrap(10) File "assert_test.py", line 2, in wrap assert num<10, 'asdfsadfsadfsadfasdfa<snip for tables>ffffffffffffffff'' AssertionError: asdfsadfsadfsadfasdfa<snip for tables>ffffffffffffffff compare to: pre:def wrap1(num): assert num<10, ('asdfsadfsadfsadfasdfasdfasdfasdfasdfasdfasdfasdffffffffff'+ 'ffffffffffffffffffffffffffffffffffffffffasdfsadfsadfsadfa'+ 'sdfasdfasdfasdfasdfasdfasdfasdfffffffffffffffffffffffffff'+ 'fffffffffffffffffffffff') return wrap1(num+1) yields: Traceback (most recent call last): File "assert_test.py", line 19, in <module> wrap1(10) File "assert_test.py", line 9, in wrap1 'fffffffffffffffffffffff') AssertionError: <omitted, it's all the same everytime> pre:def wrap2(num): assert num<10, ('asdfsadfsadfsadfasdfasdfasdfasdfasdfasdfasdfasdffffffffff'\ 'ffffffffffffffffffffffffffffffffffffffffasdfsadfsadfsadfa'\ 'sdfasdfasdfasdfasdfasdfasdfasdfffffffffffffffffffffffffff'\ 'fffffffffffffffffffffff') return wrap2(num+1) yields Traceback (most recent call last): File "assert_test.py", line 26, in <module> wrap2(10) File "assert_test.py", line 13, in wrap2 assert num<10, ('asdfsadfsadfsadfasdfasdfasdfasdfasdfasdfasdfasdffffffffff'\ AssertionError: <snip> and based on sailor_spoon's suggestion: pre:def wrap3(num): assert num<10, ('asdfsadfsadfsadfasdfasdfasdfasdfasdfasdfasdfasdffffffffff' 'ffffffffffffffffffffffffffffffffffffffffasdfsadfsadfsadfa' 'sdfasdfasdfasdfasdfasdfasdfasdfffffffffffffffffffffffffff' 'fffffffffffffffffffffff') return wrap3(num+1) yields: Traceback (most recent call last): File "assert_test.py", line 26, in <module> wrap3(10) File "assert_test.py", line 20, in wrap3 assert num<10, ('asdfsadfsadfsadfasdfasdfasdfasdfasdfasdfasdfasdffffffffff' AssertionError: <again, the same> All these assertion commands produce the same output, but in the first one, the stacktrace gave me a little extra information on the one liner, and I appreciate that as long as I don't go too far over 79. Lurchington fucked around with this message at 19:50 on Nov 10, 2010 |
# ? Nov 10, 2010 19:46 |
|
|
# ? May 30, 2024 05:51 |
|
RobotEmpire posted:Well, I dunno about all that. I did read this book called "head first into programming" or something, it's not a learn to python book but python was the language it taught. It's cheesy as gently caress, but I guess it does help some things stick, but it was also more about how to write code than, learn these tools and dive in. I can recognise when my code is poo poo, I just don't know how to improve it.
|
# ? Nov 10, 2010 19:49 |