Re: site-packages, unzipepd there but import fails
why don't you just download & excute the windown installer binary? On Jul 4, 2:47 am, defn noob <[EMAIL PROTECTED]> wrote: > On Jul 3, 8:06 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > On 3 juil, 18:51, defn noob <[EMAIL PROTECTED]> wrote: > > > > well the reason i unzipped and placed it in site-packages was because > > > nothign happened when i ran setup.py(unzipped). > > > What do you mean, "running setup.py unzipped" ??? > > > The correct way to install a package is to: > > > - unzip (untar, whatever) the archive somewhere in your own directory > > - cd to the unzipped directory > > - *from there*, run python setup.py install > > yes, which i have done. > > the command row executes but nothing happens, no errors either. -- http://mail.python.org/mailman/listinfo/python-list
Re: why is "self" used in OO-Python?
On Jul 13, 12:32 am, ssecorp <[EMAIL PROTECTED]> wrote: > I first learned about OO from Java. > > I much prefer to program in Python though. > > However I am consufed about 2 things. > > 1. Why do I have to pass self into every method in a class? Since I am > always doing why cant this be automated or abstracted away? > Are the instances where I won't pass self? > I imagine there is some tradeoff involved otherwise it would have been > done away with. > > 2. self.item instead of getters and setters. I thought one of the main > purposes of OO was encapsulation. Doesn't messing with internal object- > representations break this? > I see how the getters and setters could be just visual clutter and you > have to add them to every class so it is annoying a bit in the same > way as self described above. > However I feel like I want getters and setters when I write classes, > not sure of the advantages/disadvantages though. > Only looking at the documentation of a Python-class, will internal > representations be provided? > > If I have a class: > > class Stack(object): > def __init__(self, *items): > self.stack = list(items) > > def append(self, item): > self.stack.append(item) > > def pop(self): > return self.stack.pop() > > I can get to see the stack with var.stack but then why even implement > append when I could do self.stack.append(x) etc. > That way you could do away with OO completely. So why let people > access the main attribute but not let them manipulate it? > Makes more sense to draw the line to not access any attributes at all > no? i think the following article may be helpful to you. "Introduction to OOP with Python" http://www.voidspace.org.uk/python/articles/OOP.shtml#id34 -- http://mail.python.org/mailman/listinfo/python-list
Re: Confounded by Python objects
On Jul 24, 6:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jul 24, 11:59 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > tip: if you're not 100% sure why you would want to put an attribute > > on the class level, don't do it. > > The reason I did it was sort of C++ish (that's where I come from): I > somehow wanted a list of attributes on the class level. More for > readibility than anything elase, really. > > > hope this helps! > > Yup, did the trick. Thanks! > robert yes, i thought your code is kind of static, so it didn't work for a dynamic language like python. in python, you don't have to say "static" to make an variable a class variable, so the "name" and "sample" you kind of "declared" is indeed class variables. you may wonder why then the two instaces of "Channel" has different names, that's because you assign to name in "__init__" and make it an instance variable that shared the name "name" with a class variable. As to "sample", it never get assigned to and when you say "append" the class variable is changed in place. hope my explaination helps. -- http://mail.python.org/mailman/listinfo/python-list
how can i check whether a variable is iterable in my code?
hi, all i want to check if a variable is iterable like a list, how can i implement this? -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
On Sep 20, 6:35 pm, Aidan <[EMAIL PROTECTED]> wrote: > satoru wrote: > > hi, all > > i want to check if a variable is iterable like a list, how can i > > implement this? > > this would be one way, though I'm sure others exist: > > if hasattr(yourVar, '__iter__'): > # do stuff thank you,but this will miss out sequences like string just because it doesn't have an attribute named '__iter__' -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
thanks very much! -- http://mail.python.org/mailman/listinfo/python-list
Is `wsample` a proper name for a function like this?
I came across a function named `wsample` in a `utils` package of my workplace recently. The "w" in `wsample` stands for `weighted`, and it randomly selects an element from a container according to relative weights of all the elements. In most articles and codes I saw online, a function like this is often named `weighted_random_choice`, which sounds *correct* to me. So when I saw this `wsample` function, I considered it a improper name. Because `wsample`makes me think of `random.sample`, which returns a list of randomly generated elements, not a element. -- http://mail.python.org/mailman/listinfo/python-list
