| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Comments:
<0> so i need to iterate through the dict stripping line[0] and line[1] ? <1> a nice way to apply a function to all elements of a list and to capture the resulting list is to use the map function: map(str.strip, list) <1> you could inline that as part of the list comprehension if you wanted. <2> are there any python libraries which can load 3d models and perform operations on them? <0> how about this, sjj: http://pastebin.com/662943 <1> Stork: not entirely .... <0> not? <1> Stork: the first line is making a dictionary from a list of lists.... <0> right <1> you can either inline that map inside the list comprehension, before it gets turned into a dict, or extract a variable refering to the list ant create a dict at a later point.... <1> s/ant/and/ <0> err... who? <1> Stork: have you read the tutorial? <3> ctz: well, blender has python scripting <0> sjj, a lot of it <3> ctz: also check out soya3d and vpython
<4> ctz: possibly panda3d too <2> taking a look, thanks :) <5> hi all <5> for line in inp.readlines(): <5> print line <5> What is this readlines exactly <5> And why can't i use for i in inp: .... <6> payal: you can. <5> Why do I neeed readlines <7> you don't <6> you don't have to <6> teratorn: :P <6> hmmm <7> hi <6> i shoud do a DOE project <5> how can I get help for readlines in python inbild docs <6> documentation for everyone <6> payal: help(file.readline) <5> thanks <6> documentation for everyone, not just tech, is needed. without free, clear and understandable documentation for some things (e.g. gnupg), it can be hard to understand. <5> so what are you gonnna write about <6> payal: GPG - everyone wants to encrypt their emails and knw where a email is from. well, now they can ;) <6> payal: I just need to write some of it up <5> kbrooks: woww! have you written it <5> I want to use mutt to encrypt my emails <5> ofcourse with gpg <8> why? <8> fear or something? <6> payal: no <6> payal: not yet <8> trying to hide your conversations? <8> arent they legal? <6> i need help and input on that. <5> sorry I meant sign my emails <6> while writing it <5> what kind of help <9> Anyone knows if an 'ELF' module exists for Python ? Basically something understanding the ELF format and the debug formats (DWARF, ..) ? Did not find anything using Google or on the Python.org page, but well, maybe someone knows here :-) <6> payal: well, i'll write the "What is gnupg" thing first. <5> oh! <5> bbl <10> hi, i'm using the elementtree lib, the lib provides a function tostring(), i want to call str(myElement) instead of importing tostring and calling tostring(myElement). when i set __str__ = tostring it fails (TypeError: tostring() takes at least 1 argument (0 given) <10> ) <10> how can i bind a method to the __str__ of the cl*** with keeping the parameter? <11> batlogg: Try `__str__ = lambda self: tostring(self)`? <3> batlogg: are you ***igning it to the instance or cl*** ? <11> I imagine that's not the right way to go about it, however <11> (that ***umed you're ***igning to an instance) <11> s/***umed/***umes <10> Cerulean: i ***igned it to an instance <10> is this bad? <11> batlogg: Then the above should work <3> afaik you need to convert to an instancemethod <10> roryy: how would i do that? <11> oh, yes. You'll want to bind the method <3> cl*** a: p***; b=a(); b.__str__=types.MethodType(lambda self: 'foo',b,a) <3> that seems to work <11> batlogg: You could also add it to the cl*** using new.instancemethod <3> ah <3> is that where it is ;) <11> yeah <3> types.MethodType.__module__ usefully says '__builtin__'
<11> batlogg: If you add it to the cl*** you won't have the problem of having to attach the function to each object <11> to be honest, you should probably just subcl*** <3> or you could just use tostring(foo) already ;) <11> heh <11> but how unintuitive is that? Why does it use tostring? <11> about as unpythonic as it gets <3> *shrug* he (effbot) uses it in the PIL too <10> Cerulean: well, i'm using it within zope and need to take care about what i do on cl*** level (persistence), i create the object in the constructor... <3> and it's used in numarray/numpy iirc <10> before that it's just None <10> roryy: if i do tostring() i need to import it all the time... <11> what's wrong with importing it all the time? <11> by all the time I ***ume you mean in each module that you use it <10> Cerulean: probably nothing :) it's just inconvenient <10> Cerulean: yes <11> whatever makes your life easier <10> thanks Cerulean, roryy <12> hi all <13> batlogg: curious why you're using ElementTree over lxml <10> rockyburt: what's lxmls advantage rockyburt? <13> batlogg: speed :) <13> batlogg: its based on libxml2 i believe <13> batlogg: its fa***en's creation <10> rockyburt: speed really matters for me... how much difference? <13> batlogg: and lxml provides the ElementTree api so they're mostly api compatible <13> batlogg: significant i'm told but i haven't done any actual benchmarks <10> (btw. i'm using cElementTree) <13> oh <13> well... fa***en would be the one to ask <3> well, if they're API compatible it shouldn't be impossible to compare <10> rockyburt: see benchmarks at http://effbot.org/zone/celementtree.htm <10> celement tree should be twice as fast as lxml (as it builds on libxml2) <13> you're right <14> is nesting functions like if len(str(station[0]).split(".")[0])==2: <14> bad? <15> I hate nesting the [0] stuff <16> voltagex: depends how readable it ends up to be <15> I find that completely unreadable. <16> voltagex: and how important readability is for you. <3> voltagex: *shrug* it's your code; if you can read that easily, it's fine. I find it a bit dense <6> voltagex: depends <14> I think I'll split it up then <6> i find it bad, but only if its nested too much <14> second question, how can I preserve decimal places in a division operation? <14> i.e. 96000 / 10000 = 9.6 not 9 or 10 <3> 96000. / 10000 <3> or float(96000)/10000 <3> (i can't quite see how many zeros there are there ;) <6> 3 zeros after the tens place <6> er <14> ok <6> :P <17> roryy: to do variable coersion, at least one variable must be a float, or use float() function <17> it returns a float on a integer division <2> how to i go from "for a in bar" to for a,b,c in bar, where a,b,c are three elements from bar for each loop? <2> (not overlapping?) <3> ctz: i'd probably just do something like for i in xrange(len(bar)/3): a=bar[3*i]; b=bar[3*i+1]; c=bar[3*i+2] <2> oh, bleh, i hoped there was a nice way to do it with list comprehensions <3> itertools has all sorts of toys for things like this; maybe you can find something there <18> you can make it slightly neater by doing range(0,len(bar),3) then you only need do do i, i+1 and i+2 <3> ah, there we go <17> ctz: did you try to use map() function? <18> what you really want to do is split bar into a list of 3-element lists (s/list/tuple/ possibly) <19> ctz: [bar[i:i + 3] for i in range(0, len(bar), 3)] <2> looks like itertools.islice does what i want <2> eg for p1, p2, p3 in itertools.islice(hu.points, 0, None, 3): print p1, p2, p3 <3> that doesn't work here (gives 0, 3, ...) <19> roryy: you can use those to access bar[i:i + 3] <18> deltab: yup, that looks good <3> deltab: sorry, that was for ctz. I put range(15) in for hu.points <19> doesn't happen for me; I get TypeError: unpack non-sequence <3> err, yeah, i changed it to for p in ...
Return to
#python or Go to some related
logs:
unmasking ipw3945 amd64 #kde ls_mode coreutils #mysql repost _FILES #web ubuntu disc image mounter ubuntu .xsession ssh-add speaker-test gives static Wno-unused-functions Wno-unused
|
|