#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11 
Top Prev 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 Next

#python

<ZenMasterJG> same for the agare method
<arkanes> sedeki: yes
<computerlinguist> that's some funny piece of code :)
<sedeki> shut up
<Anusien> how do I check and see if something is a string versus a list?
<Greatred> isinstance(obj, list)
<Greatred> although its use is discouraged
<arkanes> isinstance(obj, basestring) is better
<xororand> Tubez: meanwhile i've decided to use postgresql for the whole thing. whipping up sth new in a few hours will probably be worse than a rdbms that has grown over years :)
<sedeki> do i still need __init__ ?
<computerlinguist> sedeki: no
<computerlinguist> sedeki: only if you want it to do sth.
<arkanes> because you're very unlikely to have objects that aren't strings that pretend to be strings, but non-list sequences are common
<sedeki> which is the best place to start learning python
<Greatred> sedeki: is that a question?
<sedeki> no
<Greatred> ok
<sedeki> And I bet your comment wasn't either
<sedeki> more like a rhetorical question
<Greatred> my comment? no it was a question as i couldn't tell
<Anusien> arkanes: well, I'm accepting data of a whole lot of strings and just trying some input on them
<Anusien> My only check is len(arg) which works for strings, lists, tuples... but I only want to operate on lists. Hopefully I won't pass bad datat to it though
<arkanes> is there a particular reason you only want lists?
<Greatred> or anything sequence-like?
<Anusien> So I'm parsing with PLY, and trying to handle (foo)* and (foo)+. I rewrote the grammar, but it ends up like:
<sedeki> arkanes: Any good tips on where to start learning python, except books? I'd like to learn it online as I did with PHP
<arkanes> sedeki: diveintopython.org
<sedeki> python doesn't seem exceptionally hard to learn. Only, there are many new terms to keep track on
<sedeki> roger, thanks
<Anusien> optional_foo <- foo optional_foo | epsilon {if not epsilon : $$ = [$0, $1} }
<Anusien> so I'm getting [arg, [arg, [arg]]], so I wrote a quick function to break nested lists down into just a single list
<arkanes> no reason not to accept arbitrary sequences for that
<Anusien> What do you mean by that?
<Greatred> Anusien: can you assign functions to be called when a term in your grammar is found?
<arkanes> [1,[2,3]] -> [1,2,3] and [1,(2,3)] -> [1,2,3] are equivilent
<arkanes> I really think theres something in stdlib that does that already, too
<Anusien> arkanes: sure, but I screwed up and accidentally passed a string in. PEBKAC, sure, but it was a valid problem
<arkanes> Anusien: yeah, excluding strings specifically might be a good idea
<arkanes> but do it by blacklisting strings, not whitelisting lists
<arkanes> if you see what I mean
<Anusien> yeah
<Anusien> I didn't add it. I figure while I'm writing it'll just raise an exception and halt, which is good enough
<Anusien> Since it means I screwed up my grammar
<timonator> is anyone going to make something like http://tryruby.hobix.com/ for python?
<Twey> timonator: What, crap that breaks in Konqueror? :-P
<timonator> well, ofc the person who makes that for python will make it work with links/lynx/w3m as well as for konqueror, firefox and opera
<timonator> (and telnet on port 80)
<Twey> Heheh
<timonator> actually
<timonator> having a h4x0rd python prompt with some tutorial-ish stuff built around it would be helpful, too

Previous Page  Next Page

Search ircarchive.info