[Tutor] saving .csv file as an xl worksheet

2006-03-06 Thread arun
Hi ,
  Can i save a file with a desired extension??
for ex:  I have a .csv file (test.csv) and i want to save this file as test.xls from a python script. 
 
Thanx in advance 
ac 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Invoking Excel Macro

2006-04-21 Thread arun
Hi, 
I tried invoking a macro from my python script and  It is  throwing  an error message that reads 'Run-time error 1004':
 
"This operation requires the merged cells to be identically sized"
 
My script looks like this 
 
from win32com.client import Dispatchxl = Dispatch('Excel.Application')xl.Workbooks.Add('E:\Templates\sample.xls')
xl.Run('Import_file')  # name of the macro
 
Also while (running the macro)opening the workbook it  names it as  "sample1.xls' ,and so 
It says there is no such file sample.xls
 
"
Filename =  Myexcel.xls
Workbooks("sample.xls").SaveAs Filename
"
 
Can somebody help me with this issue : (
 
 
Thanx
arun 
 
 
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Invoking Excel Macro

2006-04-21 Thread arun
I'm sorry , there is something realy wrong with 'Run-time error 1004':. I have fixed it now but still it throws an error while trying to save the workbook.
On 4/21/06, arun <[EMAIL PROTECTED]> wrote:


Hi, 
I tried invoking a macro from my python script and  It is  throwing  an error message that reads 'Run-time error 1004':
 
"This operation requires the merged cells to be identically sized"
 
My script looks like this 
 
from win32com.client import Dispatchxl = Dispatch('Excel.Application')xl.Workbooks.Add('E:\Templates\sample.xls')
xl.Run('Import_file')  # name of the macro
 
Also while (running the macro)opening the workbook it  names it as  "sample1.xls' ,and so 
It says there is no such file sample.xls
 
"
Filename =  Myexcel.xls
Workbooks("sample.xls").SaveAs Filename
"
 
Can somebody help me with this issue : (
 
 
Thanx

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


Re: [Tutor] Invoking Excel Macro

2006-04-24 Thread arun
Hi Mike, 
   It doesn't  display any dialog box rather it gives a temporary name to the file.
Ex
 newsheet.xls as newsheet1.xls 
So i'm not able to save it. Is  there an alternative to invoke the  macro and save the file from my script itself .(saving it through macro wud be a better option : )  )
 
Thanx  and Regards,
arun 
On 4/21/06, Mike Hansen <[EMAIL PROTECTED]> wrote:


In the macro, you might try Application.DisplayAlerts = False  and reset it to True after you save.
I think it might be trying to display a dialog box before it saves. 
 
Mike



From: [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED]] On Behalf Of arunSent: Friday, April 21, 2006 1:44 AMTo: 
tutor@python.orgSubject: Re: [Tutor] Invoking Excel Macro 

I'm sorry , there is something realy wrong with 'Run-time error 1004':. I have fixed it now but still it throws an error while trying to save the workbook.
On 4/21/06, arun <[EMAIL PROTECTED]> wrote:
 


Hi, 
I tried invoking a macro from my python script and  It is  throwing  an error message that reads 'Run-time error 1004':
 
"This operation requires the merged cells to be identically sized"
 
My script looks like this 
 
from win32com.client import Dispatchxl = Dispatch('Excel.Application')xl.Workbooks.Add('E:\Templates\sample.xls')
xl.Run('Import_file')  # name of the macro
 
Also while (running the macro)opening the workbook it  names it as  "sample1.xls' ,and so 
It says there is no such file sample.xls
 
"
Filename =  Myexcel.xls
Workbooks("sample.xls").SaveAs Filename
"
 
Can somebody help me with this issue : (
 
 
Thanx

arun 
 
 
 -- arun 

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


Re: [Tutor] how to instantiate a class

2009-02-25 Thread Arun Tomar
@Abhishek,

On 2/26/09, Abhishek Kumar  wrote:
> hello list,
>
> Below is the sample code of a class.
>
>
> import 
>
> Class ABC:
>  def __init__(self,a,b,c):
> statement 1
>  statement 2
>  def func(x,y):
>statement 1
>statement 2
>
> Here is the question:
>
> how to make an object of this class and how to use the methods listed
> in the class.

you can make object

newobj = ABC()

using the methods would be

newobj.func()

> do i need to create the object in a separate file or in the same file
> it can be done ??

It's upto you. You can create the object in the same file or separate
file, both works.

kindly read the documentation, especially the tutorial section. It's
one of the best available resources for learning python.

http://docs.python.org/

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


-- 
Regards,
Arun Tomar
blog: http://linuxguy.in
website: http://www.solutionenterprises.co.in
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] installation of scipy

2009-03-30 Thread Arun Tomar
hi!
Bala.

On Mon, Mar 30, 2009 at 3:57 PM, Bala subramanian
 wrote:
> Friends
> i installed scipy in fedora10 using yum. when i import stats module in it, i
> got the following warning. someone pls englihten me on this.
>
>>>> from scipy import stats
> /usr/lib/python2.5/site-packages/scipy/sparse/linalg/dsolve/linsolve.py:20:
> DeprecationWarning: scipy.sparse.linalg.dsolve.umfpack will be removed,
> install scikits.umfpack instead
>   ' install scikits.umfpack instead', DeprecationWarning )
>

deprecation is the way in python through which the developers warn the
user or the other developers that, a certain feature that has been
mentioned, would be removed or not available from the next release.

so as of now, just enjoy & ignore the error. by the next release
cycle, developers of scipy will need remove the deprecated code or use
the suggested packages in the deprecation warning.
> Thanks,
> Bala
>
> ___
> Tutor maillist  -  tu...@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>



-- 
Regards,
Arun Tomar
blog: http://linuxguy.in
website: http://www.solutionenterprises.co.in
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Web crawling!

2009-07-29 Thread Arun Tomar
Hi!
Raj.

On Wed, Jul 29, 2009 at 9:29 PM, Raj Medhekar wrote:

