@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18



Comments:

<0> been reading python lib ref for days now, trying to get things done alone
<1> It saves a cl***.
<2> nexu: http://docs.python.org/lib/module-pickle.html
<1> Diving into Python is quite nice. Avaible for free as html.
<2> freeone3000: not just cl***es but objects :)
<2> freeone3000: you did know about that 'if var: ...' thing?
<0> yeah i have that one bookmarked too
<2> nexu: then let's check some online python-tutorial-books for better examples
<0> isnt "if var: ..." same as "if var == true: ..." ?
<2> nexu: yes it is
<2> it's just more readable, elegant (thus more pythonic)
<2> (in my humble opinion) hehe
<0> and "if not var: ..." is same to "if var == false: ..." right?
<0> cuz thats what i 've been doing
<2> nexu: indeed
<0> i prefere this method



<0> looks 'cleaner'
<2> not just better looking, it also evaluates empty strings, dicts, lists, etc. as false
<2> oh, thinking about it I guess that it's the same with the other way too hehe
<2> oh, it isn't
<3> das-q, who are you?
<3> and why do you mention me?
<2> freebsd_fan: a guy that got confused by nick-completion
<0> so to use pickle i must make it into a cl*** ?
<2> nexu: no
<2> nexu: as I said: pickling is there to save objects, not just cl***es
<2> nexu: variables, functions, cl***es etc. all those are objects
<0> that incl. files too right?
<0> those i import
<4> question
<4> I have a Unicode string that I want to output in an XML doc
<4> is there a codec for 'output UTF-8 as XML entities'?
<2> nexu: umm, now that confuses me... hehe, pickling is there to save things, files are already saved on harddisk hmm
<0> das-q: no i dont mean saving to files etc
<0> das-q: just that values from a file i import, those values can be saved if i load it once more
<0> and the 'pickled' value wont get overwritten
<2> nexu: oh, you mean something like a configuration file
<0> without actually configuration file
<0> the configuration is the python file
<0> which incl methods etc
<0> or is that a bad approach ?
<2> sounds like
<2> nexu: the problem is, I don't completely understand what you're trying to do
<1> If you need to, save a refrence to your own object...
<1> That'll allow you to load it up again..
<5> somebody has a depth search python example...working one?
<0> das-q: i have a bunch of scripts, i want them all to write output to a same xchat.context. but this one has to be created first, so i though might be easier to write such method in a seperate file and import this file from all the scripts instead having this method is each file
<0> but obviously i dont want every script to make a new xchat.context. thus the idea of a variable to check this
<0> method in each file*
<2> nexu: mhm, I can't think of the best approach to save to the same file from multiple scripts running at the same time at the moment, but at least I can say that you can check if a file exists with os.path.exists(path)
<0> das-q: ah sweet, nm. i figured out a workaround :D :D :D
<2> nexu: that is?
<0> das-q: i abadoned the idea of checking based on a variable and just run a 'clean' check each time it gets loaded
<1> I'm calling c.start() after c = console.console(sys.stdin) (tis not in the stdlib, don't bother looking, I made it). So. Why is it swearing I gave one argument to c.start?
<0> das-q: http://pastebin.com/759049
<0> das-q: all 3 files in 1 paste
<2> nexu: umm, do you expect me something to say? :) *justcurious*
<0> das-q: not really, just pasting it anyway :)
<0> das-q: or perhaps you can see things i wrote that could be simplified
<2> nexu: nay, I lack of programming practice a bit
<0> das-q: ic, i'm pretty noob in python. just looking for some critics and tips from more experienced python coders :>
<2> nexu: I'm quite noobieish too. I wouldn't be if I'd done as much practice as I've done theory
<2> nexu: which isn't thaaaat much too, I'm still learning OOP
<0> das-q: heh i **** at the theory side of things, i have to learn it by making the mistakes by doing it
<0> das-q: i havent got into digging and understanding the object oriented side of python at all
<0> das-q: just started writing codes and testing it out
<6> nexu: when you do, you'll like OO
<2> nexu: nothing wrong with that :)
<0> bsmntbombdood: last time i did OO was with pascal
<0> :-o
<7> bwahahahahaahah
<6> nexu: or at least I liked it
<8> how to display a list of installed lib for python ? print __modules__ didnt work. i want to see if simple_json is available.
<2> bsmntbombdood: I just read about overloading __getattr__ some days ago and thought of supybot's logging when one calls one of it's functions, I don't know if supybot does it that way but to me it feels very elegant to log function calls that way
<6> supybot?
<2> bsmntbombdood: www.supybot.com a python irc-bot which is probably superior to all other
<6> das-q: THat's an interesting way of doing it, I've never thought of using __getattr__ that way



