Re: Python docs disappointing

2009-08-02 Thread Mohan Parthasarathy
I am a newbie and about a month old with Python. There is a wealth of
material about Python and I am really enjoying learning Python.

One thing that could have helped Python documentation is that instead of the
very raw doc string, it could have used something like PythonDoc (java doc
style) so that the functions/classes are documented better. At least I am
planning to use PythonDoc for the code that I am going to write. Let me know
if there is a better one..

-mohan

On Fri, Jul 31, 2009 at 1:10 PM, kj no.em...@please.post wrote:




 I'm pretty new to Python, and I like a lot overall, but I find the
 documentation for Python rather poor, overall.

 I'm sure that Python experts don't have this problem: they have
 internalized some good ways to access the documentation, are
 productive with it, and therefore have lost the ability to see why
 the Python documentations is deficient for beginners.  This explains
 why a suboptimal situation can persist like this: those who are
 most able fix it are also the least able to perceive it.

 I've heard similar complaints from other experienced programmers
 who are trying out Python for the first time: poor documentation.

 Here is an *entirely typical* example: on some Unix, try

 % pydoc urllib

 The displayed documentation mention the optional parameter data
 in practically every function listed (a few dozen of them).  This
 parameter is not documented *anywhere* on that page.  All that we
 are told is that its default value is always None.

 I'm sure that I can find a full description of this parameter if
 I fire up Google, and search online.  In fact, more likely than
 not, I'll find far more documentation than I want.  But my point
 is that a programmer should not need to do this.  The full
 documentation should be readily accessible directly through a few
 keystrokes.

 I would love to know how experienced Python programmers quickly
 zero in on the Python documentation they need.

 TIA!

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

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


Bridging Python and C

2009-07-23 Thread Mohan Parthasarathy
Hi,
I am a newbie. It looks like there are quite a few ways to bridge Python and
C. I have a bunch of C code and I just need Python wrappers for it. If i
google for this I get SWIG, Boost etc. And I also see

http://www.python.org/doc/2.5.2/ext/intro.html

What is the recommended way for doing this ?

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


Re: Calling functions: Why this complicated ?

2009-07-14 Thread Mohan Parthasarathy
Chris,
Thanks for your clarifications


  I am a newbie. I am reading
  http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html
  Defining a function with N arguments and calling them in M different
  ways. Why does it have to be this complicated ? I like the idea of
 calling
  the function by explicitly naming the arguments, but there are so many
 other
  ways here that is very confusing. Do people really use all these features
 ?
  Perhaps, there is a equivalent book to Javascript: Good Parts for
 Python ?

 Oh $DEITY, don't even compare Python to JavaScript. At least in
 Python, when you try to access a non-existent attribute, a proper
 NameError exception is thrown rather than silently getting back
 undefined... (*has traumatic horror story flashback*)


I did not try to compare python to Javascript.  Just because there are ten
different ways of doing certain things, not all of them may be used. Over a
period of time, people tend to use certain features more and more.

Javascript is  a different beast where some of the features need to be
avoided for writing good programs. I don't know anything about python. But
it is possible that there is a subset that people use frequently which may
be sufficient to write good programs. Sure, that would not help me the
python interview test :-)


 The calling syntax is not so much complicated as it is liberating.
 Are you a C junkie who has never heard of named arguments?
Just use the call sequence like you've always done.
 Are you a exacting Smalltalk or Objective-C person who likes to name
 all the arguments all the time for clarity?
You can do that.


That's where I fit. I did not expect to see more than that :-)


 Do you want to call a function with lots of default arguments but only
 want to override a couple of them?
Specifying them by name lets you do that succinctly.
 Do you not want to have to worry about the order of the parameters
 because it seems kinda arbitrary?