> Does anyone know a good webcrawler that could be used in tandem with the
> Beautiful soup parser to parse out specific elements from news sites like
> BBC and CNN? Thanks!
> -Raj
>

As i didn't find any good webcrawler as per my clients need, so i wrote one
for them, but it's specific for their need only. i can't disclose any more
details about it.

In short, i'm using my app to crawl the specific sites, then parse it with
beautiful soup and extract all the links on that page, then visit the links
and search for the keywords on those pages. If the keyword is occurs more
than the specified limit then it's a useful link and store it in the
database or else leave it.


-- 
Regards,
Arun Tomar
blog: http://linuxguy.in
website: http://www.solutionenterprises.co.in
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Binary chop function - this works, but I'm not sure why

2008-02-13 Thread Arun Srinivasan
I'm trying to learn Python, and I decided to try kata 2  from the
CodeKate website. It's basically just a challenge to implement a binary
search in different ways.

I wrote an implementation that works, but I'm confused as to why.

def chop(search_int, sorted_list):
if len(sorted_list) == 1 or 2:
for x in sorted_list:
if x == search_int:
return sorted_list.index(x)
return -1

midpoint = (len(sorted_list) - 1) / 2
mp_value = sorted_list[midpoint]

if mp_value == search_int:
return midpoint
elif mp_value > search_int:
return chop(search_int, sorted_list[:midpoint])
else:
return chop(search_int, sorted_list[midpoint + 1:])

Basically, it only returns the index if it matches in the if statement at
the beginning of the function, but since that is limited to lists of length
2 or 1, why doesn't it return only 0 or 1 as the index? I think there is
something about recursion here that I'm not fully comprehending.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Binary chop function - this works, but I'm not sure why

2008-02-14 Thread Arun Srinivasan
On Thu, Feb 14, 2008 at 5:27 AM, bob gailer <[EMAIL PROTECTED]> wrote:
>
> Arun Srinivasan wrote:
> > I'm trying to learn Python, and I decided to try kata 2  from the
> > CodeKate website. It's basically just a challenge to implement a
> > binary search in different ways.
> >
> > I wrote an implementation that works, but I'm confused as to why.
> >
> > def chop(search_int, sorted_list):
> > if len(sorted_list) == 1 or 2:
> Yet another way to express that is:
>
>   if 1 <= len(sorted_list) <= 2:
>
> > for x in sorted_list:
> > if x == search_int:
> > return sorted_list.index(x)
> > return -1
> >
> > midpoint = (len(sorted_list) - 1) / 2
> > mp_value = sorted_list[midpoint]
> >
> > if mp_value == search_int:
> > return midpoint
> > elif mp_value > search_int:
> > return chop(search_int, sorted_list[:midpoint])
> > else:
> > return chop(search_int, sorted_list[midpoint + 1:])
> >
> > Basically, it only returns the index if it matches in the if statement
> > at the beginning of the function, but since that is limited to lists
> > of length 2 or 1, why doesn't it return only 0 or 1 as the index? I
> > think there is something about recursion here that I'm not fully
> > comprehending.
> >
> >
> >
> > 
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
> --
> Bob Gailer
> 919-636-4239 Chapel Hill, NC
>
>

Oy, I should have seen that. Thanks for the responses - time to go
back and fix this.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Binary chop function - this works, but I'm not sure why

2008-02-14 Thread Arun Srinivasan
On Thu, Feb 14, 2008 at 11:41 AM, Arun Srinivasan
<[EMAIL PROTECTED]> wrote:
>
> On Thu, Feb 14, 2008 at 5:27 AM, bob gailer <[EMAIL PROTECTED]> wrote:
>  >
>  > Arun Srinivasan wrote:
>  > > I'm trying to learn Python, and I decided to try kata 2  from the
>  > > CodeKate website. It's basically just a challenge to implement a
>  > > binary search in different ways.
>  > >
>  > > I wrote an implementation that works, but I'm confused as to why.
>  > >
>  > > def chop(search_int, sorted_list):
>  > > if len(sorted_list) == 1 or 2:
>  > Yet another way to express that is:
>  >
>  >   if 1 <= len(sorted_list) <= 2:
>  >
>  > > for x in sorted_list:
>  > > if x == search_int:
>  > > return sorted_list.index(x)
>  > > return -1
>  > >
>  > > midpoint = (len(sorted_list) - 1) / 2
>  > > mp_value = sorted_list[midpoint]
>  > >
>  > > if mp_value == search_int:
>  > > return midpoint
>  > > elif mp_value > search_int:
>  > > return chop(search_int, sorted_list[:midpoint])
>  > > else:
>  > > return chop(search_int, sorted_list[midpoint + 1:])
>  > >
>  > > Basically, it only returns the index if it matches in the if statement
>  > > at the beginning of the function, but since that is limited to lists
>  > > of length 2 or 1, why doesn't it return only 0 or 1 as the index? I
>  > > think there is something about recursion here that I'm not fully
>  > > comprehending.
>  > >
>  > >
>  > >
>  > > 
>  > >
>  > > ___
>  > > Tutor maillist  -  Tutor@python.org
>  > > http://mail.python.org/mailman/listinfo/tutor
>  > >
>  >
>  >
>  > --
>  > Bob Gailer
>  > 919-636-4239 Chapel Hill, NC
>  >
>  >
>
>  Oy, I should have seen that. Thanks for the responses - time to go
>  back and fix this.
>

Turns out it was simple to fix - just needed to fix that test so it
wasn't silly, add the lower bound tracking (thanks Alan), and make
sure to test for empty lists. Here's the function in all (rather, what
little there is) of its glory:

def chop(search_int, sorted_list, lbound = 0):
if len(sorted_list) == 0:
return -1

if len(sorted_list) in [1,2]:
if sorted_list[0] == search_int: return lbound
elif len(sorted_list) == 2 and  sorted_list[1] == search_int:
return lbound + 1
else: return -1

midpoint = (len(sorted_list) - 1) / 2
mp_value = sorted_list[midpoint]

