Re: How complex is complex?

2009-03-19 Thread Kottiyath
On Mar 19, 9:33 pm, Kottiyath wrote: > On Mar 19, 8:42 pm, Paul McGuire wrote: > > > > > On Mar 19, 4:39 am, Kottiyath wrote: > > > > I understand that my question was foolish, even for a newbie. > > > I will not ask any more such questions in the futu

Re: How complex is complex?

2009-03-19 Thread Kottiyath
On Mar 19, 8:42 pm, Paul McGuire wrote: > On Mar 19, 4:39 am, Kottiyath wrote: > > > > > I understand that my question was foolish, even for a newbie. > > I will not ask any more such questions in the future. > > Gaaah! Your question was just fine, a good question

Re: How complex is complex?

2009-03-19 Thread Kottiyath
On Mar 19, 11:29 am, Daniel Fetchinson wrote: > > When we say readability counts over complexity, how do we define what > > level of complexity is ok? > > For example: > > Say I have dict a = {'a': 2, 'c': 4, 'b': 3} > > I want to increment the values by 1 for all keys in the dictionary. > > So, s

How complex is complex?

2009-03-18 Thread Kottiyath
When we say readability counts over complexity, how do we define what level of complexity is ok? For example: Say I have dict a = {'a': 2, 'c': 4, 'b': 3} I want to increment the values by 1 for all keys in the dictionary. So, should we do: >>> for key in a: ... a[key] = a[key] + 1 or is it Ok to

Re: Parameter sublists [was: An ordering question]

