Re: Generating text from a regular expression

2010-04-02 Thread Nathan Harmston
Thanks everyone, the invRegexInf is perfect. Thanks again, Nathan On 1 April 2010 10:17, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 31 Mar 2010 12:23:48 -0300, Paul McGuire pt...@austin.rr.com escribió: On Mar 31, 5:49 am, Nathan Harmston iwanttobeabad...@googlemail.com wrote

Generating text from a regular expression

2010-03-31 Thread Nathan Harmston
Hi everyone, I have a slightly complicated/medium sized regular expression and I want to generate all possible words that it can match (to compare performance of regex against an acora based matcher). Using the regular expression as a grammar to generate all words in its language. I was wondering

Large regular expressions

2010-03-15 Thread Nathan Harmston
Hi, So I m trying to use a very large regular expression, basically I have a list of items I want to find in text, its kind of a conjunction of two regular expressions and a big list..not pretty. However everytime I try to run my code I get this exception: OverflowError: regular expression

Re: Calling a shared library using C types

2008-03-25 Thread Nathan Harmston
Hi, Just as a follow up to this...I ve discovered that its an issue with building shared libraries on mac os and it works fine on a Linux box :S. Thanks Nathan On 25/03/2008, Nathan Harmston [EMAIL PROTECTED] wrote: On 25/03/2008, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 24

Re: Calling a shared library using C types

2008-03-24 Thread Nathan Harmston
Hi, I know this is a pretty simple question but I've spent a while on this and can't see whats wrong. I'm trying to access a shared library which I've created called Simulation.so, its created as such (snip from makefile): all: simulation simulation: Simulation.so Simulation.so: Simulation.o

Re: Calling a shared library using C types

2008-03-24 Thread Nathan Harmston
On 25/03/2008, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 24 Mar 2008 19:56:08 -0300, Nathan Harmston [EMAIL PROTECTED] escribió: import ctypes t = ctypes.CDLL('./Simulation.so') this works fine, I have a simple function I ve put in for testing which just returns the integer

Re: Pb with an AttributeError

2007-09-27 Thread Nathan Harmston
Hi, I m not sure what your trying to do, but this is where your problem is: string1 is not a string it is actually a dict because of your eval. When you call string1[param] inside the string.split() it is returning a dictionary and not a string 'param': {'key': 'SP136=', 'value': ['SD:0 ']}

Re: Pb with an AttributeError

