Click here to Skip to main content
15,888,069 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
QuestionPython 2.7: Best way for processes to log to single log file Pin
ninjaef5-Jul-18 21:39
ninjaef5-Jul-18 21:39 
AnswerRe: Python 2.7: Best way for processes to log to single log file Pin
Eddy Vluggen6-Jul-18 10:26
professionalEddy Vluggen6-Jul-18 10:26 
QuestionMemento pattern and releasing resources Pin
Abivarius3-Jul-18 9:47
Abivarius3-Jul-18 9:47 
GeneralRe: Memento pattern and releasing resources Pin
Richard MacCutchan4-Jul-18 1:07
mveRichard MacCutchan4-Jul-18 1:07 
AnswerRe: Memento pattern and releasing resources Pin
Gerry Schmitz4-Jul-18 8:03
mveGerry Schmitz4-Jul-18 8:03 
AnswerRe: Memento pattern and releasing resources Pin
Eddy Vluggen4-Jul-18 8:57
professionalEddy Vluggen4-Jul-18 8:57 
AnswerRe: Memento pattern and releasing resources Pin
Nathan Minier10-Jul-18 2:45
professionalNathan Minier10-Jul-18 2:45 
QuestionPython: how doI "select / switch in" a module/class to use at runtime Pin
ninjaef3-Jul-18 0:09
ninjaef3-Jul-18 0:09 
So I have this design in Python2.7. Basically it is an EPG app that can read EPG programme events from 1 or more XMLTV sources. I would like to be able to use a generic code base and switch-in the XMLTV parsing code. For example, in 'C' I can use:

epg.c:

#ifdef _XMLTV_rytec
#include ./xmltv/rytec.h
#endif
#ifdef _XMLTTV_bbc
#include ./xmltv/bbc.h
#endif
...
...
// Make call to external xmltv function declared in .h file (above)
// and defined in an external module compiled in using a Makefile
load_xmltv()
...
...
So what i can do here is define the preprocessor macros (_XMLTV_*) at make time, use the compiler directives to pull in the appropriate definitions for the desired xmltv parser, and switch in the corresponding source/object module (rytec.c/rytec.o and bbc.c/bbc.o) using the Makefile. Here for example, if XMLTV is not defined outside the Makefile at build (i.e. command line option) then the default rytec module is built in.

Makefile:
..
XMLTV_OBJS = ./src/xmltv/rytec.o
EPG_OBJS = epg.o $(XMLTV_OBJS)
..
obj/%.o:%.c
    gcc -c -o $@ $(CPPFLAGS) $(CFLAGS) $<

epg: $(EPG_OBJS) \
     gcc -o $@ $(CFLAGS) $(EPG_OBJS) $(LDFLAGS) $(LDLIBS)

..
How can I achieve the same thing in Python please?

modified 3-Jul-18 6:27am.

AnswerRe: Python: how doI "select / switch in" a module/class to use at runtime Pin
Richard MacCutchan3-Jul-18 2:13
mveRichard MacCutchan3-Jul-18 2:13 
GeneralRe: Python: how doI "select / switch in" a module/class to use at runtime Pin
ninjaef3-Jul-18 3:24
ninjaef3-Jul-18 3:24 
GeneralRe: Python: how doI "select / switch in" a module/class to use at runtime Pin
Richard MacCutchan3-Jul-18 4:26
mveRichard MacCutchan3-Jul-18 4:26 
GeneralRe: Python: how doI "select / switch in" a module/class to use at runtime Pin
ninjaef3-Jul-18 7:14
ninjaef3-Jul-18 7:14 
GeneralRe: Python: how doI "select / switch in" a module/class to use at runtime Pin
Richard MacCutchan3-Jul-18 8:25
mveRichard MacCutchan3-Jul-18 8:25 
QuestionMy Entity Framework Design Pin
Kevin Marois2-Jul-18 7:14
professionalKevin Marois2-Jul-18 7:14 
AnswerRe: My Entity Framework Design Pin
Richard Deeming2-Jul-18 8:17
mveRichard Deeming2-Jul-18 8:17 
GeneralRe: My Entity Framework Design Pin
Kevin Marois2-Jul-18 8:30
professionalKevin Marois2-Jul-18 8:30 
GeneralRe: My Entity Framework Design Pin
Richard Deeming2-Jul-18 9:00
mveRichard Deeming2-Jul-18 9:00 
GeneralRe: My Entity Framework Design Pin
Kevin Marois2-Jul-18 10:15
professionalKevin Marois2-Jul-18 10:15 
GeneralRe: My Entity Framework Design Pin
Kevin Marois4-Jul-18 17:33
professionalKevin Marois4-Jul-18 17:33 
GeneralRe: My Entity Framework Design Pin
Richard Deeming5-Jul-18 1:27
mveRichard Deeming5-Jul-18 1:27 
GeneralRe: My Entity Framework Design Pin
Kevin Marois9-Jul-18 6:17
professionalKevin Marois9-Jul-18 6:17 
GeneralRe: My Entity Framework Design Pin
Kevin Marois9-Jul-18 6:19
professionalKevin Marois9-Jul-18 6:19 
GeneralRe: My Entity Framework Design Pin
Richard Deeming9-Jul-18 8:20
mveRichard Deeming9-Jul-18 8:20 
GeneralRe: My Entity Framework Design Pin
Kevin Marois16-Jul-18 6:28
professionalKevin Marois16-Jul-18 6:28 
GeneralRe: My Entity Framework Design Pin
Richard Deeming16-Jul-18 8:16
mveRichard Deeming16-Jul-18 8:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.