Re: trying to create simple py script

2012-08-10 Thread Ifthikhan Nazeem
I have been using Flask for a while and it's been a positive experience so
far. It's simplicity helps you to get things done faster.


On Fri, Aug 10, 2012 at 8:35 AM, Lutz Horn lutz.h...@fastmail.fm wrote:

 Hi Smaran,

 Am Do, 9. Aug 2012, um 23:52, schrieb Smaran Harihar:
  I am trying to create a simple cgi-script to receive a Ajax
  call, manipulate the string received and send it back as JSON.

 I can recommend bottle. The following example manipulates a JSON request
 body and returns it. That is *much* easier than using CGI.

 #!/usr/bin/env python

 from bottle import request, post, run

 @post('/hello')
 def index():
 if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
 body = request.json
 body[baz] = qux
 return body
 else:
 return 'This is a normal HTTP Post request.'

 run(host='localhost', port=8080)

 Lutz
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-08 Thread Ifthikhan Nazeem
Who could have predicted that a request for suggesting books on OOP can
come so far!


On Wed, Aug 8, 2012 at 9:31 PM, lipska the kat lipskathe...@yahoo.co.ukwrote:

 On 08/08/12 17:42, Dennis Lee Bieber wrote:

 On Wed, 08 Aug 2012 10:51:45 +0100, lipska the kat
 lipskathe...@yahoo.co.uk  declaimed the following in
 gmane.comp.python.general:


 The point I'm obviously struggling to make is that words convey concepts
 The word Person conveys a whole lifetime of experience of People and as
 imperfect human beings many of us are unable to tease out 'bits of being
 a person' that are relevant to the system we are developing. Inevitably
 other seemingly irreversibly entwined bits keep popping up to cloud our
 thinking. This is my experience, not an isolated case but one that has
 popped up again and again.

  You've never considered writing a genealogy program, have you?
 One
 that never acknowledges Person?

  Before I start let me say that this thread really has been the most
 enormous fun and I can take any amount of ridicule so don't hold back.

 Normally when I have a bath I think of the best way to stop the mice from
 feasting on my herb patch without killing them. This evening I lay there
 thinking about this outwardly tricky problem when I realised that what we
 have here, at it's most basic, is a Tree.

 I am not a genealogy expert, the nearest I've been to a family tree is the
 ones my old mum thrusts under my nose at Christmas, Sunday lunch,
 birthdays,funerals etc etc . They are increasing large, beautifully hand
 drawn and most definitely a Tree

 So here is my off the cuff, in the bath design for a genealogy system

 A Tree consists of Node(s) and Leaf(s), relationships are modelled by
 following the Line(s) in the Tree diagram and that is it. Line may be a
 class as in 'the patriarchal line' I'm not sure, it would come out in the
 iterative wash.

 We can infer whatever we want from this simple model. A Leaf is a child,
 until it becomes a parent when it becomes a Node. To anthropomorphize a bit
 more (I love that word) and introduce non species specific words and
 concepts, a Node can be a father or mother (simple to implement by virtue
 of an enumeration e.g enum Gender{MALE, FEMALE, HERMAPHRODITE,
 NON_GENDER_SPECIFIC_CHIMERA, ...}) A male sibling of a parent is an uncle,
 a female an aunt and a cousin is ...I  have no idea but hopefully you can
 see where I'm going with this. Furthermore our system can work for Horses
 and Dogs and Zoomorphs and Epiphytes, Parasites and Zygomorphs and Fungi
 and Parrots and anything else you can possibly think of ...

 But what of all the ephemeral data that goes with a sentient existance on
 this planet such as birth certificates, newspaper articles, christenings,
 death certificates, photographs etc etc, what about pegigree certificates,
 innoculation records and any other trivia, information and flotsam that
 goes with a pedigree Dog or Horse or indeed Parrot.

 Well you don't need me to answer this one do you, we could have a class
 called Ephemera ... but then I prefer the Just In Time concept to loading
 data, I'd store the gubbins in a 'database' (don't get me started on
 databases) or I may decide to pickle the data out to disk and pull it out
 when someone requests it and probably charge them a small fortune for the
 privilige of looking at their own families historical information.

 And not a 'Person' in sight

 Of course you may be a genealogy expert and just waiting to shoot me down
 in flames, go ahead, I'll have a good smile about it next time I'm in the
 bath.

 lipska

 --
 Lipska the Kat: Troll hunter, sandbox destroyer
 and farscape dreamer of Aeryn Sun
 --
 http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-05 Thread Ifthikhan Nazeem
I would recommend Bruce Eckel's Thining in Python. Check it out here
http://www.mindview.net/Books/TIPython/



On Sun, Aug 5, 2012 at 8:28 PM, Mark Lawrence breamore...@yahoo.co.ukwrote:

 On 05/08/2012 19:04, Jean Dubois wrote:

 On 5 aug, 02:11, shearich...@gmail.com wrote:

 One reason you may be having difficulty is that unlike some languages
 (C++/Java) object-orientation is not a be all and end all in Python, in
 fact you could work with Python for a long time without really 'doing it'
 at all (well other than calling methods/properties on existing API's).
 Having said that here's what I would suggest ...

 Could do worse than this :

 http://www.diveintopython.net/**object_oriented_framework/**index.htmlhttp://www.diveintopython.net/object_oriented_framework/index.html

  This example seems to tell you need the concept of dictionaries to
 explain object oriented programming, is this really necessary?

 and this

 http://docs.python.org/**tutorial/classes.htmlhttp://docs.python.org/tutorial/classes.html

 Unfortunately, the trouble with this explanation is exactly what made
 me ask the original question: it starts from concepts in c++ making it
 very hard to understand for someone who does not know that language
 already.


 read together.

 Judging by your question this is a probably a little advanced for now
 but you could bookmark it for the future:

 http://www.catonmat.net/blog/**learning-python-design-**
 patterns-through-.http://www.catonmat.net/blog/learning-python-design-patterns-through-.
 ..

 Here's the corresponding PDF to go with the video:

 http://assets.en.oreilly.com/**1/event/45/Practical%20Python%**
 20Patterns.http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns.
 ..

 Can someone here on this list give a trivial example of what object
 oriented programming is, using only Python?

 thanks in advance
 Jean


 Try this 
 http://www.voidspace.org.uk/**python/articles/OOP.shtmlhttp://www.voidspace.org.uk/python/articles/OOP.shtml???

 --
 Cheers.

 Mark Lawrence.

 --
 http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why 'Flat is better than nested'

2012-07-31 Thread Ifthikhan Nazeem
*as many as (about) 2*N - log2(N) parent child relationships*
*
*
I would like to know how did you come up with the above formula? Forgive my
ignorance.

--
Thanks and Best Regards,
Iftikhan Nazeem
*Skype* : iftecan2000



On Tue, Jul 31, 2012 at 11:04 PM, Terry Reedy tjre...@udel.edu wrote:

  import this

 prints 'The Zen of Python', a poem by Tim Peters that consists of python
 proverbs such as Flat is better than nested. (Others things being equal)
 why? Because it is a restatement of the principle of parsimony, of not
 multiplying entities without necessity.

 Suppose we have a unstructured collection of N items. Organizer comes
 along and says 'Let there be structure. Let us organize the items as leaf
 nodes in a hierarchical tree' (which is equivalent to nesting). To do so,
 we can add as many as N-1 new non-leaf nodes and as many as (about) 2*N -
 log2(N) parent child relationships. In other words, nearly quadruple the
 number of entities to learn, discuss, and remember. Well, there had better
 be a good necessity to do so ;-).

 And, of course, once new entities *are* conjured up, it is hard to get rid
 of them.

 --
 Terry Jan Reedy


 --
 http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Error

2012-07-29 Thread Ifthikhan Nazeem
Hi,

Have you tried printing the list which is passed onto the set. The items in
the list passed should be hashable and possibly there are objects which are
not hashable.

On Sun, Jul 29, 2012 at 2:30 PM, subhabangal...@gmail.com wrote:

 On Sunday, July 29, 2012 2:57:18 PM UTC+5:30, (unknown) wrote:
  Dear Group,
 
 
 
  I was trying to convert the list to a set, with the following code:
 
 
 
  set1=set(list1)
 
 
 
 Dear Peter,
 Thanks for the answer. But my list does not contain another list that is
 the issue. Intriguing. Thinking what to do.
 Regards,
 Subhabrata.
  the code was running fine, but all on a sudden started to give the
 following error,
 
 
 
  set1=set(list1)
 
  TypeError: unhashable type: 'list'
 
 
 
  please let me know how may I resolve.
 
 
 
  And sometimes some good running program gives error all on a sudden with
 no parameter changed, how may I debug it?
 
 
 
  Thanking You in Advance,
 
 
 
  Regards,
 
  Subhabrata Banerjee.

 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list