Then specify the arguments by name.
 etc...

 And if you try and specify an argument twice, Python will throw an
 error, so anything truly confusing will get caught right away.
 And there's only one definition syntax, so while the call could be
 complicated, figuring out what it means by looking to the definition
 is fairly easy.

 There really aren't that many ways it's done in practice. In practice,
 the following styles cover 90% of cases:
 - All named arguments: foo(bar=a, baz=b, qux=c)
 - All sequential arguments: foo(a, b, c)
 - All sequential arguments, with a few optional arguments given by
 name: foo(a, b, c, flag=True, style=qux)

- Simple pass-through: foo(*args, **kwargs)

 Granted, there's 4 of them, but each taken by itself seems pretty easy
 to read, IMHO.


So, all four of them above has its use cases in practice i guess.

thanks
mohan




 Cheers,
 Chris
 --
 http://blog.rebertia.com

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


Re: Seeking old post on developers who like IDEs vs developers who like simple languages

2009-05-28 Thread Mohan Parthasarathy
On Mon, May 18, 2009 at 12:31 AM, Ulrich Eckhardt
eckha...@satorlaser.comwrote:

 Steve Ferg wrote:
  On the one hand, there are developers who love big IDEs with lots of
  features (code generation, error checking, etc.), and rely on them to
  provide the high level of support needed to be reasonably productive
  in heavy-weight languages (e.g. Java).
 
  On the other hand there are developers who much prefer to keep things
  light-weight and simple.  They like clean high-level languages (e.g.
  Python) which are compact enough that you can keep the whole language
  in your head, and require only a good text editor to be used
  effectively.

 This distinction is IMHO not correct. If you took a look at Java, you would
 notice that the core language syntax is much simpler than Python's. OTOH,
 if you add the standard libraries, you would soon see that Python's
 libraries are not as consistent (i.e. conformant to PEP8) as Java's.

 What makes up for Python's perceived usability problems though is the
 commandline parser that allows you to inspect the type of an object and its
 parts of it at runtime, in particular the docstrings are a treasure there.

 That said, an IDE that provides auto-completion (e.g. that gives you a list
 of available class members) is a good thing in Java, because you don't have
 to browse the documentation as often. With Python, that is impossible
 because there are no types bound to parameters, so any type that fits is
 allowed (duck typing).


I just downloaded the Aptana IDE which has Python support and I have not
tried it yet. But I remebered seeing this thread. Has anyone used the Aptana
IDE for Python development ?

thanks
mohan



 Uli

 --
 Sator Laser GmbH
 Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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

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


Performance java vs. python

2009-05-19 Thread Mohan Parthasarathy
On Mon, May 18, 2009 at 5:56 AM, Aahz a...@pythoncraft.com wrote:

 In article mff7e6-e43@satorlaser.homedns.org,
 Ulrich Eckhardt  eckha...@satorlaser.com wrote:
 Steve Ferg wrote:
 
  On the one hand, there are developers who love big IDEs with lots of
  features (code generation, error checking, etc.), and rely on them to
  provide the high level of support needed to be reasonably productive
  in heavy-weight languages (e.g. Java).
 
  On the other hand there are developers who much prefer to keep things
  light-weight and simple.  They like clean high-level languages (e.g.
  Python) which are compact enough that you can keep the whole language
  in your head, and require only a good text editor to be used
  effectively.
 
 This distinction is IMHO not correct. If you took a look at Java, you
 would
 notice that the core language syntax is much simpler than Python's.

 That's half-true.  The problem is that you have to digest a much bigger
 chunk of Java before you can start being productive.  Consider how simple
 it is to write a non-regex grep in Python.  In addition, Python's object
 model is simpler than Java's, not even talking about the contortions that
 Java's static class model forces you into.


I am new to Python. I am slowly realizing that Python might be a better
choice when compared to java on the server side. Is there any performance
comparison between Java and Python ? For example, if I use the J2EE solution
vs. python (Django etc.) on the server side, would one perform better over
the other ?

-mohan

