Re: [Tutor] Python 2.4 or Python 2.5?
On 4/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Im confused When i had python 2.4 all my scripts work correctly should i > reinstall python 2.4? Or should I keep 2.5? Where can I find information > on coding for python 2.5? Context? -- - Rikard - http://bos.hack.org/cv/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 2.4 or Python 2.5?
<[EMAIL PROTECTED]> wrote > Im confused When i had python 2.4 all my scripts work correctly > should i > reinstall python 2.4? Or should I keep 2.5? Where can I find > information > on coding for python 2.5? Coding for 2.4 is not significantly different to coding for 2.4. Your 2.4 scripts should all still work provided you have set up the same environment. The most likely change is that you had some configuration settings for 2.4 that have changed or not been set in 2.5. (for example are your PYTHONPATH and PATH settings still correct?) However without any information about what the problem is it is hard to make a recommendation. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 2.4 or Python 2.5?
[EMAIL PROTECTED] wrote: > Im confused When i had python 2.4 all my scripts work correctly should i > reinstall python 2.4? Or should I keep 2.5? Where can I find information > on coding for python 2.5? Each .x release of Python comes with a "What's New" document that details the changes since the previous release. For Python 2.5 you can read it here: http://docs.python.org/whatsnew/whatsnew25.html There are usually very few changes that are incompatible with old code. The biggest roadblock to updating is availability of third-party extensions. The API for C extensions is *not* compatible between dot releases so extension modules usually have to be re-released for a new Python release. Python 2.5 has been out for a while now so most extension modules have been updated. But if there is something you depend on you should check its availability before upgrading. You can also have two versions of Python on the same machine without any trouble. You will have to re-install any add-on modules and packages you use. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to program to python the right way?
Adam Pridgen wrote: > Hello everyone, > > I have pretty much finished hacking on my Thesis and I have come to > the conclusion, > I really do not know how to use Python to it "full" extent. Some of > the things I have really messed up in my implementation are > serialization (specifically sub-classes), classes, and instantiating > them the "correct" way, and there are some things I have not tried, > but I would like to like contained execution and thread management. > Are there any books (with examples) out there that show some of these > techniques and explain the gotchas that come with the package. Thanks > in advance. I think the Python Cookbook is an excellent book for learning idiomatic Python. Your question is pretty vague, can you ask a more specific question about an area where you are having trouble? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Exceptions while dealing with MySQL
Hello list, I am developing a network management system that relies heavily on a MySQL database. The logic of the program is unavoidably coupled with query results I get from various tables. This is OK as long the mysql server has 100% uptime, but it hardly does. Say that I have to make at least 20 different kinds of queries here and there in different parts of my code(all together more than a thousand queries). What is the best approach to make error checking possible, with the least amount of code duplication? Right now my code is probably ill-structured in terms of the database backend. A MySQLdb.connection object is juggled around as an arguement to my own program's objects, so that they can retrieve the info they need from the database tables when needed. After a whole program iteration has finished, the connection object is destroyed and a new one is cerated for the next iteration. This means that a 5-minute downtime of the SQL server will cause my program to crash. It is really too much trouble checking for exceptions every time I make a simple query. What approach should I try take? Thanks a lot. A better backend design will make my application much more robust. Thanos ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Exceptions while dealing with MySQL
Thanos Panousis wrote: > Hello list, > > I am developing a network management system that relies heavily on a > MySQL database. The logic of the program is unavoidably coupled with > query results I get from various tables. > > This is OK as long the mysql server has 100% uptime, but it hardly > does. Say that I have to make at least 20 different kinds of queries > here and there in different parts of my code(all together more than a > thousand queries). What is the best approach to make error checking > possible, with the least amount of code duplication? > > Right now my code is probably ill-structured in terms of the database > backend. A MySQLdb.connection object is juggled around as an arguement > to my own program's objects, so that they can retrieve the info they > need from the database tables when needed. After a whole program > iteration has finished, the connection object is destroyed and a new > one is cerated for the next iteration. > > This means that a 5-minute downtime of the SQL server will cause my > program to crash. It is really too much trouble checking for > exceptions every time I make a simple query. What approach should I > try take? What do you want to have happen when the server is down? Should the program wait and retry? One possibility would be to wrap the database connection in a class which checks for exceptions and retries. If you are only doing queries (no updates) this might work OK. Or perhaps the wrapper could test for availability of the database before making a request. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Exceptions while dealing with MySQL
Well, the best thing to do is to just keep on asking until the server is up. Sending emails and other logging can be done inside whatever wrapper function. So if wrappers is a good way to go, how should I pursue this? Just making my own wrapper functions or subclassing from MySQLdb? Is it really possible that this is not a very common problem to which others have already provided some kind of solution? Or is it just rather easy to resolve so everyone just re-does it? On 4/21/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Thanos Panousis wrote: > > Hello list, > > > > I am developing a network management system that relies heavily on a > > MySQL database. The logic of the program is unavoidably coupled with > > query results I get from various tables. > > > > This is OK as long the mysql server has 100% uptime, but it hardly > > does. Say that I have to make at least 20 different kinds of queries > > here and there in different parts of my code(all together more than a > > thousand queries). What is the best approach to make error checking > > possible, with the least amount of code duplication? > > > > Right now my code is probably ill-structured in terms of the database > > backend. A MySQLdb.connection object is juggled around as an arguement > > to my own program's objects, so that they can retrieve the info they > > need from the database tables when needed. After a whole program > > iteration has finished, the connection object is destroyed and a new > > one is cerated for the next iteration. > > > > This means that a 5-minute downtime of the SQL server will cause my > > program to crash. It is really too much trouble checking for > > exceptions every time I make a simple query. What approach should I > > try take? > > What do you want to have happen when the server is down? Should the > program wait and retry? > > One possibility would be to wrap the database connection in a class > which checks for exceptions and retries. If you are only doing queries > (no updates) this might work OK. Or perhaps the wrapper could test for > availability of the database before making a request. > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] No speedup in
Hi, I am using Python Thread library for my parallel processing course project. I am doing matrix convolution on a multi-processor machine. I just found out that no speed-up is obtained with threading. It is probably because of something called GIL in Python. How can I get around that GIL and get speed-up? Thanks in advance. Daniel __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] No speedup in
You cannot get around the GIL in python. Maybe you could try passing chunks of your matrix that are copies of the submatrises you want to multiply using threads. This way it will be different objects, thus no GILI could be awfully wrong though, I am a beginner in threads as well. On 4/21/07, FAN Ying Wai <[EMAIL PROTECTED]> wrote: > Hi, > I am using Python Thread library for my parallel > processing course > project. I am doing matrix convolution on a > multi-processor machine. I > just found out that no speed-up is obtained with > threading. It is > probably because of something called GIL in Python. > How can I get around > that GIL and get speed-up? > Thanks in advance. > Daniel > > > > __ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to program to python the right way?
I guess the problem I am trying to quell really revolves around style and the proper way to do application programming with Python. So one of the things I found out the hard way about is classes. I started of programming my Python Classes using the old style, because I did not understand how the process works when a class is instantiated. class Foo: string = "" int = 0 On 4/21/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Adam Pridgen wrote: > > Hello everyone, > > > > I have pretty much finished hacking on my Thesis and I have come to > > the conclusion, > > I really do not know how to use Python to it "full" extent. Some of > > the things I have really messed up in my implementation are > > serialization (specifically sub-classes), classes, and instantiating > > them the "correct" way, and there are some things I have not tried, > > but I would like to like contained execution and thread management. > > Are there any books (with examples) out there that show some of these > > techniques and explain the gotchas that come with the package. Thanks > > in advance. > > I think the Python Cookbook is an excellent book for learning idiomatic > Python. > > Your question is pretty vague, can you ask a more specific question > about an area where you are having trouble? > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to program to python the right way?
Disregard this email, gmail mis-fired. On 4/21/07, Adam Pridgen <[EMAIL PROTECTED]> wrote: > I guess the problem I am trying to quell really revolves around style > and the proper way to do application programming with Python. So one > of the things I found out the hard way about is classes. > > I started of programming my Python Classes using the old style, > because I did not understand how the process works when a class is > instantiated. > > > class Foo: > string = "" > int = 0 > > > On 4/21/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > Adam Pridgen wrote: > > > Hello everyone, > > > > > > I have pretty much finished hacking on my Thesis and I have come to > > > the conclusion, > > > I really do not know how to use Python to it "full" extent. Some of > > > the things I have really messed up in my implementation are > > > serialization (specifically sub-classes), classes, and instantiating > > > them the "correct" way, and there are some things I have not tried, > > > but I would like to like contained execution and thread management. > > > Are there any books (with examples) out there that show some of these > > > techniques and explain the gotchas that come with the package. Thanks > > > in advance. > > > > I think the Python Cookbook is an excellent book for learning idiomatic > > Python. > > > > Your question is pretty vague, can you ask a more specific question > > about an area where you are having trouble? > > > > Kent > > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] No speedup in
Hello Ying Wai! If you are using NumPy you should ask your question on the NumPy mailing list: http://projects.scipy.org/mailman/listinfo/numpy-discussion There is some project to simplify parallel computing with Python called IPython1, which is part of the IPython project: http://ipython.scipy.org/moin/IPython1 Regards, Eike. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] No speedup in
* Thanos Panousis <[EMAIL PROTECTED]> [070421 19:56]: > You cannot get around the GIL in python. > > Maybe you could try passing chunks of your matrix that are copies of > the submatrises you want to multiply using threads. This way it will > be different objects, thus no GILI could be awfully wrong though, > I am a beginner in threads as well. That won't help either. The G in GIL stands for global. There are basically two way around this: a) use multiple processes (aka fork), and communicate the results back to the main program. b) use a C-language level extension to do the heavy lifting, and make this extension give up the GIL, while doing the heavy lifting. Andreas > > On 4/21/07, FAN Ying Wai <[EMAIL PROTECTED]> wrote: > > Hi, > > I am using Python Thread library for my parallel > > processing course > > project. I am doing matrix convolution on a > > multi-processor machine. I > > just found out that no speed-up is obtained with > > threading. It is > > probably because of something called GIL in Python. > > How can I get around > > that GIL and get speed-up? > > Thanks in advance. > > Daniel > > > > > > > > __ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam protection around > > http://mail.yahoo.com > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] No speedup in
Eike Welk wrote: > There is some project to simplify parallel computing with Python > called IPython1, which is part of the IPython project: > http://ipython.scipy.org/moin/IPython1 See also Parallel Python (and others on the links page): http://www.parallelpython.com/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Exceptions while dealing with MySQL
"Thanos Panousis" <[EMAIL PROTECTED]> wrote > I am developing a network management system that relies heavily on a > MySQL database. The logic of the program is unavoidably coupled with > query results I get from various tables. That's pretty unusual, it normally indicates a non OO design. > This is OK as long the mysql server has 100% uptime, but it hardly > does. Welcome to the real world... :-) > thousand queries). What is the best approach to make error checking > possible, with the least amount of code duplication? Either write a generic wrapper around the execution of a query, possibly by building a query class or just wrap all the queries in try/except clauses > program to crash. It is really too much trouble checking for > exceptions every time I make a simple query. Welcome to the real world again. In industrial strength code every file access, every database query, every memory allocation (fortunately not often an issue in Python!) and every network connection has to be protected. Before try/except style programming that meant that around 75% of all code was error handling. With try/except we can keep that down to 50%, sometimes less. But if reliability matters you gotta catch the errors. > What approach should I try take? - genericize the queries so you catch errors in one place. - catch the errors - do both if you have any doubts or alternatively, pray HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor