[Tutor] Python C API - Defining New Classes with Multiple Inheritance

2010-12-23 Thread Logan McGrath
Hi, I've just started using the Python C API for version 2.7.1, and I've got a question! How do you define a new type which inherits from multiple types? I've been browsing the source code for Python 2.7.1 but I'm having a tough time finding examples. I see that MySQLdb defines low-level class

Re: [Tutor] paramiko error with put()

2010-12-23 Thread Evert Rol
I don't really know the answer, but more a question/note (below): > Hi I am using paramiko 1.7.6 "fanny" on microsoft windows xp v2002 service > pack3 with python 2.4.2 > > I have the follwing script: > import paramiko > > hostname='blah' > port=22 > username='blah' > password='blah' > fullpat

[Tutor] paramiko error with put()

2010-12-23 Thread Adam Cryer
Hi I am using paramiko 1.7.6 "fanny" on microsoft windows xp v2002 service pack3 with python 2.4.2 I have the follwing script: *import paramiko hostname='blah' port=22 username='blah' password='blah' fullpath='root\\path\\file.xls' remotepath='/inbox/file.xls' self.client= paramiko.SSHClient

Re: [Tutor] Dynamically generated classes

2010-12-23 Thread Karim
On 12/23/2010 10:13 AM, Alan Gauld wrote: "Rasjid Wilcox" wrote I've been playing with dynamically generated classes. In particular: class ClassMaker(object): def __init__(maker_self, name): maker_self.name = name # class Foo(object): def __init__(self):

Re: [Tutor] Dynamically generated classes

2010-12-23 Thread Rasjid Wilcox
On 23 December 2010 20:13, Alan Gauld wrote: > I think it will do what you want but I wouldn't bother putting the class > definitions inside the init - unless there is a good reason. At the very > least I would create two factory methods which are called by init. > That would allow you to reset th

Re: [Tutor] Dynamically generated classes

2010-12-23 Thread Karim
Thanks for the link. I use Adapter already for java to align to different interface. I was curious about the facade implementation. Regards Karim On 12/23/2010 01:25 PM, Alan Gauld wrote: "Karim" wrote You mentioned the facade pattern. Could you please provide a basic simple implementatio

Re: [Tutor] Weighted Random Choice - Anyone have an efficient algorithm?

2010-12-23 Thread Steven D'Aprano
Modulok wrote: Does anyone know of an efficient way of doing a weighted random choice? (I don't even know what algorithms like this would be called.) If you google for "python weighted random choice" you will find a number of hits. Preferably, something that doesn't grow exponentially with

Re: [Tutor] Dynamically generated classes

2010-12-23 Thread Alan Gauld
"Karim" wrote You mentioned the facade pattern. Could you please provide a basic simple implementation of this pattern in python? Not without spending more time than I have available. But you can read about it on wikipedia, including Java example code. However I think I actually should ha

Re: [Tutor] Problems processing accented characters in ISO-8859-1 encoded texts

2010-12-23 Thread Steven D'Aprano
Josep M. Fontana wrote: Sorry! Sorry! Sorry! I just found out this question had already been answered by Steven D'Aprano in another thread! The trick was to add '\w' besides [a-zA-Z]. Hah ha! I didn't see this before I answered... I thought the question sounded familiar :) -- Steven

Re: [Tutor] Problems processing accented characters in ISO-8859-1 encoded texts

2010-12-23 Thread Josep M. Fontana
Hi Steven, On Thu, Dec 23, 2010 at 11:51 AM, Steven D'Aprano wrote: > Note also that \w means alphanumeric, not just alpha, so it will also match > digits. I'm sorry you didn't get to read my next message because in there I said that you yourself had already solved my problem a few weeks ago.

Re: [Tutor] Weighted Random Choice - Anyone have an efficient algorithm?

2010-12-23 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Modulok wrote: Does anyone know of an efficient way of doing a weighted random choice? (I don't even know what algorithms like this would be called.) Preferably, something that doesn't grow exponentially with the number of elements in the list, or the size of their resp

Re: [Tutor] Problems processing accented characters in ISO-8859-1 encoded texts

2010-12-23 Thread Steven D'Aprano
Josep M. Fontana wrote: I am working with texts that are encoded as ISO-8859-1. I have included the following two lines at the beginning of my python script: !/usr/bin/env python # -*- coding: iso-8859-1 -*- If I'm not mistaken, this should tell Python that accented characters such as 'á', 'Á',

Re: [Tutor] Problems processing accented characters in ISO-8859-1 encoded texts

2010-12-23 Thread Josep M. Fontana
Sorry! Sorry! Sorry! I just found out this question had already been answered by Steven D'Aprano in another thread! The trick was to add '\w' besides [a-zA-Z]. Please, accept my apologies. I devote time to this project whenever I have some free time. I got very busy with other things at some point

Re: [Tutor] Dynamically generated classes

2010-12-23 Thread Karim
Hello Alan, You mentioned the facade pattern. Could you please provide a basic simple implementation of this pattern in python? Regards Karim On 12/23/2010 10:13 AM, Alan Gauld wrote: "Rasjid Wilcox" wrote I've been playing with dynamically generated classes. In particular: class Clas

[Tutor] Problems processing accented characters in ISO-8859-1 encoded texts

2010-12-23 Thread Josep M. Fontana
I am working with texts that are encoded as ISO-8859-1. I have included the following two lines at the beginning of my python script: !/usr/bin/env python # -*- coding: iso-8859-1 -*- If I'm not mistaken, this should tell Python that accented characters such as 'á', 'Á', 'ö' or 'è' should be cons

Re: [Tutor] Dynamically generated classes

2010-12-23 Thread Alan Gauld
"Rasjid Wilcox" wrote I've been playing with dynamically generated classes. In particular: class ClassMaker(object): def __init__(maker_self, name): maker_self.name = name # class Foo(object): def __init__(self): self.parent = maker_self

[Tutor] Dynamically generated classes

2010-12-23 Thread Rasjid Wilcox
Hi all, I've been playing with dynamically generated classes. In particular: class ClassMaker(object): def __init__(maker_self, name): maker_self.name = name # class Foo(object): def __init__(self): self.parent = maker_self def