P.S: I have changed the subject line to reflect the new thread


 --
 Aahz (a...@pythoncraft.com)   *
 http://www.pythoncraft.com/

 In 1968 it took the computing power of 2 C-64's to fly a rocket to the
 moon.
 Now, in 1998 it takes the Power of a Pentium 200 to run Microsoft Windows
 98.
 Something must have gone wrong.  --/bin/fortune
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Performance java vs. python

2009-05-19 Thread Mohan Parthasarathy
On Tue, May 19, 2009 at 10:42 AM, Daniel Fetchinson 
fetchin...@googlemail.com wrote:

   On the one hand, there are developers who love big IDEs with lots of
   features (code generation, error checking, etc.), and rely on them to
   provide the high level of support needed to be reasonably productive
   in heavy-weight languages (e.g. Java).
  
   On the other hand there are developers who much prefer to keep things
   light-weight and simple.  They like clean high-level languages (e.g.
   Python) which are compact enough that you can keep the whole language
   in your head, and require only a good text editor to be used
   effectively.
  
  This distinction is IMHO not correct. If you took a look at Java, you
  would
  notice that the core language syntax is much simpler than Python's.
 
  That's half-true.  The problem is that you have to digest a much bigger
  chunk of Java before you can start being productive.  Consider how
 simple
  it is to write a non-regex grep in Python.  In addition, Python's object
  model is simpler than Java's, not even talking about the contortions
 that
  Java's static class model forces you into.
 
 
  I am new to Python. I am slowly realizing that Python might be a better
  choice when compared to java on the server side. Is there any performance
  comparison between Java and Python ? For example, if I use the J2EE
 solution
  vs. python (Django etc.) on the server side, would one perform better
 over
  the other ?

 Benchmarks always test for a given feature. The available benchmarks
 will most likely not test the feature relevant for your particular
 application simply because there are about a gazillion different ways
 of using a web framework. So the best you can do is simply test the
 bottleneck part of your application and see for yourself, otherwise
 you will be left with comments like django is used at work because
 it's faster for us or I use j2ee because performance is better for
 my web app. When it will come to choosing your framework these will
 help little to none.


Ah! I should have been careful before asking such general question about
performance. I agree with you. But mine was more academic. I should not
given a specific example.

AFAIK, for java on the client side, JVM performance is one of the critical
things which has been tuned to death until now. Even Google's Android which
uses Java for the programming language uses a Dalvik Virtual machine which
was spefically designed to handle low CPU, memory and power environments.
Similarly, Python can also be used to program on Nokia phones etc. Of course
programming natively (C/C++) would make a difference in environments where
CPU, memory and power are a big constraint. Given the context, do we know
how Python compares with Java or even native programming. What is the
overhead of  Python's interpreted code ? Some standard benchmarks would help
compare apples to apples  though it may not help deciding which framework to
choose.

-mohan



 Cheers,
 Daniel

 --
 Psss, psss, put it down! - http://www.cafepress.com/putitdown
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Circular relationship: object - type

2009-05-14 Thread Mohan Parthasarathy
Hi,

I have read several articles and emails:

http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html#relationships-transitivity-figure
http://mail.python.org/pipermail/python-list/2007-February/600128.html

 I understand how type serves to be the default metaclass when an object is
created and it also can be changed. I also read a few examples on why this
metaclass can be a powerful concept. What I fail to understand is the
circular relationship between object and type. Why does type have to be
subclassed from object ? Just to make Everything is an object and all
objects are  inherited from object class.

Why can't just type be the class from which object class is instantiated ?
Why does it have to be a subclass of object also ?

Sorry if this has been answered before.

Thanks in advance,
mohan
-- 
http://mail.python.org/mailman/listinfo/python-list


How to see the code definiton in the shell ?

2009-05-13 Thread Mohan Parthasarathy
Hi,

I am new to Python. I tried searching this but could not find an answer. In
the interactive shell, I write a new function and I want to be able to see
all the code that I wrote at a later time. Just typing the function name
only shows

 allmethods
function allmethods at 0x822b0

How do I see the actual code ?

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