Re: [Tutor] Beginners

2007-01-17 Thread raghu raghu

I dont have any programming background, i know only c language.

On 1/18/07, wesley chun <[EMAIL PROTECTED]> wrote:


On 1/17/07, raghu raghu <[EMAIL PROTECTED]> wrote:
> can i follow 'Learning Python' by oreily. Is it good for beginners? can
any
> one suggest me i am planning to buy  a  hard copy (text book)


what is your programming background, what languages do you know
already?  or are you completely new to programming?  the books we
recommend are based on where you are coming from -- that will help you
find the right book for your needs.

cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com





--

  Vanam
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Beginners

2007-01-17 Thread raghu raghu

can i follow 'Learning Python' by oreily. Is it good for beginners? can any
one suggest me i am planning to buy  a  hard copy (text book)

--

  Vanam
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Query about getattr used as a dispatcher

2007-01-17 Thread raghu raghu

i am following 'dive into python' for learning. i come across a term
getattr() which gives reference about a function.Its written it can be used
as a dispatcher. Below example given for that builtin function:
import statsout
 def output(data,format='text'):
   output_function = getattr(statsout,"output_%s"  % format)
   return output_function(data)
Actually i installed python 2.5 i ran this script and its showing error it
could not import statsout.why is it so?could any one explain this script
briefly. i dont know whether i am following the right book. as i am a
beginner is it right  to follow this book?or is there any other book which
is best for beginners?

--

  Vanam
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Difference between 'yield' and 'print'

2007-01-16 Thread raghu raghu

Is there any difference between yield and print in python script?i have
written a script based on fibonacci series where in i used yield and print
in two different scripts:
the script is given below:
def fib(n):
   a,b = 0,1
   while a<=n:
  print a
  a,b = b,a+b

for x in fib(4):
   print  x. When i executed this script i am getting this error:
Typeerror:"nonetype" is not iterable
But the same script if 'print' is replaced with 'yield' inside while loop it
is executing properly without any type errors
could any one reply why print cant be used instead of yield and why error is
generated?

--

  Vanam
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread raghu raghu

Hi everyone,

I have a quick quick question joining out of order dictionary values.

For example:

I created an empty


config={}


Added some key/value pairs


config["test1"]="elem1"
config["test2"]="elem2"
config["test3"]="elem3"


etc




Dumped the values and joined them at the same time.


print "\\".join(config.values())

elem1\elem3\elem2

This is fine but it doesn't entirely solve the issue.

Only some of the key/value pairs in the dictionary are needed so a
dump of all values does not work.

Also, the order in which the values are joined is important so walking
through and joining all values does not work either.


The simplest way would be to do something like:


print "\\".join((config["val2"],config["val1"],config["val3"]))

elem2\elem1\elem3

or


print "%s\\%s\\%s" % (config["val2"],config["val1"],config["val3"])

elem2\elem1\elem3

but this seems somehow uneligent.

Are there a more efficient/compact ways of doing this kind of
operation or is this it?

The key/value pairs in these examples are contrived for purposes of
this discussion but the end goal is to piece together server and
directory path information for use with pysvn.

I have a Perl programmer who is learning Python and he is griping that
this kind of operation is far simpler in Perl.

To print or to retain individual values from a list,it has to be written in
the form of
config={'test1':'elem1','test2':'elem2','test3':'elem3'}
config['test4'] = 'elem4'
print config.values()
print config['test1']- To get individual values from a list
If we want to retrieve all the values or say 2 from 4 its not possible to
put in a while loop and get that as a list only takes one argument at a time
better way is to extract individually and respective keys could not be
obtained if corresponding values are given.



--

  Vanam
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 35, Issue 27

2007-01-09 Thread raghu raghu

i have a clarification regarding built in function,in some scripts it is
being used and it is give n: if _name_ == '_main_'
why this is being used in the scripts?

On 1/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]

