| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Comments:
<hds> hmm <johnlev_> and they need to be interpreted differently <stain> is the integer as a string or as some int-object? <bit`> johnlev_, I've read to avoid type checking in python... you lock yourself in. think properties <stain> if it is a string: <stain> >>> "12313".isdigit() <stain> True <johnlev_> stain: ok, ta. <hds> would something like foo = ["1", "2", "3"] db.cursor.execute("insert into ...values(%s, %s, %s,)", *foo) work? <stain> if it is some integer object I would refactor your API so that strings and integers arrives in two different ways <Yhg1s> hds: no, but 'tuple(foo)' would. <Yhg1s> hds: and depending on the db-api module, just using 'foo' might work too. <hds> Yhg1s: k <johnlev_> stain: not an option, this is a command line argument <robinl1> How to bind events in wxpython? <TL_CLD> How "low level" can Python go? A few of us here at the office are debating whether Python could be used to create a server that communicated with a Meridian PBX <robinl1> textbox = wx.TextCtrl(frame, size=(200, -1)) <robinl1> wx.EVT_TEXT_ENTER(textbox, test) <robinl1> this doesnt work <bit`> stain, It's kind of hard to grasp when coming from java/c++ <robinl1> omfg you guys are not talkative :| <TFK> these are the kind of things that the demo/wiki/whatever covers. <bit`> johnlev_, did you try looking at the std lib code? like optparse or getopt? <bit`> robinl1, could be we don't use wxpython <TFK> And I'm not sure there are many wxPython developers here to begin with. #wxwidgets/#wxpython may be more helpful, with advanecd questions. <DataBeaver> Is there any reference-like documentation for the PyTypeObject and PyMethodDef structs? <cbrinker> I am looking for a standalone python workflow engine. Some googling didnt turn up anything too obvious, is there a package/egg out there that does WF, before I start buidling my own? <hds> Yhg1s: why tuple(foo) and not *foo? <bit`> TFK, going to check. so far books seems to skip the why sometimes <robinl1> those channels are empty. <TFK> bit`, pardon, the why of what? <johnlev_> bit`: yes, I'm using optparse <skar> hi, i want to run "data=data+temp", but if data string is initialized only here, how to check if var exists already or not? <mennis> What is the best way to get upstream patches to the python tree? <Juhaz> skar, initialize to known default value (eg. None), and check for that <stain> skar: start with data="" ? <stain> before the loop <stain> or whatever <stain> hds: because the execute method expects a second argument, not a whole lot of more arguments <stain> and the second argument should be a tuple by the DB API 2.0 docs.. some modules might expect both lists and dicts though <stain> robinl1: you have to bind some some function <stain> DataBeaver: have you checked the Python "API" docs? <stain> ok, that should be all of the backlog of questions, right? <stain> where can I cash in my $5? <bit`> johnlev_, Why not to check for types, and how to avoid it.. afk for while <Cheery> stain. hehe. :D <stain> johnlev_: ah, but then just use isdigit, because it will be a string anyway <Cheery> That's what I were just going to do. <johnlev_> stain: am doing <Cheery> Thought I'm not doing a real lisp implementation, just something fun. <bit`> opps meant for TFK <stain> Cheery: I think the only boring thing would do to do the parsing, otherwise you can just use ("apply", ("lambda", ("x", ))) etc. and such <qk> how to do something like: ['a', 'b'] in ['a', 'b', 'c'] -> True ? <joaop5> hmnn length([x for x in a if x in b]) == length(a) <joaop5> should work :) <ignacio> No, that will choke on dupes and permutations. <joaop5> being a the smaller one <qk> hmm.. <ignacio> Join them with a unique character then use in on the strings. <qk> i think i'm looking for list comprehensions magic function ;) <joaop5> i love list comprehensions so much i just wanted to used them :) <joaop5> qk, check goopy, there's probably there a function for that <cbrinker> Is there movement to get python to natively support AOP? <ignacio> Decorators? <ignacio> Hell, Python already supports monkeypatching... <heviLUT> there is __get__ <joaop5> qk: def intersection(a, b): <joaop5> """ <joaop5> intersection(a, b) -> list of items in both A and B <heviLUT> usually aop provides enter/leave on functions <DataBeaver> stain: Yeah, but I can't find any _reference_ documentation about those structures. i.e. something that lists all members and their meanings. Right now I'm looking specifically for the function signatures to be used with the various METH_* values. <heviLUT> and with __get__ with monkey same result can almost made <heviLUT> a bot more controlling logic more <Yhg1s> hds: they do entirely different things. <Yhg1s> hds: *foo unpacks the sequence foo into the argument list. 'bar(*foo)' is 'bar(foo[0], foo[1], foo[2])', etc. <Yhg1s> hds: tuple(foo) just returns a tuple of the same contents as 'foo'. <skar> stain,juhaz:thanks will do that <robinl1> how to open a file with read and write capabilities? (popen) <cosmint> I want to use object attribute names in %(name)s string substitution. Is there a very simple way to do this, or a simple way to make a key/value dict of object attribute/values? <qk> joaop5: something like: L1 == [x for x in L1 if x in L2] <heviLUT> open(aFile,"rw") ? <robinl1> doesn't work <neurogeek> robinl1, meaning you want to write to a popen output file? <robinl1> neurogeek: want to read and write to it <hds> Yhg1s: ah. ok. <cosmint> qk: Almost sounds like a possible job for sets. <heviLUT> what is the problem <cosmint> Specifically an intersection.. <neurogeek> robinl1, that makes no sense at all, popen output is read-only <robinl1> neurogeek: no it isn't <Yhg1s> yes, it is. <Yhg1s> popen is only reading, or only writing. <neurogeek> ?? <robinl1> why could i write to it then? <robinl1> to make interfaces? <robinl1> that's what i do with it. <Yhg1s> os.popen2() is both, as is the popen2 module and subprocess. <neurogeek> robinl1, the question is: why would you? <Yhg1s> use the subprocess module. <robinl1> hmm ok i see <cosmint> "%(first)s %(middle)s %(last)s" % ({'first':self.first,'middle':self.middle,'last':self.last}) <neurogeek> rw is an invalid mode for open <robinl1> Traceback (most recent call last): <robinl1> File "simplecmdline.py", line 13, in Execute <robinl1> line = command[0].readline() <robinl1> IOError: [Errno 9] Slechte bestandsbeschrijver <cosmint> I would like to do % (o) <cosmint> awww slechte <qk> cosmint: yea.. it works too: set([]) == set(L1) - set(L2) <TFK> ?>pasteit@ <neurogeek> cosmint, hmm?? <Yhg1s> robinl1: did you forget to read the documentation for subprocess, popen2 or os.popen2? <robinl1> nevermind i fixed it, lol <DataBeaver> robinl1: Use r+, w+ or a+ depending on how you want to open the file <ignacio> cosmint: Why not just define .__str__()? <Yhg1s> robinl1: I will ask you one last time to stop saying lol. <robinl1> sorry, i'm used to it. <Yhg1s> DataBeaver: his is a pipe, not a file. <DataBeaver> Ah. <cosmint> I want a k/v dict of object attributes, -OR- I want % string substitution to accept an object from which to grab attribute values for %(named)s string substitution "things". <DataBeaver> I got confused by others talking about file open modes :P <sapo> hi guys, i have some strings like this: <type int> how can i remove the <type > and leave only the "int" word? <cosmint> I want to make code like this much less annoying: <cosmint> "%(first)s %(middle)s %(last)s" % ({'first':self.first,'middle':self.middle,'last':self.last}) <cosmint> I want to use "%(first)s %(middle)s %(last)s" % simplesomething <DataBeaver> "%s %s %s"%(self.first,self.middle,self.last) <Yhg1s> cosmint: less annoying how? Less annoying like string.Template ? Less annoying like '"%(first)s %(middle)s %(last)s" % self.__dict__'? <cosmint> I want to use %(named)s params. <cosmint> Yhg1s: __dict__ <cosmint> Thank you. <neurogeek> DataBeaver, someone said open("file","rw") i just said, thats an invalid mode <heviLUT> I did, and yep it is invalid, sorry <neurogeek> heviLUT, no prob. <Yhg1s> for file it would be either 'r+' (open for reading and also in-place writing), 'w+' (open for writing, truncating the file if it exists, and also reading inbetween') and 'a+' (open for appending, but also be able to seek and read') <Yhg1s> but mixing reading and writing is confusing, fragile and nonportable (particularly 'a+') <robinl1> YAY! <robinl1> it works <heviLUT> usually if managing binary data (own db) read & write is used <robinl1> i made a wxpython app which is basically a better version of an xterm - executes an command, you can give input to it. <robinl1> it's really cool :) <robinl1> but , one question - how to make my app add a line to the textbox every time it sees something new? <robinl1> <robinl1> i open a pipe to a command, and i have 3 widgets, one to execute the command, one to display the output, and one to write input, i'm using command.read(), but hell, how do i make it stop when it wants input? <heviLUT> robinl1: which command you are usign ? <robinl1> os.popen2() <robinl1> command[1].read() <heviLUT> command = os.popen2( .. ) ? <robinl1> yes. <heviLUT> ok, I was looking for where is the command function or cl*** member :) <robinl1> :P
Return to
#python or Go to some related
logs:
#debian #gentoo odbc is not loaded in lampp #perl factory could not find class from #web floorplans linux xfig qcad xsetbg: command not found #kde #freedesktop
|
|