Re: [Tutor] Starting python from a DOS prompt from any directory?

2007-01-02 Thread Mark Wilkinson

I think this will answer your question:
 
http://www.python.org/doc/faq/windows.html#how-do-i-run-a-python-program
-under-windows
 
Mark
This email and any attachment may contain confidential, privileged information 
for the sole use of the intended recipient. If you are not the intended 
recipient, do not disclose, reproduce, disseminate or otherwise use this 
communication. If you received this communication in error, please immediately 
notify the sender via email and delete the communication from your system.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Starting python from a DOS prompt from any directory?

2007-01-02 Thread Steve Oldner
Sorry for the delay, and the confusion.
 
C and D are the local PC dir, where C has the network and mandatory programs 
installed.  D is my working DIR.  SO PYTHON is installed locally for me.   



From: [EMAIL PROTECTED] on behalf of Bob Gailer
Sent: Mon 1/1/2007 4:11 PM
To: Alan Gauld
Cc: tutor@python.org
Subject: Re: [Tutor] Starting python from a DOS prompt from any directory?



Alan Gauld wrote:
> "Steve Oldner" <[EMAIL PROTECTED]> wrote
>  
>> Alan, I work for a state government, so I'm not suppose to
>> download PYTHON without submitting reasons and
>> getting permissions.  
>>
>
> Sure I understand that, but it looks from your post that
> you have somehow managed to install Python.
As I recall Steve said at the beginning that he ran Python from a
network drive.
> If your
> account has permissions to install any software then
> you probably have permissions to set at least USER
> level Environmenent Variables (You may not be able to
> set them at SYSTEM level)
>
>  
>> I'm an applications programmer working on SAP
>>
>
> I know the kind of set up, we have similar teams of
> folks working on Siebel and Oracle.
>
> Alan G.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>  


--
Bob Gailer
510-978-4454

___
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] Need help with rewriting script to use Decimal module

2007-01-02 Thread Dick Moores
from decimal import Decimal as D