You can reach the person managing the list at
[EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

   1. Re: Need help with rewriting script to use Decimal  module
  (Dick Moores)
   2. import glob.glob('*.py') (J?nos Juh?sz)
   3. Re: import glob.glob('*.py') (Kent Johnson)
   4. Apologies... (Tim Golden)
   5. 'root' dir of a package from within the package ? (Dave S)
   6. Re: is gotchas? (Hugo Gonz?lez Monteverde)
   7. Re: 'root' dir of a package from within the package ?
  (Michael Lange)


--

Message: 1
Date: Mon, 08 Jan 2007 04:20:24 -0800
From: Dick Moores <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Need help with rewriting script to use Decimal
module
To: Terry Carroll <[EMAIL PROTECTED]>, tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 06:32 PM 1/7/2007, Terry Carroll wrote:
>I may add this algorithm to the cookbook.

You should.

Dick






--

Message: 2
Date: Mon, 8 Jan 2007 13:56:23 +0100
From: J?nos Juh?sz <[EMAIL PROTECTED]>
Subject: [Tutor] import glob.glob('*.py')
To: tutor@python.org
Message-ID:
<
[EMAIL PROTECTED]>
Content-Type: text/plain; charset="US-ASCII"

Hi All,

I am playing with reportlab and I would like to make a directory where I
can place all of my projects as ___.py files.
A project file should be like this:
test.py
title="Test project"
duedate = '2007-02-28'
description = "description _"
detailed="""
detaileddetaileddetaileddetaileddetaileddetaileddetailed
detaileddetaileddetaileddetaileddetaileddetaileddetailed
detaileddetaileddetaileddetaileddetaileddetaileddetailed
detaileddetaileddetaileddetaileddetaileddetaileddetailed
detaileddetaileddetaileddetaileddetaileddetaileddetailed
"""
test.py

I plan to make a python script, that collect all the projectfiles from
that folder and render them as a report summary.
I planned to import these files as modules like

for filename in glob.glob('*.py'):
if '_' in filename: continue
import filename
render(filename)

Probably you have better ideas to do that.


Yours sincerely,
__
Janos Juhasz



--

Message: 3
Date: Mon, 08 Jan 2007 08:38:42 -0500
From: Kent Johnson <[EMAIL PROTECTED]>
Subject: Re: [Tutor] import glob.glob('*.py')
To: J?nos Juh?sz <[EMAIL PROTECTED]>
Cc: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

J?nos Juh?sz wrote:
> I plan to make a python script, that collect all the projectfiles from
> that folder and render them as a report summary.
> I planned to import these files as modules like
>
> for filename in glob.glob('*.py'):
> if '_' in filename: continue
> import filename
> render(filename)


This won't work, the import statement does not take a variable as an
argument. You need something like
module = __import__(filename)
render(module)

You will want to take care that your modules don't have any side effects
on import.

>
> Probably you have better ideas to do that.

You might want to look at the existing Python document generation tools.
There is a summary here (be sure to read the comments and the original
post just below this one):
http://www.voidspace.org.uk/python/weblog/arch_d7_2006_12_30.shtml#e599

In particular PythonDoc supports structured comments that are similar to
what you outlined and has pluggable output generators that could be used
to drive ReportLab.

Kent



--

Message: 4
Date: Mon, 08 Jan 2007 16:49:24 +
From: Tim Golden <[EMAIL PROTECTED]>
Subject: [Tutor] Apologies...
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

... my many apologies to the readers of the tutor
list. I went away for a week without suspending delivery
just as my company changed name - and decided to send
an irritating response to anything directed at the
old name. The list admin has very properly unsubscribed
the old address (otherwise you'd be seeing loads more
of the things!). Sorry again. Hope it didn't spoil your
new year.

TJG


--

Message: 5
Date: Mon, 8 Jan 2007 19:24:37 +
From: Dave S <[EMAIL PROTECTED]>
Subject: [Tutor] 'root' dir of a package from within the p