#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 
Top Prev 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 Next

#python

<sipher> ffs
<sipher> I give up
<sipher> Too early
<kbrooks> sipher: once again, my command was only an example!!! :-)
<kbrooks> sipher: time there is what?
<sipher> 4:42
<kbrooks> sipher: its 7:42 here
<sipher> I just meant I give up on trying to type subdirectories.. yay. I did it
<zyp> 13:42 here
<zyp> or rather, 13:43
<alakdan> ZenMasterJG: if there are 'class methods' are there 'class variables' ? I want something like that
<kbrooks> sipher: lol
<ZenMasterJG> alakdan: by class variable, do you mean a variable that keeps its value across instances of a class, or... ?
<kbrooks> How do I find a free port in Python?
<T`> hh i thought dict keys can be accedssed thru dict.key?
<T`> doesn't seem to work now
<T`> is this not the case? i might be getting confused with javascript or something may be
<Leeds> dict.keys()
<kbrooks> T`: d[key]
<zyp> T`, it's not the case.
<alakdan> ZenMasterJG: yeah sort of.
<ZenMasterJG> alakdan: take a look at this: http://diveintopython.org/object_oriented_framework/class_attributes.html
<ZenMasterJG> but basically, if you want multiple instances of a class to be able to access the same varible, you use the class name instead of self, like for class Foo, instead of calling something self.var, you can call it Foo.var to make it a class attribute
<ZenMasterJG> like static, if you speak Java
<T`> sorry guys.. i defintely confused that with JS
<alakdan> ZenMasterJG: Yeah like a static in Java. Can I call Foo.var inside a Foo.method ? Basically I am trying to use (learning) the logging module. For each class type, I want a different logger, thus for every class instance I dont have to produce new logger instance or something.
<SEAwolfx> alakdan: you can use metaclass-programming for that resulting in not to use class-variables. the classes itself must only be declared to get the logging-aspect.
<whaley> alakdan: yes, just use var instead of self.var inside of the method
<SEAwolfx> s/to use/using/
<AndroidData> is it possible for me to encrypt/compress my data files so others can't access them (that easily)? if so, do tell.
<Leeds> AndroidData: of course it is... but do you mean in Python, or generally?
<VladDrac> be warned, if anyone says "you can use metaclass ..." he's usually suggesting a non-solution :)
<alakdan> ZenMasterJG: thanks for the link (the dive into python) I guess that is what I need. Though I am not sure its the pythonic way of doing it. I am not sure I can grasp metaclass-programming for now :)
<polpak> alakdan: you essentially want all instances of your class to share the same variable?
<SEAwolfx> alakdan: metaclass programming would be the best to not spoil the business-logic with logging-procedures.
<ZenMasterJG> assuming you can keep your head from exploding.
<alakdan> whaley: try this, class A(object):\n myvar=1; def method1(self): print myvar . afaik, it wont work
<polpak> alakdan: try self.myvar
<VladDrac> metaclasses are the best way to add incomprehensible implicitness that will allow you to shoot yourself in the foot later
<ZenMasterJG> no, A.var, if you want a class variable
<VladDrac> (or someone else)
<polpak> ZenMasterJG: no..
<SEAwolfx> VladDrac: depends on the use-case ;)
<ZenMasterJG> polpak: self.var will give him an instance variable
<VladDrac> the standard use-cases for metaclasses are the default way python uses them
<whaley> alakdan: ZenMasterJG is right... i told ou wrong... you must qualify the variable with either self.var or ClassName.var
<whaley> *you
<polpak> ZenMasterJG: unless you're planning on re assigning self.myvar it will reference the class variable
<VladDrac> anything else usually adds confusion
<VladDrac> imnsho

Previous Page  Next Page

Search ircarchive.info