Re: How to mix-in __getattr__ after the fact?

2011-11-01 Thread DevPlayer
On Oct 31, 8:01 am, dhyams wrote: > Thanks for all of the responses; everyone was exactly correct, and > obeying the binding rules for special methods did work in the example > above.  Unfortunately, I only have read-only access to the class > itself (it was a VTK class wrapped with SWIG), so I ha

Re: Assign values from list to list of instances

2011-11-01 Thread Gnarlodious
On Nov 1, 3:33 pm, Terry Reedy wrote: > > for obj, val in zip(Orders, locus): > > obj.locus = val > > > I'm not sure how worthwhile it is converting the above to a list > > comprehension (when the list would just be thrown away). Having said > > that the call to zip creates an unnecessary list. >

Re: Question about metaclass

2011-11-01 Thread Makoto Kuwata
On Wed, Nov 2, 2011 at 1:40 PM, Ian Kelly wrote: > > If you want to customize the dict you need to do it in __new__, not > __init__.  By the time __init__ is called, the class has already been > created. > > class MetaClass(type): >    def __new__(mcs, name, bases, dict): >        for k, v in dict

Re: Question about metaclass

2011-11-01 Thread Patrick Maupin
On Nov 1, 11:02 pm, Makoto Kuwata wrote: > Hi, > > I want to define a special class which groups functions, like: > >     class Greepting(FuncGroup): >         def hello():          # no self, no @staticmethod! >             print("Hello!") >         def goodbye():        # no self, no @staticmeth

Re: Question about metaclass

2011-11-01 Thread Ian Kelly
On Tue, Nov 1, 2011 at 10:02 PM, Makoto Kuwata wrote: > I tried the following code which converts instance mthods into > static method automatically, but I don't get result what I want. > (python 2.5.5) > >    import sys >    from types import FunctionType > >    class MetaClass(type): >        de

Question about metaclass

2011-11-01 Thread Makoto Kuwata
Hi, I want to define a special class which groups functions, like: class Greepting(FuncGroup): def hello(): # no self, no @staticmethod! print("Hello!") def goodbye():# no self, no @staticmethod! print("Good Bye!") Geeting.hello():

Re: understand program used to create file

2011-11-01 Thread alex23
On Nov 2, 5:27 am, pacopyc wrote: > Hi, I have about 1 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? Word documents store metadata inside of them, one field

Re: How filecmp walk into subdirectories?

2011-11-01 Thread John Gordon
In Muddy Coder writes: > I tried to compare two directories, each with hundreds of files in > multiple level subdirectories, to find out the different files. I used > filecmp module to the job as: > comp=filecmp.dircmp(adir, bdir) > comp.report() > It worked, and printed out the identical and

How filecmp walk into subdirectories?

2011-11-01 Thread Muddy Coder
Hi Folks, I tried to compare two directories, each with hundreds of files in multiple level subdirectories, to find out the different files. I used filecmp module to the job as: comp=filecmp.dircmp(adir, bdir) comp.report() It worked, and printed out the identical and different files. However,

Re: sending more then 2 messages to SocketServer fasils

2011-11-01 Thread Roy Smith
In article <4eb00a7a$0$6560$9b4e6...@newsspool4.arcor-online.net>, MrSmile wrote: > Hi people! > I have asked myself why I am not capable sending 2 messages a time to a > Socketserver. Why is that?! There's a lot of confusing code here. It would help when asking these kinds of questions to re

Re: Sort items in wxListCtrl

2011-11-01 Thread Ric
On Tue, 1 Nov 2011 16:14:50 -0700 (PDT), Miki Tebeka wrote: >Why not use the build in wx.FileDialog? > >Also, have a look at the demo that comes with wxPython. It has an example with >a sortable list control. Thanks for responding, How would wx.FileDialog help me in this case? I am trying to di

Re: Module for Python and SGE interaction

2011-11-01 Thread Terry Reedy
On 11/1/2011 1:31 PM, Abhishek Pratap wrote: On Mon, Oct 31, 2011 at 10:31 PM, Abhishek Pratap mailto:abhishek@gmail.com>> wrote: Hey Guys I shud mention I am relative new to the language. Could you please let me know based on your experience which module could help me with

Re: parsing text from "ethtool" command