2009-03-13 Thread Kottiyath
On Mar 14, 5:39 am, Chris Rebert wrote: > On Fri, Mar 13, 2009 at 5:30 PM, Peter Pearson > wrote: > > On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic > > wrote: > > [snip] > >> a.sort(key=lambda (x, y): b[y - 1], reverse=True) > > > Huh?  I had no idea one could do this: > > def g( ( (

An ordering question

2009-03-13 Thread Kottiyath
Hi, I have 2 lists a = [(4, 1), (7, 3), (3, 2), (2, 4)] b = [2, 4, 1, 3] Now, I want to order _a_ (a[1]) based on _b_. i.e. the second element in tuple should be the same as b. i.e. Output would be [(3, 2), (2, 4), (4, 1), (7, 3)] I did the same as follows: >>> l = len(a) * [N

Re: Porting to new Python version

2009-02-19 Thread Kottiyath
On Feb 19, 5:50 pm, Gabor Urban wrote: > Hi, > > I have a tough issue: we are using a Python application written quite > a time ago for version 2.4. The code is mature, and there are no bugs. >  My bosses came up with the idea to port it to the latest release... I > am not really convinced that it

Re: Is there something easier than ORM?

2009-02-17 Thread Kottiyath
一首诗 wrote: > Hi all, > > Recently I am studying some python ORM libraries, such as sqlalchemy. > > These are very powerful technologies to handle database. But I think > my project are not complicated to enough to benefit from a complete > ORM system. > > What I really want, is some easy ways to

Spam

2009-02-12 Thread Kottiyath
Hi, There seems to be lot of spam coming in this newsgroup. Is it possible to have some mechanism similar to say - slashdot - wherein mails can be moderated by any of the usual users? This is required only for people who is posting for the first time (or people who has been rated spam befo

Re: Import without executing module

2009-02-01 Thread Kottiyath
On Feb 2, 12:19 pm, Stephen Hansen wrote: > On Sun, Feb 1, 2009 at 11:05 PM, Ray wrote: > > Basically, someone has created a python script and I would like to > > make use of his functions.  I would prefer to not modify his file so > > what I would like to do is just write my script and import pa

Re: Swapping values of two variables

2009-01-29 Thread Kottiyath
On Jan 30, 8:31 am, Steven D'Aprano wrote: > On Thu, 29 Jan 2009 17:50:04 -0800, tony.clarke5 wrote: > > On Jan 30, 12:29 am, Eric Kang wrote: > >> In python, I set: > > >> x=1 > >> y=3 > > >> z = x > >> x = y > >> y = z > > >> This gave me 3 1, which are the values of x and y swapped. The > >> f

Re: pyAA for Python2.5

2009-01-28 Thread Kottiyath
On Jan 29, 1:51 am, Rob Williscroft wrote: > Kottiyath wrote in news:6a594643-f6a2-4d8d-aab3-27eb16cb2fb8 > @b38g2000prf.googlegroups.com in comp.lang.python: > > > > > I have mingw32-gcc in my path. If I try that too -it fails. > > > C:\Documents and Settings\Gues

Re: pyAA for Python2.5

2009-01-27 Thread Kottiyath
On Jan 27, 11:56 pm, Mike Driscoll wrote: > On Jan 27, 12:12 pm, Kottiyath wrote: > > > > > Hi, > >    I would like to obtain pyAA for Python 2.5. I went through their > > web site, but they provide the windows exe only for Python2.4. I tried > > compiling

pyAA for Python2.5

2009-01-27 Thread Kottiyath
Hi, I would like to obtain pyAA for Python 2.5. I went through their web site, but they provide the windows exe only for Python2.4. I tried compiling from source, but that also was to no avail - it errs out as follows: C:\Documents and Settings\Guest\pyAA>python setup.py install running install

Re: Counting number of objects

2009-01-27 Thread Kottiyath
Thank you everyone for your very helpful comments and suggestions. I have interacted in other newsgroups, but this is the most helpful of them all. As per the comments, I have now decided to go with the weakref mechanism - as per Andreas suggestion, functionally it looks correct that the person sh

Counting number of objects

2009-01-25 Thread Kottiyath
Hi, I am creating a class called people - subclasses men, women, children etc. I want to count the number of people at any time. So, I created code like the following: class a(object): counter = 0 def __new__(cls, *args, **kwargs): a.counter += 1 return object.__new__(cls,

Python logging rollover

2009-01-12 Thread Kottiyath
Hi, I want to do a log rollover - preferably based on day; size is also Ok. I checked logging.TimedRotatingFileHandler, but I am not sure whether it will suit my purpose. Mine is a desktop application. So, everytime the machine starts, the whole logging system is reinitialized. So, in such a case,

Re: Traceback in Logging

2009-01-08 Thread Kottiyath
The issue is that I am on Python 2.4 which doesnt support func name. I am using filename and lineno now. That does serve the purpose. Thank you, I had not checked all the parameters. Regards K Vinay Sajip wrote: > On Jan 6, 4:17 pm, Kottiyath wrote: > > I dont want the whole tracebac

Re: Traceback in Logging

2009-01-06 Thread Kottiyath
- esp since the application is >10K LOC. This might be a good item to have in the logging system - along with time and level, just proc name and the line number. Thank you for the help. Regards K Vinay Sajip wrote: > On Jan 6, 1:33 pm, Kottiyath wrote: > > This seems somewhat k

Traceback in Logging

2009-01-06 Thread Kottiyath
Hi all, Is it possible to print traceback for all logging? I have created something like this: def trace(): import traceback return ''.join(traceback.format_stack(limit=4)[1:]) And during every logging, append it - self.logger.info('Data: %s, kwargs: %s Traceback: %s' %(data

Re: Is there a better algorithm?

2009-01-02 Thread Kottiyath
On Jan 3, 2:38 am, mr wrote: > As has been noted, the best is to fix the input to be regular-3- > tuples. For the fun of it, here's another variation of a solution: > > tuples = [(1, 2), (3, 4, 5), (6, 7)] > > def triple_or_pair(seq): >     u = None >     try: >         k, u, v = seq >     except

Is there a better algorithm?

2009-01-02 Thread Kottiyath
I have the following list of tuples: L = [(1, 2), (3, 4, 5), (6, 7)] I want to loop through the list and extract the values. The only algorithm I could think of is: >>> for i in l: ... u = None ... try: ... (k, v) = i ... except ValueError: ... (k, u, v) = i ... print k, u, v - 1 N

Re: Python module import loop issue

2008-12-29 Thread Kottiyath
On Dec 30, 8:24 am, "Gabriel Genellina" wrote: > En Mon, 29 Dec 2008 19:47:51 -0200, Carl Banks   > escribió: > > > On Dec 29, 10:51 am, Kottiyath wrote: > >> Module Factory: > >> A1Factory: {'B1Tag':1.1.B1, 'C1Tag':1.2.C1, &

Python module import loop issue

2008-12-29 Thread Kottiyath
This might not be pure python question. Sorry about that. I couldnt think of any other place to post the same. I am creating a _medium_complex_ application, and I am facing issues with creating the proper module structure. This is my first application and since this is a run-of-the-mill applicatio

Re: Iterating over objects of a class

2008-12-24 Thread Kottiyath
On Dec 24, 11:48 pm, "Gabriel Genellina" wrote: > En Wed, 24 Dec 2008 16:18:55 -0200, Kottiyath   > escribió: > > >> The other thing to remember is that because the 'registry' contains > >> references to the instances, they won't be garbage

Re: Iterating over objects of a class

2008-12-24 Thread Kottiyath
On Dec 24, 11:04 pm, MRAB wrote: > Diez B. Roggisch wrote: > > Kottiyath schrieb: > >> Hi, > >>    How can I iterate over all the objects of a class? > >>    I wrote the code like following: > >> class baseClass(object): > > > Consider ado

Re: Iterating over objects of a class

2008-12-24 Thread Kottiyath
On Dec 24, 10:52 pm, "Diez B. Roggisch" wrote: > Kottiyath schrieb: > > > Hi, > >    How can I iterate over all the objects of a class? > >    I wrote the code like following: > > class baseClass(object): > > Consider adopting PEP 8  coding convention

Iterating over objects of a class

2008-12-24 Thread Kottiyath
Hi, How can I iterate over all the objects of a class? I wrote the code like following: class baseClass(object): __registry = [] def __init__(self, name): self.__registry.append(self) self.name = name def __iter__(self): baseClass.item = 0 return

Event Driven programming - Doubts

2008-12-22 Thread Kottiyath
Hi, I have been looking at Twisted and lately Circuits as examples for event driven programming in Python. Even though I understood how to implement the code in these and what is deferred etc, I have not yet understood the implementation of deferred. I went through a lot of tutorials, but I

Twisted for non-networking applications

2008-12-21 Thread Kottiyath
Hi all, Is it a good idea to use Twisted inside my application, even though it has no networking part in it? Basically, my application needs lots of parallel processing - but I am rather averse to using threads - due to myraid issues it can cause. So, I was hoping to use a reactor pattern to

Re: Can anyone suggest a good HTTP/1.1 web client?

2008-12-16 Thread Kottiyath
> If you'd like to help out with the new Twisted HTTP client, that would be > wonderful.  Even if you can just try it out and report any problems you run > into, that would be immensely helpful. > > Jean-Paul I would love to help out with the client. But, I am extremely tied up at the current mom

Can anyone suggest a good HTTP/1.1 web client?

2008-12-16 Thread Kottiyath
Hi all, I have to connect to a secure website every second to get the data and then post to it. I have been investigating on many web clients in python, but nothing fits the bill properly. The ones I tried implementing are: 1. httplib based - I created myself. (I cannot use urllib2 sinc

__import__ problem

2008-12-06 Thread Kottiyath
Hi all, When I try to import a module via __import__, I am facing ImportError. But, when I tried to import it via usual 'import', it worked fine. Please see below: try: import exact except: logging.exception('Error during importing')

Re: Good introductory book?

2008-12-03 Thread Kottiyath
On Dec 3, 7:44 pm, "Ken D'Ambrosio" <[EMAIL PROTECTED]> wrote: > Hi, all.  I'm getting ready to do some projects in Python, and I've cut my > teeth a little bit, but I've found the "Learning|Programming Python" books > from O'Reilly to be more-or-less useless (to my surprise -- I'm usually an > O'R

Re: Reg: PIL2.4 Error: AttributeError: pixel_access

2008-12-01 Thread Kottiyath
On Dec 1, 11:20 pm, Kottiyath <[EMAIL PROTECTED]> wrote: > Hi all, >     I am facing the following problem in PIL 2.4: > Code: > img = ImageGrab.grab() > img.save("image2.jpg") > > Error: >     img.save("image2.jpg") >   File "C:\Pyth

Reg: PIL2.4 Error: AttributeError: pixel_access

2008-12-01 Thread Kottiyath
t;> print Image.VERSION 1.1.6 I had installed PIL in Python2.5 earlier and had done image capture also. But I need to go back to Python2.4 (because pymedia exe is available for only python2.4) and now I am facing this issue. I am pretty new to application programming, so if someone can help me o