Re: cx_oracle and commands

2008-09-05 Thread Edwin . Madari
gaius hammond Wrote: >Hi all, > > >I am having a very strange problem with cx_Oracle, has anyone >seen this kind of behavior before: > > > >ActivePython 2.5.2.2 (ActiveState Software Inc.) based on >Python 2.5.2 (r252:60911, Mar 27 2008, 18:53:24) [C] on sunos5 >Type "help", "copyright", "credits"

Re: urllib fails to connect

2008-08-20 Thread Edwin . Madari
jlist wrote: > > I found out why. I set a proxy in IE and I didn't know > ActiveState Python use IE proxy! > > > I'm running ActiveState Python 2.5 on Windows XP. It used > > to work fine. Today however I get (10061, 'Connection refused') > > for any site I try with urllib.urlopen(). > switching

Re: who to call a list of method inside the class itself

2008-08-19 Thread Edwin . Madari
[EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] wrote: > > > 1. return string names of required methods in getAllMethod > > return ['method1', 'method2', 'method3'] > > 2. use gettattr on self and then exetute methods in applyAll > > def applyAll(self): > > for method_name in self.

Re: who to call a list of method inside the class itself

2008-08-19 Thread Edwin . Madari
[EMAIL PROTECTED] wrote: > Hi, > > Is the following code is ok. who to call all method. > It is working but the call to m() without a reference to self seems > strange > > Thanks for your help > > class CustomMethod: > def method1(self): > > def method2(self): > ...

Re: Newbie problem inserting into MySQL

2008-08-18 Thread Edwin . Madari
> -Original Message- > From: Madari, Edwin > Sent: Monday, August 18, 2008 3:03 PM > To: 'len'; python-list@python.org > Subject: Re: Newbie problem inserting into MySQL > > > -Original Message- > > From: > [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] > > yt

Re: Newbie problem inserting into MySQL

2008-08-18 Thread Edwin . Madari
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > ython.org] > On Behalf Of len > Sent: Monday, August 18, 2008 11:55 AM > To: python-list@python.org > Subject: Newbie problem inserting into MySQL > > > Hi All > > I have started a little pet project to learn py

Re: How to delete a line with re?

2008-08-18 Thread Edwin . Madari
running this snippet, is blanking out ^abdc$.. what is the issue ? abcd efg hijk lmn $ efg hijk lmn regards Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peng Yu Sent: Sunday, August 17, 2008 11:47 PM To: python-list@python.org Subject: How to de

Re: Vmware api

2008-08-18 Thread Edwin . Madari
do the ESX server provide any api's or an interactive session may ? thx. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eric Wertman Sent: Sunday, August 17, 2008 2:43 PM To: python-list@python.org Subject: Re: Vmware api I would also be intereste

Re: Python does not get environment variable when using cron.

2008-08-18 Thread Edwin . Madari
source in or execute .profile (or .bash_profile which ever is applicable to you) as a first thing in the cron to get environment variables. hope that helps. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eric Wertman Sent: Sunday, August 17, 2008

any success in compiling mod_python3.3 on cygwin for apache2.2

2008-08-16 Thread Edwin . Madari
has any one out there succeeded in compiling/installing mod_python for apache2 and python 2.5. I am using python 2.5 on cygwin. thanks in advance Edwin The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work produc

RE: updating dictionaries from/to dictionaries

2008-08-14 Thread Edwin . Madari
by the way, iterating over bar will throw KeyError if that key does not exist in foo. to see that in action, simply set another key in bar after copy.deepcopy stmt in this example.. bar['xtra'] = 0 and re-run fun learning with python... Edwin -Original Message- From: Madari, Edwin

RE: updating dictionaries from/to dictionaries

2008-08-14 Thread Edwin . Madari
if the values for any of the keys are None, both do not work as can be seen below!!. since both loops are iterating over keys(), 'get' method which would return a '0' for non existing key does not encounter any non-existing keys. impo

RE: SOAPpy and ArrayOfString

2008-08-14 Thread Edwin . Madari
for someMethod(Field1 ArrayOf_xsd_string, other_parameters) a call someMethod( ['str1', 'str2', 'str3'], other_parameters) *works for me* with SOAPpy 0.12.0. yes sir it does. in PERL, let alone array types, even for simple types it was hard for me with all the '->', and '$' prefixing for obje

RE: urldecode function?

