| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Comments:
<0> er <0> it's a bit more complicated <1> kjetilho : thanks mi amigo <0> I have a simple cl*** with two variables, "id" and "children" <1> deltab: thanks as well <0> "children" is a list containing another instances of this cl*** <2> so in other words, can an average user learn Python or do i need something less complicated? <3> anyone here uses kid the template framework ? <4> HeLiX`89, work through a tutorial and see :) <5> HeLiX`89: of course he can. http://www.python.org/doc/2.4.2/tut/tut.html <6> can someone tell me if it's bad for some reason to define exceptions for a mdoule in __init__.py? <6> i am having a really weird inconsistent problem <0> the code is at http://pastebin.com/579167 <5> sockpuppet: why would you do that? the user of the cl*** needs to be able to access the exception cl*** to handle thrown errors <0> my question is if such magic with stacks "works as expected", in other words, if it can emulate pointers <6> why can't they if i do that?
<5> if you define a cl*** dynamically inside __init__? <6> let's say i have cl*** a and it contains cl*** aException in __init__.py <6> script.py can easily do from a import aException <6> sorry if my terminology is bad, i am just learning the language <7> jkt|: yes, references work pretty much like pointers <5> not if you define aException _inside_ __init__, which is what you said <6> well i just tested that on my system and it worked fine... <7> he's talking __init__.py yes, not the __init__ method <5> oh! <6> yes. __init__.py <7> sockpuppet: not really 'bad', not a common thing to see though <5> sorry. <6> let's say i also have a/b/__init__.py which contains bException <6> from a/foo.py i can do "from a import aException" <6> from b/bar.py i can't do "from b import bException" or any variation thereof <6> it simply wont work <6> i can do "from __init__ import bException" <7> you should use absolute imports <7> from a.b import bException <6> that wont work either. <7> it should, with correct path settings <6> hmm <0> joedj: so if I ***ign an instance to something, it will contain "pointer", right? <6> i must be doing something grossly wrong ;) <7> i.e. the parent of a/ must be in the path <7> jkt|: effectively, yeah <6> gah, wtf, it's working now <6> that is what i had in the first place... i must have done something else wrong somewhere else. <0> hmm <2> ffs im only on page 3 and im already confused <6> well thanks for the help ;) <0> so if I have some variable representing "current item" and I want to make it point to something else <7> sockpuppet: python 2.5 is supposed to introduce the concept of relative imports that might simplify this, i think <0> I should del it at first, right? <7> jkt|: no point, x = y; x = z; will decrease the reference count on 'y' just as x = y; del x; x = z; would <6> i prefer to be explicit in my code anyways. <5> HeLiX`89: skip straight to chapter 3 <5> but I see now that it isn't meant for novice programmers at all <4> sockpuppet, that's not explicit, it's redundant :) <6> oh. <0> joedj: okay, but what if I want to store x for later use? something like stack.append(x); x = sth_else; x = stack.pop()? <4> HeLiX`89, there are also python tutorials for non-programmers <0> joedj: I was unable to find something about this in the official docs :( <8> hi <0> *anything <9> '__keys' is a private member in a cl*** right? <10> Yes. <4> right, Alterego, but many people eschew their use <9> benji, well, I know what I'm doing if that's what you mean ;) <10> "at least two underscores at the beginning, and no more than one underscore at the end" <9> Right, thank you <10> That makes __foo__ public again. <11> Alterego: no. it isn't. <10> Bizarrest... convention... evar. <11> Alterego: it's a variable that is mangled in order to stop namespace conflicts. <10> It's as private as you get, anyway. <11> hari`: that's also a lie. <7> jkt|: you do it like that, that's fine <10> Without inside-out objects or some other fugly hack. <9> Yes, well. No need to be pedantic. I did read the part about private members only being "hard" to access. <11> Alterego: if you have methods or values you wish to define as private, preceed them with a single underscore.
<4> which is what "private" means to me in the contex of Python <10> Jerub, "lie" indicates a hostile accusation that I have some malice in saying what I'm saying. <10> Jerub, no need to be an ***hole about it. <11> Alterego: if you want to stop namespace conflicts with subcl***es (a good example is where you have a supercl*** that's a mixin, or something like an xmlrpc server cl***), use __foo <11> hari`: sorry, it's a common colloquialism here. <11> hari`: there are 'lie's, which are those facts that seem okay on the surface, but aren't actually accurate. <10> Well, colloquialisms that make you seem like an ***hole might want to get reviewed. <9> Well, now you're just confusing me :) <11> hari`: then there are 'useful lies', which are things that seem okay on the surface, and it doesn't pay to dig. <10> In C++, a "private" is not visible through normal means by a subcl***. I think __foo falls into that category. <10> In C++, a "protected" is visible by a subcl*** but not by outsiders. I think "_foo" fits into that category. <9> Actually, thinking about it. This object doesn't even need to be private. <10> Though there's nothing *stopping* an outsider from doing all kinds of end-runs, or simply ignoring wisdom in the _foo case. <11> hari`: yep, that's exactly it. <10> So stop with the "lie" stuff, mmkay? <12> do you every *really* need to use private and public? <9> Well, I don't have to account for other peoples stupidity. <11> hari`: in python, we only use __foo when it would break code to not use it, and we only use _foo when we do not want to publish something as an externally accessable api because it might change in future. <10> amdy, it's like a lock on your front door-- it keeps the honest people out. <7> Alterego: man, i want your job <11> Alterego: yes, this is a primary tenant of python, all python programmers are automatically ***umed to be 'Consenting Adults' <10> Not as a security concern, but as a design concern. <13> tenet <9> joedj, I'm self employed ;) <11> oh wow, I've been mispelling that for years, thanks deltab <10> A tenant of a python is, quite briefly, the chick inside that egg just swallowed. <13> heh <14> in xmpppy: AttributeError: Client instance has no attribute 'Dispatcher' <14> I'm using the example from xmpppy site <14> why this error? <15> hi, i'm getting this error with an install on win32: ImportError: no module named com <15> where do i find this com module <16> i still can't get a bitmapbutton to work in wx, i dunno what i'm doing wrong <16> i can't find an example though /: <0> joedj: hmm, it seems that I haven't explained it correctly <0> joedj: I need to "store pointer to the current object somewhere" <0> and restore it after some time <0> object means instance of a cl*** <17> jotham, what's the app you're trying to run? <7> jkt|: stack.append(x); x = somethingElse; ...later...; x = stack.pop() # <- that's what this does <16> button2 = wxBitmapButton(window, 100, wxBitmap = "testss.bmp") any ideas? <0> joedj: yup, but I have something like stack.append(x); x.modify(); ...later... x = stack.pop() <0> joedj: where x should carry the modifications done by modify() (which is not a method of that cl***, in fact) <17> jkt|, given that x is a mutable object so that it can be modified, no problems there <0> the example is at http://pastebin.com/579227 <18> tark: you shouldn't be using from wxPython import * <18> tark: wx.BitmapButton(parent, id, wx.Bitmap("location/of/image.png")) <19> in Python i read "everything not in a funtion belongs to __main__" do\can i specifically define __main__ myself to bring a sense of structure to the code? Rather than a few functions & some seemingly random statements? <18> notice the wx. <-- <10> altf2o, nope, any module *could* be a __main__, it just depends on what you ask the python executable to start with. <10> altf2o, you'll sometimes see a bit at the bottom of a .py file: if __name__ == "__main__": <19> ahh, nice... <20> hi, i have python2.4-cheetah installed on ubuntu but for some reason in /usr/lib/python2.4/site-packages/Cheetah there is no CacheRegion.py so i copied it over from a slackware install and am wondering if thats ok to do? <10> That lets it run that code only if it's run individually. Otherwise it's for importing into other code. <9> hari`, or both :) <10> Alterego, exactly. The if __name__ thing is often used as unit tests for importable modules. <16> finally found an example of it http://wiki.wxwidgets.org/docbrowse.cgi/wxwin_wxbitmapbutton.html <21> Can an imported module access the toplevel code by import __main__ ? <22> altf2o: The book? I heard bad things about it and find it dreadfully .. well...boring I think is what I'm looking for. ... diveintopython(.org) seems a lot better. <19> so would it be similar to: def func(): ... if __name__ == "__main__": func() ..... ? <16> my question is, if I want to store multiple bmps, do I have to have allocate memory for each one? <0> hmm, that stacking doesn't seem to work :( <16> or can i put them all onto bmpDC? <10> Sgeo, yes. I've had to do that for some stupid code. <10> Sgeo, and you can do import within a certain def, too. def foo(args): import __main__ ; __main__.STUPIDGLOBAL = 5 ; dosomething() <19> halenger> what i'm currently reading is, "How To Think Like A Computer Scientist : Python Version" thus far, it's proven a very easy, but informative read. I have a couple books i found as well released under the GNU free doc. license. <22> Ah, I've heard good things about that too. diveintopython.org is a free online book also. <19> ahh, dive into python is actually one of them. I'll be sure to give that a read. <9> altf2o, I read that a few days ago. It is very good if you're already a programmer. <22> Heh. I use it as a general reference and find it turns up high on google when I search for something python related also. Handy, good examples and a good read in general. <0> hmm, it was PEBKAC :) <19> thx for the recommendation, i'm almost half way done w/ this one, i'll move to that one next. <22> No worries.
Return to
#python or Go to some related
logs:
chroot /mnt/gentoo Exec format error ubuntu play pls ubuntu hang enterprise volume management #math install grub raid 0 ubuntu #web #lisp #css dhclient3 sniffer Universe repos
|
|