Re: Python replace multiple strings (m*n) combination
On Friday, February 24, 2017 at 11:48:22 AM UTC-8, MRAB wrote: > On 2017-02-24 18:54, kar6...@gmail.com wrote: > > I have a task to search for multiple patterns in incoming string and > > replace with matched patterns, I'm storing all pattern as keys in dict and > > replacements as values, I'm using regex for compiling all the pattern and > > using the sub method on pattern object for replacement. But the problem I > > have a tens of millions of rows, that I need to check for pattern which is > > about 1000 and this is turns out to be a very expensive operation. > > > > What can be done to optimize it. Also I have special characters for > > matching, where can I specify raw string combinations. > > > > for example is the search string is not a variable we can say > > > > re.search(r"\$%^search_text", "replace_text", "some_text") but when I read > > from the dict where shd I place the "r" keyword, unfortunately putting > > inside key doesnt work "r key" like this > > > > Pseudo code > > > > for string in genobj_of_million_strings: > >pattern = re.compile('|'.join(regex_map.keys())) > >return pattern.sub(lambda x: regex_map[x], string) > > > Here's an example: > > import re > > # A dict of the replacements. > mapping = {'one': 'unu', 'two': 'du', 'three': 'tri', 'four': 'kvar', > 'five': 'kvin'} > > # The text that we're searching. > text = 'one two three four five six seven eight nine ten' > > # It's best to put the strings we're looking for into reverse order in > # case one of the keys is the prefix of another. > ordered_keys = sorted(mapping.keys(), reverse=True) > ordered_values = [mapping[key] for key in ordered_keys] > > # Build the pattern, putting each key in its own group. > # I'm assuming that the keys are all pure literals, that they don't > # contain anything that's treated specially by regex. You could escape > # the key (using re.escape(...)) if that's not the case. > pattern = re.compile('|'.join('(%s)' % key for key in ordered_keys)) > > # When we find a match, the match object's .lastindex attribute will > # tell us which group (i.e. key) matched. We can then look up the > # replacement. We also need to take into account that the groups are > # numbered from 1, whereas list items are numbered from 0. > new_text = pattern.sub(lambda m: ordered_values[m.lastindex - 1], text) > > > It might be faster (timing it would be a good idea) if you could put all > of the rows into a single string (or a number of rows into a single > srting), process that string, and then split up the result. If none of > the rows contain '\n', then you could join them together with that, > otherwise just pick some other character. Thanks, what is the idea behind storing the keys and values in a list, I assume looking up for a value in a map is faster getting the value from the list. Also I like the idea of combining multiple rows into one string and passing it. I would batch up the million rows in to strings and give it a shot. -- https://mail.python.org/mailman/listinfo/python-list
Re: regarding cache clearing header in python cgi
Dear All, In Php the following headers base we can clean the cache in the url "header('Cache-Control: no-store, no-cache, must-revalidate'); " I want to know Php equivalent headers in Python-cgi If any know regarding this kindly mail me. regards, Prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
regarding cache clearing header in python cgi
Dear All, In Php the following headers base we can clean the cache in the url "header('Cache-Control: no-store, no-cache, must-revalidate'); " I want to know Php equivalent headers in Python-cgi If anybody know regarding this kindly mail me. regards, Prabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
How to connect python and Mysql?
Dear All, I am using python2.4 and Mysql 4.0.20. Now I am want to connect python and mysql. I have problem to install Mysql-python-1.2.0 interface into my machine. When I try to install this interface the following error restrict to install fully. /System/Links/Executables/ld: cannot find -lmysqlclient_r collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 So If anybody knows regarding this kindly mail me regards PRabahar __ Free antispam, antivirus and 1GB to save all your messages Only in Yahoo! Mail: http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Regarding MySQLdb
Dear All After installation of Mysql-Python Interface. I try to import MySQLdb but I got below error How to correct this error. regards Praba >>> import MySQLdb Traceback (most recent call last): File "", line 1, in ? File "MySQLdb/__init__.py", line 27, in ? import _mysql ImportError: libmysqlclient.so.12: cannot open shared object file: No such file or directory >>> import _mysql Traceback (most recent call last): File "", line 1, in ? ImportError: libmysqlclient.so.12: cannot open shared object file: No such file or directory >> __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
mail sending using telnet in python
Dear All, Normally we can send mail using telnet in linux. In the following way [~user]telnet Ipaddress 25 mail from: [EMAIL PROTECTED] 250 o.k(response of from commandline) rcpt to: [EMAIL PROTECTED] 250 o.k(response of from commandline) data 354 go ahead(response of from commandline) Hello world(message to send) . 250 ok 1120805818 qp 1463 Is it possible to run same thing same manner in python? If possible kindly help me with specimen code. Actually I gone through telnetlib module documentation but I cann't get solution for it. regards prabahar __ Free antispam, antivirus and 1GB to save all your messages Only in Yahoo! Mail: http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
reg php equivalent move_uploaded file function in python
Dear all, Is there any php equivalent move_uploaded_file($source_path, "$upload_dir/$name"); function in python to upload a file to server? Kindly give me answer. regards Prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Reg file uploading
Dear All, I have doubt regarding file uploading. When we upload a file to the remote server we can get file type through file extentions. How we can find out file type if a file doesn't have any extentions ? with regards PRabahar __ Free antispam, antivirus and 1GB to save all your messages Only in Yahoo! Mail: http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
How to limit the uploading file size in python?
Dear All, In Php we can limit the uploading file size by php.ini configuration file. But In python what way we can limit the file uploading size. kindly let me know. regards Prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Retrive file name from the window's file path
Dear All, I am using Python 2.4 in the linux platform. At present I am working on webbased file manager. When I try to upload a file from the linux cgi script easily fetch the file name by the filefield.filename. But When I try to upload a file from the windows machine It won't retrieve the file instead of retrieved full path (C:\\WINDOWS\my.gif). And at the same I couldn't know how to get file name from window's file path C:\\WINDOWS\my.gif. I try to workout these things by os.path.basename().os.path.splitext(). Kindly let me how to handle these situation prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
how to build email message with attachment?
Dear All, Can any one let me know? How to build email in python? with some some examples. regards Prabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
how to append cgi FieldStorage Class instance
Dear All, I have doubt in python cgi script. I describe that doubt with below code import cgi form = cgi.FieldStorage() passwd = form['passwd'].value print passwd But Now I want to assign some value to form['passwd'] field value form['passwd'] = 'surese' Now If I try to print print form['passwd'].value. It will raise error. So kinldy let me how to edit or append instance of FieldStorage class regards PRabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to append cgi FieldStorage Class instance
--- Fuzzyman <[EMAIL PROTECTED]> wrote: > > praba kar wrote: > > Dear All, > > I have doubt in python cgi script. I describe > > that doubt with below code > > import cgi > > form = cgi.FieldStorage() > > passwd = form['passwd'].value > > print passwd > > But Now I want to assign some value to > form['passwd'] > > field value > > form['passwd'] = 'surese' > > Now If I try to print > > print form['passwd'].value. It will raise error. > > So kinldy let me how to edit or append instance > > of FieldStorage class > > > > A form *isn't* a dictionary, this means that your > code : > form['passwd'] = 'surese' > > is wrong. > Turn the form into a dictionary and use that. How Can I convert a form instance into dictionary Kindly let me know. Why are you trying to assign values directly in the form ? To reduce variable usage in my project. regards Prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Python-cgi or Perl-cgi script doubt
Dear All, I want to know difference between Python-cgi and Perl-cgi and also I want to which one is efficient from the performance. regards Prabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Sample code to build rfc822 mail message building
Dear All, I am new to python world. I have pasted my code which I used it to build rfc822 format mails for webbased mailing system task(which is like to yahoo.com web interface). Now I am asking some suggestions and guidence regarding this below code. Still What way I can improve this code. If anyone find error kindly let me know how to correct it. # This function to handle attachment files def addAttachment(filename,ctype): #mimetypes guesses the type of file and stores it in ctype maintype, subtype = ctype.split('/', 1) if not os.path.exists(filename): return 0 fp = open(filename, 'rb') #open the file if maintype == 'text': #check for maintype value and encode and return according to the # type of file attach = MIMEText(fp.read(),_subtype=subtype) elif maintype == 'message' and subtype == "rfc822": attach = email.message_from_file(fp) attach = MIMEMessage(attach) elif maintype == 'message' and subtype <> "rfc822": attach = email.message_from_file(fp) elif maintype == 'image': attach = MIMEImage(fp.read(),_subtype=subtype) elif maintype == 'audio': attach = MIMEAudio(fp.read(),_subtype=subtype) else: #print maintype, subtype #if it does not equal any of the #above we print to screen and encode and return attach = MIMEBase(maintype, subtype) #the encoded value attach.set_payload(fp.read()) encode_base64(attach) fp.close() filename = os.path.basename(filename) attach.add_header('Content-Disposition', 'attachment',filename=filename) return attach #This function base I try to build email message def create_mail(domain, user, form, from_name): to = cc = bcc = subject = body = '' attachments = [] send_addresses = '' if form.has_key('to'): to = form['to'].value.strip() send_addresses = to if form.has_key('cc'): cc = form['cc'].value.strip() send_addresses = to + ',' + cc if form.has_key('bcc'): bcc = form['bcc'].value.strip() send_addresses = to + ',' + cc + ',' + bcc if form.has_key('subject'): subject = form['subject'].value if form.has_key('body'): body = form['body'].value if form.has_key('attachments[]'): attachments = form.getlist("attachments[]") if not len(attachments) > 0: # This header is for non Multipart message # I want to know reduce below redundant code msg = MIMEBase('text','html') msg['Return-Path'] = user+'@'+domain msg['Date'] = formatdate(localtime=1) msg['Subject'] = subject msg['From'] = from_name msg['To'] = to msg["Cc"] = cc msg.set_payload(body) # Guarantees the message ends in a newline msg.epilogue = '' else: msg = MIMEMultipart() msg['Return-Path'] = user+'@'+domain msg['Date'] = formatdate(localtime=1) msg['Subject'] = subject msg['From'] = from_name msg['To'] = to msg["Cc"] = cc body = MIMEText(body) #Here is the bod msg.attach(body) # Guarantees the message ends in a newline msg.epilogue = '' for eachfile in attachments: row = eachfile.split(':') att_name = row[0] att_type = row[1] filename = domaindir + '/' + domain + '/' + user + '/temp/upload/' + att_name if addAttachment(filename,att_type): attach = addAttachment(filename,att_type) msg.attach(attach) # To send message to all the send_addresses for eachid in send_addresses.split(","): fh = os.popen('/bin/sendmail %s'% (eachid),'w') fh.write(msg.as_string()) fh.close() __ Free antispam, antivirus and 1GB to save all your messages Only in Yahoo! Mail: http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Reg Python Byte code
Dear All, Python 2.3 creates byte code with *.pyc extention. But Python 2.4 creates bytes code with *.pyo. Is there any difference between *.pyc and *.pyo?. Actually After python compiled a program then that program will run from the *.pyc byte code. If I delete that byte code what will be happen.? If I delete *.pyc byte code in the python 2.3 then It will create again *.pyc byte code. But If I delete *.pyo byte code in the python 2.4 then It will not create again *.pyo. Why this difference. If I delete byte code of the python. I want to know Whether it will affect the performance of the programme or not. Kindly clear me all the doubts regarding byte code of python. with regards Prabahar Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html -- http://mail.python.org/mailman/listinfo/python-list
Doubt C and Python
Dear All, I want to know the link between c and python. Some people with C background use Python instead of programming in C.why? regards Prabahar Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html -- http://mail.python.org/mailman/listinfo/python-list
Reg python nature.
Dear All, I want to know the link between c and python. Some people with C background use Python instead of programming in C.why? regards Prabaha Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html -- http://mail.python.org/mailman/listinfo/python-list
Doubt Regarding link between C and Python
Dear All, I want to know the link between c and python. Some people with C background use Python instead of programming in C.why? regards Prabahar Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt C and Python
--- James <[EMAIL PROTECTED]> wrote: > > Some people with C background use Python instead > > of programming in C.why? > > Becuase it is much more efficient. > > -James What why it is more efficient. Kindly let me know with some details. regards Prabahar Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html -- http://mail.python.org/mailman/listinfo/python-list
reg packages examples
Dear All, I want to know about Modules and packages. I can understand about Modules but I cannot understand about Packages. Kindly let me know about Packages with small example. I can understand conceptually but I don't know how to write programmatically. regards Prabahar Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html -- http://mail.python.org/mailman/listinfo/python-list
Reg Python Modules/Packages
Dear All, I know how to use modules. But I want to know how to create package. Can any one let me know how to write package through small specimen code. regards PRabahar Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html -- http://mail.python.org/mailman/listinfo/python-list
Python built email message doesn't support OutLook Express
Dear All, I am working in web based email system project. Here I try to build email message from scratch. I used below code to build email message msg = email.MIMEBase('text','html') msg['Return-Path'] = user+'@'+domain msg['Date'] = formatdate(localtime=1) msg['Subject'] = subject msg['From'] = from_name msg['To'] = to msg['Cc'] = cc msg.set_payload("Body of the email messagge") fh = os.popen('/bin/sendmail %s'% (eachid),'w') fh.write(msg.as_string()) fh.close() This code will build plain email message properly. But after building the message. If a email user download this mail through out look express then this email message will display without any alignment. If a user type 3 paragraph message outlook express display as a single line. What could be problem?. Kindly let me know ASAP regards Prabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
reg email packages work
Dear All, I am working in web based email system project. Here I try to build email message from scratch. I used below code to build email message msg = email.MIMEBase('text','html') msg['Return-Path'] = user+'@'+domain msg['Date'] = formatdate(localtime=1) msg['Subject'] = subject msg['From'] = from_name msg['To'] = to msg['Cc'] = cc msg.set_payload("Body of the email messagge") fh = os.popen('/bin/sendmail %s'% (eachid),'w') fh.write(msg.as_string()) fh.close() This code will build plain email message properly. But after building the message. If a email user download this mail through out look express then this email message will display without any alignment. If a user type 3 paragraph message outlook express display as a single line. What could be problem?. Kindly let me know ASAP regards Prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python built email message doesn't support OutLook Express
--- Sybren Stuvel <[EMAIL PROTECTED]> wrote: > praba kar enlightened us with: > > This code will build plain email message properly. > > It's not a plain email message. It's an html email > without a plain > text part. Highly annoying to many people. > > > But after building the message. If a email user > download this mail > > through out look express then this email message > will display > > without any alignment. > > Post the msg.as_string() output so we can see whay > you're sending. msg = email.MIMEBase('text','html') msg['Return-Path'] = user+'@'+domain msg['Date'] = formatdate(localtime=1) msg['Subject'] = subject msg['From'] = from_name msg['To'] = to msg['Cc'] = cc msg.set_payload("Body of the email messagge") fh = os.popen('/bin/sendmail %s'% (eachid),'w') fh.write(msg.as_string()) fh.close() Here I am sending what I was built in the message example to headers(address,cc address, subject) and Body of the mail content (ie) msg.set_payload("Body of the email messagge") regards Prabahar __ Free antispam, antivirus and 1GB to save all your messages Only in Yahoo! Mail: http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: reg email packages work
--- Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Steve Holden enlightened us with: > > It's obvious you aren't using that EXACT code, > because it doesn't > > formulate a three-paragraph message. So the bit we > really need to > > see is how you capture and formulate the argument > to set_payload(). > > I'd rather see what I asked for, which is the output > of > msg.as_string(). That contains all that's sent to > the client. msg.as_string() have all the client data(which include headers and body of the message > > Sybren > -- > The problem with the world is stupidity. Not saying > there should be a > capital punishment for stupidity, but why don't we > just take the > safety labels off of everything and let the problem > solve itself? > Frank > Zappa > -- > http://mail.python.org/mailman/listinfo/python-list > __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python built email message doesn't support OutLook Express
--- "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > That is not what Sybren requested - we need the > message text. If you > send html, make sure your paragraphs are html > paragraphs (enclosed in > -tags) and not pure whitespace, as html ignores > these. > I am sending text message as a paragraph __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Ternary Operator in Python
Dear All, I am new to Python. I want to know how to work with ternary operator in Python. I cannot find any ternary operator in Python. So Kindly clear my doubt regarding this __ Yahoo! Messenger Show us what our next emoticon should look like. Join the fun. http://www.advision.webevents.yahoo.com/emoticontest -- http://mail.python.org/mailman/listinfo/python-list
Ternary Operator in Python
Dear All, I am new to Python. I want to know how to work with ternary operator in Python. I cannot find any ternary operator in Python. So Kindly clear my doubt regarding this With regards, Prabahar __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail -- http://mail.python.org/mailman/listinfo/python-list
how to parse system functions output
Dear all, I want to parse the system functions output but I couldn't do it. Kindly assist me in this task. eg) bytesused = os.system('du -sh /Users/enmail') if I print this bytesused variable the output of bytesused variable is the below 14M /Users/enmail 0 Now From this Output I want only '14M" I cannot split this output by space. If anyone know regarding this mail me ASAP regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
doubt regarding main function
Dear All, I have doubt regarding main function in Python. In Python we can create a function and we can call a function directly. (eg:) def test(): print 'main function test' I can call this function the following way eg) test() So why we need the below way of calling a function? if __name__ == '__main__': test() What is the advantage of this way calling a function. Kindly mail me as early as possible regards, Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
doubt regarding Conversion of date into timestamp
Dear All, I am new to Python I want to know how to change a time into timestamp eg "Fri, 8 Apr 2005 09:22:14 +0900" like format date I want to change as a timestamp. I have used below code to get timestamp import time time.strptime(v,'%a, %d %b %Y %X +0900') function. This function will return time stamp. But If the format of date string is changed. This function raise error eg My web application always return different format of date Fri, 8 Apr 2005 10:31:37 +0530 Fri, 8 Apr 2005 10:11:03 +0900 Fri, 8 Apr 2005 09:40:47 +0800 Kindly help to resolve this problem. with regards, Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
How to check whether a list have specific value exist or not?
Dear All In Php we can find in_array() function which function is mainly useful to check whether a specific value is exist in the array or not. But In python In cannot find any function like that. I want to check a list have specific value or not. So If any one know regarding this mail me with regards PRabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
change the date string into timestamp
Dear All, In Php strtotime() will change a date string into timestamp. I want to know which python function will change a date string into timestamp. Date string format is below Fri, 8 Apr 2005 09:22:14 +0900 regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: change the date string into timestamp
--- Michael Hoffman <[EMAIL PROTECTED]> wrote: > praba kar wrote: > > > In Php strtotime() will change a date > > string into timestamp. I want to know which > > python function will change a date string > > into timestamp. > > What do you mean by "a timestamp?" > -- Time stamp means datestring will converted as seconds example is below Fri, 8 Apr 2005 09:22:14 +0900 this date value time stamp is 1112962934 Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Doubt regarding sorting functions
Dear All, I am new to Python. I am in need of some sorting functions (eg) numerical sorting functions and alphapetical sorting functions. I have searched through net But I cannot find any regarding this so If anyone know regarding this. Kindly mail me as early as possible with regards PRabahr Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Doubt regarding sorting of a list specific field
Dear All, I have doubt regarding sorting. I have a list that list have another list (eg) list = [[1234,'name1'],[2234,'name2'],[0432,'name3']] I want to sort only numeric value having array field. How I need to do for that. with regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
trouble to print array contents using slice operator
Dear all, In Php array_slice function base we can print array contents as per our desire eg) $a = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); $arr = array_slice($a,10,10); this function will print 11,12,13,14,15 But I try to print the same thing in python using slice operator eg) print a[10:10] This statement print [] empty array. How I need to get my desired output like php array_slice function? with regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
module MySQLdb is missing in python 2.3.3
Dear All, I am using python 2.3.3 version. If I try to import MySQLdb. Here I found " the following error" importError: No module named MySQLdb. So what I need to do for this ?. How I need to install this MySQLdbo. praba Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
goto statement
Dear All, In Python what is equivalent to goto statement regards, praba __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
regarding main function
Dear All, I want to know the difference between calling a function directly and through main function compose() if __name__ == __main__: compose() Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
regarding system function
Dear All, In Php If I send a command to system function then It will return 1 on success and 0 on failure. So based upon that value I can to further work. But In Python If I send a command to system function then It will return 0 only for both conditions(success and failure). So What I need to do for this. I want the result like php system function. regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: regarding system function
--- Robert Kern <[EMAIL PROTECTED]> wrote: > praba kar wrote: > > Dear All, > > > > In Php If I send a command to system function > > then It will return 1 on success and 0 on failure. > So > > based upon that value I can to further work. > > > > But In Python If I send a command to system > > function then It will return 0 only for both > > conditions(success and failure). > > Are you sure about that? > > In [3]:os.system('cat foo') > cat: foo: No such file or directory > Out[3]:256 > I agree above statement but When I delete a directory os.system('rm -rf test') 0 if directory is not present then I again try to delete os.system('rm -rf test') now this time also It will print 0 Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Doubt regarding python Compilation
Dear all, I have doubt regarding python Compilation. I want to know whether Python is compiler language or interpreted language. If Python is interpreter language why compilation is there. with regards Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
how to connect my sql with Python
Dear All, I am doing Python-cgi Project in my company. To connect My sql database(Mysql 4.1.11.) into Python(2.3.3) cgi. I have installed MySQL-python-1.2.0. After installation of MySQL-Python-1.2.0 I try import MySQLdb module. It raised the following error >>import MySQLdb Traceback (most recent call last): File "", line 1, in ? File "/System/Links/Libraries/python2.4/site-packages/MySQLdb/__init__.py", line 27, in ? import _mysql ImportError: libmysqlclient.so.14: cannot open shared object file: No such file or directory so kindly give me guidance to connect Mysql and Python regards Praba Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Difference between Python CGI applications and Php applications
Dear all, I have a project that is conversion of Php Web applications into Python cgi applications. In my mind compare python-cgi php is better. But I want to know clearly. which one is better. so kindly show me the advantages of python-cgi compare to Php regards PRaba Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
RFC 2822 format date printing function in python
Dear All, In Php we can print RFC 2822 formatted date by date('r') with parameter r. Then it will print the below format date. "Thu, 7 Apr 2005 01:46:36 -0300". I want to print same RFC 2822 format in python. Is it possible in python? . If possible kindly mention the function related to print RFC format date regards, Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Reg strip_tags function in Python.
Dear All, In Php I can use strip_tags() function to strip out all html tags. I want to know that strip_tags() equivalent function in Python. regards praba Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
regarding try/except usa
Dear All, Is there any rules and regulations to use try/except in python? Can any one explain to me when I need to use try/except and when we I need not use try/except?. This Question mainly for to maintain code integrity in my project. But I know how to use try/except regards Praba Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Regarding Mail sending Module
Dear All, In Php we can do all the mailing operations like sending a text as a message, adding attachment to a mail, adding additional headers and so on using Mail_mime class. I want to know like that class or modules in Python. I already gone through MimeWriter,smtplib and so on. But I can't get clear details. so if anyone know regarding this kindly give me answer regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Regarding Mail sending smtplib Module
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ## import email.Message import email.Utils import mimetypes import os,string fromAddr="[EMAIL PROTECTED]" toAddr= ["[EMAIL PROTECTED]","[EMAIL PROTECTED]"] mainMsg=email.Message.Message() mainMsg["Date"]=email.Utils.formatdate(localtime=1) mainMsg["Subject"]="en new contents" mainMsg["From"]=fromAddr mainMsg["To"]= string.join(toAddr,",") ## I am sending below message ## here mainMsg.set_payload("Good to win win\n") server = smtplib.SMTP('localhost') server.set_debuglevel(1) server.sendmail(fromAddr, toAddr, mainMsg.as_string()) server.quit() ## This is the output of above send mail program. Here I want to avoid this line "Received: from unknown (HELO prabahar.enmail.com) (59.92.13.47) by mailserver with SMTP; 11 May 2005 10:09:11 - " How can I do this? . Why python give this line? . Mail sending Module in php will not give this type line. Here I have another doubt Php mail sending module give MessageId automatically but python doesn't set that. why? output *** Return-Path: <[EMAIL PROTECTED]> Delivered-To: [EMAIL PROTECTED] Received: (qmail 6865 invoked from network); 11 May 2005 10:09:11 - Received: from unknown (HELO prabahar.enmail.com) (59.92.13.47) by mailserver with SMTP; 11 May 2005 10:09:11 - Received: (dqd 1118 invoked from network); 12 Apr 2005 06:38:59 - Received: from unknown (HELO prabahar.enmail.com) (127.0.0.1) by prabahar.enmail.com with SMTP; 12 Apr 2005 06:38:59 - Date: Tue, 12 Apr 2005 03:38:59 -0300 Subject: en new contents From: [EMAIL PROTECTED] To: [EMAIL PROTECTED],[EMAIL PROTECTED] Good to win win with regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
reg mail sending without smtp module
Dear All, Is it possible to send a message as a mail with out smtplib module? If you find out any module for mail sending(without smtplib) kindly mail me. regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: reg mail sending without smtp module
--- Tim Williams <[EMAIL PROTECTED]> wrote: > - Original Message - > From: "John Abel" <[EMAIL PROTECTED]> > > > > praba kar wrote: > > > > >Dear All, > > > > > > Is it possible to send a message as a > mail > > >with out smtplib module? If you find out any > module > > >for mail sending(without smtplib) kindly mail me. > > > > > >regards > > >Prabahar > > > > > > > socket > > > > Telnetlib, though you will effectively have to > write your own SMTP client > (ie your own version of smtplib). > > Why don't you want to use smtplib ? > In Php we can build a Mail Message by Mail_mime class and send this message by Mail::Factory's class send Method. Here Php doesn't use any smtp modules. Like that In Python I used email.Message class to build Mail Message and Now I am searching modules to send this message as mail. regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
regarding php equivalent Mail::Factory Module
Dear All, In Php we can send mail by Mail::Factory's send method. Here php using send method instead of using any smtp module like that I want to know that kind of python module Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: reg mail sending without smtp module
Dear All, From this below answer I got clear idea for mail sending Module. I am expecting this kind of answer . Thank you for your immediate response. --- Mike Meyer <[EMAIL PROTECTED]> wrote: > praba kar <[EMAIL PROTECTED]> writes: > > In Php we can build a Mail Message by > > Mail_mime class and send this message by > > Mail::Factory's class send Method. Here Php > > doesn't use any smtp modules. Like that > > In Python I used email.Message class to > > build Mail Message and Now I am searching > > modules to send this message as mail. > > Python isn't PHP. In python, the standard way to > send a message is > with the smtp module. If you do an "import this" in > a python > interpreter, it will tell you (among other things) > "There should be > one-- and preferably only one --obvious way to do > it." The smtp module > is that way. Since smtp is also how mail is sent > around the internet, > this makes a lot of sense. > > Now, the PHP mail command uses the system's sendmail > binary (at least > on Unix). You can do that by hand using the > subprocess module in 2.4, > or os.system or os.popen or something similar on > earlier versions of > Python. All this really does is asks sendmail to put > a message in the > queue from the command line, rather than via the > smtp port. It's > probably slower than talking to the already running > smtp daemon. > > On Windows, the PHP mail command connects to an smtp > server - which is > exactly what smtplib does. > > -- > Mike Meyer <[EMAIL PROTECTED]> > http://www.mired.org/home/mwm/ > Independent WWW/Perforce/FreeBSD/Unix consultant, > email for more information. > -- > http://mail.python.org/mailman/listinfo/python-list > Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: reg mail sending without smtp module
Dear All, From this below answer I got clear idea for mail sending Module. I am expecting this kind of answer . Thank you for your immediate response. --- Mike Meyer <[EMAIL PROTECTED]> wrote: > praba kar <[EMAIL PROTECTED]> writes: > > In Php we can build a Mail Message by > > Mail_mime class and send this message by > > Mail::Factory's class send Method. Here Php > > doesn't use any smtp modules. Like that > > In Python I used email.Message class to > > build Mail Message and Now I am searching > > modules to send this message as mail. > > Python isn't PHP. In python, the standard way to > send a message is > with the smtp module. If you do an "import this" in > a python > interpreter, it will tell you (among other things) > "There should be > one-- and preferably only one --obvious way to do > it." The smtp module > is that way. Since smtp is also how mail is sent > around the internet, > this makes a lot of sense. > > Now, the PHP mail command uses the system's sendmail > binary (at least > on Unix). You can do that by hand using the > subprocess module in 2.4, > or os.system or os.popen or something similar on > earlier versions of > Python. All this really does is asks sendmail to put > a message in the > queue from the command line, rather than via the > smtp port. It's > probably slower than talking to the already running > smtp daemon. > > On Windows, the PHP mail command connects to an smtp > server - which is > exactly what smtplib does. > > -- > Mike Meyer <[EMAIL PROTECTED]> > http://www.mired.org/home/mwm/ > Independent WWW/Perforce/FreeBSD/Unix consultant, > email for more information. > -- > http://mail.python.org/mailman/listinfo/python-list > Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Reg php equivalent Mail_mime Module in Python
Dear All, email.Message module base we can build message for mailing services which is like php Mail_mime module. In php Mail_mime module willautomatically build all the header fields like content-type, content-Transfer-encoding, Return-Path and so on for a mailing messages. I want to know this(Mail_mime) kind of module in python. If Mail_mime like modules are not available in python kindly give guidenance how to build message for mailing service. regards Prabahar Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Reg Date string conversion into timestamp function
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type function 1) parsedate function failed if a date string like below format "16-MAY-2005 01:26" 2)parsedate_tz function also failed if a date string is different format if any one find some other date string conversion function kindly let me know Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
reg python related job searching
Dear All, Can any one guide me how to get python related jobs?. Actually Now I am in Python web programming field. I have technical knowledge about Python, ZOPE and Twisted-web(Twisted Python) with 1 year exp.. Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
reg php.ini equivalent file in python
Dear All, I have one doubt. Is there python.ini file like php.ini in Php? Actually php.ini file controls many aspects of PHP's behavior. The following details of php.ini will explain about it. max_execution_time = 5000 ; Maximum execution time of each script, in seconds (UNIX only) memory_limit = 134217728; Maximum amount of memory a script may consume (128MB) post_max_size = 67108864; Maximum POST-Content length (64MB) If I want to update the above details in Python where I need to change these things in Python regards, Prabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
regarding cgi
Dear All, I have doubt regarding headers in cgi programming. If I gives "Content-Type:text/plain" then I try to print html contents. Is right or wrong after giving content-type: text/plain? regards Prabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Regarding Content-type headers
Dear All, I have doubt regarding headers in cgi programming. If I gives "Content-Type:text/plain" then I try to print html contents. Is right or wrong after giving content-type: text/plain? regards Prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Reg cgi header
Dear All, I have doubt regarding headers in cgi programming. If I gives "Content-Type:text/plain" then I try to print html contents. Is right or wrong after giving content-type: text/plain? regards Prabahar __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
How to right align IPaddress?
Dear all, Is it possible to right align the Ipaddress? Normally we can right align the list of numbers by %3u or %7u. How we can right align the Ipaddress? I expects below format output eg 203.199.200.0 203.33.20.0 with regards, Prabahar ___ Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for FREE! http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
regarding popen function
Dear All, The following way of popen function usage is wrong or not kindly give me answer regarding this time = os.popen("echo %s | tai64nlocal" % line[2]).read() Actually here I didn't use any file handler and I didn't close file handler. regards Prabahar __ Free antispam, antivirus and 1GB to save all your messages Only in Yahoo! Mail: http://in.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list