def bestFracForMinimumError(decimal, minimumError):
 denom = 0
 while True:
 denom += 1
 num = round(D(str(decimal)) * D(str(denom)))
 error = abs(str((str(D(num) / D(str(denom))) - 
D(str(decimal))) / str(D(str(decimal)) * d("100"
 if error <= D(minimumError):
 break
 return int(num), D(denom), error

dec = D(".34576598876876867756765765")

me = D(".0001")

print bestFracForMinimumError(dec, me)


Traceback (most recent call last):
   File "fracSimple2-c.py", line 17, in 
 print bestFracForMinimumError(dec, me)
   File "fracSimple2-c.py", line 8, in bestFracForMinimumError
 error = abs(str((str(D(num) / D(str(denom))) - D(str(decimal))) 
/ str(D(str(
decimal)) * d("100"
   File "E:\Python25\lib\decimal.py", line 578, in __new__
 "First convert the float to a string")
TypeError: Cannot convert float to Decimal.  First convert the float 
to a string

I don't understand this TypeError. Seems to me that I've converted 
EVERYTHING in that line 8 to a string.

Dick

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


[Tutor] Encoding and Decoding

2007-01-02 Thread Carlos
Hello,

I have been having problems to solve a situation in which I need to 
encode and decode information, hope that someone can give me a hand. The 
solution for this problem has gone thru many iterations, but I recently 
found that the long (for me) is the only one.

As you might remember Im working with some elements, for example:

ELEMENTS = [{'Name': 'Access', 'Parent': 'Plot', 'Level': 1.0, 'Height': 
3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Circulation_01', 'Parent': 
'Access', 'Level': 1.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Circulation_02', 'Parent': 
'Access', 'Level': 2.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Circulation_03', 'Parent': 
'Access', 'Level': 3.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Int_Circ_01', 'Parent': 
'Circulation_01', 'Level': 1.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Int_Circ_02', 'Parent': 
'Circulation_01', 'Level': 1.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Int_Circ_03', 'Parent': 
'Circulation_02', 'Level': 2.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Int_Circ_04', 'Parent': 
'Circulation_02', 'Level': 2.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Int_Circ_05', 'Parent': 
'Circulation_03', 'Level': 3.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0},
{'Name': 'Int_Circ_06', 'Parent': 
'Circulation_03', 'Level': 3.0, 'Height': 3.0, 'Width': 3.0, 'Depth': 3.0}
 ]

The genetic algorithm that Im using (GA) generates solutions for a given 
problem, expressed in a list, this list is composed by integers. Every 
element in the list takes 8 integers, is a little messy but this is because

List [0] = Tens X position
List [1] = Units X position
List [2] = Decimals X position
List [3] = If < than 5 the number is negative, else is positive

Then if the result is List = [6, 1, 2, 3] the X position equals -612.3. 
This is the same for the Y position. If there are 10 elements the list 
is going to be 80 integers long and if there are 100 elements, well you 
get a very long list...

With this in mind my question would be, how can I keep track of this 
information? I mean how can I assign this List positions to each 
element? This is needed because this is going to be a long list and the 
GA needs to evaluate the position of each element with respect to the 
position of the other elements. So it needs to know that certain numbers 
are related to certain element and it needs to have access to the size, 
level, name and parent information... I hope that this is clear enough.

Thanks in advance,
Carlos






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


Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-02 Thread Kent Johnson
Dick Moores wrote:
> from decimal import Decimal as D
> 
> def bestFracForMinimumError(decimal, minimumError):
>  denom = 0
>  while True:
>  denom += 1
>  num = round(D(str(decimal)) * D(str(denom)))
>  error = abs(str((str(D(num) / D(str(denom))) - 
This looks backwards^^

Don't you need D(str(num)) ? Then converting it back to a str before you 
call abs will not work.

Your old approach of
def D(num):
   return Decimal(str(num))

would probably make for more readable code and fewer errors.

I'm not sure this approach will work, though, if you are trying to get 
higher precision, I would think you would have to do all the 
calculations in Decimal, not going to floats for num. I admit I haven't 
thought it through, though. I think you can use Decimal.quantize() 
instead of round().

HTH
Kent

> D(str(decimal))) / str(D(str(decimal)) * d("100"
>  if error <= D(minimumError):
>  break
>  return int(num), D(denom), error
> 
> dec = D(".34576598876876867756765765")
> 
> me = D(".0001")
> 
> print bestFracForMinimumError(dec, me)
> 
> 
> Traceback (most recent call last):
>File "fracSimple2-c.py", line 17, in 
>  print bestFracForMinimumError(dec, me)
>File "fracSimple2-c.py", line 8, in bestFracForMinimumError
>  error = abs(str((str(D(num) / D(str(denom))) - D(str(decimal))) 
> / str(D(str(
> decimal)) * d("100"
>File "E:\Python25\lib\decimal.py", line 578, in __new__
>  "First convert the float to a string")
> TypeError: Cannot convert float to Decimal.  First convert the float 
> to a string
> 
> I don't understand this TypeError. Seems to me that I've converted 
> EVERYTHING in that line 8 to a string.
> 
> Dick
> 
> ___
> 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] Encoding and Decoding

2007-01-02 Thread Kent Johnson
Carlos wrote:

> The genetic algorithm that Im using (GA) generates solutions for a given 
> problem, expressed in a list, this list is composed by integers. Every 
> element in the list takes 8 integers, is a little messy but this is because
> 
> List [0] = Tens X position
> List [1] = Units X position
> List [2] = Decimals X position
> List [3] = If < than 5 the number is negative, else is positive
> 
> Then if the result is List = [6, 1, 2, 3] the X position equals -612.3. 
> This is the same for the Y position. If there are 10 elements the list 
> is going to be 80 integers long and if there are 100 elements, well you 
> get a very long list...
> 
> With this in mind my question would be, how can I keep track of this 
> information? I mean how can I assign this List positions to each 
> element? This is needed because this is going to be a long list and the 
> GA needs to evaluate the position of each element with respect to the 
> position of the other elements. So it needs to know that certain numbers 
> are related to certain element and it needs to have access to the size, 
> level, name and parent information... I hope that this is clear enough.

I will assume there is a good reason for storing the coordinates in this 
form...

Do the numbers have to be all in a single list? I would start by 
breaking it up into lists of four, so if you have 10 elements you would 
have a list of 20 small lists. It might make sense to pair the x and y 
lists so you have a list of 10 lists of 2 lists of 4 numbers, e.g.
[ [ [6, 1, 2, 3], [7, 2, 8, 4] ], ...]

Another thing to consider is whether you might want to make a class to 
hold the coordinate values, then you could refer to x.tens, x.units, 
x.decimal, x.sign by name.

If you need a single list for the GA to work, one alternative would be 
to make converters between the nested representation and the flat one. 
Alternately you could wrap the list in a class which provides helpful 
accessors.

HTH
Kent

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


Re: [Tutor] Encoding and Decoding

2007-01-02 Thread Carlos
Hi Kent,

I have yet to get into OO, and the GA that I'm using was done in this 
way, so I can't mess with it that much. So for now yes, the list has to 
be a flat element containing all this info.

I have been reading about OO lately and a element class seems to be a 
good idea, I'm working on it now, but I still don't get OO very well. My 
initial idea is that a loop could iterate over the element list and 
create objects with the needed parameters and hooks to the list that 
link to the correct list locations.

Could you elaborate on the converters and the class that wraps the list???

Thanks




Kent Johnson wrote:
> I will assume there is a good reason for storing the coordinates in 
> this form...
>
> Do the numbers have to be all in a single list? I would start by 
> breaking it up into lists of four, so if you have 10 elements you 
> would have a list of 20 small lists. It might make sense to pair the x 
> and y lists so you have a list of 10 lists of 2 lists of 4 numbers, e.g.
> [ [ [6, 1, 2, 3], [7, 2, 8, 4] ], ...]
>
> Another thing to consider is whether you might want to make a class to 
> hold the coordinate values, then you could refer to x.tens, x.units, 
> x.decimal, x.sign by name.
>
> If you need a single list for the GA to work, one alternative would be 
> to make converters between the nested representation and the flat one. 
> Alternately you could wrap the list in a class which provides helpful 
> accessors.
>
> HTH
> Kent
>
>

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


Re: [Tutor] Encoding and Decoding

2007-01-02 Thread Kent Johnson
Carlos wrote:
> Hi Kent,
> 
> I have yet to get into OO, and the GA that I'm using was done in this 
> way, so I can't mess with it that much. So for now yes, the list has to 
> be a flat element containing all this info.
> 
> I have been reading about OO lately and a element class seems to be a 
> good idea, I'm working on it now, but I still don't get OO very well. My 
> initial idea is that a loop could iterate over the element list and 
> create objects with the needed parameters and hooks to the list that 
> link to the correct list locations.
> 
> Could you elaborate on the converters and the class that wraps the list???

OK, off the top of my head (not tested) here are some things to get you 
started.

You could write a function that would retrieve a coordinate value given 
an index number, for example:
def getCoord(data, ix):
   base = ix*4
   value = data[ix]*10 + data[ix+1] + data[ix+2]/10.0
   if data[ix+3] < 5:
 value = -value
   return value

Now if data is your big list, you can write getCoord(data, 5) to get the 
value stored at data[20] to data[23]. Similarly you could write a setter 
and maybe a getXY() function that returns a pair (x, y). So that is a 
place to start.

If you want to avoid passing the list around it might make sense to make 
a class to hold it. Then you would have something like
class Data(object):
   def __init__(self, lst):
 self.data = lst

   def getCoord(self, ix):
 base = ix*4
 value = self.data[ix]*10 + self.data[ix+1] + self.data[ix+2]/10.0
 if self.data[ix+3] < 5:
   value = -value
 return value

Now you can create a Data object from a list of values and ask it for 
values:
d = Data()
d.getCoord(5)

I'm not sure this is much improvement over passing around the list, 
actually; you still have to pass around the Data object...it might just 
be a matter of taste.

HTH,
Kent

> 
> Thanks
> 
> 
> 
> 
> Kent Johnson wrote:
>> I will assume there is a good reason for storing the coordinates in 
>> this form...
>>
>> Do the numbers have to be all in a single list? I would start by 
>> breaking it up into lists of four, so if you have 10 elements you 
>> would have a list of 20 small lists. It might make sense to pair the x 
>> and y lists so you have a list of 10 lists of 2 lists of 4 numbers, e.g.
>> [ [ [6, 1, 2, 3], [7, 2, 8, 4] ], ...]
>>
>> Another thing to consider is whether you might want to make a class to 
>> hold the coordinate values, then you could refer to x.tens, x.units, 
>> x.decimal, x.sign by name.
>>
>> If you need a single list for the GA to work, one alternative would be 
>> to make converters between the nested representation and the flat one. 
>> Alternately you could wrap the list in a class which provides helpful 
>> accessors.
>>
>> HTH
>> Kent
>>
>>
> 
> ___
> 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] basic python question/getting values

2007-01-02 Thread Joe M
I apologize in advanced as I know this is basic information, but I cannot 
seem to figure it.

I have a few scripts that will return a value ie here I am testing to see 
if a database is alive (script is called dbping.py):

def db_alive():
dbRunning = '0'
try:
con = pg.connect(dbname='xxx', host='localhost', user 
='xxx',port = xxx)
pass
except pg.InternalError:
dbRunning = '1'
return dbRunning

This should return a value of 1 if the db is not running else it will 
return a value of 0.

Ok, now I want to call this from another script and have it write 
to a file with the return value (and other values to be added later, but 
right now all I am interested in in getting the return values)

I tried this sort of thing but it doesn't work (I will be writing to a 
file later, but right now getting it to print the value of dbRunning would 
be nice)

import dbping
l = dbping.db_run(db_run.dbRunning)
print l

NameError: name 'db_run' is not defined

Thanks for any pointers

[EMAIL PROTECTED]
SDF Public Access UNIX System - http://sdf.lonestar.org
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python cx_Oracle.LOB

2007-01-02 Thread Jalil

I am trying to fetch a CLOB datatype with with cx_Oracle and I can seem to
get it to work.



I was able to fetch the text from the db with sql commands  but i can fetch
in a python code.

I get this output.

[(,)]

when I run my code.

any way to find out how to go around this?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] basic python question/getting values

2007-01-02 Thread Kent Johnson
Joe M wrote:
> I have a few scripts that will return a value ie here I am testing to see 
> if a database is alive (script is called dbping.py):
> 
> def db_alive():
>   dbRunning = '0'
>   try:
>   con = pg.connect(dbname='xxx', host='localhost', user 
> ='xxx',port = xxx)
>   pass
>   except pg.InternalError:
>   dbRunning = '1'
>   return dbRunning
> 
> This should return a value of 1 if the db is not running else it will 
> return a value of 0.
> 
> Ok, now I want to call this from another script and have it write 
> to a file with the return value (and other values to be added later, but 
> right now all I am interested in in getting the return values)
> 
> I tried this sort of thing but it doesn't work (I will be writing to a 
> file later, but right now getting it to print the value of dbRunning would 
> be nice)
> 
> import dbping
> l = dbping.db_run(db_run.dbRunning)
> print l
> 
> NameError: name 'db_run' is not defined

What is db_run? What happens if you try
l = dbping.db_alive()

??

Kent

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


Re: [Tutor] Encoding and Decoding

2007-01-02 Thread Carlos

Kent,

Will give this a try.

Thanks for your help,
Carlos


Kent Johnson wrote:
> OK, off the top of my head (not tested) here are some things to get 
> you started.
>
> You could write a function that would retrieve a coordinate value 
> given an index number, for example:
> def getCoord(data, ix):
>   base = ix*4
>   value = data[ix]*10 + data[ix+1] + data[ix+2]/10.0
>   if data[ix+3] < 5:
> value = -value
>   return value
>
> Now if data is your big list, you can write getCoord(data, 5) to get 
> the value stored at data[20] to data[23]. Similarly you could write a 
> setter and maybe a getXY() function that returns a pair (x, y). So 
> that is a place to start.
>
> If you want to avoid passing the list around it might make sense to 
> make a class to hold it. Then you would have something like
> class Data(object):
>   def __init__(self, lst):
> self.data = lst
>
>   def getCoord(self, ix):
> base = ix*4
> value = self.data[ix]*10 + self.data[ix+1] + self.data[ix+2]/10.0
> if self.data[ix+3] < 5:
>   value = -value
> return value
>
> Now you can create a Data object from a list of values and ask it for 
> values:
> d = Data()
> d.getCoord(5)
>
> I'm not sure this is much improvement over passing around the list, 
> actually; you still have to pass around the Data object...it might 
> just be a matter of taste.
>
> HTH,
> Kent

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


Re: [Tutor] basic python question/getting values

2007-01-02 Thread Joe M
Thanks. I appreciate the quick response. I am going to kick myself for 
this one ;)

On Tue, 2 Jan 2007, Asrarahmed Kadri wrote:

> Date: Tue, 2 Jan 2007 19:38:04 +
> From: Asrarahmed Kadri <[EMAIL PROTECTED]>
> To: Joe M <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] basic python question/getting values
> 
> Hey, the call should be:
> dbping.db_alive()
> and not dbping.db_run()
>
> HTH,
> Regards,
> Asrarahmed
>
>
> On 1/2/07, Joe M <[EMAIL PROTECTED]> wrote:
>> 
>> I apologize in advanced as I know this is basic information, but I cannot
>> seem to figure it.
>> 
>> I have a few scripts that will return a value ie here I am testing to see
>> if a database is alive (script is called dbping.py):
>> 
>> def db_alive():
>> dbRunning = '0'
>> try:
>> con = pg.connect(dbname='xxx', host='localhost', user
>> ='xxx',port = xxx)
>> pass
>> except pg.InternalError:
>> dbRunning = '1'
>> return dbRunning
>> 
>> This should return a value of 1 if the db is not running else it will
>> return a value of 0.
>> 
>> Ok, now I want to call this from another script and have it write
>> to a file with the return value (and other values to be added later, but
>> right now all I am interested in in getting the return values)
>> 
>> I tried this sort of thing but it doesn't work (I will be writing to a
>> file later, but right now getting it to print the value of dbRunning would
>> be nice)
>> 
>> import dbping
>> l = dbping.db_run(db_run.dbRunning)
>> print l
>> 
>> NameError: name 'db_run' is not defined
>> 
>> Thanks for any pointers
>> 
>> [EMAIL PROTECTED]
>> SDF Public Access UNIX System - http://sdf.lonestar.org
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>> 
>
>
>
> -- 
> To HIM you shall return.
>

[EMAIL PROTECTED]
SDF Public Access UNIX System - http://sdf.lonestar.org
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python cx_Oracle.LOB

2007-01-02 Thread Jason Massey

An example of your code would help. According to the cx_oracle docs at
http://www.python.net/crew/atuining/cx_Oracle/html/index.html under the LOB
Objects heading:

6. LOB Objects

*NOTE*: This object is an extension the DB API. It is returned whenever
Oracle CLOB, BLOB and BFILE columns are fetched.

*NOTE*: Internally, Oracle uses LOB locators which are allocated based on
the cursor array size. Thus, it is important that the data in the LOB object
be manipulated before another internal fetch takes place. The safest way to
do this is to use the cursor as an iterator. In particular, do not use the
fetchall() method. The exception "LOB variable no longer valid after
subsequent fetch" will be raised if an attempt to access a LOB variable
after a subsequent fetch is detected.

*fileexists*( ) Return a boolean indicating if the file referenced by the
BFILE type LOB exists.

*getfilename*( ) Return a two-tuple consisting of the directory alias and
file name for a BFILE type LOB.

*read*( [offset = 1, [amount]]) Return a portion (or all) of the data in
the LOB object.

*setfilename*( dirAlias, name) Set the directory alias and name of the
BFILE type LOB.

*size*( ) Returns the size of the data in the LOB object.

*trim*( [newSize = 0]) Trim the LOB to the new size.

*write*( data, [offset = 1]) Write the data to the LOB object at the given
offset. Note that if you want to make the LOB value smaller, you must use
the trim() function.
I'd try the read method on your object.

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


I am trying to fetch a CLOB datatype with with cx_Oracle and I can seem to
get it to work.



I was able to fetch the text from the db with sql commands  but i can
fetch in a python code.

I get this output.

[(,)]

when I run my code.

any way to find out how to go around this?


___
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] python cx_Oracle.LOB

2007-01-02 Thread Jalil

Thanks Jason,
here is my code



import cx_Oracle

db = cx_Oracle.connect('xx','x','')
cursor=db.cursor()
#cursor.execute('set long 5000')
#sqlen="""set long 5000"""
#cursor.execute(sqlen)
sqtext="""select TExt from sq_updates where action_id= '851151'"""
cursor.execute(sqtext)
rettext = cursor.fetchmany()

print rettext



On 1/2/07, Jason Massey <[EMAIL PROTECTED]> wrote:


An example of your code would help. According to the cx_oracle docs at
http://www.python.net/crew/atuining/cx_Oracle/html/index.html under the
LOB Objects heading:

6. LOB Objects

*NOTE*: This object is an extension the DB API. It is returned whenever
Oracle CLOB, BLOB and BFILE columns are fetched.

*NOTE*: Internally, Oracle uses LOB locators which are allocated based on
the cursor array size. Thus, it is important that the data in the LOB object
be manipulated before another internal fetch takes place. The safest way to
do this is to use the cursor as an iterator. In particular, do not use the
fetchall() method. The exception "LOB variable no longer valid after
subsequent fetch" will be raised if an attempt to access a LOB variable
after a subsequent fetch is detected.

 *fileexists*( ) Return a boolean indicating if the file referenced by the
BFILE type LOB exists.

 *getfilename*( ) Return a two-tuple consisting of the directory alias and
file name for a BFILE type LOB.

 *read*( [offset = 1, [amount]]) Return a portion (or all) of the data in
the LOB object.

 *setfilename*( dirAlias, name) Set the directory alias and name of the
BFILE type LOB.

 *size*( ) Returns the size of the data in the LOB object.

 *trim*( [newSize = 0]) Trim the LOB to the new size.

 *write*( data, [offset = 1]) Write the data to the LOB object at the
given offset. Note that if you want to make the LOB value smaller, you must
use the trim() function.
I'd try the read method on your object.

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

> I am trying to fetch a CLOB datatype with with cx_Oracle and I can seem
> to get it to work.
>
>
>
> I was able to fetch the text from the db with sql commands  but i can
> fetch in a python code.
>
> I get this output.
>
> [(,)]
>
> when I run my code.
>
> any way to find out how to go around this?
>
>
> ___
> 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] Need help with rewriting script to use Decimal module

2007-01-02 Thread Terry Carroll
On Mon, 1 Jan 2007, Dick Moores wrote:

> bestFracForMinimumError() is only a small part of a program I wrote 
> long ago, called frac.py 

Dick, if your goal is to have a routine to get the fraction with the least 
possible error (as opposed to learing how to use Decimal), have a look at 
this recipe from the Python Cookbook:

 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317

> dec = .345765988765560057657654654
> me = .01
> num, denom, error = bestFracForMinimumError(dec, me)
> print "%f = %d/%d with %f per cent error" % (dec, num, denom, error)

The parameters are different from yours, but as I understand it, your 
equivalent is:

>>> dec = .345765988765560057657654654
>>> me = .01
>>> max_denom = 1/me
>>> (num, denom) = farey(dec,max_denom)
>>> error = abs((num/denom) - dec) *100
>>> print "%f = %d/%d with %f per cent error" % (dec, num, denom, error)
0.345766 = 40258524/116432863 with 0.00 per cent error
>>>

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


Re: [Tutor] basic python question/getting values

2007-01-02 Thread Carroll, Barry
Joe:

See below:

> -Original Message-
> Date: Tue, 2 Jan 2007 19:16:33 + (UTC)
> From: Joe M <[EMAIL PROTECTED]>
> Subject: [Tutor] basic python question/getting values
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
> 
> I apologize in advanced as I know this is basic information, but I
cannot
> seem to figure it.
> 
> I have a few scripts that will return a value ie here I am testing to
see
> if a database is alive (script is called dbping.py):
> 
> def db_alive():
>   dbRunning = '0'
>   try:
>   con = pg.connect(dbname='xxx', host='localhost', user
> ='xxx',port = xxx)
>   pass
>   except pg.InternalError:
>   dbRunning = '1'
>   return dbRunning
> 
<>
> 
> import dbping
> l = dbping.db_run(db_run.dbRunning) # 
> print l
> 
> NameError: name 'db_run' is not defined

You are not calling the function you defined. The name and number of
parameters are both wrong.  To match your function definition, your
assignment should be:

>>> l = dbping.db_alive()

Note, also, that the "pass" statement in dbping.db_alive will cause a
syntax error.  "pass" is only used when a code block is required but has
no executable statements.  For example:

>>> intval = 0
.
.
.
try:
intval = int(strval)
except ValueError:
pass
# strval is not a valid string representation of an integer.
# intval remains 0.
# Suppress the error and continue the program.  


> 
> Thanks for any pointers
> 
> [EMAIL PROTECTED]
> SDF Public Access UNIX System - http://sdf.lonestar.org
> 

HTH.

Regards,
 
Barry
[EMAIL PROTECTED]
541-302-1107

We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed



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


Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-02 Thread Terry Carroll
On Tue, 2 Jan 2007, Terry Carroll wrote:

> Dick, if your goal is to have a routine to get the fraction with the least 
> possible error (as opposed to learing how to use Decimal), have a look at 
> this recipe from the Python Cookbook:
> 
>  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317

BTW, to get the higher precision in Decimal:

import decimal

def farey(v, lim):
  '''Named after James Farey, an English surveyor.
  No error checking on args -- lim = max denominator,
  results are (numerator, denominator), (1,0) is infinity
  '''
  if v < 0:
n,d = farey(-v, lim)
return int(-n),int(d)
  z = lim-lim   # get 0 of right type for denominator
  lower, upper = (z,z+1), (z+1,z)
  while 1:
mediant = (lower[0] + upper[0]), (lower[1]+upper[1])
if v * mediant[1] > mediant[0]:
if lim < mediant[1]: return (int(upper[0]), int(upper[1]))
lower = mediant
elif v * mediant[1] == mediant[0]:
if lim >= mediant[1]: return (int(mediant[0]), int(mediant[1]))
if lower[1] < upper[1]: return (int(lower[0]), int(lower[1]))
return (int(upper[0]), int(upper[1]))
else:
if lim < mediant[1]: return lower
upper = mediant

dec = decimal.Decimal("0.345765988765560057657654654")
me = decimal.Decimal("0.01")
max_denom = 1/me

(num, denom) = farey(dec,max_denom)
error = abs(decimal.Decimal(str(float(num)/denom)) - dec) *100
print "%s = %d/%d with %s per cent error" % (dec, num, denom, error)


Which gives:

0.345765988765560057657654654 = 878844001/2541730620 with 
4.3994234234534600E-11 per cent error

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


[Tutor] simple animation

2007-01-02 Thread Ketan Maheshwari
Hi All

I want to create a simple animation on a 2D cartesian plane, wherein 
there are 2 identical circles drawn at an arbitrary distance with each 
other.
Now the idea is to move the circles randomly with a fixed step size and 
check the distance between their centers. this uses the formula
d=sqrt((x2-x1)**2+(y2-y1)**2). When this distance becomes same as 
2*radius, the circles are considered to be tangential.
Is it possible to show this scenario as an animation sequence and 
capturing the coordinates of the centers of the circles at each step and 
stopping the iteration when they get tangential.

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


Re: [Tutor] simple animation

2007-01-02 Thread Christopher Arndt
Ketan Maheshwari schrieb:
> Is it possible to show this scenario as an animation sequence and 
> capturing the coordinates of the centers of the circles at each step and 
> stopping the iteration when they get tangential.

Have a look at the PyGame library: http://pygame.org

Don't be put off be the name, it's actually rather a 2D/3D animation and
multimedia library than something specific to games. Have a look at the
tutorials on the site too:

http://pygame.org/wiki/tutorials

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


Re: [Tutor] simple animation

2007-01-02 Thread Kent Johnson
Ketan Maheshwari wrote:
> Hi All
> 
> I want to create a simple animation on a 2D cartesian plane, wherein 
> there are 2 identical circles drawn at an arbitrary distance with each 
> other.

Here is a simple animation written in Tkinter that might get you started:

http://effbot.org/zone/tkinter-animation.htm

Kent

> Now the idea is to move the circles randomly with a fixed step size and 
> check the distance between their centers. this uses the formula
> d=sqrt((x2-x1)**2+(y2-y1)**2). When this distance becomes same as 
> 2*radius, the circles are considered to be tangential.
> Is it possible to show this scenario as an animation sequence and 
> capturing the coordinates of the centers of the circles at each step and 
> stopping the iteration when they get tangential.
> 
> Thanks.
> k.
> ___
> 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] simple animation

2007-01-02 Thread Ketan Maheshwari
That helps.
Thanks.

Kent Johnson wrote:
> Ketan Maheshwari wrote:
>> Hi All
>>
>> I want to create a simple animation on a 2D cartesian plane, wherein 
>> there are 2 identical circles drawn at an arbitrary distance with 
>> each other.
>
> Here is a simple animation written in Tkinter that might get you started:
>
> http://effbot.org/zone/tkinter-animation.htm
>
> Kent
>
>> Now the idea is to move the circles randomly with a fixed step size 
>> and check the distance between their centers. this uses the formula
>> d=sqrt((x2-x1)**2+(y2-y1)**2). When this distance becomes same as 
>> 2*radius, the circles are considered to be tangential.
>> Is it possible to show this scenario as an animation sequence and 
>> capturing the coordinates of the centers of the circles at each step 
>> and stopping the iteration when they get tangential.
>>
>> Thanks.
>> k.
>> ___
>> 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] mod_python

2007-01-02 Thread Jalil

I was just wondering if anyone know of a any good site with examples of
mod_python tutorial.
the mod_python manual assume isnt really that helpful.

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


Re: [Tutor] SPE - Stani's Python Editor ?

2007-01-02 Thread Chris Hengge

I've recently started playing with Eclipse and the two PyDev plugin's over
the holidays. I'm seriously liking it... but my likes are more closely
related to Visual Studio as an editor, so this is like the perfect
environment for me..

http://www.showmedo.com/videos/series?name=PyDevEclipseList

This link shows you two video's on how pydev works, and how to setup.

On 12/31/06, Dick Moores <[EMAIL PROTECTED]> wrote:


 At 04:48 PM 12/31/2006, Vladimir Strycek wrote:

Hi all,
some time ago i instaled SPE with python 2.4... it works very good...
but yesterday my pc crash completly ( some dll went missing somehow :-)
)... so  after format and  reinstalling of windows i begin to install
all my programs back...

When i come to python i download new 2.5 version and only version for
win i could find is SPE-0.8.2.a-wx2.6.1.0-py24 which doesnt work... :-(
newer version ist just rpm and i need exe for win... any idea if there
will be exe or any more development in SPE cause homepage is not running
etc...

Or can you suggest similar IDE for python... ?


I have SPE 0.8.3.c, which is for Python 2.5.  There is a mailing list for
SPE users. See the archive at 
.
Stani was looking for another host for the website. His last post, of Wed
Nov 29, says he has found one, and "Don't worry the SPE website will come
back."

In the meantime, if anyone wants a copy of the file I downloaded,
SPE-0.8.3.c.win32-py2.5.exe, please contact me.
"Program info
Spe version 0.8.3.c
Python version 2.5  (2.3 required)
wxPython version 2.6.3.3.  (2.6.1.0. required)"

The size of SPE-0.8.3.c.win32-py2.5.exe is 1,147 KB.

Dick Moores
[EMAIL PROTECTED]



___
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] Starting python from a DOS prompt from any directory?

2007-01-02 Thread Daniel McQuay

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


"Bob Gailer" <[EMAIL PROTECTED]> wrote

>> Sure I understand that, but it looks from your post that
>> you have somehow managed to install Python.
> As I recall Steve said at the beginning that he ran Python from a
> network drive.

Nope, he said it was a networked PC but that Python was
in his D: drive, which I assumed was local. But that raises an
interesting proposition,. one that I've never tried. Is it possible
under Windows to install Python from machine A onto
a network drive and then run Python from machine B accessing
that drive? In other words does the installer need to do any magic
in the registry for Python to work or is it all just path setting
and shortcuts?

Can anyone confirm or otherwise the possibility?



i can try this under my networked drive tomorrow at school and if in fact
you can.

Curious,


--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

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



regards,

--
Daniel McQuay
boxster.homelinux.org
H: 814.825.0847
M: 814-341-9013
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] mod_python

2007-01-02 Thread Luke Paireepinart
Jalil wrote:
> I was just wondering if anyone know of a any good site with examples 
> of mod_python tutorial.
> the mod_python manual assume isnt really that helpful.
I have been learning mod_python recently and I found the manual to be 
quite good...
what are you having problems with specifically?
>
> thanks
>
>
> 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>   

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