| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Comments:
<0> feyd: also, not all objects of a cl*** have to execute init, you could do myinstanceone = MyCl***One; myinstanceone.method() <1> sanmarcos: yes i know that. <0> feyd: what is your specific questions about cl***es and objects then? <1> i had read a survey about object oriented programming in MIT open lecture notes..but.. <1> sanmarcos: it was about the communication of different cl***es.. <0> feyd: ill post an example online <1> sanmarcos:ok thanks.. <1> can i send something on pm? <0> feyd: sure <2> CardinalFang: you've come to the right channel ;) <1> sanmarcos:first i wanna try what you said. <1> (17:55:00) sanmarcos: feyd: check out the python tut, for example you have two cl***es, both have __inits__, when you do instanceone = MyCl***one(), that cl***es __init__ (init sequence, constructor) is executed, and on instanceone (an object) you have all of MyCl***one's methods (functions that were defined with def in the cl***) <3> What is the simplest way to initialyse a 2d array (to 0) ? <4> how to declare a variable as global or so, but when the 'type' is not yet availabe. It seems to work in many (e.g. var=""). python just renews the ***ignment. But is there a clean way? <5> calmar: Python doesn't 'declare' types.
<5> calmar: 'None' is usually used as 'not available yet'. <3> any idea ? <4> Yhg1s: oh I see. another similar question: can a 'declare' a function, even when that will follow later? in a C manner? <5> any: if you mean a list (rather than an array), something like 'map(list, [[]]*outersize)' <0> feyd: http://pastebin.com/541744 <5> calmar: nope. but you only need to define functions before you try to execute them, not before another function tries to use 'em. <4> Yhg1s: Yeah, I see. thanks a lot! <3> Yhg1s: Is it best than doing a for i in xrange ... append ? <3> better* <5> any: well, _best_ might be anything. 'better' would be to create the second dimension as you need it, rather than pre-create it. <1> sanmarcos: thank you very much..i will try that when i eat something to live:) <3> Yhg1s: with for loops ? <5> any: depends on when you need the second dimension. <3> I would like to 'declare' a 2d list that contains '0'. <6> any [[0 for i in xrange(x)] for i in xrange(y)] <3> werneck: exactly what i need, thank you. <3> I need to learn list comprehensions. <7> damn i use slackware 10.0 and cant get that damn pythoncard and its dependencies working <8> what's the python equivalent of the __FUNCTION__ macro in c? <5> there is none. You can use the inspect or the traceback module to get the same kind of information (and more), though. <8> hrm. that's annoying. <5> what are you trying to do? <8> print out errors in functions without writing the function name into every error string manually :P <5> use exceptions or warnings. <8> e.g. printf("%s: blah failed", __FUNCTION__) <9> or logging <5> or, as I said, use the traceback or inspect modules. <5> personally, I'd just print a traceback (even if you continue execution). <8> tracebacks work for me, but they don't work for engineers who use this program <9> then use logging <5> but functionnames do? <9> and turn on the use of function names <8> we want something that both of us understand to some degree :P <0> how would I load a .so module in python? <5> well, you have four suggestions that can all do what you want. <8> but i'll look at those suggestions <5> sanmarcos: 'import' <8> thanks :) <0> Yhg1s: hmm ok, somehow it is not detecting it, but ill keep trying <5> sanmarcos: it should be somewhere in sys.path, like all modules. <5> sanmarcos: and it should actually be a Python extension, not an arbitrary .so file. <5> if you want to load one of those, use 'ctypes' or (shudder) 'dl'. <0> Yhg1s: there should be a .py file in there right? <0> Yhg1s: I have a def file and so, what was the function to list a module's submodules ? <5> sanmarcos: eh? a .so file is a compiled (written in C) extension <5> sanmarcos: it doesn't usually contain .py files. <5> sanmarcos: also, a .so file can't have submodules, just packages can (and packages are directories.) You can use 'dir()' to see the attributes of a module, which (in the case of a package) can be submodules. But those aren't necessary all the submodules, just the imported ones. <0> Yhg1s: I have a .so file and a def file somewhere else, ok let me see, (I am trying to install a module on another wndows box) <5> eh, windows doesn't use .so files. <5> and I don't know what a 'def' file is. do you mean a .py file? <0> Yhg1s: ahhh.. right <1> sanmarcos: i have looked your code.it was helpful <0> feyd: I am glad :( <1> sanmarcos:so we just use the functions.if we made the instance ..we can use it on the other cl***es..i guess that's the trick. <0> s/:(/:) <10> GAH! I hate the PSP syntaxt. <10> -t <0> sp3tt: pretty much everybody does <10> It's completely impossible to output anything. <3> How can I something like [x for x in xrange(10) if x>3 else 0] but that works ? <3> +do
<5> any: [0, 0, 0] + [x for x in xrange(4,10)] <5> or, if you prefer, [ x>3 and x or 0 for x in xrange(10) ] <5> (that only works if 'x' can never be false when 'x > 3' is true, but that happens to be the case with integers.) <3> thank you Yhg1s <1> i gtg folks.have nice time <11> later <4> well, that (global) variable set to None, will get ***igned to an object later in the running - So I set it to None. But python complains already before it's going to run because it sees something like that: None.function(), I think. Or do I something wrong. Hm <12> hi all <0> is there any python gui options for developing with OpenStep/ possibly Cocoa? <4> well, probably I do something wrong :) <13> SaLuToN!!! <13> what's the best way to implement a list with 'ranged' keys. <13> what I am looking for is that when I have a page nr i can lookup some value's belonging with that pagenr <4> (yeah, the program calls that function once when I don't know about it :) <13> and the page nr's are specified in ranges <13> like 1 - 10 <13> 11 - 30 <13> etc. <13> do I make any sense yet? <13> =) <4> dictionnaire is not what you're looking for, isn'it? startu_net <14> startu_net: I think you could do like: list = { range(1,10): "data for page 1-10", ... } <14> That's a dictionary, actually. <14> Though searching that one may be inefficient. <13> lack: that way it will add ten entries? <14> No, you'd get one entry: <13> but then how to find it when I have page 5? <14> startu_net: THat's the inefficient part :) <14> What is the data you need to access? An object? <13> ew... I have to make RDF statements... and those contain the predicats/objects <13> but I don't think that influences anything....? <14> Probably the best solution would be to have multiple entries from a list or dictionary, each referencing the same data. <14> a = someMutableObject() <14> list[1] = a; list[2] = a; list[3] = a; ... <13> ok <14> startu_net: You could do this with a loop, or maybe a list comprehension. <13> the filling you mean? <14> Yep. <13> k. <13> will do that <13> thx <0> what does the 'rb' mode in open() do? <13> read in byte mode <0> it is needed in windows to read non text files, but what about in unix? <0> s/unix/posix <13> same I gues <14> I think with posix, you just use 'r' and it should work... <15> I'm having some issues with a simple script that uses RDFLib ... it chokes when I call the SPARQLGraph's .query() method: http://deadbeefbabe.org/paste/2822 (I've asked at #redfoot but no one's there ... post-superbowl hangovers or something) <14> I suspect that if you don't open a binary file in Windows with 'rb' it will translate line endings for you. <15> any suggestions welcome <0> lack: but If I do "rb" in unix, there are no major drawbacks or consequences? (I am trying to avoid a os specific check for opening an image) <16> hi all <16> CardinalFang: hi <13> shawnb: what r u making? <14> sanmarcos: Here on my linux box "rb" seems to have no effect different than "r" on a text file... no error, and I read the same data either way. <0> lack: ok, so I dont need a check <14> sanmarcos: Doesn't appear that you do. <15> startu_net: wanting to setup a SPARQL access point (eventually) but I've just recently picked up RDFLib <15> startu_net: so I'm just trying to run a simple query at first <15> that script chokes on the line: "result = sparqlGr.query(select, where)" <16> CardinalFang: you there? <16> I have a file with names and the rates in front of them <16> foo 121 <16> bar 12221 <16> foo 1.45 <16> bartw 3421.1 <17> Could someone point me in the right direction here? I'm using sockets (SOCK_STREAM), but socket.recv() brings the whole app to a SCREACHING HALT. The server may send the client data without the client first asking for it, so I need to constantly be checking the socket for data. <16> Presently I have a awk program to add all foo's, bars etc <18> wow <16> can I do it in Python? <18> this python tut i have here is really neat, now im starting to understand it, and now i see its usefulness <16> I need total of each and taht too sorted proerly <16> is python OK for this? <17> payal, I don't see why not. Pick up good tuts on file I/O and string manipulation. Should be cake.,
Return to
#python or Go to some related
logs:
#ubuntu #python qbwdp crashing YM #kde Temporary failure in name resolution emerge xorg-x11 perl prnit Euphidime #web #math
|
|