2011-11-01 Thread Ian Kelly
On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka wrote: > In my box, there are some spaces (tabs?) before "Speed". IMO > re.search("Speed", line) will be a more robust. Or simply: if "Speed" in line: There is no need for a regular expression here. This would also work and be a bit more discriminat

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Terry Reedy
On 11/1/2011 2:56 AM, Steven D'Aprano wrote: On Mon, 31 Oct 2011 20:44:45 -0400, Terry Reedy wrote: [...] def is_ascii_text(text): for c in text: if c not in LEGAL: return False return True If text is 3.x bytes, this does not work ;-). OP did not specify by

Re: proving two formula are same each other!

2011-11-01 Thread Steven D'Aprano
On Tue, 01 Nov 2011 05:03:17 -0700, pyman wrote: > hello, I need some idea to prove two formula is same. Impossible. As you explained further on, they are different formula. If they are different, they aren't the same. This has nothing to do with Python. In another message, you tell us: "thes

Re: parsing text from "ethtool" command

2011-11-01 Thread Miki Tebeka
In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. -- http://mail.python.org/mailman/listinfo/python-list

Re: Sort items in wxListCtrl

2011-11-01 Thread Miki Tebeka
Why not use the build in wx.FileDialog? Also, have a look at the demo that comes with wxPython. It has an example with a sortable list control. -- http://mail.python.org/mailman/listinfo/python-list

Chaco for real-time plot of PySerial data

2011-11-01 Thread Jack Keegan
Hi there, I asked this question on the enthought chaco mailing list some time last by have yet to receive a reply. Thought I'd ask here to see if anyone could shed some light on things for me. I have been considering using chaco / traits for close to a year now and am finally biting the bullet so

parsing text from "ethtool" command

2011-11-01 Thread extraspecialbitter
I'm still trying to write that seemingly simple Python script to print out network interfaces (as found in the "ifconfig -a" command) and their speed ("ethtool "). The idea is to loop for each interface and print out its speed. I'm looping correctly, but have some issues parsing the output for al

Re: Assign values from list to list of instances

2011-11-01 Thread Terry Reedy
On 11/1/2011 11:37 AM, duncan smith wrote: On 01/11/11 15:05, Gnarlodious wrote: I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This

Re: Does anyone use Python Tools for visual studio?

2011-11-01 Thread Brian Curtin
On Tue, Nov 1, 2011 at 11:57, Wei wrote: > I got several buggy things going on. > First, the view of class tree stops expanding after creating more than > two classes. > Second, after 800 lines of code the classes and methods can't be > folded. (meaning the + sign is gone) > P.S. there is no warni

Re: understand program used to create file

2011-11-01 Thread Jon Clements
On Nov 1, 7:27 pm, pacopyc wrote: > Hi, I have about 1 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > > Thanks My suggestion would be the same as DaveA's.

Re: understand program used to create file

2011-11-01 Thread Chris Angelico
On Wed, Nov 2, 2011 at 6:27 AM, pacopyc wrote: > Hi, I have about 1 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > Technically, you can't find out just fro

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Duncan Booth
MRAB wrote: > On 01/11/2011 18:54, Duncan Booth wrote: >> Steven D'Aprano wrote: >> >>> LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' >>> MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range (128)) >>> >>> # Untested >>> def is_ascii_text(text): >>> for c in text:

Re: When I use Python under Windows. I found some file handles are not closed,

2011-11-01 Thread Gabriel Genellina
En Mon, 31 Oct 2011 12:57:15 -0300, 罗勇刚(Yonggang Luo) escribió: How did detecting where those handlers are created to tracing it and close it. Mainly because I was using C binding library(subvertpy) and file is not closed. A better place to ask is python-list@python.org Please include t

Re: understand program used to create file

2011-11-01 Thread Dave Angel
On 11/01/2011 03:27 PM, pacopyc wrote: Hi, I have about 1 files .doc and I want know the program used to create them: writer? word? abiword? else? I'd like develop a script python to do this. Is there a module to do it? Can you help me? Thanks If you're on Linux, just use the process module

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Stefan Behnel
pyt...@bdurham.com, 31.10.2011 20:54: Wondering if there's a fast/efficient built-in way to determine if a string has non-ASCII chars outside the range ASCII 32-127, CR, LF, or Tab? I know I can look at the chars of a string individually and compare them against a set of legal chars using standa

Re: getting columns attributes in declarative style with sqlalchemy

