| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Comments:
<0> can you post the code for that function in the pastebin? <1> kosh, the function is rather long with a bunch of SQL in it, http://deadbeefbabe.org/paste/681 <2> jeld, can you print range before you enter that loop ? <2> jeld, my bet is you re***igned the range function to be a variable of type long <3> hi, how to lists directory in python ? <4> zygfryd`: os.listdir <3> thx <1> polpak <- genius!!! <2> it's a common pitfall for new people =) <2> jeld, glad I could help though <1> is there some sort of flag I can use so python would warn me about things like that <0> you should probably fix the function also <0> long functions are bad for many reasons <1> like perl use warnings <0> jeld: nope no flag will warn of doing that <1> kosh, it is mostly long because of the embeded SQL statements
<5> is there a way to tell xml.dom to ignore errors, such as if you want to parse html and there's going to be things like unclosed <br>'s? <2> jeld, you should look at possibly using something like SQLObject to avoid having to muck about with all that SQL in your code <2> marencian, unfortunately HTML is not XML. So if you want to parse HTML you'll need something specific to HTML parsing, not XML parsing <1> polpak, I am using MySQLdb <2> jeld, I know <6> Greetings. Stupid question. How do I convert a string with 1 character to an int? <2> jeld, SQLObject abstracts the serialization of your cl***es so you don't have to worry about the SQL stuff <6> int('d') does not work for example. <5> polpak: are there any HTML modules you know of that have the same kind of accessing methods as the XML DOM? <4> hansderagon: what int do you want to convert it to? <1> polpak, ah, I see, gotta look at that API, thanx <6> deltab... a key pressed. <6> I want to convert the value of a key pressed to an int. <6> and substract 'a' from it. <2> marencian, there's this one http://docs.python.org/lib/module-HTMLParser.html <6> So I can get a basic index. <6> Lets make this simpler. <2> marencian, but it looks more like SAX than DOM <6> I want the ascii value in int of a key pressed. <4> then you need ord(c) <6> I searched the web, but found nothing. <6> int() does not work on characters or strings. <6> Drives me crazy. <4> it works on strings containing numerals <4> int('1234') <5> polpak: yeah, I've seen that one. It doesn't have accessors like dom, just handlers for parsing, which is very awkward <4> int('cabba6e', 16) <2> marencian, yeah, I know. I prefer DOM also <6> deltab, that is an hex to int conversion. <6> I want an ascii to int conversion. <6> But thanks. <7> hi <8> hansderagon, then you need ord <7> does exist any module to work on mysql ? <8> ord('a') == 97 <6> benji, THANKS! <6> You got it. <4> hansderagon: I did answer you, btw <2> marencian, look at this site <2> marencian, http://www.boddie.org.uk/python/HTML.html Specfically they talk about 2 methods for using XML dom modules for reading HTML <4> peoro: MySQLdb (from mysql.com) <7> ok, thanks :) <5> polpak: sounds very promising, thanks :) <2> hansderagon, <4> then you need ord(c) <2> hansderagon, he said that like 10 mins ago <4> 5 <2> deltab, I have no concept of time. It seems like it was ages ago ;p <4> not that I'm counting :-) <0> what is this time thing you speak of? :) <9> quick point of clarification for an OOP-with-python n00b: a cl*** must be defined within a module? <0> bkjones: can you think of any way to define a cl*** outside of a module considering that a file is a module <9> this is new to me. I'm going through "Learning Python" as I try to code for an ongoing project. Sorry for the ignorance. <2> bkjones, module is just another name for file with python code in it <9> oh <9> thanks <2> bkjones, so yes, a cl*** must be defined in a file <10> :P <9> of course. How else would you do it? ;-P <2> bkjones, unless it's a builtin <9> or you're using IDLE ;-) <10> what module does a cl*** defined in interactive mode belong to?
<9> there's no import, iirc. <9> you define it and use it in the same session. <2> bkjones, welcome to python btw. =) <9> thank you. <9> I think. <9> :) <2> bkjones, it's pretty nice <10> polpak: every programmer love "their" language though... :P <4> polpak: uh, module isn't just another name for a file with python code in it <9> rixxon: not me <9> I code mostly in php and perl. <9> I don't like either very much. <10> bkjones: those two are my hate languages <10> heh <9> I think the more experience you have with a language, the more you learn about it, the less you like it. <10> well, it doesn't feel as cool to write that code when you understand it :P <9> heh <4> polpak: modules can be created from files containing python code, but they needn't be; some are created from files containing compiled C, for example, and a few are built in and not loaded at all <11> is there something like isnumber()? <11> if i want to know if string is a number <10> Keyser-: regexp <10> Keyser-: i don't know how you use regexp in python (google!) but here's a pattern for it anyway: /^\d+$/ <11> ok, thanks <11> or does someone have another solution? <10> (you might want to check .,- aswell) <8> Keyser-, '123'.isdigit() <11> yeah, that's a bit easier & faster :) <11> thanks <10> benji: cool, but what if he wants to check for a floating point? <11> no need for those <10> benji: or a negative number <8> then he asks for that <11> :) <10> benji: well, im asking ;) <8> :) <11> int()? <8> In that case try: float(my_string) except ValueError: print 'hmm, not a float' <10> i see <10> thank you <9> ok! I was able to take a procedural piece of code to connect and query postgresql, rewrite it as a cl*** with a couple of methods, call the methods from a separate python script, and get back data! <9> not bad! Lots of "self.varname" stuff everywhere though :-/ <10> bkjones: get an autocompleting editor <9> actually, that's a good little poll: what's everyone's favorite python editor? <10> vim <8> gvim <9> you have autocompletion in vim? <12> help me search the docs. I'm looking for a python equiv of 'mkdir' :) <10> yea well gvim :P <9> ? <8> ooh yes, bkjones <10> bkjones: ctrl+p <8> read about the new omni complete in vim7 (ships with support for Python built-in) <9> GAH! It Works! <9> thanks. <10> magic <9> I use vim 99.99999% of the time as a sysadmin, not a coder. <9> :-/ <9> I'll learn. <10> :) <13> caleb_work: the 'os' module has it. <12> Yhg1s: thanks! <8> bkjones, you should read about how to configure it, you can complete on current buffer, other buffers, and ctags <9> btw, if anyone else is also a sysadmin, --> http://www.linuxlaboratory.org <14> if I have a string of the form "a=atext&b=btext&c=ctext" what's the best way to turn it into a dictionary of form {'a' : 'atext' , 'b' : 'btext' , 'c' : 'ctext'}? <14> I figure first I'll split it with the & delimiter <9> benji: I think I'll give myself time to get used to the syntax and stuff before I go making it easier for myself to forget ;-) <14> so I get a list ['a=atext', 'b=btext', 'c=ctext'] <8> heh <9> but I'm a veteran of .vimrc-foo, so I'll get there. <14> is there an easy way to get from the list to a dictionary without using a loop?
Return to
#python or Go to some related
logs:
#linux america's army sucks install w32codecs in dchroot megaide centos let i++ bash proftpd gentoo virtual user apt-get mysqltcl disable password on blank screen ubuntu #gentoo #css
|
|