2008-08-14 Thread Edwin . Madari
afraid not.. simple to create your own, NOTE that key words can be supplied more than once. Hence... import urllib def urldecode(query): d = {} a = query.split('&') for s in a: if s.find('='): k,v = map(urllib.unquote, s.split

RE: threading

2008-08-14 Thread Edwin . Madari
1. check out the Caveats for thread module: http://docs.python.org/lib/module-thread.html Threads interact strangely with interrupts: the KeyboardInterrupt exception will be received by an arbitrary thread. (When the signal module is available, interrupts always go to the main thread.) i.e.,

RE: Fixed-length text file to database script

2008-08-14 Thread Edwin . Madari
#your thought is right. === def sizes2fields(sizes): d = [] begin = 0 for i in sizes: if begin: end = begin + i else: end = i d.append((begin, end)) begin += i return tuple(d) def slicestring(s, field

RE: a question about mysqldb

2008-08-14 Thread Edwin . Madari
db module properly formats arguments, if input arguments are separated from table_name and colum_names. columns = ('tID', 'tNote') table_name = 'tmp' sql = 'select %s from %s where tID=:1' % ( ', '.join(columns), table_name) cursor.execute(sql, (1,)) # sql is now 'select tID, tNote from tmp

RE: a question about mysqldb

2008-08-14 Thread Edwin . Madari
replace the name of table before calling *.execute. s.dbptr.execute(str % (e[0])) good luck. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Evan Sent: Thursday, August 14, 2008 11:27 AM To: python-list@python.org Subject: a question about mysqldb

RE: Fixed-length text file to database script

2008-08-14 Thread Edwin . Madari
here is a working code snippet to read from MySQL db. python tutorial has examples of reading from files. put them together to do your task. === import MySQLdb con = MySQLdb.connect(host='127.0.0.1', port=4321, user='joe', passwd='shmoe', db='t

RE: Formatting input text file

2008-08-14 Thread Edwin . Madari
save following code in script.py, and run it as 'python script.py ' with your sample data this prints out following which is what you are looking for (i think) 3.08333 9.05526 3.13581 4.08322 4.02526 3.95891 import sys data = [] row = [] f

RE: Random Problems

2008-08-13 Thread Edwin . Madari
use songs.extend( asongs ) #append is for single item - where ever it might be. >>> l1 = range(5) >>> l2 = range(5,10) >>> l1 [0, 1, 2, 3, 4] >>> l2 [5, 6, 7, 8, 9] >>> l1.extend(l2) >>> l1 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> good luck. Edwin -Original Message- From: [EMAIL PROT

Re: Checking a file's time stamp.

2008-08-12 Thread Edwin . Madari
os.paht.gmtime(path) returns the last modification of path. check out http://docs.python.org/lib/module-os.path.html regards Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of William Purcell Sent: Tuesday, August 12, 2008 1:47 PM To: Python List Subject:

Re: for x,y in word1, word2 ?

2008-08-11 Thread Edwin . Madari
sounds like *soundex* is what you are looking for. google soundex regards Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marc 'BlackJack' Rintsch Sent: Monday, August 11, 2008 3:09 AM To: python-list@python.org Subject: Re: for x,y in word1, word2

Re: SSH utility

2008-08-11 Thread Edwin . Madari
for similar tasks, I use pexpect http://pypi.python.org/pypi/pexpect. spawning bash process and simulate an interactive session. Here sending ls command, retrieving results and exiting. In the spawned process ssh or any other command, is just another command. actual session

RE: regular expression extracting groups

2008-08-10 Thread Edwin . Madari
if its *NOT* an exercise in re, and if input is a bunch of lines within '{' and '}' and each line is key="value" pairs, I would not go near re. instead simply parse keys and array of values into a dictionary, and process them from the dictionary as below, and the key option correctly has 2 entr

RE: How to round a floating point to nearest 10?

2008-08-09 Thread Edwin . Madari
>>> round(76.1, -2) 100.0 >>> round(76.1, -1) 80.0 >>> round(76.1) 76.0 >>> builtin function round, will work for you.. Help on built-in function round in module __builtin__: round(...) round(number[, ndigits]) -> floating point number Round a number to a given precision in

RE: "shelve" save object

2008-08-09 Thread Edwin . Madari
since choice of dbm used by shelve http://docs.python.org/lib/node327.html depends on os, and whats available on it, shevle files saved on one os, most likely do not work on another os, sometimes on similar os but different machines might not work either - goes back to what's available on that m

RE: Extract string from log file

2008-08-09 Thread Edwin . Madari
from each line separate out url and request parts. split the request into key-value pairs, use urllib to unquote key-value pairs..as show below... import urllib line = "GET /stat.gif?stat=v&c=F-Secure&v=1.1%20Build%2014231&s=av%7BNorton%20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorto

RE: sending to an xterm

2008-08-08 Thread Edwin . Madari
since I do not have access to xterm, here is the interactive session for spawning bash(another session if you will), sending ls command to it, and retrieving the results. things to note are: 1. after spawning expect for the prompt, timeout, and eof #which ever happens first 2. return value is th

RE: very newbie question

2008-08-07 Thread Edwin . Madari
delete the extra 'tries += 1' after else: print "Higher..." tries += 1 #delete this while at it, and add this line as the first line in function ask_number() global the_number, tries good luck. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMA

RE: Testing for the first few letters of a string

2008-08-07 Thread Edwin . Madari
use re module import re template = '^My name is alex' astring = 'My name is alex, and I like pie' if re.match(template, astring): print 'Found it' else: print '%s does not begin with %s' % (astring, template) good luck. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EM

RE: A question about string and float number

2008-08-06 Thread Edwin . Madari
#this is a better way of testing a string for float def isFloat(s): try: s = float(s) except: return False return True -Original Message- From: Madari, Edwin Sent: Wednesday, August 06, 2008 10:22 PM To: 'Wei Guo'; python-list@python.org Subject: RE: A question

RE: A question about string and float number

2008-08-06 Thread Edwin . Madari
type(s) == type(float()) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Wei Guo Sent: Wednesday, August 06, 2008 9:23 PM To: python-list@python.org Subject: A question about string and float number Hi all, I am new of python. Could anyone help me a quest

Re: Using an DTD not specified in XML file for validation

2008-08-06 Thread Edwin . Madari
can you edit the xml and add the dtd/scheama ? .Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ben Finney Sent: Wednesday, August 06, 2008 7:07 PM To: python-list@python.org Subject: Re: Using an DTD not specified in XML file for validation Brian

python equivalent for this perl soap client

2008-08-06 Thread Edwin . Madari
use SOAP::Lite; use Data::Dumper; $ENV{HTTP_proxy} = "my_proxy_server_not_soap_proxy_server"; $ENV{HTTP_proxy_user} = ""; #set correct value $ENV{HTTP_proxy_pass} = ""; #set correct value my $soap = SOAP::Lite ->service('file:./local_file_copy_of_wsdl.wsdl'); my $som = $soap->soapMethod("method",

SOAPpy how to

2008-08-06 Thread Edwin . Madari
unable to get past local proxy server with SOAPpy client. In the code below using 'thproxy' or 'httpproxy' variable for http_proxy fails. from SOAPpy import WSDL proxyuser='..' proxypass='.. httpproxy="a.b.c.com:1234" theproxy='http://'+proxyuser+':'+proxypass+'@'+httpproxy wsdl='sample

soap call through firewall

2008-08-06 Thread Edwin . Madari
hi, any hints/pointers appreciated if you have succeeded in making a soap call through a firewall. other than this http://www.ibm.com/developerworks/xml/library/x-tipfire.html cannot find much. thanks in advance Edwin The information contained in this message and any attachment may be propr

Re: UnicodeDecodeError, how to elegantly deal with this?

2008-08-04 Thread Edwin . Madari
if you can print out values of 'filemask', and 'thefile' variables, when it crashes, I can help. thx. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jorgen Bodde Sent: Monday, August 04, 2008 2:24 PM To: python-list@python.org Subject: UnicodeDec

Re: xlrd

2008-08-04 Thread Edwin . Madari
here is working code that will read & display contents of all rows & columns in all the sheets, you need xlrd 0.6.1 import xlrd, os, sys book = xlrd.open_workbook(sys.argv[1]) print "The number of worksheets is", book.nsheets for shx in range(book.nsheets): sh = book.sheet_by_index(shx) p

RE: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Edwin . Madari
for nth square root: use math.sqrt n times for example >>> import math >>> num = 625 >>> how_many_sqrt = 2 >>> for i in range(how_many_sqrt): .. num = math.sqrt(num) .. >>> num 5.0 all comparisons work fine for arbitrary floating point numbers... For readability print them with required prec

RE: Continually check object status

2008-08-02 Thread Edwin . Madari
updated creature running in its own thread will get you started. try it for yourself, change sleep times per your need. import os, sys, threading, time class Creature: def __init__(self, status): self.status = status self.state = 'run' def start(self): self.athread = thr

building python from source on HP

2007-05-07 Thread Edwin . Madari
appreciate hints or pointers for building python on HP. running 'make test' fails with following cryptic message, after running configure, & make. Attempting to build python from source on HP-UX B.11.11 U 9000/800 3314646674 unlimited-user license *** Error exit code 1 Stop. not sure if out