2011-11-01 Thread tres . bailey
Hi Gabriele, I'm not an Alchemy expert, but I have used the ColumnProperty of the model/column objects to solve this problem in the past. So to get the column name for the description column in your example above, you would use the following syntax: Country.description.property.columns[0].nam

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread MRAB
On 01/11/2011 18:54, Duncan Booth wrote: Steven D'Aprano wrote: LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) # Untested def is_ascii_text(text): for c in text: n = ord(c) if n>= len(M

Re: getting columns attributes in declarative style with sqlalchemy

2011-11-01 Thread tres . bailey
Sorry for the repost, if it does in fact repost. I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past. You can use the following syntax to do it: [col.name for col in Country.__table__.columns._all_cols]

understand program used to create file

2011-11-01 Thread pacopyc
Hi, I have about 1 files .doc and I want know the program used to create them: writer? word? abiword? else? I'd like develop a script python to do this. Is there a module to do it? Can you help me? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Ian Kelly
On Mon, Oct 31, 2011 at 6:32 PM, Patrick Maupin wrote: > On Oct 31, 5:52 pm, Ian Kelly wrote: >> For instance, split() will split on vertical tab, >> which is not one of the characters the OP wanted. > > That's just the default behavior.  You can explicitly specify the > separator to split on.  B

Re: Does anyone use Python Tools for visual studio?

2011-11-01 Thread Tamer Higazi
buy wingIDE or use PyDEV If you tell me that you are using IronPython then buy wingIDE, there you can make use of the .net classes in python too. Tamer Am 01.11.2011 18:01, schrieb Wei: > On Nov 1, 12:57 pm, Wei wrote: >> I got several buggy things going on. >> First, the view of class tree s

Re: sending more then 2 messages at a time to a SocketServer fails

2011-11-01 Thread Tamer Higazi
Am 01.11.2011 17:13, schrieb Miki Tebeka: > MKTest.getObj(data[0]) will return the same object on every call(with the > same data that was initialized 1'st time). Any Daten parameter after the 1'st > call is ignored. Not true! The singleton object has nothing todo. Here one more example for you

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Duncan Booth
Steven D'Aprano wrote: > LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' > MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) > > # Untested > def is_ascii_text(text): > for c in text: > n = ord(c) > if n >= len(MASK) or MASK[n] == '\0': retur

Sort items in wxListCtrl

2011-11-01 Thread Ric
I am trying to create a small application in wxPython and would like to ask for some help. I am trying to display folders and files in ListCtrl but sorted first folders followed by files (like in a file manager style) but not sure how to do this? Would I need to do this in code somehow or ListCt

Re: sending more then 2 messages at a time to a SocketServer fails

