Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Use of factory pattern in Python?

Reply
Thread Tools

Use of factory pattern in Python?

 
 
Nathan Harmston
Guest
Posts: n/a
 
      12-07-2006
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
different types and different numbers of attributes. ( and their
corresponding nodes in the future will have methods )
eg

chr1 SGD gene 5 8 id=1 name=3 dbref=6
chr1 SGD intron 5 6 id=5 notes="spam"
chr1 SGD exon 7 8 id=5

so I was thinking of having a factory class to return the individual
objects for each row......ie

class Factory():
# if passed a gene return a gene object
# if passed an intron return an intron object
# if passed an exom return an exon object

Is this a good way of doing this, or is there a better way to do this
in Python, this is probably the way I d do it in Java.

Many Thanks

Nathan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Regex to breakdown a pattern and use the pattern to breakdown a string ChrisC Perl Misc 4 06-25-2010 05:46 PM
Abstract factory and Factory pattern C# ASP .Net 4 07-31-2008 03:22 PM
Re: Use of factory pattern in Python? Gabriel Genellina Python 1 12-07-2006 10:30 AM
documents related to factory design pattern and Abstract foctory pattern. sunny C++ 1 12-07-2006 04:26 AM
Abstract Factory or Factory Method pattern question.... Medi Montaseri C++ 17 09-03-2003 06:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57