| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Comments:
<0> i'd like to do the same with the tag list <0> but it'd turn into a horrible m*** crawling infinite loop mess <0> :) <0> since every time instantiated a tag object it'd get a list of related tags <0> which would then get a list of related tags <1> Have you thought about a relational database? <0> i guess it kind of seems like overkill for what i want <2> sqlite maybe? <1> And, what is the criteria for a tag to be related to another tag? Name similarity? Category? <0> afty: it's returned in the related tags list <0> if you click on any tag <1> DraX: right, but how does your code get the related tags? Or is that an external routine? <0> it will return a list of related tags at the top <0> afty: it uses the web ``api'' <0> which is basically <0> you p*** it a tag
<2> i would also recommend looking at axiom. if you need to work in a pythonic way with a set of relational data, its very good. <0> and it returns a \n seperated list ofrelated tags <1> DraX: Gotcha <0> http://0b97de37b8d86dae.paste.se/ <0> that get's related tags. <3> Can someone tell me how to add methods to an already defined cl*** <1> ued: cl***name.newmethodname = existingmethod <0> ued: you can inherit the cl*** in a new cl*** like cl***s Bob(list) <0> or you can do that <0> :) <1> DraX's way is better though <3> I want to add to an existing cl***, not create more cl***es to worry about <3> do I have to def the function <3> and then bind it to the cl*** <3> ? <1> ued: yep <3> OK Thanks <1> DraX: I would probably not have the tag object automatically get the list of related tags. I think I'd just have a method like getRelatedTags() or something... <0> afty: i was thinking about that <1> DraX: otherwise, as you noted, object construction can get crazy <1> I have to call it a night. Later all. <0> thanks for the help :) <1> np <0> i should really learn to do list comprehensions instead of this lambda stuff :) <0> map(lambda) i mean <4> stop whatever you're doing and learn listcomp and/or generator expressions <0> generator expressions? <4> you know the difference between range and xrange? <5> hey I havea question regarding reading from lists and printing out a table in a web browser. I'm totally new at this and have no idea what I'm doing. Basically the file I want to read is a file full of lists. each list contains three items. On my page i want to have 3 items to a row but can't figure out how to make it work, can any one help me? <0> leeds; yeah <4> well, listcomp and generator expressions are similar - listcomp returns a completed list, while a generator expression returns an object which will generate the next item in the sequence as it's iterated over... something like that, anyway <6> this might not be the best channel to ask this, but would a process listening on one UDP socket for all data be an less efficient (***uming all other things equal) than a process listening on multiple UDP sockets, each for a different part of the data it would recieve? <4> _Amanda_: can you paste your datafile (or some of it, or some made-up data in the same format) on the pastebin? <5> ['dave',3215,'blaaah'] <4> okay... is it one list per line? <5> yes <4> out of interest, where did the data come from? <5> random data <5> it's for an ***ignment, just making stuff up. <4> oh, for an ***ignment? trying to get your homework done? :-) <5> ha yeah prety much. I'm having a lot of trouble with it. I'm not too sure why I decided to take programming. <4> because it's what all the cool kids are taking? <5> ha maybe <5> http://cmpt165.cs.sfu.ca/~ann3/***ign4-2.html <5> that's the site its on <4> anyway, if you were doing it for fun, I'd just tell you the answer... if it's for an ***ignment, I can only teach it to you <5> the user name is admin and the p*** is cmpt165 <5> ha alright <5> I'm getting really wonky output <5> it's reading each character, not the list items. <4> wow <4> is the file format fixed by the ***ignment, or can you change it? <5> no, it can be changed. It's just a txt right now <7> how are you creating the table? <5> this is my code so far <5> if form["user"].value=="admin" and form["p***"].value=="cmpt165": <5> f=open('/home/ann3/public_html/cl***list.txt', 'r') <5> l=f.readlines() <5> print """<table border="2">""" <5> print "<tr><th>Name</th><th>Student ID</th><th>More Info</th></tr>" <5> for i in l:
<5> print "<tr>" <5> for a in i: <5> print "<td>"+a+"</td>" <5> print '</tr>' <5> print '</table>' <5> else: <5> print "<h1>That is an incorrect username and p***word combination.</h1>" <5> print "<a href=""http://cmpt165.cs.sfu.ca/~ann3/***ign4-2.html"">Click here to try again.</a>" <5> print "</body></html>" <4> whoa! don't paste like that here! <5> sorry <4> you'll get yourself kicked out of the channel - we have a pastebin for long pastes <5> oh i see <4> first thing is that readlines is redundant - you can just iterate over the file object ("for i in f:") to get the same effect <5> :S <2> the problem is just that you arent parsing the lines, you are expecting that to be done automatically. <4> now, one of the oddities of python is that strings are actually treated as a sequence of characters, rather than a monolithic object - that is, you can iterate over a string and get one character at a time, or grab slices by doing i[1:4], for example <4> so your "for a in i:" is actually reducing the string to a list of characters and running the list once for each character - which isn't what you want to do <5> oh okay, yeah that's not wht i want it to do <4> now, if you can change the format of the datafile, I would change it to csv or tsv - comma separated values or tab... <0> or pickle! <2> with the current format, each line could just be eval()'ed <4> eval is evil <0> pickle is my friend <0> :) <4> eval mixes code and data <5> we were told to use pickle <5> but I don't know how to <0> pydoc cPickle <0> but mostly it rolls down to <2> where did the data come from? <5> its just random <0> cPickle.dumps and cPickle.loads <4> the problem with using pickle is that you can only sensibly produce the data with a python script - if you use tsv or csv you can write it by hand <4> _Amanda_: can you use third-party modules or only the python standard library? <0> ahh tru <2> i mean, the format. was it intended to be python syntax? <0> yyou may look at yaml <5> standard only <0> there is a python module to do yaml <4> pity... otherwise I'd say treat it as JSON <0> json would work to <0> yaml is nice though :) <4> _Amanda_: so, are you going to gain/lose points if you do/don't use pickle? <4> for the record, two of the problems of this channel are that you often get lots of people shouting different questions and solutions, and people tend to take practical questions and turn them into fun theoretical ones :-) <5> it doenst matter if i use pickle or not <5> it was just suggested <2> then i reannounce my eval() vote <4> okay, then I suggest tsv <0> the only big problem with csv or tsv <0> is that menas you can not have tabs or commas in the string <0> so if that's not an issue (no blobs) <0> then cool <0> otherwise use pickle :) <4> it looks like no blobs is fine in this situation to me <0> and if user input is involved you should probably make sure to check the string for , or tab just in case <2> eval can handle both. hah. <0> but eval is potentially dangerous <2> not in a cl***room setting where it is just a small project running on a static source of data. <0> still shouldn't get into the habit :) <8> hi there, I'm getting an error trying to run the circe python irc client on windows: <8> File "C:\Python23\lib\site-packages\circelib\scripting.py", line 32 <8> cmds = ((k, v) for k, v in vars(script_module).items() if k[:4] == "cmd_") <8> is this a 2.3 problem? <8> err, the error is "SyntaxError: invalid syntax" <8> http://deadbeefbabe.org/paste/229 <2> that would be invalid syntax on 2.3, yes <8> (sorry about the spam) <8> hmm, thought so <8> is upgrading to 2.4 the best bet? <2> good idea anyway <8> I guess <9> is there a standard ansi color package for python <9> oh maybe ncurses?
Return to
#python or Go to some related
logs:
Ubuntu choose runlevel +can ping +cannot surf the web linux #perl gentoo getting rid of kde-env libpostproc transcode fedora core 5 soundmax ubuntu mic #oe #gaim #css HILIGHT=BLINK
|
|