2011-11-01 Thread MRAB
On 01/11/2011 15:07, MrSmile wrote: Hi people! I have asked myself why I am not capable sending 2 messages a time to a Socketserver. Why is that?! Here the Server: import SocketServer from ast import literal_eval class MKTest(object): DSX = [] MKTestInst = None def __init__(se

Re: Module for Python and SGE interaction

2011-11-01 Thread Abhishek Pratap
Hey Guys Pushing this one again just in case it was missed last night. Best, -Abhi On Mon, Oct 31, 2011 at 10:31 PM, Abhishek Pratap wrote: > Hey Guys > > I shud mention I am relative new to the language. Could you please let me > know based on your experience which module could help me with fa

Re: Does anyone use Python Tools for visual studio?

2011-11-01 Thread Wei
On Nov 1, 12:57 pm, Wei wrote: > I got several buggy things going on. > First, the view of class tree stops expanding after creating more than > two classes. > Second, after 800 lines of code the classes and methods can't be > folded. (meaning the + sign is gone) > P.S. there is no warning or erro

Re: C API: Making a context manager

2011-11-01 Thread Stefan Behnel
Chris Kaynor, 01.11.2011 17:19: On Tue, Nov 1, 2011 at 8:57 AM, Stefan Behnel wrote: Chris Kaynor, 31.10.2011 19:34: I am currently rewritting a class using the Python C API to improve performance of it, however I have not been able to find any documentation about how to make a context manager

Does anyone use Python Tools for visual studio?

2011-11-01 Thread Wei
I got several buggy things going on. First, the view of class tree stops expanding after creating more than two classes. Second, after 800 lines of code the classes and methods can't be folded. (meaning the + sign is gone) P.S. there is no warning or errors in my code. -- http://mail.python.org/ma

Re: C API: Making a context manager

2011-11-01 Thread Chris Kaynor
On Tue, Nov 1, 2011 at 8:57 AM, Stefan Behnel wrote: > Chris Kaynor, 31.10.2011 19:34: >> >> I am currently rewritting a class using the Python C API to improve >> performance of it, however I have not been able to find any >> documentation about how to make a context manager using the C API. > >

Re: Assign values from list to list of instances

2011-11-01 Thread Ulrich Eckhardt
Am 01.11.2011 16:05, schrieb Gnarlodious: I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads lik

Re: sending more then 2 messages at a time to a SocketServer fails

2011-11-01 Thread Miki Tebeka
MKTest.getObj(data[0]) will return the same object on every call(with the same data that was initialized 1'st time). Any Daten parameter after the 1'st call is ignored. -- http://mail.python.org/mailman/listinfo/python-list

Re: C API: Making a context manager

2011-11-01 Thread Stefan Behnel
Chris Kaynor, 31.10.2011 19:34: I am currently rewritting a class using the Python C API to improve performance of it, however I have not been able to find any documentation about how to make a context manager using the C API. You should take a look at Cython. It makes these things *so* much ea

modified legend appears out of view! It didn't used to. MWE included.

2011-11-01 Thread cpbl
I seem to be using Python 2.7.2+ (latest update of Ubuntu). The following code used to work nicely, but now gives me an unreadable legend. The legend is showing up mostly out of view below and to the left of the figure. Does that happen for you? Is there a regression bug, or am I doing something wr

Re: Assign values from list to list of instances

2011-11-01 Thread duncan smith
On 01/11/11 15:05, Gnarlodious wrote: I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads like do

Re: Assign values from list to list of instances

2011-11-01 Thread Dave Angel
On 11/01/2011 11:05 AM, Gnarlodious wrote: I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads li

Re: Assign values from list to list of instances

2011-11-01 Thread Peter Otten
Gnarlodious wrote: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is

sending more then 2 messages at a time to a SocketServer fails

2011-11-01 Thread MrSmile
Hi people! I have asked myself why I am not capable sending 2 messages a time to a Socketserver. Why is that?! Here the Server: import SocketServer from ast import literal_eval class MKTest(object): DSX = [] MKTestInst = None def __init__(self,Daten): MKTest.DSX.append(Date

Assign values from list to list of instances

2011-11-01 Thread Gnarlodious
I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads like doggerel. Is there a more pythonesque way

sending more then 2 messages to SocketServer fasils

2011-11-01 Thread MrSmile
Hi people! I have asked myself why I am not capable sending 2 messages a time to a Socketserver. Why is that?! Here the Server: import SocketServer from ast import literal_eval class MKTest(object): DSX = [] MKTestInst = None def __init__(self,Daten): MKTest.DSX.append(Date

Support for Galois/Counter Mode (GCM) ?

2011-11-01 Thread Roland Hedberg
Hi ! Is there a crypto library for Python that has support for GCM ?? -- Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: proving two formula are same each other!

2011-11-01 Thread Dave Angel
(You forgot to do a REPLY-ALL, so that your message didn't get sent to the list) Python doesn't have formulae, it has functions and methods. So you have to describe more completely what kind of formula you have, math, physics, chemistry? the formula is related to math. And how is

Re: proving two formula are same each other!

2011-11-01 Thread Dave Angel
On 11/01/2011 08:03 AM, pyman wrote: hello, I need some idea to prove two formula is same. if N = 3, these formula are same each other. each formula has 3 input . To prove this, drawing shape or anything would be possible. how can I do this? please give me your idea! for example: N = 1 : formula

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Peter Otten
Steven D'Aprano wrote: > On Mon, 31 Oct 2011 22:12:26 -0400, Dave Angel wrote: > >> I would claim that a well-written (in C) translate function, without >> using the delete option, should be much quicker than any python loop, >> even if it does copy the data. > > I think you are selling short th

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Steven D'Aprano
On Mon, 31 Oct 2011 22:12:26 -0400, Dave Angel wrote: > I would claim that a well-written (in C) translate function, without > using the delete option, should be much quicker than any python loop, > even if it does copy the data. I think you are selling short the speed of the Python interpreter.

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Steven D'Aprano
On Mon, 31 Oct 2011 20:44:45 -0400, Terry Reedy wrote: [...] >> def is_ascii_text(text): >> for c in text: >> if c not in LEGAL: >> return False >> return True > > If text is 3.x bytes, this does not work ;-). OP did not specify bytes > or unicode or Python version