if mp_value == search_int:
return midpoint
elif mp_value > search_int:
return chop(search_int, sorted_list[:midpoint])
else:
return chop(search_int, sorted_list[midpoint + 1:], lbound +
midpoint + 1)

Alan, could you please explain why

if sorted_list[0] == search_int: return 0
elif len(sorted_list) == 2 and  sorted_list[1] == search_int: return 1
else: return -1

is faster than:

>for x in sorted_list:
>if x == search_int:
>return sorted_list.index(x)
>return -1

Thanks for the help!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python regex help

2008-09-28 Thread Arun Tomar
hi!

i've data extracted in the form of list using regex.
it looks something like the one below. 

print reobj
['Jyoti Soni - 0 Year(s) 0 Month(s)\n', 'Tel: 09975610476(M)\n', '\n',
'Minal - 0 Year(s) 0 Month(s)\n', 'Tel: 9890498376(M)\n', '011 02162
250553(R)\n']

i'm trying to use regex to remove the following information
1. - 0 Years *
2. Tel: & (M)
3. (R)
 & store the remaining portion as a new list.

I've been using shell scripting & using sed & pipes i've solved it, but
with python, i need to practice more ;).

regds,
arun.




signature.asc
Description: This is a digitally signed message part
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python regex help

2008-09-28 Thread Arun Tomar
On Sun, 2008-09-28 at 17:26 +0100, Alan Gauld wrote:
> "Arun Tomar" <[EMAIL PROTECTED]> wrote
> 
> > I've been using shell scripting & using sed & pipes i've solved it,
> > but with python, i need to practice more ;).
> 
> Can you show us some output as you'd like irt?
> Can you show us the sed script that works?
sample data:
Contact Candidate   
Jyoti Soni - 0 Year(s) 0 Month(s)
MCA

Keyskills:
C , C + + , Java , JSP , Oracle , S / W Testing

B.Sc Pt.Ravishanker University,Raipur
MCA Pt.Ravishanker University,Raipur




Currently in: Pune
CTC(p.a): Not Disclosed
Modified: 27 Sep 2007
Tel: 09975610476(M)

Account Information
Account Information


Contact Candidate   
Minal - 0 Year(s) 0 Month(s)
MCA

Keyskills:
c , c + + , java , ASP . NET , VB , Oracle , Dimploma in Web Designing

B.Sc Shivaji University , Maharasthra
MCA Shivaji University , Maharashtra




Currently in: Pune
CTC(p.a): INR 0 Lac(s) 5 Thousand
Modified: 27 Jan 2006
Last Active: 06 Sep 2007
Tel: 9890498376(M)
011 02162 250553(R)

Account Information
Account Information

small shell scripts that works: 
#!/bin/bash

print $1

 sed -ne '/Contact/,+1p' -e '/Tel/p' $1 |sed -e '/Contact Candidate/d'|
sed -e 's/\-//'|sed -e '/^$/d'|sed -e 's/ *$//'|sed -e 's/Tel://g' -e
's/(M)//g' -e 's/0 Year(s) 0 Month(s)//g' -e 's/(R)//g' -e '/> Similar
Resumes/d' 

sample output
Jyoti Soni  
 09975610476
Minal  
 9890498376

> 
> Also can you show us the Python code that doesn't work
> and what went wrong? Its easier to fix what's broken than
> to guess at what might do what you want :-)
python code that works, after that i'm a bit lost ;)

import re

filename = "script.txt"

#regex pattern
p1 = re.compile("Contact Candidate",re.IGNORECASE)
p2 = re.compile ("Tel:", re.IGNORECASE)

#open the file
fh = open(filename,'r')
#read the contents of the file to an array.
file_array = fh.readlines()

#create an empty array
new_array = []
mod_array = []
for i in range(len(file_array)):
if p1.search(file_array[i]):
new_array.append(file_array[i+1])
if p2.search(file_array[i]):
new_array.append(file_array[i])
new_array.append(file_array[i+1])


basically i'm trying my hand with text manipulation with python. i'm
thorough with shell scripting, sed & awk. 

after this data is extracted i would like to convert it to a csv file,
then i would like to insert the data into a database etc etc. i hope
this gives a good idea of what i'm trying to do.


regds,
arun.


signature.asc
Description: This is a digitally signed message part
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python regex help

2008-09-28 Thread Arun Tomar
On Sun, 2008-09-28 at 17:26 +0100, Alan Gauld wrote:
> "Arun Tomar" <[EMAIL PROTECTED]> wrote
> 
> > I've been using shell scripting & using sed & pipes i've solved it,
> > but with python, i need to practice more ;).
ok, i got it.
here is the code that needs to be included after code in the last mail ;)

sub1 = "(-.*)|(Tel:)|\(M\)|\(R\)"
new_reg = re.compile(sub1)
for n in range(len(new_array)):
mod_array.append(new_reg.sub('',new_array[n]))



cheers,
arun.

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


[Tutor] vim python debugging

2008-09-28 Thread Arun Tomar
hi!

I"m trying to setup vim for python debugging mode. But it gives me
error. Has anyone succeeded in doing so. 

link:
http://code.google.com/p/vimpdb/

ideally I'm trying to evaluate vim & emacs as command line editors &
debugging for python. 

arun.


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


Re: [Tutor] vim python debugging

2008-09-28 Thread Arun Tomar
On Sun, 2008-09-28 at 22:12 -0600, Alec Henriksen wrote:
> It would be very helpful to include the error message you received... I
> can't help you, but just a thought.
> 
> On Mon, 2008-09-29 at 09:39 +0530, Arun Tomar wrote:
> > hi!
> > 
> > I"m trying to setup vim for python debugging mode. But it gives me
> > error. Has anyone succeeded in doing so. 
> > 
> > link:
> > http://code.google.com/p/vimpdb/
> > 
> > ideally I'm trying to evaluate vim & emacs as command line editors &
> > debugging for python. 
> > 
error that i get:

http://code.google.com/p/vimpdb/issues/detail?id=3

regds,
arun.

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


[Tutor] list to csv

2008-09-30 Thread Arun Tomar
hi!

