Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'subject:Python': 0.05; '__name__': 0.07; 'problem?': 0.07; 'subject:help': 0.07; 'python': 0.09; 'cmd': 0.09; 'skip:# 60': 0.09; 'sql,': 0.09; 'subject:2.7': 0.09; '\xe2\x80\xa6)': 0.09; 'subject:Help': 0.10; 'def': 0.10; 'dec': 0.15; "'__main__':": 0.16; '........': 0.16; 'cyclic': 0.16; 'here..': 0.16; 'lower- case': 0.16; 'socketserver': 0.16; 'subject:] [': 0.16; "where's": 0.16; 'wrote:': 0.17; 'variables': 0.17; 'subject:] ': 0.19; 'module': 0.19; 'skip:p 30': 0.20; 'written': 0.20; 'import': 0.21; 'defined': 0.22; 'pass': 0.25; 'least': 0.25; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'logging': 0.27; 'right.': 0.27; 'question': 0.27; 'see,': 0.27; "doesn't": 0.28; 'separated': 0.29; 'skip:( 50': 0.29; 'way?': 0.29; "we're": 0.30; 'attach': 0.30; 'bus': 0.30; 'file': 0.32; 'could': 0.32; 'getting': 0.33; 'builds': 0.33; 'skip:h 40': 0.33; 'handle': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'tutorial': 0.33; 'skip:d 20': 0.34; 'returning': 0.35; 'so,': 0.35; 'something': 0.35; 'really': 0.36; 'but': 0.36; 'modules': 0.36; 'should': 0.36; 'execute': 0.37; 'level': 0.37; 'two': 0.37; 'data': 0.37; 'easier': 0.38; 'things': 0.38; 'received:10': 0.38; 'sure': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'your': 0.60; 'content-disposition:inline': 0.60; 'skip:u 10': 0.60; 'lower': 0.61; 'first': 0.61; 'provide': 0.62; 'here': 0.65; 'results': 0.65; 'life': 0.66; 'informations': 0.75; 'introduce': 0.80; 'here!': 0.84; 'received:10.94': 0.84; 'transmits': 0.84; 'understand,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uni-mainz.de; i=@uni-mainz.de; q=dns/txt; s=ironport; t=1356326348; x=1387862348; h=date:from:to:subject:message-id:references:mime-version: content-transfer-encoding:in-reply-to; bh=GnjjuFv+W5zjjDzXAEzT5soHunLNj6WqEKcbYnrl6o0=; b=eOZwczPP1JS6YJ92CVX2vXrNZDtpsF1TM8xt/3kWm1tpsrUP1cnaRy6I UApWSa8395DLjmx/RY3B19/2tAfCTsS4MX/kTiQO90mqUAVd8u/rqFuM8 9i72F5fRbrHbXVswHPvSf8xtyCTlwminTP3LDM7T/02LmYfHSYJYL3luG A=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmwGAJDk11AKXgZQ/2dsb2JhbABEg0iCcrdNc4IeAQEEASMPAUsLCxgCAiYCAhQpChYTGYdoAwkKoySIGg2JVYEiiktqgRqCFjJhA5YLAYEcjyyCdYIh Date: Mon, 24 Dec 2012 06:18:55 +0100 From: Thomas Bach To: Subject: Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces) References: <37264cd5-8acd-416b-a808-50216f9fbfa0@googlegroups.com> <3f14f739-e660-4883-a940-c77a6092cb79@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3f14f739-e660-4883-a940-c77a6092cb79@googlegroups.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [88.68.6.180] X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 86 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356326349 news.xs4all.nl 6872 [2001:888:2000:d::a6]:54537 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35440 Hi there, On Sun, Dec 23, 2012 at 01:42:14PM -0800, prilisauer@googlemail.com wrote: > […] In the lower section you see, that the modules should execute > sqls. In case It could occur that two queries occur at the same > time. PS: IT IS NOT A QUESTION ABOUT SQL, etc. I do not understand, > how I could handle the part which is marked with Problemsection1 and > Problemsection2 I actually do not understand the problem you are stating. But, did you have a look at SQLAlchemy? If you are coping a lot with SQL it really makes your life much easier and they also provide the necessary mechanisms for threading. > import HomeLog # LogHandler Modules should be written all lower-case separated by underscores. > # Attach Loghandler > Loghandler = HomeLog.Logging() Have a look at the logging module and tutorial. I don't know what is in HomeLog.Logging, but this doesn't seem right. Variables defined at module level should be written all upper-case. > # Attach SocketServer > HomeSocketServer.HomeSocketServerStart() > > # Attach Scheduler > HomeSched = HomeScheduler.HomeScheduler() > […] > # This is a "Sample" that builds 2byte Cmd and transmits it on bus > PowerOnLamp1=Dali.send(0,0,1,80) You do all this on the module level? These things should go into functions with proper names or at least into a if __name__ == '__main__': pass > ############################################################### > HomeDaliServer.py > ........ > def send (self,DaliAdress,RequestType,Request,RequestValue): > # Problemsection1: > # Here it's getting Interesting > # We're at the HomeDaliServer, and now I want to use QuerySqlite() > in the file HomeDatastore.py So, where's the problem? # make sure not to introduce cyclic dependence here! import home_data_store def send (connection,DaliAdress,RequestType,Request,RequestValue): results = home_data_store.query_sqlite(connection, …) return results > ############################################################### > HomeScheduler.py > # Problemsection2: > # If new workerthread is started, Informations must be queried using > QuerySlite() and also update data So, here's a first sketch (untested): def query(): data = do_something() return data def update(data): do_something_with(data) > HomeDatastore.py > def QuerySqlite(): > #doing something here.. > # returning Data Have you read the Python tutorial by the way? Regards, Thomas.