How to Adding Functionality to a Class by metaclass(not by inherit)

2005-08-11 Thread kyo guan
How to Adding Functionality to a Class by metaclass(not by inherit) #example: import inspect class Foo(object): def f(self): pass def g(self): pass class MetaFoo(type): def __init__(cls, name, bases, dic):

Re: Psyco & Linux

2005-08-11 Thread Fausto Arinos Barbuto
Hi Steve; Steve M wrote: >> First, I tried the usual "python setup.py install" but that did not work. > How exactly did it fail? Perhaps you can paste the error output from > this command. Sure, he is the output: linux:/home/fausto/Documents/psyco-1.4 # python setup.py install PROCES

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Steven Bethard
Ray wrote: > 1. Where are the access specifiers? (public, protected, private) There's no enforceable way of doing these. The convention is that names that begin with a single underscore are private to the class/module/function/etc. Hence why sys._getframe() is considered a hack -- it's not of

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Jeff Schwab
Ray wrote: > Devan L wrote: > >>Fausto Arinos Barbuto wrote: >> >>>Ray wrote: >>> >>> 1. Where are the access specifiers? (public, protected, private) >>> >>>AFAIK, there is not such a thing in Python. >>> >>>---Fausto >> >>Well, technically you can use _attribute to mangle it, but technic

Lightweight Python distribute it in under 2MBs for Win32

2005-08-11 Thread Ramza Brown
I am sorry if I think like this, but sometimes(keyword sometimes) I like distributing my interpreters. Anyway, I found the absolute minimum libraries needed for Python to work with Win32. And, I included FLTK for the GUI toolkit. Sorry, but wxPython didn't fit my <30MB requirement. You can b

Re: Regular expression to match a #