2007-09-27 Thread Nathan Harmston
Did I just help someone with their homework? Hope not :S On 27/09/2007, Nathan Harmston [EMAIL PROTECTED] wrote: Hi, I m not sure what your trying to do, but this is where your problem is: string1 is not a string it is actually a dict because of your eval. When you call string1[param

Re: adding a static class to another class

2007-09-17 Thread Nathan Harmston
if there anyway of doing this without using a metaclass..or by using a decorator or notany help would be greatly appreciated. Many Thanks in advance Nathan On 17/09/2007, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Nathan Harmston a écrit : HI, I m trying to start an api in a similar

Re: Free Python Ebook

2007-09-16 Thread Nathan Harmston
Theres a few python ebooks listed on the wiki http://wiki.python.org/moin/PythonBooks Hope this helps, Nathan On 16/09/2007, Marco [EMAIL PROTECTED] wrote: Hi George, Please tell me from which website I will get the free Python Ebook. which one do you mean? I only know

adding a static class to another class

2007-09-16 Thread Nathan Harmston
HI, I m trying to start an api in a similar way to the djangic way of Class.objects.all(). Ie objects is a Manager class. So: class Foo(object): def __init__(self): self.test = NEE class Manager(object): def __init__(self): pass def all(self): return COCONUTS

Adding attributes stored in a list to a class dynamically.

2007-09-02 Thread Nathan Harmston
Hi, Sorry if the subject line of post is wrong, but I think that is what this is called. I want to create objects with class Coconuts(object): def __init__(self, a, b, *args, **kwargs): self.a = a self.b = b def spam( l ) return Coconuts( l.a, l.b, l.attributes ) l in a

Re: Tokenizer for python?

2007-08-21 Thread Nathan Harmston
Hi, From your description I think something like PyParsing might be useful to you. http://pyparsing.wikispaces.com/ If not then I guess I m not understanding your question right. Hope this helps Nathan On 21/08/07, Robert Dailey [EMAIL PROTECTED] wrote: Hi, I am looking for a sort of

Problem using Optional pyparsing

2007-08-16 Thread Nathan Harmston
Hi, I know this isnt the pyparsing list, but it doesnt seem like there is one. I m trying to use pyparsing to parse a file however I cant get the Optional keyword to work. My file generally looks like this: ALIGNMENT 1020 YS2-10a02.q1k chr09 1295 42141045 142297 C1254 95.06

Complexity of methods etc

2007-08-12 Thread Nathan Harmston
Hi, I was wondering if anyone knew of any resources, where I might be able to find information about the complexity of certain python functions or little tips on how to reduce complexity. I mean like the .join(), kind of thing? I want to see if there are any improvements I can add to my coding

Converting between objects

2007-07-19 Thread Nathan Harmston
Hi, I have being thinking about this and was wondering with built in types you can do things like float(1) or str(200) is there way I can define conversion functions like this: say i have a class A and a class B bobj = B() aobj = a(bobj) in a neater way than just defining a set of methods

Creating logged functions using decorators

2007-07-07 Thread Nathan Harmston
Hi, I m thinking about writing some code which logs the input and output of a function/script and stores it in a database using sqlalchemy (although I havent started on this yet). I want to do this via a decorator ( I think this is the best way ). def log(fn): def newfn(*args): print

Re: Programming Idiomatic Code

2007-07-03 Thread Nathan Harmston
HI, Thanks to everyone for your comments ( i never knew with existed, but to quote Borat I like, unfortunately I cant apply for the job as i m in the UK and dont have the experience but hey 10 minutes of programming python beats 12 hours of programming in Clipper-derived unreadable drivel (you

Re: Programming Idiomatic Code

2007-07-03 Thread Nathan Harmston
Using a module global for this kind of data is usually a bad idea (except eventually for run-once throw-away scripts, and even then...) Why is this a bad idea? Don't you have any idea ? -- Not really.problem with access, using unneeded memory... I grasping at straws here... --

Re: Programming Idiomatic Code

2007-07-03 Thread Nathan Harmston
Clipper-derived unreadable drivel I'm intrigued, what language are you working in? Clipper v5 was a pretty impressive development language for 1990 - with code blocks, a flexible pre-processor, garbage collection, exception handling, decent speed and an API to allow easy integration with

Programming Idiomatic Code

2007-07-02 Thread Nathan Harmston
Hi, I m sorry but I m bored at work (and no ones looking so I can write some Python) and following a job advertisement post,I decided to write the code to do its for the one entitled Ninjas or something like that. I was wondering what could be done to my following code to make it more

Accessing variable from a function within a function

2007-06-24 Thread Nathan Harmston
Hi, I m playing around with extended euclids algorithm from Knuth. I m trying to build a function with a function inside it. def exteuclid(m,n): a,a1,b,b1,c,d = 0,1,1,0,m,n def euclid(c,d): q = c /d r = c % d if r == 0: print a,b return d

Re: Python Help!!!

2007-06-13 Thread Nathan Harmston
Hi, you could try this: def parse(self, ifile): id= seq= for line in open(ifile, 'r'): if ''==line[0]: if id!= and len(seq)0: yield id,seq seq = id=line[1:].strip(\n) elif

Type error when using SQLAlchemy and Python

2007-06-11 Thread Nathan Harmston
HI, I posted this to sqlalchemy but didnt get a response, so I was wondering if anyone on python-list could help me. I m currently trying to build an api for a database and I really like the way that Djangos manager ( Class_name.objects ) is set up. This seems very intuitive for me. After

recursion error using setattr and getattr

2007-06-07 Thread Nathan Harmston
Hi, I m trying to implement an object which contains lazy variables. My idea is to alter the getattr and the setattr methods. However I keep on getting a recursion error. My idea is that the lazy variable can be stored in a variety of places, Database, PyTables etc. The lazy variable is a large

Re: alternative to eclipse [ python ide AND cvs ]

2007-05-18 Thread Nathan Harmston
I have had very few problems with eclipse on ubuntu with pydev installed. Is it still running under the gnu jvm, not the sun one? It was crashing on me until I changed them around, detials about changing it around on ubuntu anyway

Using the CSV module

2007-05-09 Thread Nathan Harmston
Hi, I ve been playing with the CSV module for parsing a few files. A row in a file looks like this: some_id\t|\tsome_data\t|t\some_more_data\t|\tlast_data\t\n so the lineterminator is \t\n and the delimiter is \t|\t, however when I subclass Dialect and try to set delimiter is \t|\t it says

Re: Using the CSV module

2007-05-09 Thread Nathan Harmston
not as useful as it might be - due to the restrictions you describe. Why not write a simple parser class ? On Mi, 9.05.2007, 10:40, Nathan Harmston wrote: Hi, I ve been playing with the CSV module for parsing a few files. A row in a file looks like this: some_id\t|\tsome_data\t|t

Re: Restricting the alphabet of a string

2007-05-01 Thread Nathan Harmston
Thanks, I might just move my trinary string (if I get that far) to be encoded as 0, 1, 2, thanks for your help. On 30 Apr 2007 11:14:10 -0700, John Machin [EMAIL PROTECTED] wrote: On Apr 30, 9:53 pm, Nathan Harmston [EMAIL PROTECTED] wrote: Hi, I ve being thinking about playing around

Restricting the alphabet of a string

2007-04-30 Thread Nathan Harmston
Hi, I ve being thinking about playing around with bit strings but use in some encoding problems I m considering and was trying to decide how to implement a bit string class. Is there a library out there for doing basic things with bit strings already is my first question? I know that I can

Re: Requirements For A Visualization Software System For 2010

2007-04-05 Thread Nathan Harmston
You could look at sage.its all python! http://sage.scipy.org/sage/ I wish Xah Lee would stop trolling.oh well Cheers Nathan -- http://mail.python.org/mailman/listinfo/python-list

Metaclass uses?

2006-12-15 Thread Nathan Harmston
Hi, Recently I posted a question about the factory pattern in python. I ve implemented this following one of the ideas posted. After some reading I ve seem a lot of Aspect Oriented Programming mentioned but I m not really sure what it is. Can anyone help me understand how metaclasses can improve

Use of factory pattern in Python?

2006-12-07 Thread Nathan Harmston
Hi, Im trying to find the best way to do a certain task and my so far I have found that using something similar to factory pattern might be the best bet. I m parsing a file to be stored as a graph (using NetworkX). Each row in the file corresponds to a node in the graph. However rows have

Graph Data Structures

2006-11-25 Thread Nathan Harmston
Hi All, Currently I am working on a generic graph library so I can do various graph based analysis for various projects I have ideas for. Currently I am implementing Graph as a wrapper around a dictionary. Currently my implementation works like this: t = Graph() n1 = Node(Node1)

Importing module of data dicts and constants

2006-11-25 Thread Nathan Harmston
Hi All, I ve got a single module which I m using to contain a lot of dictionaries, constants, general information, which are used by various other modules. However I can't seem to access them: in data.py _SEQTYPE_DNA = 0 _SEQTYPE_RNA = 1 _SEQTYPE_PROT = 2 _seqType = { DNA:_SEQTYPE_DNA,

Re: Graph Data Structures

2006-11-25 Thread Nathan Harmston
https://networkx.lanl.gov/ This was working for me earlier, I managed to get everything from there earlier. It seems a very good package. It seems theres more out there than what I had thought, which unfortunately makes it harder for me to decide what to use (pynetwork and bgl look useful

Re: Graph Data Structures

2006-11-25 Thread Nathan Harmston
Hi, The idea is that I m going to use it to build graphs for sequence alignment (at the moment), I read a discussion on the corebio (reimplementation of biopython) group about using intervals to represent sequence slices. The idea being that, my graph may contain millions of alignments and

Re: Graph Data Structures

2006-11-25 Thread Nathan Harmston
Hi, It seems that by just going through the problem writing out a better explanation for the reply I have figured out a solution and the problem isnt as difficult as I thought it would be. What is a wontok? Thanks Nathan PS -- the start of my reply: class Interval(object): _id = gene1

Parsing XML using SAX

2006-10-23 Thread Nathan Harmston
Hi, Currently I m writing an XML parser that processes an xml file using sax, and I have it working, however I want to make the code of my parser less cluttered and more readable by other people (including myself). However it is quite messy at the moment. The main reason is that Python doesnt have