| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Comments:
<0> How do i extract just the name from '1.First Last</a>' using regexp? a simple '\n1\..*</a>' will find it but also include the stuff I don't want.. <1> regexp? Pah <1> ask in a perl channel <2> Hmmm, can I <2> with some obscure form of porting and hacking <2> wrtie an OS 100% on python? <2> write* <1> google "unununium" <1> they tried that <1> then switched development to the linux kernel <3> Patrick`: s/tried/trying/ ? <3> Patrick`: I thought it was an ongoing affair. <1> I don't know how active development is <1> but all I know is they don't use 100% python any more <1> beastly fido? <1> pah
<2> Hmmm, I want 100% python =P <1> they found it had speed issues <1> for some reason <2> Yes, I imagine it having speed issues, but I can always do ASM modules right? =P <1> just have "the linux kernel" as a module <3> Yeah. <3> Latest build is a year old. <3> Fork them. <2> No, that doesn't gives me that fuzzy feeling I just did something that isn't worth anyone time <4> Any one know what this runtime error means? " module compiled against version 90504 of C-API but this version of numpy is 90500 " <5> hi, getting a segfault in the "$ python" commandline parser thing <2> Hmmm, did anybody implement Python in Python yet? <5> "pypy" <6> hello. i have a question. I have a wrapper object, which consist of constructor and __getattr__ method, which is used to relay all the function calls to some other object, but catch one particular exception in try/except construct. the object works, but the exception is not caught. it is instead propagated away. I know I call the __getattr__ method, but exception raised from within the object I relay to (using getattr(self.c,attr)) is not caugh <6> any idea what may be wrong? <7> ?>pasteit@jooray <8> You're trying to catch the wrong type of exception? Or your except: is throwing something else? <7> ?>pasteitmin@ <6> no <6> I'm trying to catch EOFError, which is raised there <6> I tried also generic except: <6> with no parameters <6> def __getattr__(self, attr): <6> try: <6> print 'here' <6> r = getattr(self.c, attr) <6> except: <6> print 'caught' <6> this is the function, if I call this object's method (like a.something()), then, here is printed, self.c.something() is executed correctly <6> but if that self.c.something() raises an exception, it is not caught <9> Anyone here know about AOP? <6> the call trace does not even show anything about this object, only the self.c object and then <stdin> (I'm trying it from python command shell) <6> is __getattr__ somehow special in exception propagation? <8> Could self.c *possibly* refer to the same object? Endless recursion? <6> no way <6> it is created in init and is a completely different object, which does what it has to do <9> Aspect Oriented Programming? Anyone? <6> this cl*** has only __init__ in addition to __getattr__, which does self.c = anotherobject() <6> and the wrapping is working correctly, except for catching exceptions <6> the 'caught' part is never printed <7> jooray, obviously, __getattr__ only *gets* the object. It doesn't relate to execution in any way. <7> Now, if there's a problem getting (say, self.c doesn't have attr), an exception will be raised. <10> Hi all <6> TFK: I don't understand. I thought __getattr__ is a function, that is called when there's no such attribute in cl***. I want to wrap that call to another cl*** and catch it's exception (like when self.c.get_line raises EOFError, I want to catch it there) <6> TFK: because this is the cl***, which knows what to do with the error <11> Does the python "readline" method use the GNU Readline library? <7> jooray, you can't, without making the code uglier. __getattr__ doesn't call get_line, does it? So it can't catch any errors raised by it. <6> Artimus: I believe not <6> __getattr__ calls getattr(s.c,attr), which in turn is get_line (if attr is "get_line") <6> but it looks you are true, I just don't know how to fix it :) <7> So? get_line is just a method. It doesn't get called until it's prepended with the magic (). <7> Why are you using __getattr__ anyway? Why not wrap the methods you want to delegate explicitly? <6> TFK: because there are like 60 methods <6> TFK: each one can raise that exception <7> Why no use inheritance? <6> TFK: because I would have inherit 60 methods and catch EOFError in every one of them <6> and when the underlying object changes, I would have to modify mine <7> (1) __getattr__ is not the way to go. (2) what are you writing? <6> TFK: I am using pympdclient2 library, which is a music playing daemon client <6> TFK: it communicates with mpd using socket <6> TFK: mpd can disconnect client any time (after timeout, lost network connection)
<6> TFK: I want to try to establish the connection again <6> TFK: since it is stateless protocol, it's not a problem for me <6> TFK: but I think I'll change the pympdclient2 library itself, not just wrap it. I just didn't want to fork the original code <7> Handling this error seems like a job for the user, not the communication cl***. <6> TFK: I don't want to wrap all the commands with try/except and try to establish the connection again <6> TFK: it's a common problem that can be solved generally <7> How? <7> Again, it seems like a problem for the user, not the communication layer. You monitor the connection during data processing. <6> TFK: I create a mpdconnection object <12> How do i find the name of the current module? <7> __name__ <6> TFK: I don't want to handle EOFError when I do conn.play() <6> TFK: I want the play() thing to know when the socket is disconnected, reconnect and launch the play command <7> and you have 60 similar methods? <6> TFK: yes. search(), next(), previous(), list(), find(), ... <6> TFK: outputs(), select_output(), ... <7> Hmm, interesting. <2> Hmmm, if I'm doing a byte code interpreter in python <6> the bad thing is, they are not even methods <6> they are grabbed from some kind of array in the library <6> and implemented in __getattr__ <2> Should I just hardcode everything with if else or should I was time making a custom format for storing python code for each opcode? >_> <6> (that's why I learned about it, I'm working in python for the first hour) <2> s/was time/waste time <6> yuriks: depends if you want to modify opcodes on the fly, or they are and always will be hardcoded <2> Well, I don't pretend to modify opcodes... <7> Well, one possibility is doing what you tried to do, although I still think that there should be a better way. I'll paste an example soon. <2> But I think the latter will be easier to update? <6> yuriks: maybe.. but maybe you'll end in quote and escape of quotes hell :) <2> hmm.... yes.... <2> I'll just hardcode >_> <13> jooray: __getattr__ only works when it can't find the attribute, if you do self.c.something <13> () - you're byp***ing the self's __getattr__ <2> hmmm, what was the name of the cl*** constructor again? xD <6> yuriks: __init__ <2> ah, right, I was in doubt if it was the cl*** name <7> jooray, something like this: http://phpfi.com/106649 <2> Like in CPP <6> TFK: understand <6> TFK: so I'll create a reference to method and then call it <6> I'll try <7> (but not from within __getattr__, please!) <9> Does anyone use PEAK for AOP? <2> And is there anything better than a list for storing fixed position stuff? <2> Like, I will have a dictionary that will map "NOP" to a list containing "has 0 arguments", and a list with the arguments, and blablabla <2> Something less like dinamic lists, and more like arrays <7> jooray, say, these ~60 methods, is there a convenient method of grabbing them programmatically? For example, are these all the methods of this object? <2> Or C structs for that matter =P <2> Is doing a cl*** just to it to act at as struct <14> I'm new to encryption but not to programming in Python. If I want to encrypt a binary file with Python 2.4 do I need to pickle the file to a string and then encrypt it? From what I understand the encrypt() method must take a string. <2> a bad ideia? <7> aleutian, you can p*** myfile.read(), I think. <7> A file is a just a stream of bytes (as is the type 'str'), "binary" or "text" or whatever s a human distiction (and a Windows quirk, to be fair). <14> TFK - Understood. I think I was thinking too complicated. I will experiment here for a bit with read(). <2> Ok, so, is creating a cl*** just to it to act like a C struct a bad or a good ideia? <7> yuriks, it's OK. You can also use a dictionary. <2> Hmm, what is better? =P <2> a dicationary seems good <7> If you don't need anything fancy, a dict should do just fine. <2> Ok... what IS an opcode? an name = "NOP", byte = 0, args = 3? <2> ]I think tht is engough, right? Should be <2> And it wasn't really necessary to ask those last 2 'questions' =-P <7> That I don't know, I'm afraid. <6> TFK: well, no <6> TFK: the author of pympdclient2 is a pervert <2> LOL <7> lol <6> TFK: they are implemented using __getattr__ <6> TFK: I said, that's where I learned about this ugly function :) <7> __getattr__ is a cl*** implementation detail, shouldn't matter much. <6> TFK: so there is no method play(), there's only a __getattr__-based implementation <6> TFK: but yes, I can put the names to the array and somehow construct wrappers for each <7> Hmmm. <6> TFK: I've been working with several languages, most recently java, where everything must be predeclared, so this was a shock for me. When I saw the code, I had to grab a cup of fresh clean water
Return to
#python or Go to some related
logs:
#bind #ubuntu #sendmail packman unixhead forums.gentoo.org CONFIG_BLK_DEV_LOOP iso trackmasters.nl #perl rivatv deb #math bcm gentoo howto
|
|