2005-08-11 Thread Bryan Olson
John Machin wrote: [...] > Observation: factoring out the compile step makes the difference much > more apparent. > > >>> ["%.3f" % t.timeit() for t in t3, t4, t5, t6] > ['1.578', '1.175', '2.283', '1.174'] > >>> ["%.3f" % t.timeit() for t in t3, t4, t5, t6] > ['1.582', '1.179', '2.284', '

Re: constructing bytestrings

2005-08-11 Thread Bryan Olson
Lenny G. wrote: > I use 's = os.read(fd, 12)' to grab 12 bytes from a file. Now, I want > to create a string, s1, which contains 16-12=4 bytes: 4,0,0,0, followed > by the contents of s. > > I know how to 's1 = "\x04\x00\x00\x00"' and how to 's3 = s1+s', but I > don't know how to construct s1

Re: Jargons of Info Tech industry

2005-08-11 Thread James Stroud
Xah Lee is a known troll. You are retarded to reply to his drivel. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Adding Functionality to a Class by metaclass(not by inherit)

2005-08-11 Thread Steven Bethard
kyo guan wrote: > How to Adding Functionality to a Class by metaclass(not by inherit) > [snip] > > class MetaFoo(type): > def __init__(cls, name, bases, dic): > super(MetaFoo, cls).__init__(name, bases, dic) > > for n, f in inspect.ge

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Paul McGuire
Please look through this example code, and the comments. If I've misspoken, please anyone correct my errors. -- Paul class OldStyleClass: """A definition of an old style class.""" pass class NewStyleClass(object): """Note that NewStyleClass explicitly inherits from object. This

Re: MainThread blocks all others

2005-08-11 Thread Bryan Olson
Nodir Gulyamov wrote: > [...]I should show you real code [...] > Please find below real code. Sorry for amount of sources. Yeah, it's too much for me. Can you construct a minimal example that doesn't do what you think it should? -- --Bryan -- http://mail.python.org/mailman/listinfo/python-li

Using globals with classes

2005-08-11 Thread Madhusudan Singh
Hi I am relatively new to Python. I am using Qt Designer to create a UI for a measurement application that I use. Everything seems to be clear but the use of globals (defined in the module that is generated using pyuic, that contains the form class). I am using qwtplot to display a running plot

Re: list to tuple

2005-08-11 Thread James Stroud
Try the zip funciton: py> a = [11,12,13,14] py> b = [2,3,4,5] py> c = [20,21,22,23,24,25] py> zip(a,b,c) [(11, 2, 20), (12, 3, 21), (13, 4, 22), (14, 5, 23)] On Thursday 11 August 2005 09:05 pm, zxo102 wrote: > Hi, >I got several dynamic lists a1, b1, c1, from a python > application

Re: list to tuple

2005-08-11 Thread Ruslan Spivak
"zxo102" <[EMAIL PROTECTED]> writes: > Hi, >I got several dynamic lists a1, b1, c1, from a python > application such as >a1 = [1,5,3,2,5,...], the len(a1) varies. Same to b1, c1, > >With python, I would like to reorganize them into a tuple like > >t1 = ((a1[0],b1[0],c1[0]

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Ben Finney
Ray <[EMAIL PROTECTED]> wrote: > 1. Where are the access specifiers? (public, protected, private) No such thing (or, if you like, everything is "private" by default). By convention, "please don't access this name externally" is indicated by using the name '_foo' instead of 'foo'; similar to a "pr

Re: list to tuple

2005-08-11 Thread Paddy
Try this: >>> a,b,c = list('tab'),list('era'),list('net') >>> a,b,c (['t', 'a', 'b'], ['e', 'r', 'a'], ['n', 'e', 't']) >>> tuple(((x,y,z) for x,y,z in zip(a,b,c))) (('t', 'e', 'n'), ('a', 'r', 'e'), ('b', 'a', 't')) >>> - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Paul McGuire
Instance variables are typically defined in __init__(), but they can be added to an object anywhere. The only exception is when defining the magic __slots__ class variable to pre-define what the allowed instance variables can be. class A: pass a = A() a.instVar1 = "hoo-ah" a.instVar2 = "another

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Ray
Thanks guys! Your explanations have cleared up things significantly. My transition from C++ to Java to C# was quite painless because they were so similar, but Python is particularly challenging because the concepts are quite different. (I always have this paranoid feeling: "Am I using Python to wr

Buglet in win32 odbc

2005-08-11 Thread Frank Millman
Hi all I am using win32 odbc to connect to SQL Server. I have just started using the 'bit' data type, which is a boolean type which can store 1 or 0. This works with win32, but it returns '1' or '0'. Obviously I can change it to an int, but it would be nicer and more correct if it returned an int

Re: list to tuple

2005-08-11 Thread zxo102
Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python supports LSP, does it?

2005-08-11 Thread en.karpachov
On Thu, 11 Aug 2005 15:02:08 -0400 Terry Reedy wrote: > I remember discussion of the LSP on comp.object some years ago when I > was reading it. (I presume there still are, just don't read it > anymore.). One of the problems is that biology and evolution do not > obey it. Birds (in general) c

Where can be a problem?

2005-08-11 Thread Lad
I use the following ### import re Results=[] data1='' ID = re.compile(r'^.*=(\d+)&.*$',re.MULTILINE) Results=re.findall(ID,data1) print Results # to extract from data1 all numbers such as 15015,15016,15017 But the program extracts only the last number 15017. Why? Thank you

Re: signals (again)

2005-08-11 Thread bill
I found a good solution to this problem in Richard Steven's _Network_Programming_. It seems like everything shows up in Steven's books! Rather than pausing, you do a blocking read on a pipe. You only write to the pipe from within the signal handler. However, this brings up the better question:

Re: set of sets

2005-08-11 Thread Matteo Dell'Amico
Paolo Veronelli wrote: > Yes this is really strange. > > from sets import Set > class H(Set): > def __hash__(self): > return id(self) > > s=H() > f=set() #or f=Set() > > f.add(s) > f.remove(s) > > No errors. > > So we had a working implementation of sets in the library an put a > broken

<    1   2   3