I've a list

new_array = ['n1', 'm1', 'p1', 'n2', 'm2', 'p2', 'n3', 'm3', 'p3']

I am trying to convert this to a csv in 3 columns so that the final
output would look something like this

"n1","m1","p1"
"n2","m2","p2"
"n3","m3","p3"

regds,
arun.



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


[Tutor] automatically generate python/pylons documentation

2008-10-17 Thread Arun Tomar
hi!

I'm trying to generate documentation for my pylons web application.

my personal opinion:
1. pudge:
I've reviewed pudge. it was not very useful & hard to know as most of
the links are not working on the site and lack of support.
2. epydoc
I liked epydoc, the generated document looks more like what is
generate by ruby tools, i guess rdoc. if i give it a single python
file it works fine. but if i want epydoc to go into a specific folder
& generate the documentation for all the files & files in the sub
directories, it doesn't automatically do that. any pointers there.
3. sphinx:
i've read a little about it. haven't tried it yet.

my objective is to automatically generate documentation for my entire
pylons webapp or any other python application.

regds,
arun.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] automatically generate python/pylons documentation

2008-10-18 Thread Arun Tomar
hi!

On Sat, Oct 18, 2008 at 5:17 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 17, 2008 at 10:18 AM, Arun Tomar <[EMAIL PROTECTED]> wrote:
>> hi!
>>
>> I'm trying to generate documentation for my pylons web application.
>
>> 2. epydoc
>> I liked epydoc, the generated document looks more like what is
>> generate by ruby tools, i guess rdoc. if i give it a single python
>> file it works fine. but if i want epydoc to go into a specific folder
>> & generate the documentation for all the files & files in the sub
>> directories, it doesn't automatically do that. any pointers there.
>
> I have used epydoc to create docs for entire packages by giving it the
> package name on the command line. The package must be in the current
> Python path.
>
> Looking at epydoc's own makefile it appears that you can also specify
> a directory.

I've a pylons web application in the directory called helloworld.
if i give the command for epydoc to generate the documentation it
gives the below mentioned errors:

 epydoc helloworld/
  Error: Directory 'helloworld/' is not a package
  Error: Nothing left to document!

Can you guide me how can i accomplish this task.

> Kent
>

Regds,
Arun.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] automatically generate python/pylons documentation

2008-10-18 Thread Arun Tomar
hi!

On Sat, Oct 18, 2008 at 10:42 PM, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "Arun Tomar" <[EMAIL PROTECTED]> wrote
>>
>> if i give the command for epydoc to generate the documentation it
>> gives the below mentioned errors:
>>
>> epydoc helloworld/
>>  Error: Directory 'helloworld/' is not a package
>>  Error: Nothing left to document!
>
> What happens if you don;t pass the trainiling slash:
>
> epydoc helloworld

if i do not give a trailing slash, the output is like this
epydoc helloworld
+---
| In helloworld:
| No documentation available!
| Error: Import failed:
|ImportError: No module named helloworld
|
  Error: Nothing left to document!

>
> Alrternatively just make it a package by creating an init.py file as
> suggested by Marc
>
> Alan G

creating a __init__.py file does the trick but not completely.
 epydoc helloworld
+---
| In /tmp/helloworld/setup.py:
| Import failed (but source code parsing was successful).
| Error: SystemExit: usage: (imported) [global_opts] cmd1
[cmd1_opts] [cmd2 [cmd2_opts] ...]
|   or: (imported) --help [cmd1 cmd2 ...]
|   or: (imported) --help-commands
|   or: (imported) cmd --help
|
|error: no commands supplied (line 30)
|
+---
| In /tmp/helloworld/helloworld/websetup.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named config.environment (line 7)
|
+---
| In /tmp/helloworld/helloworld/config/middleware.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named config.environment (line 13)
|
+---
| In /tmp/helloworld/helloworld/config/environment.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named lib.app_globals (line 6)
|
+---
| In /tmp/helloworld/helloworld/controllers/template.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named lib.base (line 1)
|
+---
| In /tmp/helloworld/helloworld/controllers/error.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named lib.base (line 6)
|
+---
| In /tmp/helloworld/helloworld/tests/__init__.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named config.middleware (line 33)
|
+---
| In /tmp/helloworld/helloworld/tests/test_models.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named config.middleware (line 33)
|
+---
| In /tmp/helloworld/helloworld/tests/functional/__init__.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named config.middleware (line 33)
|
+---
| In /tmp/helloworld/helloworld/lib/base.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named lib.helpers (line 13)
|
Warning: No information available for
helloworld.helloworld.lib.base.BaseController's base
 pylons.controllers.WSGIController
Warning: 1 markup error was found while processing docstrings.  Use
the verbose switch (-v) to display markup errors.

this creates a directory with the documentation which is working but
as you can see there are some import errors.

regds,
arun
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] faulty code (maths)

2008-11-23 Thread Arun Tomar
hi!


On Sun, Nov 23, 2008 at 5:07 PM, David <[EMAIL PROTECTED]> wrote:
> Hello everybody,
>
> I recently came across a book by Prof. Langtangen: Indroduction to Computer
> Programming: http://folk.uio.no/hpl/INF1100/INF1100-ebook-Aug08.pdf
>
> I am trying to solve exercise 1.18 ("Why does the following program not work
> correctly?"), but I don't find the mistake: why does the line
>
> q = sqrt(b*b - 4*a*c)

problem here is that the method sqrt doesn't accepts -negative numbers
which in this case is the outcome of the expression above. to rectify
that u can use the following

q = sqrt(math.fabs(b*b - 4*a*c))

basically convert the negative number to absolute number, rest of the
stuff will work.

>
> cause an error? I was playing around with the code, but got nowhere.
>
> Here the entire code:
>
> a = 2; b = 1; c = 2
> from math import sqrt
> q = sqrt(b*b - 4*a*c)
> x1 = (-b + q)/2*a
> x2 = (-b - q)/2*a
> print x1, x2
>
>
> Many thanks for a pointer!
>
> David
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Regards,
Arun Tomar
blog: http://linuxguy.in
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] lists

