Re: Need help with simple OOP Python question
Hi, You are getting same object because you are overriding the dictionary update. Its printing the proper value with the last updated instance of B. If you want to see the two different instances of class B give print self.sub inside the sub_add method in class A. CHEERS CNA 9986229891 On Mon, Sep 5, 2011 at 12:17 PM, Kristofer Tengström krille...@gmail.comwrote: Hi, I'm having trouble creating objects that in turn can have custom objects as variables. The code looks like this: - class A: sub = dict() def sub_add(self, cls): obj = cls() self.sub[obj.id] = obj class B(A): id = 'inst' base = A() base.sub_add(B) base.sub['inst'].sub_add(B) print # prints a blank line print base.sub['inst'] print base.sub['inst'].sub['inst'] -- Now, what I get from this is the following: __main__.B instance at 0x01FC20A8 __main__.B instance at 0x01FC20A8 Why is this? What I want is for them to be two separate objects, but it seems like they are the same one. I've tried very hard to get this to work, but as I've been unsuccessful I would really appreciate some comments on this. I'm sure it's something really easy that I just haven't thought of. Python version is 2.6.5 (I'm using Panda3D to create a 2½D game). -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Trapping MySQLdb warnings
Hi Tim, Use this method it will sort tour problem. def do_query(insert_query): import warnings with warnings.catch_warnings(): warnings.simplefilter('error', MySQLdb.Warning) try: cursor.execute(insert_query) conn.commit() return 'Success' except MySQLdb.Error, error: logging.error(Error in insertion %s query is , error) return 'Failure' finally: conn.close() try: xyz = do_query(insert_query) except MySQLdb.Warning, warning: logging.warning(warning) you need to use the with statement and then you need to catch the warnings hope it helps CHEERS CNA 9986229891 On Thu, Jun 16, 2011 at 9:25 PM, Tim Johnson t...@johnsons-web.com wrote: * Tim Johnson t...@johnsons-web.com [110615 18:53]: * geremy condra debat...@gmail.com [110615 18:03]: On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson t...@johnsons-web.com wrote: Using Python 2.6.5 on linux. When using MySQLdb I am getting warnings printed to stdout, but I would like to trap, display and log those warnings. . Have you tried http://docs.python.org/library/warnings.html#temporarily-suppressing-warnings Hi Geremy: I just looked at the docs there. This is a new module (to me), and I am unsure of the implementation or whether this is what I should use. I tried the following : try : self.__rdb.execute(S) except warnings.catch_warnings: std.mrk('',0,mysql.py:196) ## DEBUG call ## and it does not look like my code modification ## is catching the warning. Well, I am so far, absolutely baffled. I've looked at the docs for the `warning' module. No real examples that I can see. and why has the _mysql_exceptions.Warning exception no longer working? grrr.. Be good to hear some other experiences here. thanks -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
job for python lead
Hi , There is a opening for the position of python lead in a company called TEK systems global services for bangalore location.Interested candidates can send in their profiles to snara...@teksystems.com. CHEERS CNA 9986229891 -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is the best book to learn python
search for byte of python in google its good book for beginners . . CHEERS CNA 9986229891 On Mon, Jan 24, 2011 at 10:39 PM, santosh hs santosh.tron...@gmail.comwrote: Hi All, i am beginner to python please tell me which is the best available reference for beginner to start from novice -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Links and pointers to basics of soap and suds
Hi All, I am very new to the soap and its python client suds.Can anyone tell me how the actual will happens i nthe webservices including suds and soap API. Thanks in advance CHEERS CNA 9986229891 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python documentation too difficult for beginners
If you are really beginner in python you can look into the dive into python,search as in google as the same its quite helpful for beginners.Also you can go for the byte of python. CHEERS CNA 9986229891 On Tue, Nov 2, 2010 at 4:42 PM, jk sanjo...@yahoo.com wrote: Hi, I've been coding in PHP and Java for years, and their documentation is concise, well structured and easy to scan. Others have mentioned this apparently for years (see: http://stackoverflow.com/questions/4046166/easy-to-navigate-online-python-reference-manual/4070851 and http://www.russellbeattie.com/blog/python-library-docs-still-suck and http://xahlee.org/perl-python/xlali_skami_cukta.html). Compare for instance the differences in ease of use, and speed of use, of these: http://docs.python.org/library/functions.html#open http://uk.php.net/manual/en/function.fopen.php The former is difficult to find (try searching for 'open' in the search box and see what you get). It is simply a collection of paragraphs without strong enough contrast to differentiate the different parts - parameters, parameter values, return types, exceptions and related functions. It is slow to read and doesn't allow easy visual scanning. The latter has clearly delineated, standardised content areas for each of these without excessive text. It uses tables which are easy to scan for possible opening modes and allows users to contribute their own examples. Sadly, the use of restructured text by python doesn't allow a new document generator to be written - all existing documentation would need updating with docblocks or something similar. Has anyone else struggled while trying to learn the language? The whole documentation system seems geared towards people who already know what they're looking for and is close to useless for beginners. I'm not the only one who finds google an easier way to find documentation about python. Is there much chance that the Python maintainers will change their documentation system to make it more like Java or PHP? How would I go about trying to make that happen? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
MS Word Document to html conversion
Hi, I am working on application where it requires uploaded document from has to be converted to the html pages.Am searching for the suitable python package i dint found any thing apart from word2html.py.But the word2html.py is not available for download anywhere can any one suggest me how to solve this problem. Thanks in advance Srinivas HN -- http://mail.python.org/mailman/listinfo/python-list
Problem With the PyRtf Footers
Hi all, Am using the pyrtf for the generating the rtf documents from the html.Am able to generate the documents the problem is with the footer.Its coming only for the first page for the rest of the pages it is coming empty.Am using the section.FirstFooter for the first page footer and section.Footer for the subsequent pages.I am not able to figure out what is exactly the problem.If any body knows please help me. Thanks in Advance ! Srinivas HN ph-9986229891 -- http://mail.python.org/mailman/listinfo/python-list