| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Comments:
<0> Does it support indexing? <1> like [i], yes <0> Perhaps you should make it support __iter__? <1> that's what I'm trying to build <2> Hey guys, I'm having some trouble with a python script I'm writing and I just can't seem to figure out what could be happening. <1> I'm trying to implement __iter__ without making a list <0> alus, oh. for i in xrange(self._len): yield self[i] <1> neat <2> Right after my import statements I'm declaring a variable: DEBUG = False <2> I then declare another variable right after that: ALLOWED_OSX_VERSIONS = ['10.3', '10.4'] <2> I then wrote a bunch of functions that use both of those just fine.
<3> good night <2> THe last function I wrote is main(), and it can access ALLOWED_OSX_VERSIONS jsut fine but it can't seem to access DEBUG <2> Why would it be able to access one and not the other? <4> what error do you get when accessing DEBUG? <0> Maybe you ***igned to DEBUG inside main()? <2> Yango_: UnboundLocalError: local variable 'DEBUG' referenced before ***ignment <2> TFK: That's actually the problem; I want to ***ign a new value to DEBUG based on user input but when I say DEBUG = True it makes a new variable DEBUG in main's scope and doesn't touch the original <0> There's your problem. Write 'global DEBUG' at the top of the main() module <2> TFK: But why can I access it just fine from all the other functions in the same script? And why can I access the second one from inside main just fine? <0> Because you don't ***ign to them there. <0> (No, I don't understand it very well :-( ) <5> lol <5> x = 2 <5> def y(): <5> x # 2 <5> x = 2 # error <1> TFK: thanks <5> the error is because python hasnt been told you want to change x <2> TFK: I access DEBUG in the other functions in an if statement; if I try to put it in an if statement in main I get the UnboundLocalError <0> http://www.faqts.com/knowledge_base/view.phtml/aid/4722 <--- by Time Peters? <2> TFK: OK, the global thing worked. I'm going to have to read up a bit more on global scope, I think <2> TFK: Thanks <4> can filters be chained? <5> Yango_, filters? <6> What is the simplest way to load a variety of image formats on multi-platforms under python? I didn't see anything clearly in the repository. <4> {{ myvar|default:"Empty String"|default_if_none:"None Value" }} <6> s/repository/module index/ <4> oops wrong channel! <7> im trying to write a multithreaded network app using threading and socket modules. Everything seems to work fine, but when I exit the program on linux, it hangs and wont quit the program. Also, the socket enters the FIN_WAIT state and so blocks restart of the program for 5 minutes or so. <8> SO_REUSEADDR <9> probably best to fix the problem first tho <9> sounds like you aren't closing the socket properly <7> in the parent, as the last statement i do a self.server.close() where self.server is the listening socket <10> shadfc, are you using __del__ for this ? <7> umm, im not sure what that is (new to python) <9> http://www.amk.ca/python/howto/sockets/sockets.html#SECTION000510000000000000000 ? <11> hi ^_^ how can i get Most stuff out an unknown exception? <11> atm i'm printing sys.exc_info[0] and sys.exc_info[1] but even that's a little dull <11> is there a way to get e.g an callstack? <11> that lead to the exception <4> uttumuttu, import traceback <12> hi...what's the best way to sort a list of objects, based on an attribute of those objects? i've tried doing like list.sort(key=lambda indi:indi.score), but it seems to give me no joy
<4> what's the problem with that, chzmgr` ? <12> well, it seems to do something, but not equivalent to a plain sort() :S <4> well, it shouldn't do the same thing as a plain sort, of course! <12> ok, this is going to be a bit of a pain to explain, so bear with me :) <13> python newb here, how can i get a string describing an object? is there anything like php <13> 's print_r? <14> repr() <14> if it's not detailed enough for you, upgrade your __repr__ method <12> right...so i've got a list of individuals, which contain a "chromosome" - a list of binary values <4> so, in short, there's no automatic var_dump or print_r, zeasier <14> and yes, it's not as good as print_r, but that's a sacrifice you're going to have to make because python's object system is infinitely more complicated than tying methods to an array, like php's. <12> calling sort on the list of individuals sorts them fine for some reason (this isnt my code) <9> Jerub: infinitely ? <4> check the indiviual cl*** <12> but, if i evaluate the chromosome (i.e. sum it), and store the value in a variable in each individual, and sort on this, then it doesnt sort properly <4> and see how are __*__ defined <13> Jerub: more complex? it actually seems simpler to me <13> but i'll find out soon enough <12> would __cmp__ be responsible? <14> zeasier: php's objects are a special case of their hashmap construct. <4> complex from the point of view of internal implementation, not from the user point of view <13> also is there better documentation on mod_python anywhere? that is besides modpython.org? <4> chzmgr`, probably <12> hmmm, curious <9> how good is mod_python anyway? better than cgi ? <13> daveBSD: everything is better then cgi <8> mod_python not by much though. <13> also what is better? <13> faster, easier? <6> Hmm..PIL seems to say indicate that I should look at the included README for information on usage/redistribution, but there is no such file included. :/ <6> Ah..and another site seems to indicate it's BSD-like licensed. <15> ignacio: what would you prefer to mod_python? <8> TurboGears <15> hm "megaframework" sounds intimidating <4> TG comes with a production web server? <9> well cgi is slow but i was under the impression that mod_python only supported a subset of the language <8> It uses CherryPy. <15> daveBSD: that's not true <14> mod_python isn't much better than CGI at all <4> repeat, cherrypy comes with a production web server? :) <14> Yango_: cherrypy IS a production web server. <4> CherryPy's HTTP server is pretty good but let's face it, it is no Apache. For this reason, you might want to run your CherryPy site BehindApache in some cases. <13> heh, megaframework. is that a framework with more then average bloat? <9> heh. cherrypy <14> zeasier: well, it's actually a framework containing frameworks. it contains sqlobject, cherrypy, mochikit, kid, etc. <4> so it's a metaframework instead <14> Yango_: yeah, putting it behind apache is probably a good idea, and there's detailed docs on how to do it. <14> Yango_: but saying that something is 'no apache' isn't exactly a positive thing. apache is a bloated piece of ****, that just happens to be really quite good at serving static content and php pages. <4> Jerub, then what do you get of using that combination instead of apache+mod_python + some other framework?
Return to
#python or Go to some related
logs:
perl if match failed syslog-ng tutorial gentoo-wiki ubuntu creative pd1001 aperez.net opensuse freenx resume #math #lisp than d4x #linux #perl
|
|