2009-01-20 Thread Arun Tomar
hi!

On Tue, Jan 20, 2009 at 10:30 PM, Kent Johnson  wrote:
> On Tue, Jan 20, 2009 at 11:30 AM, Norman Khine  wrote:
>> Hi
>> What am I doing wrong
>>
>>>>> media_list = ['upper_b.wav', 'upper_a.wav']
>>>>> print '%s' % (for x in media_list)
>>  File "", line 1
>>print '%s' % (for x in media_list)
>>^
>> SyntaxError: invalid syntax
>>>>> print '%s' % (x for x in media_list)
>> 
>>
>> I want to replace %s with the items of the list as individual item string,
>> i.e
>>
>> 'upper_b.wav', 'upper_a.wav'
>
> I'm not sure what you want, maybe one of these?
>
> In [1]: media_list = ['upper_b.wav', 'upper_a.wav']
>
> In [2]: print ', '.join(media_list)
> upper_b.wav, upper_a.wav
>
> In [3]: print ', '.join(repr(x) for x in media_list)
> 'upper_b.wav', 'upper_a.wav'
>
> Kent

may be you want to do it this way:

In [10]: for x in media_list:
   : print "%s" % x
   :
   :
upper_b.wav
upper_a.wav



-- 
Regards,
Arun Tomar
blog: http://linuxguy.in
website: http://www.solutionenterprises.co.in
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] about import statement

2011-01-10 Thread arun kumar
Hi Friends,

I'm Arun Kumar from India, Just a month ago i started learning
programming .learned some basics of python. I'm really enjoying
programming in python.

I have some doubts in python. When we write programs,we write some
import statements at the beginning of the code. how to know that we
should import something. How do we know that certain classes are in
particular module?

Thanks

Arun Kumar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] about import statement

2011-01-11 Thread arun kumar
I'm trying to program with google api i downloaded the libraries
provided by the google.
http://code.google.com/apis/gdata/docs/client-libraries.html

In oder to write program with google api, i need to write some import
statements. But i'm unable to understand the hierarchy of the
modules,packages,which classes are in which package.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Importing packages

2011-01-21 Thread arun kumar
Hi,

I'm trying to program with gdata
(http://code.google.com/p/gdata-python-client/) using python
library.I'm having problem in writing import statements.

The source directory content is like this:

atom(folder): this folder contains some files with the .py extension
gdata (folder):this folder contains some folders and as well as some
files with the .py extension. Also each of the folders contain a
__init__.py file.

I want to use the classes and functions of the gdata and its inner
folders' classes and functions.

please  tell me how write the import statements

-- 
Thank you

Arun Kumar
http://clicknscroll.blogspot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Importing packages

2011-01-21 Thread arun kumar
hi,

I am not understanding what you are saying. I included those modules
in the sys.path. i want  to know how to write the import statement for
the modules and packages. I downloaded the gdata client library and
extracted it. It contained a scr directory which contained two
directories:
1)atom
2)gdata

gdata again has some 31 directories and some .py files.These 31
directories contains files with .py extension.

Where as the atom directory no further dirrectories. It contained only
files with .py extension

I want to write the import statementt for the files in gdata directory
and also for the files in the 31 directories of the gdata.