<2> coulix: mhm, search for 'path' under http://docs.python.org/lib/module-sys.html
<8> ok thanks
<2> bsmntbombdood: in the book 'Learning Python' there was it overloaded just to print 'Trace: ' + attr ... and that remembered me of supybot's log (well, I really don't know how supybot implements logging)
<2> bsmntbombdood: I'll put the example code of that for you in a pastebin, just to take a look
<6> das-q: and then do you use getattr to get the function back from the string?
<2> bsmntbombdood: http://pastebin.com/759061
<6> das-q: interesting
<2> bsmntbombdood: oh, I didn't understand what you were asking for, but the example shows just that hehehe
<0> das-q: hey thats interesting indeed
<9> hey?
<9> how is everyone this evening?
<2> is 6.21 a.m. over here, I'm tired thus
<2> s/is/it's
<9> damn
<9> where is that?
<2> Berlin, Germany
<9> nice
<9> hows the weather?
<2> I see a little light blue but mostly greyish
<10> how do i calculate the average of a few numbers using python ?
<9> the weather here in Portland Oregon, US is rainy
<7> razorclaw: sum(mynumbers)/len(mynumbers)
<2> damn, you were faster
<9> yeah
<9> its pretty much always like this
<10> Jerub, that returns say 210/200 -> 1
<10> but say if i want 1.05
<2> but sum(bleh)/len(bleh) will be unprecise, use sum(bleh)/float(len(bleh)) instead for preciseness
<11> :P
<10> das-q, thanks
<2> razorclaw: np
<12> Is there such thing as global variables, accessable in all scopes?
<13> 1)
<13> no
<13> 2) why?
<12> It would be nice for like a Settings object for my game. So I didn't have to p*** the settings object to everything. Being able to access the settings of the game globally would be nice.
<14> !M$
<14> ;)
<13> no it wouldnt. globals are bad.
<12> At least that's what old brainwashed programmers will tell you
<13> why dont you just make the settings object an attribute of some Game object, and the methods can easily access it.
<13> ldlework: you disagree with decades of study proving such?
<12> Didn't I just say I don't want to p*** an object around everywhere
<13> ldlework: i didnt say you should. i was suggesting how to avoid it!
<11> ldlework: you could do a singleton, but singletons in python are weird. closest i could get to one was the borg pattern (google it)
<11> it creates a new object every time you call it, but the contents in it are always the same
<12> How will the method's access the settings object without p***ing it to them?
<13> jay`: 1) singleton doesnt fit here. 2) its trivial to create real singletons in python.
<13> ldlework: ATTRIBUTE
<12> You are saying
<11> ironfroggy: know of any good resources? none of the ones i found on google worked
<13> self.settings
<12> ah
<12> Because the game code is procedural code.
<13> jay`: well, not that i think singletons are great, but look for a singleton metacl***
<13> ldlework: well, stop that then.
<13> so you just got a bunch of random, loosely related functions you're calling?
<12> Yeah
<12> I haven't written anything
<12> But I don't see the game part being a cl***.
<12> No need to do that
<13> you've got a good reason right here.
<12> The game just needs to be a loop
<12> guised as a state machine
<13> you're asking how to do a certain thing, which i explain can be solved if you use good design and encapsulate properly, and you say "but thered no need to do that".
<6> ironfroggy: a global variable would be exactly the same as an instance variable in this case
<13> bsmntbombdood: error. logic is incorrect.
<12> If there is such thing as globals, which is what I'm asking, then no a cl*** is superflous here.
<12> I use other cl***es
<12> I just don't think the game loop needs to be an engine
<6> ironfroggy: how is my logic incorrect


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #python
or
Go to some related logs:

/dev/dsp busy skype
rewrite_tags php
sata /dev/address
Client does not support authentication protocol requested by server; fc4
ubuntu locales is broken or not fully installed
debian motd no mail
sendmail howto for gentoo
#python
#centos
pwmconfig fglrx



Home  |  disclaimer  |  contact  |  submit quotes