#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 12 13 
Top Prev 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 Next

#python

<KirkMcDonald> Them someone could write a map file which executes any code they want to.
<Tubez> Just send "import os\n os.remove("c:\windows\explorer.exe")
<Tubez> You see the point?
<AndroidData> yeah
<Tubez> With proper quoting ofc :P
<KirkMcDonald> So my suggestion is probably less good if you're wanting to send them over the Internet. :-)
<AndroidData> the plan is to send them over the internet, yeah
<KirkMcDonald> So parsing a map file is probably best...
<KirkMcDonald> And you'll want to say far, far away from anything smelling of eval.
<KirkMcDonald> s/say/stay/
<AndroidData> err ok
<KirkMcDonald> (That is, don't just execute strings that are found in the map file.)
<AndroidData> how do I get the amount of lines a file has?
<Tubez> by counting them :P
<AndroidData> os.open returns an integer. I need to convert this to a file. how do I do this?
<timonator> why not use "open" instead?
<AndroidData> ?
<KirkMcDonald> Yes, there's a builtin function "open".
<KirkMcDonald> Use that.
<AndroidData> ok got it
<AndroidData> ok. converting a string to class.
<KirkMcDonald> I recommend a dictionary.
<Tubez> Indeed, a static mapping of some kind.
<Tubez> To prevent people from just doing stuff.
<KirkMcDonald> { 'foo' : foo, 'bar' : bar } # where foo and bar are classes
<KirkMcDonald> Then it will complain loudly if it gets some class name it doesn't know about.
<KirkMcDonald> (Which is what you want.)
<AndroidData> I'm doing exactly that.
<prologic> Do you have to close an ssl socket ? afaik it doesn't inherit the same methods as a socket does, only read/write and methods to do with ssl certificates
<AndroidData> I have a "mdata" dict. It goes in the form of {"a": "tile.grass()"}
<AndroidData> I also have a "mdata2" dict. That goes in the form of "aaaaaaaaaaaaaaaa" (16 a's: the map is 16x16 in size)
<AndroidData> I know how to loop through mdata2 properly. Now all I need to know is how to convert mdata["a"] to a class
<KirkMcDonald> Here's what I recommend.
<KirkMcDonald> Have your data file look more like: a=grass
<KirkMcDonald> Then you'll have {'a':'grass'}
<KirkMcDonald> Then you have another mapping like: {'grass' : tile.grass}
<AndroidData> yeah, but I want tile.grass and such
<KirkMcDonald> Note that the value there is the /actual class/.
<KirkMcDonald> That mapping will be statically defined in your code somewhere.
<KirkMcDonald> The set of allowed tile types will be strictly defined.
<AndroidData> ok
<Enquest> When I worked and learned PHP I always used the manual by simple typing php.net/while to see how to use a function or command ... Does pyhton have such a manual?
<spaceinvader> http://docs.python.org/ref/while.html
<josip> http://www.google.com/search?domains=www.python.org&sitesearch=www.python.org&sourceid=google-search&q=while&submit=search
<josip> :)
<josip> (using the search field from here http://www.python.org/doc/ )
<timonator> Enquest: why not use firefox and add a "search engine" from that search field or so
<Enquest> timonator, wich search engine can I add?
<timonator> that search field josip linked you to
<timonator> right-click into it

Previous Page  Next Page

Search ircarchive.info