On 1/21/11, Pacific Morrowind  wrote:
> Hi;
>
> On 21/01/2011 1:10 AM, arun kumar wrote:
>> Hi,
>>
>> I'm trying to program with gdata
>> (http://code.google.com/p/gdata-python-client/) using python
>> library.I'm having problem in writing import statements.
>>
>> The source directory content is like this:
>>
>> atom(folder): this folder contains some files with the .py extension
>> gdata (folder):this folder contains some folders and as well as some
>> files with the .py extension. Also each of the folders contain a
>> __init__.py file.
>>
>> I want to use the classes and functions of the gdata and its inner
>> folders' classes and functions.
>>
>> please  tell me how write the import statements
> Without knowing the exact names/format of those folders can't be 100%
> exact but you'd want to say something along the lines of
>
> import gdata.example.funky
> to import the module gdata/example/funky.py
> or
> import gdata.example2
> to import the package gdata/example2 (__init__.py) - just a quick method
> to say the same thing as import gdata.example2.__init__ basically and
> logically is clear that that is the base fuctions/info etc. for that
> package (example2).
> Pacific
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
Thank you

Arun Kumar
http://clicknscroll.blogspot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] html files to pdf document

2011-06-20 Thread arun kumar
HI,  i have a some 100 plus html individual files.I want to convert them to
a single pdf document programatically. How to convert them in  python. Are
there any functions,modules or libraries for python to achieve this.

-- 
Thank you

Arun Kumar
http://clicknscroll.blogspot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 88, Issue 83

2011-06-21 Thread arun kumar
On Tue, Jun 21, 2011 at 12:46 PM,  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
>tutor-requ...@python.org
>
> You can reach the person managing the list at
>tutor-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>   1. Re: html files to pdf document (Timo)
>   2. Re: html files to pdf document (Michiel Overtoom)
>   3. Re: html files to pdf document (Walter Prins)
>   4. Re: html files to pdf document (Michiel Overtoom)
>   5. Socket Programming issue (aditya)
>   6. Re: Socket Programming issue (Alan Gauld)
>
>
> --
>
> Message: 1
> Date: Mon, 20 Jun 2011 18:58:56 +0200
> From: Timo 
> To: tutor@python.org
> Subject: Re: [Tutor] html files to pdf document
> Message-ID: <4dff7c50.3000...@gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 20-06-11 17:34, arun kumar wrote:
> > HI,  i have a some 100 plus html individual files.I want to convert
> > them to a single pdf document programatically. How to convert them in
> >  python. Are there any functions,modules or libraries for python to
> > achieve this.
> Just a question, but did you use Google before asking here? Because the
> first hit when searching for "python html to pdf" looks like it should
> do what you want.
>

Cheers,
> Timo
>
> >
> > --
> > Thank you
> >
> > Arun Kumar
> > http://clicknscroll.blogspot.com
> >
> >
> >
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
>
>
> yes i did a Google search but  did find anything useful. The xhtml2pdf is
> buggy in i'm unable to install it. Also mailed the community of  xhtml2pdf
> but didn't receive any reply from  them.
>

   Thanks
   Arun Kumar

> --
>
> Message: 2
> Date: Mon, 20 Jun 2011 19:11:13 +0200
> From: Michiel Overtoom 
> To: tutor@python.org
> Subject: Re: [Tutor] html files to pdf document
> Message-ID: <00e86b69-6d07-46ed-b4ca-4f740509b...@xs4all.nl>
> Content-Type: text/plain; charset=us-ascii
>
>
> On Jun 20, 2011, at 18:58, Timo wrote:
>
> > On 20-06-11 17:34, arun kumar wrote:
> >> HI,  i have a some 100 plus html individual files.I want to convert them
> to a single pdf document programatically. How to convert them in  python.
> Are there any functions,modules or libraries for python to achieve this.
>
> > Just a question, but did you use Google before asking here? Because the
> first hit when searching for "python html to pdf" looks like it should do
> what you want.
>
> Maybe for you, but not for the OP. Google will give different search
> results depending on your location, nationality, IP address and previous
> searches from that address.
>
> Please post the URL of the first hit you got?
>
> Greetings,
>
> --
> "Freedom: To ask nothing. To expect nothing. To depend on nothing." - Ayn
> Rand
>
>
>
> --
>
> Message: 3
> Date: Mon, 20 Jun 2011 23:19:52 +0100
> From: Walter Prins 
> To: tutor@python.org
> Subject: Re: [Tutor] html files to pdf document
> Message-ID: 
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello,
>
> On 20 June 2011 18:11, Michiel Overtoom  wrote:
>
> >
> > On Jun 20, 2011, at 18:58, Timo wrote:
> >
> > > On 20-06-11 17:34, arun kumar wrote:
> > >> HI,  i have a some 100 plus html individual files.I want to convert
> them
> > to a single pdf document programatically. How to convert them in  python.
> > Are there any functions,modules or libraries for python to achieve this.
> >
> > > Just a question, but did you use Google before asking here? Because the
> > first hit when searching for "python html to pdf" looks like it should do
> > what you want.
> >
> > Maybe for you, but not for the OP. Google will give different search
> > results depending on your location, nationality, IP address and previous
> > searches from that address.
> >
>
> At the risk of belaboring the point, I think what Timo was gentlying tryin

[Tutor] splitting the large file into small pieces and download

2012-01-26 Thread Arun Kumar
Hi all,

I want to build a small download accelerator program. I want to know how to
split the file to be downloaded into small pieces and assign the each small
piece to a thread for downloading.
-- 
Thanks & Regards,

Arun Kumar
http://clicknscroll.blogspot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 95, Issue 80

2012-01-30 Thread Arun Kumar
that works for both,
> -- next part --
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20120130/a5996b2a/attachment-0001.html
> >
>
> --
>
> Message: 6
> Date: Mon, 30 Jan 2012 11:55:12 +0530
> From: Ganesh Kumar 
> To: tutor@python.org
> Subject: [Tutor] Help Glade Tutorial.
> Message-ID:
> >
> Content-Type: text/plain; charset="utf-8"
>
> Hi Guys,
>
> I am searching for a Glade tutorial, on how to create simple projects Glade
> with python
>
> 1) design a simple interface in glade
> 2) use the glade interface to write some really simple application with
> python.
>
> I search in goggled i didn't get good tutorials, guide me guys How to start
> with Glade.
>
> -Ganesh
>
> Did I learn something today? If not, I wasted it.
> -- next part --
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20120130/fec2e0a2/attachment-0001.html
> >
>
> --
>
> Message: 7
> Date: Mon, 30 Jan 2012 00:51:58 -0600
> From: Chris Fuller 
> To: tutor@python.org
> Subject: Re: [Tutor] Help Glade Tutorial.
> Message-ID: <201201300051.58828.cfuller...@thinkingplanet.net>
> Content-Type: Text/Plain;  charset="utf-8"
>
>
> Which ones did you look at, and why did you not like them?  Keep in mind
> that
> Glade is an interface builder, and hasn't got anything much to do with the
> target language, other than requiring there be a libglade library to read
> the
> XML files.
>
> I actually got started with some articles in Linux Journal, which don't
> appear
> high on the google search unless you include those terms.  Search for
> "glade
> tutorial" or "glade linux journal".  Leave Python or pyGTK out of your
> search
> for now.
>
> You might need a little help with using the XML files glade produces, but
> that's covered in the pyGTK documentation.  It's also in the Linux Journal
> articles.  You can google "pygtk glade" if you need more.
>
> Cheers
>
> On Monday 30 January 2012, Ganesh Kumar wrote:
> > Hi Guys,
> >
> > I am searching for a Glade tutorial, on how to create simple projects
> Glade
> > with python
> >
> > 1) design a simple interface in glade
> > 2) use the glade interface to write some really simple application with
> > python.
> >
> > I search in goggled i didn't get good tutorials, guide me guys How to
> start
> > with Glade.
> >
> > -Ganesh
> >
> > Did I learn something today? If not, I wasted it.
>
>
>
> --
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 95, Issue 80
> *
>



-- 
Thanks & Regards,

Arun Kumar
http://clicknscroll.blogspot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] I need a good resource for python Django

2013-08-17 Thread Arun Kumar
Hi,

Can anyone suggest me a good resource for python Django. I've gone through
the official website of Django but it is of limited use to me. Any help on
this would be highly appreciated.

Regards,
Arun Kumar
http://clicknscroll.blogspot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] time.mktime(time.gmtime(time tuple from any timezone)) always will be the same ?

2007-07-13 Thread Arun Kumar PG

Guys,

May be a dumb question but I am a bit confused (may be coz working over 24
hours for the last couple days:)). so the question is:

No matter which timezone I am in if i say   time.gmtime(time.mktime((
datetime.date().timetuple( I will always get the same value. - right ?

thx for answering this dumbo question but i need a break!
--
Cheers,

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


[Tutor] Suggestions required on Gaming

2006-10-04 Thread Arun Kumar PG
Hi All Python lovers!I want to develop a Car racing game using Python. I was looking for the libraries which I should use for the same. Some of the options are below and I want you suggestions about the best set of tools and APIs as per your experiences:
- PyGame- Panda3D- Pixie for rendering- RenderMan- What else ?I will really appreciate if you guys could please let me know the right set of tools and APIs as per your experience.Thanks,
- Arun
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Suggestions required on Gaming

2006-10-04 Thread Arun Kumar PG
Thanks Luke.I want to make a 3-D car race game between two players. And yes its gonna  be a networked game where each user will be using his/her own PC and playing.- Arun
On 10/4/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
Arun Kumar PG wrote:> Hi All Python lovers!>>> I want to develop a Car racing game using Python. I was looking for> the libraries which I should use for the same. Some of the options are
> below and I want you suggestions about the best set of tools and APIs> as per your experiences:>> - PyGame> - Panda3D> - Pixie for rendering> - RenderMan> - What else ?
>> I will really appreciate if you guys could please let me know the> right set of tools and APIs as per your experience.Need more info.There are many types of car-racing games.Do you want it to be 3d, 2d? first-person, third-person, top-down, etc.
The correct tool is the one which does the specific job best.We don't know what the job is so we can't help you choose a tool.-Luke
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Suggestions required on Gaming

2006-10-04 Thread Arun Kumar PG
Also, my idea is to have a centralised Python server which acts as a dispachter to send the coordinate and other information to the gaming clients.On 10/4/06, 
Arun Kumar PG <[EMAIL PROTECTED]> wrote:
Thanks Luke.I want to make a 3-D car race game between two players. And yes its gonna  be a networked game where each user will be using his/her own PC and playing.- Arun

On 10/4/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:

Arun Kumar PG wrote:> Hi All Python lovers!>>> I want to develop a Car racing game using Python. I was looking for> the libraries which I should use for the same. Some of the options are
> below and I want you suggestions about the best set of tools and APIs> as per your experiences:>> - PyGame> - Panda3D> - Pixie for rendering> - RenderMan> - What else ?
>> I will really appreciate if you guys could please let me know the> right set of tools and APIs as per your experience.Need more info.There are many types of car-racing games.Do you want it to be 3d, 2d? first-person, third-person, top-down, etc.
The correct tool is the one which does the specific job best.We don't know what the job is so we can't help you choose a tool.-Luke


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


Re: [Tutor] Suggestions required on Gaming

2006-10-04 Thread Arun Kumar PG
Thanks Luke! This is helpful :)- ArunOn 10/4/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
Arun Kumar PG wrote:> Thanks Luke.>> I want to make a 3-D car race game between two players. And yes its
> gonna  be a networked game where each user will be using his/her own> PC and playing.If you want it to be 3d, you have a couple'o choices...Pygame with the PyopenGL interface,Panda3d,Soya,
PyOgre,and perhaps others.The only one I've used was Panda3d, and I didn't get very far, so Ican't comment on that.  I can say, though,I've played Disney's Toontown game, which is a 3d mmorpg made with
Panda3d, so yes, it's possible to make 3d networked games in Python :) >Also, my idea is to have a centralised Python server which acts as adispachter to send the coordinate and other information to the gaming
clients.For your networking, you'll probably want to use Twisted.HTH,-Luke>> - Arun>>> On 10/4/06, *Luke Paireepinart* <
[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:>> Arun Kumar PG wrote:> > Hi All Python lovers!> >
> >> > I want to develop a Car racing game using Python. I was looking for> > the libraries which I should use for the same. Some of the> options are> > below and I want you suggestions about the best set of tools and
> APIs> > as per your experiences:> >> > - PyGame> > - Panda3D> > - Pixie for rendering> > - RenderMan> > - What else ?
> >> > I will really appreciate if you guys could please let me know the> > right set of tools and APIs as per your experience.> Need more info.> There are many types of car-racing games.
> Do you want it to be 3d, 2d? first-person, third-person, top-down,> etc.> The correct tool is the one which does the specific job best.> We don't know what the job is so we can't help you choose a tool.
> -Luke>>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter and python

2006-10-08 Thread Arun Kumar PG
Hi,You can try:>> import sys>> sys.path.append('')>> import Or else you can append the path to global PYTHONPATH environment variable and whenever you will type:
python  on the command prompt/bash shell the script gets executed.Hope that helps.Thanks,- Arun
On 10/8/06, max . <[EMAIL PROTECTED]> wrote:
first off i just started looking for Tkinter tutorials but havent found muchand what i have found was not very good if anyone knows og any Tkintertutorials pleas let me knowsecond is thair anyway to change the path that python looks for a program in
ex: if i enter python hello into the command line then i get this error/Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/Python:can't open file 'hello1': [Errno 2] No such file or directory
can i chage that search path?if so how?thx^_^"  s33 y4_Search—Your way, your world, right now!
http://imagine-windowslive.com/minisites/searchlaunch/?locale=en-us&FORM=WLMTAG___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] Tkinter and python

2006-10-08 Thread Arun Kumar PG
> python  on the command prompt/bash shell the script gets> executed.Hey Dave,Thanks for correcting me. I should read what I am writing before I hit the send button :). It was a stupid mistake.. 
Appending path to PYTHONPATH will allow us to import the module in some other Python script without requiring us to do sys.path.apend(). To execute the script from bash what Dave suggests is correct.Also, if you don't want to append path to PYTHONPATH you can also place the module under site-packages directory under Python home directory.
Thanks,- AOn 10/8/06, Dave Kuhlman <[EMAIL PROTECTED]> wrote:
On Sun, Oct 08, 2006 at 08:36:31PM +0530, Arun Kumar PG wrote:> Hi,>> You can try:>> >>import sys> >>sys.path.append('')> >>import <
module.py>>> Or else you can append the path to global PYTHONPATH environment variable> and whenever you will type:>> python  on the command prompt/bash shell the script gets
> executed.>Not true, if I understand you correctly.  PYTHONPATH affects wherePython looks for modules to be imported.  But if I type thefollowing at the command line:$ python mymodule.py
it is the shell (in my case bash) that looks for mymodule.py, notPython.  It analogous to my typing:$ vi mymodule.pyor (trying to avoid a fight between vi and emacs fanatics):$ emacs 
mymodule.pyNeither vi nor emacs try to find mymodule.py; the (bash or other)shell does.So perhaps a solution to the problem is to make mymodule.pyexecutable and put it somewhere on your path.  Then execute it by
typing at the command line:$ mymodule.pyNow the shell will run it just like any other executable script andit will use Python as the interpreter for that script.How you make the script executable probably depends on which shell
you are using.  For bash, you could do the following:1. Insert the following line as the first line of your script:   #!/usr/bin/env python2. Change the priveleges of the script to make it executable.
   Example:   $ chmod u+x mymodule.py3. Put mymodule.py on your path, that is, in a directory that is in   your PATH environment variable.  Alternatively, add the path to   the directory containing 
mymodule.py to your PATH environment   variable.Dave--Dave Kuhlmanhttp://www.rexx.com/~dkuhlman___
Tutor maillist  -  Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Writing serialized objects from BaseHTTPServer

2006-10-19 Thread Arun Kumar PG
Hi Guys,I wrote a simple server using sockets ,the traditional whille True: scoket.accept() approach. This server reads some pickled parameters sent by the client using the cPickle module -> do some processing -> and finally writes a list of tuples, objects using cPickle back to the client output stream (
cPickle.dump).Now I want to replace this server with an HTTP server. Python's BaseHTTPServer basically. I was wondering when using BaseHTTPServer if I want to read/write a serialized object to meet the above behavior how could I achive this using HTTP server ? We need a content-type to specify before writing back to the client -- whats the content-type for serialised objects which I want to write back to the client using cPickle ?
Thanks.Arun
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Writing serialized objects from BaseHTTPServer

2006-10-24 Thread Arun Kumar PG
any replies for the below ?
On 10/19/06, Arun Kumar PG <[EMAIL PROTECTED]> wrote:
Hi Guys,I wrote a simple server using sockets ,the traditional whille True: scoket.accept() approach. This server reads some pickled parameters sent by the client using the cPickle module -> do some processing -> and finally writes a list of tuples, objects using cPickle back to the client output stream ( 
cPickle.dump).Now I want to replace this server with an HTTP server. Python's BaseHTTPServer basically. I was wondering when using BaseHTTPServer if I want to read/write a serialized object to meet the above behavior how could I achive this using HTTP server ? We need a content-type to specify before writing back to the client -- whats the content-type for serialised objects which I want to write back to the client using cPickle ? 
Thanks.Arun
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Good book for python

2007-01-04 Thread Arun Kumar PG

"Python in a nutshell" is a good one. Also Python docs are the all time
favorite.

On 1/4/07, deepak shingan <[EMAIL PROTECTED]> wrote:


Hi Folks,

I am new in Python area and want to know Python concepts with more
deatils.
Please suggest some good books on python.


Thanks in Advance
-Deepak


  **




__
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] threading.currentThread() always same across request ?

2007-04-13 Thread Arun Kumar PG

Guys,

I have a web application and I want to store an object per request so thta
that is available across all classes till end of request.

I am planning  to write the below code in my entry program which is executed
as soon as a request comes:

entry.py
 import threading

 th = threading.currentThread()
 th.service = somemod.Service()

then in other parts of program whereever I want to use service:

 th = threading.currentThread()
 if hasattr(th, 'service'):
   th.service.call_whatever()

I am wondering if I will ever face a problem in this case ? I want to make
sure that since the request till the end the same "service" object is
available and it should not collide with any other request. Since it's a web
application multilple request may come simutaneously.

Is this approach correct ?
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] threading.currentThread() always same across request ?

2007-04-14 Thread Arun Kumar PG

Thx guys.

now quick question on the usage of thread local storage.

In my case I have the below object model:

class Base(object):'
 def __init__(self):
   self.__service = None
 def _GetService():
   if not hasattr(threading.currentThread(), 'service'):
 threading.currentThread().service = Service()
 self.__service =  threading.currentThread().service

   return self.__service

class Child1(Base):'
 def DoSomething():
   service = self._GetService()
   # use service

class Child2(Base):'
 def DoSomething():
   service = self._GetService()
   # use service

The above Child classes are used by a controller:

class Controller(object):
 def process(self):
   c1 = Child1()
   c1.DoSomething()
   
   ...
   c2 = Child2()
   c2.DoSomething()

Using the above technique the "service" is instantiated only one time i.e.
as soon as I create the first instance of the Child class abd associated
with the current thread for future instantiation of any Child class.

Now in this scenario how can I use thread local ? Where do I keep the thread
local object as in my case I am instantiating the Child classes ? Using
currentThread() always gives me the same thread instance for a given request
and I can bypass instantiating the Service class by simply returning the
"service" attribute already attached to the current thread.

Any suggestion appreciated!

- A






On 4/15/07, Kent Johnson <[EMAIL PROTECTED]> wrote:


Andreas Kostyrka wrote:
> * Kent Johnson <[EMAIL PROTECTED]> [070414 19:53]:
>> That's a good point. Does anyone know when to prefer threading.local()
>> vs thread attributes?
> It's design question, I guess:
>
> *) if you have thread subclasses, then use thread attributes.
> *) if you have standard threads, then use thread.local().
>
> The idea is, that it's "rude" to stick attributes on an object that is
> not owned by you.
>
> Rationale:
> *) Somebody might decide to make threading.Thread be a new style
> object with __slots__ => your code breaks.
>
> I know, it's unprobably, but if you derive a subclass, you can be at
> least sure that the object will have a __dict__ ;)

If you use threading.local() you can be sure the names you use don't
conflict with any attributes of the thread.

Kent
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor