How can I do this in Python?
Hi, I have a web program and a user can have access to a page only after he logged in. So, the program comes with a Login form and the user logins.But I do not know how to return the user back to where he came from, after a successful login. Something like this: PageWhereUserMustBeLogin >UserSigned->- ^--<---<| Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I do this in Python?
Can you please explain in more details (1) choice? Thanks Regards, L -- http://mail.python.org/mailman/listinfo/python-list
How to get the extension of a filename from the path
Hello, what is a way to get the the extension of a filename from the path? E.g., on my XP windows the path can be C:\Pictures\MyDocs\test.txt and I would like to get the the extension of the filename, that is here txt I would like that to work on Linux also Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the extension of a filename from the path
Thank you ALL for help Regards, L. -- http://mail.python.org/mailman/listinfo/python-list
How to find the type ...
Hello How can I find out in Python whether the operand is integer or a character and change from char to int ? Regards, L. -- http://mail.python.org/mailman/listinfo/python-list
How to compare files
Hi, What is the best method for comparing two files by words? I was thinking about reading files by words and compare them but a word in one file can be linked with a new line character ( \n) and this '\n' will cause that the words will considered to be different( eventhough without '\n' are the same) Thanks for help. LAd. -- http://mail.python.org/mailman/listinfo/python-list
Web shop in Python
Does anyone know about an e-shop solution written in Python? Thanks for reply Lad. -- http://mail.python.org/mailman/listinfo/python-list
Web frame systems vs. pure Python
I am thinking about a new project and I do not know if I should use Python with HTML code only or use a web frame such as Cherry or a similar ( which one then??) and a template system. Can you please explain what I will get / lose if I use a web frame system? Thanks a lot La. -- http://mail.python.org/mailman/listinfo/python-list
How can I run a program?
Hello, I am running Python on XP and have a problem with a program if its name consists '-' for example: my-program.py When I try to run a program with such name I get the error : Traceback (most recent call last): File "", line 1, in ? NameError: name 'my' is not defined Python thinks that the name of program is my.py only but the name is my-program.py What is a solution? Thank you Lad. -- http://mail.python.org/mailman/listinfo/python-list
Administrative prohibition error when sending email
I use a new webhosting provider and I can not send an email from my script. This is the script that I use to test the connection ### import smtplib,poplib, #I first login to my POP3 account M=poplib.POP3('www.mywebh.com') M.user('MYWeb) M.pass_('12345') print M.pass_ #check if you login successfully #next send a message fromaddr = "[EMAIL PROTECTED]" toaddrs = "[EMAIL PROTECTED]" msg="This is a test" server = smtplib.SMTP('www.ebayworldstuff.com:25') server.set_debuglevel(1) server.sendmail(fromaddr, toaddrs, msg) server.quit() # It ends with SMTP error 550: Administrative prohibition Where can be a problem? Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Administrative prohibition error when sending email
I solved the problem. The reason was uncomplete email message msg should be like this timezone = ' %+03d%02d' % (-time.timezone/3600, time.timezone%3600) MessageSubject="This is a subject" BodyMessage="This is a body" msg='From: '+fromaddr+' <'+fromaddr+'>\nTo: '+toaddrs+'<'+toaddrs+'>\nDate: '+ time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime(time.time()))+timezone+'\nSubject: '+MessageSubject+'\nReply-to: '+toaddrs+'\nX-Mailer: Microsoft Outlook Express 5.50.4133.2400\n\n'+BodyMessage -- http://mail.python.org/mailman/listinfo/python-list
Where can be a problem?
I use the following ### import re Results=[] data1='' ID = re.compile(r'^.*=(\d+)&.*$',re.MULTILINE) Results=re.findall(ID,data1) print Results # to extract from data1 all numbers such as 15015,15016,15017 But the program extracts only the last number 15017. Why? Thank you for help La. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can be a problem?
Peter, I tried exactly this import re Results=[] data1='' ID = re.compile(r'^.*=(\d+)&.*$',re.MULTILINE) Results=re.findall(ID,data1) print "Results are= ",Results # and received Results are= ['15017'] Not all numbers What exactly did you get? Thanks. L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can be a problem?
Thank you Peter for help. The reason why it did not work was the fact that findall function required CRLF among lines -- http://mail.python.org/mailman/listinfo/python-list
Has anybody tried to make a navigation like Google?
Hi, I would like to make in my web application a similar navigation like Google uses, I mean at the bottom of each page there are numbers of returned pages after you search query. Has anyone tried that? Is there an algorithm for that? I do not want to re-invent the wheel. Thank you for help La. -- http://mail.python.org/mailman/listinfo/python-list
MYSQL - how to install ?
I use XP windows and Python 2.3. How can I install MYSQL on my computer? I could not find any installer for MYSQL and Python 2.3 Thanks for help Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: MYSQL - how to install ?
I am sorry it was my fault I did not say that clearly. I do not have a problem to install MySQL server but I do not know how to install MySQLdb module on my windowsXP so that I can work with MySQL server via Python 2.3. Thanks for help Lad -- http://mail.python.org/mailman/listinfo/python-list
MySQL problem
I have the following program( only insert a record) import MySQLdb conn = MySQLdb.connect (host = "localhost",user = "", passwd = "",db="dilynamobily") cursor = conn.cursor () cursor.execute("""CREATE TABLE produkt1 ( id int(10) unsigned NOT NULL auto_increment, MyNumber varchar(30) NOT NULL default '', PRIMARY KEY (id)) """) #MyValue=111 cursor.execute ("""INSERT INTO produkt1 (MyNumber) VALUES(111) """) # It works. But If I change the program like the following ( only use a variable MyValue in INSERT statement it does not work. ##THIS DOES NOT WORK import MySQLdb,re,string conn = MySQLdb.connect (host = "localhost",user = "", passwd = "",db="dilynamobily") cursor = conn.cursor () cursor.execute("""CREATE TABLE produkt1 ( id int(10) unsigned NOT NULL auto_increment, MyNumber varchar(30) NOT NULL default '', PRIMARY KEY (id)) """) MyValue=111 cursor.execute ("""INSERT INTO produkt1 (MyNumber) VALUES(MyValue) """) # Program says OperationalError: (1054, "Unknown column 'MyValue' in 'field list'") Where is a problem. Thanks for help Lad. -- http://mail.python.org/mailman/listinfo/python-list
Question on sorting
Hi, I have a file of records of 4 fields each. Each field is separated by a semicolon. That is Filed1;Ffield2;Field3;Field4 But there may be also empty records such as (only semicolons). For sorting I used # lines = file('Config.txt').readlines()# a file I want to sort lines.sort() ff=open('ConfigSorted.txt','w')# sorted file ff.writelines(lines) ff.close() ### It was sorted but empty records were first. I need them to be last(at the end of the file). How can I do that? Thanks for help Lad -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on sorting
wes weston <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Lad wrote: > > Hi, > > I have a file of records of 4 fields each. > > Each field is separated by a semicolon. That is > > > > Filed1;Ffield2;Field3;Field4 > > > > But there may be also empty records such as > > > > (only semicolons). > > > > For sorting I used > > # > > lines = file('Config.txt').readlines()# a file I want to sort > > lines.sort() > > ff=open('ConfigSorted.txt','w')# sorted file > > ff.writelines(lines) > > ff.close() > > ####### > > It was sorted but empty records were first. I need them to be last(at > > the end of the file). How can I do that? > > > > Thanks for help > > Lad > > Lad, > The sort call can have a function name as an arg. You > could do: > > def mycompare(s1,s2): > #return -1 to put s1's at front; 1 to put s1's at back; 0 for a tie > #if s1=="" and s2<>"": return 1 > > lines.sort(mycompare) > Wes, Thank you for reply. But I do not understand mycompare function. Can you please explain to me how it should work? Thanks LAd -- http://mail.python.org/mailman/listinfo/python-list
Re: Question on sorting
Peter Otten <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Lad wrote: > > > wes weston <[EMAIL PROTECTED]> wrote in message > > news:<[EMAIL PROTECTED]>... > >> Lad wrote: > >> > Hi, > >> > I have a file of records of 4 fields each. > >> > Each field is separated by a semicolon. That is > >> > > >> > Filed1;Ffield2;Field3;Field4 > >> > > >> > But there may be also empty records such as > >> > > >> > (only semicolons). > >> > > >> > For sorting I used > >> > # > >> > lines = file('Config.txt').readlines()# a file I want to sort > >> > lines.sort() > >> > ff=open('ConfigSorted.txt','w')# sorted file > >> > ff.writelines(lines) > >> > ff.close() > >> > ### > >> > It was sorted but empty records were first. I need them to be last(at > >> > the end of the file). How can I do that? > >> > > >> > Thanks for help > >> > Lad > >> > >> Lad, > >> The sort call can have a function name as an arg. You > >> could do: > >> > >> def mycompare(s1,s2): > >> #return -1 to put s1's at front; 1 to put s1's at back; 0 for a tie > >> #if s1=="" and s2<>"": return 1 > >> > >> lines.sort(mycompare) > >> > > Wes, > > Thank you for reply. But I do not understand mycompare function. Can > > you please explain to me how it should work? Thanks > > compare(a, b) is just a function for comparing two items/lines. I must > return -1 if ab, and 0 if a==b. For example the following > compare moves the "" records to the end and keeps the order of others > unaffected: > > >>> items = ["", ";a;b;;", ";b;a;;", "a;b;c;d;e", "a;;;d;e"] > >>> def compare(a, b): > ... return cmp(a == "", b == "") or cmp(a, b) > ... > >>> items.sort(compare) > >>> items > [';a;b;;', ';b;a;;', 'a;;;d;e', 'a;b;c;d;e', ''] > Petr, thank you for help and explanation. It works Lad -- http://mail.python.org/mailman/listinfo/python-list
Why I can NOT use Python but PHP
I would like to set up my website and allow customers to choose products there, including shopping carts. I would like to use Python but it would be very complicated to start from nothing. Why is there not any(?) framework or complete e-commerce solution written in Python? There are lots in PHP.One, very nice is http://www.oscommerce.org Lad -- http://mail.python.org/mailman/listinfo/python-list
PyParsing module or HTMLParser
I came across pyparsing module by Paul McGuire. It seems to be nice but I am not sure if it is the best for my need. I need to extract some text from html page. The text is in tables and a table can be inside another table. Is it better and easier to use the pyparsing module or HTMLparser? Thanks for suggestions. La. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyParsing module or HTMLParser
Paul, Thank you for your reply. Here is a test page that I woul like to test with PyParsing http://www.ourglobalmarket.com/Test.htm >From that I would like to extract the tittle ( it is below Lanjin Electronics Co., Ltd. ) (Sell 2.4GHz Wireless Mini Color Camera With Audio Function ) description - below the tittle next to the picture Contact person Company name Address fax phone Website Address Do you think that the PyParsing will work for that? Best regards, Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyParsing module or HTMLParser
Paul, thanks a lot. It seems to work but I will have to study the sample hard to be able to do the exercise (the extraction of the description ) successfully. Is it possible to email you if I need some help with that exercise? Thanks again for help Lad. -- http://mail.python.org/mailman/listinfo/python-list
Python or PHP?
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find the type ...
Thank you ALL for help and explanation Regards, L. -- http://mail.python.org/mailman/listinfo/python-list
Why it doesn't work?
I have a list L={} Now I can assign the value L['a']=1 and I have L={'a': 1} but I would like to have a dictionary like this L={'a': {'b':2}} so I would expect I can do L['a']['b']=2 but it does not work. Why? Thank you for reply Rg, L. -- http://mail.python.org/mailman/listinfo/python-list
WSGI
Hello, is there any mod_cgi - WSGI gateway available? (I know only about fast_cgi -WSGI gateway .) Regards, L -- http://mail.python.org/mailman/listinfo/python-list
Datetime objects
How can I find days and minutes difference between two datetime objects? For example If I have b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000) a=datetime.datetime(2006, 8, 1, 18, 19, 45, 765000) Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Datetime objects
Sybren Stuvel wrote: > Lad enlightened us with: > > How can I find days and minutes difference between two datetime > > objects? > > For example If I have > > b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000) > > a=datetime.datetime(2006, 8, 1, 18, 19, 45, 765000) > > diff = b - a Ok, I tried >>> diff=b-a >>> diff datetime.timedelta(0, 52662, 922000) >>> diff.min datetime.timedelta(-9) which is not good for me. So I tried to use toordinal like this diff=b.toordinal()-a.toordinal() but I get diff=1 Why? where do I make a mistake? Thank you for help -- http://mail.python.org/mailman/listinfo/python-list
Re: Datetime objects
John Machin wrote: > Lad wrote: > > Sybren Stuvel wrote: > > > Lad enlightened us with: > > > > How can I find days and minutes difference between two datetime > > > > objects? > > > > For example If I have > > > > b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000) > > > > a=datetime.datetime(2006, 8, 1, 18, 19, 45, 765000) > > > > > > diff = b - a > > > > Ok, I tried > > > > >>> diff=b-a > > >>> diff > > datetime.timedelta(0, 52662, 922000) > > >>> diff.min > > datetime.timedelta(-9) > > Reread the manual: > > 1. "min" is minIMUM, not minUTES > > 2. You need: > >>> diff.days > 0 > >>> diff.seconds > 52662 > >>> diff.microseconds > 922000 > >>> minutes = (diff.seconds + diff.microseconds / 100.0) / 60.0 > >>> minutes > 877.715368 > >>> > > > > > > which is not good for me. > > > > So I tried to use toordinal like this > > diff=b.toordinal()-a.toordinal() > > > > but I get > > diff=1 > > > > Why? > > because toordinal() works only on the date part, ignoring the time > part. > > HTH, > John Thank you for the explanation -- http://mail.python.org/mailman/listinfo/python-list
Datetime question
In a datetime object I would like to change days and hours. Or in other words, I would like to copy this datetime object but increase days and hours. Is it possible? For example:If I have a datetime object like this datetime.datetime(2006, 8, 3, 14, 13, 56, 609000) I would like to make a new ,for example like this datetime.datetime(2006, 8, 12, 10, 13, 56, 609000) is it possible to do so? Thank you L -- http://mail.python.org/mailman/listinfo/python-list
How to get hours and minutes from 'datetime.timedelta' object?
Hello, what is the best /easest way how to get number of hours and minutes from a timedelta object? Let's say we have aa=datetime.datetime(2006, 7, 29, 16, 13, 56, 609000) bb=datetime.datetime(2006, 8, 3, 17, 59, 36, 46000) so c=bb-aa will be datetime.timedelta(5, 6339, 437000) I can easily get days ( c.days) but I still can not figure out how easily to get hours and minutes Any idea? Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
IP address
I would like to record visitor's IP address.How can I do that in Python? Thanks for help L -- http://mail.python.org/mailman/listinfo/python-list
Re: IP address
Sybren Stuvel wrote: > Lad enlightened us with: > > I would like to record visitor's IP address.How can I do that in > > Python? > > Too little information. Visitors of what? > > Sybren I have a website written in Python and I would like to login every visitor's IP address. In other words, if a visitor come to my Python application, this application will record his IP. Is it possible? Thank you B. -- http://mail.python.org/mailman/listinfo/python-list
Re: IP address
Sybren Stuvel wrote: > Lad enlightened us with: > > I have a website written in Python and I would like to login every > > visitor's IP address. > > Ehm... that's probably "log" not "login". > > > In other words, if a visitor come to my Python application, this > > application will record his IP. Is it possible? > > Sure it is. At least, using most Python web-interfaces. I can't give > you more info, since you don't describe anything about the website. Is > it mod_python? Django? CGI? Something else? Try giving us some > information we can work with! It is Django with mod_python Regards, L -- http://mail.python.org/mailman/listinfo/python-list
How to decode a string
To be able to decode a string successfully, I need to know what coding it is in. The string can be coded in utf8 or in windows-1250 or in another coding. Is there a method how to find out the string coding. Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to decode a string
Fredrik Lundh wrote: > Lad wrote: > > > To be able to decode a string successfully, I need to know what coding > > it is in. > > ask whoever provided the string. > > > The string can be coded in utf8 or in windows-1250 or in another > > coding. Is there a method how to find out the string coding. > > in general, no. if you have enough text, you may guess, but the right > approach for that depends on the application. > > Fredrik, Thank you for your reply The text is from Mysql table field that uses utf8_czech_ci collation, but when I try `RealName`.decode('utf8'),where RealName is that field of MySQL I will get: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128) Can you please suggest the solution? Thank you L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to decode a string
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Lad wrote: > > > The text is from Mysql table field that uses utf8_czech_ci collation, > > but when I try > > `RealName`.decode('utf8'),where RealName is that field of MySQL > > > > I will get: > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: > > ordinal > > not in range(128) > > > > Can you please suggest the solution? > > Do you get this from converting the value from the database or from trying > to print the unicode string? Can you give us the output of > > print repr(RealName) > > Ciao, Marc 'BlackJack' Rintsch for print repr(RealName) command I will get P?ibylov\xe1 Ludmila where instead of ? should be also a character Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to decode a string
Fredrik Lundh wrote: > Lad wrote: > > > for > > print repr(RealName) command > > I will get > > > > P?ibylov\xe1 Ludmila > > where instead of ? should be also a character > > that's not very likely; repr() always includes quotes, always escapes > non-ASCII characters, and optionally includes a Unicode prefix. > > please try this > >print "*", repr(RealName), type(RealName), "*" > > and post the entire output; that is, *everything* between the asterisks. > The result of print "*", repr(RealName), type(RealName), "*" is * 'Fritschov\xe1 Laura' * Best regards, L -- http://mail.python.org/mailman/listinfo/python-list
Re: How to decode a string
Fredrik Lundh wrote: > "Lad" wrote: > > > The result of print "*", repr(RealName), type(RealName), "*" is > > > > * 'Fritschov\xe1 Laura' * > > looks like the MySQL interface is returning 8-bit strings using ISO-8859-1 > encoding (or some variation of that; \xE1 is "LATIN SMALL LETTER A > WITH ACUTE" in 8859-1). > > have you tried passing "use_unicode=True" to the connect() call ? > > Frederik, Thank you for your reply. I found out that if I do not decode the string at all, it looks correct. But I do not know why it is ok without decoding. I use Django and I do not use use_unicode=True" to the connect() call. -- http://mail.python.org/mailman/listinfo/python-list
Any idea how to do this in Python?
In a web application users can post some information. I would like to link each posting with a "weight of importance" for a user, depending on a keywords in the posting. For example, I know that a user A is interested in Nokia mobiles while user B in Siemens mobiles. So, if a user A is signed, he would see postings with more Nokia information FIRST, while B user will see FIRST information about Siemens mobiles How can be that done in Python? Thank you for any idea. L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Any idea how to do this in Python?
Dennis, Thank you for your reply You say: >Pretend you are the computer/application/etc. How would YOU > perform such a ranking? That is what I do not know , how to perform such ranking. Do you have any idea? Regards, Lad. -- http://mail.python.org/mailman/listinfo/python-list
Dictionaries
How can I add two dictionaries into one? E.g. a={'a:1} b={'b':2} I need the result {'a':1,'b':2}. Is it possible? Thank you L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionaries
Tim Chase wrote: > > How can I add two dictionaries into one? > > E.g. > > a={'a:1} > > b={'b':2} > > > > I need > > > > the result {'a':1,'b':2}. > > >>> a.update(b) > >>> a > {'a':1,'b':2} > > -tkc Thank you ALL for help. However It does not work as I would need. Let's suppose I have a={'c':1,'d':2} b={'c':2} but a.update(b) will make {'c': 2, 'd': 2} and I would need {'c': 3, 'd': 2} (because `c` is 1 in `a` dictionary and `c` is 2 in `b` dictionary, so 1+2=3) How can be done that? Thank you for the reply L -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionaries
Steven, Thank you for your reply and question. > > What should the result be if both dictionaries have the same key? The answer: the values should be added together and assigned to the key That is {'a':1, 'b':5} ( from your example below) Is there a solution? Thanks for the reply L. > > a={'a':1, 'b'=2} > b={'b':3} > > should the result be: > {'a':1, 'b'=2} # keep the existing value > {'a':1, 'b'=3} # replace the existing value > {'a':1, 'b'=[2, 3]} # keep both values > or something else? > > Other people have already suggested using the update() method. If you want > more control, you can do something like this: > > def add_dict(A, B): > """Add dictionaries A and B and return a new dictionary.""" > C = A.copy() # start with a copy of A > for key, value in B.items(): > if C.has_key(key): > raise ValueError("duplicate key '%s' detected!" % key) > C[key] = value > return C > > > -- > Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionaries
Steven, Thank you for help; Here is a code that works in a way I need A={'c':1,'d':2,'e':3,'f':2} B={'c':2,'e':1} if len(A)>=len(B): Delsi=B C = A.copy() else: Delsi=A C = B.copy() for key, value in Delsi.items(): if C.has_key(key): C[key]=C[key]+value else: C[key]=value How easy :-) Regards, L. Steven D'Aprano wrote: > On Wed, 18 Oct 2006 09:31:50 -0700, Lad wrote: > > > > > Steven, > > Thank you for your reply and question. > > > >> > >> What should the result be if both dictionaries have the same key? > > The answer: the values should be added together and assigned to the key > > That is > > {'a':1, 'b':5} > > ( from your example below) > > > > Is there a solution? > > Of course there is a solution. You just have to program it. > > Look again at my example code before: > > def add_dict(A, B): > """Add dictionaries A and B and return a new dictionary.""" > C = A.copy() # start with a copy of A > for key, value in B.items(): > if C.has_key(key): > raise ValueError("duplicate key '%s' detected!" % key) > C[key] = value > return C > > > Can you see how to modify this function to do what you want? > > (Hint: instead of raising a ValueError exception, you want to do something > else.) > > > -- > Steven. -- http://mail.python.org/mailman/listinfo/python-list
Dictionaries again - where do I make a mistake?
I use the following code to sort dictionary. Olddict={'r':4,'c':1,'d':2,'e':3,'f':2} Newdict={} i = [(val, key) for (key, val) in Olddict.items()] i.sort() # by val i.reverse() # Get largest first. for (val, key) in i: print key,val Newdict[key]=val print Olddict print Newdict Sorting seems to be OK,. the command print key,val prints the proper values but I can not create Newdict to be sorted properly. Where do I make a mistake? Thank you for help. L -- http://mail.python.org/mailman/listinfo/python-list
FOR statement
If I have a list Mylist=[1,2,3,4,5] I can print it for i in Mylist: print i and results is 1 2 3 4 5 But how can I print it in a reverse order so that I get 5 4 3 2 1 ? Thanks. L -- http://mail.python.org/mailman/listinfo/python-list
Re: FOR statement
[EMAIL PROTECTED] wrote: > Lad wrote: > > If I have a list > > > > Mylist=[1,2,3,4,5] > > I can print it > > > > for i in Mylist: > >print i > > > > and results is > > 1 > > 2 > > 3 > > 4 > > 5 > > > > > > But how can I print it in a reverse order so that I get > > 5 > > 4 > > 3 > > 2 > > 1 > > > > > > > > ? > > > > > > Thanks. > > L > > reverse the list in place with reverse method > > l.reverse() > for i in l: > print i > > and the reverse it back if needed Thank you ALL for help. L. -- http://mail.python.org/mailman/listinfo/python-list
Test
Test -- http://mail.python.org/mailman/listinfo/python-list
Sorted list - how to change it
I have a sorted list for example [1,2,3,4,5] and I would like to change it in a random way e.g [2,5,3,1,4] or [3,4,1,5,2] or in any other way except being ordered. What is the best/easiest way how to do it? Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Sorted list - how to change it
Wolfram Kraus wrote: > On 09.11.2006 10:52, Lad wrote: > > I have a sorted list for example [1,2,3,4,5] and I would like to change > > it in a random way > > e.g [2,5,3,1,4] or [3,4,1,5,2] or in any other way except being > > ordered. > > What is the best/easiest > > way how to do it? > > > > Thank you for help > > L. > > > use random.shuffel: > > >>> import random > >>> x = [1,2,3,4,5] > >>> random.shuffle(x) > >>> x > [1, 4, 2, 3, 5] > >>> random.shuffle(x) > >>> x > [4, 2, 1, 3, 5] > > see: http://docs.python.org/lib/module-random.html Wolfram, Thanks a lot for help L. -- http://mail.python.org/mailman/listinfo/python-list
How to add few pictures into one
Hello , is it possible to add( with PYTHON language) several image files into one? Thanks for reply L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
K.S.Sreeram wrote: > Lad wrote: > > Hello , > > is it possible to add( with PYTHON language) several image files into > > one? > > Google for 'Python Imaging Library'... > > Regards > Sreeram > > > Thank you for your reply. I was thinking about this: to open each image file in binary mode , read it and write into the result image file? Is that possible? Regards, L -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Steve Holden wrote: > Lad wrote: > > K.S.Sreeram wrote: > > > >>Lad wrote: > >> > >>>Hello , > >>>is it possible to add( with PYTHON language) several image files into > >>>one? > >> > >>Google for 'Python Imaging Library'... > >> > >>Regards > >>Sreeram > >> > >> > >> > > > > Thank you for your reply. > > I was thinking about this: > > to open each image file in binary mode , read it and write into the > > result image file? > > Is that possible? > > Regards, > > L > > > Of course, but what you haven't said yet is how you want the resulting > image file to behave. Do you want it to contain tiled copies of the > original images, or be an animation with each frame being one of the > original images, or something else I haven't thought of. > > We aren't mind readers here. > > though-some-regulars-get-close-ly y'rs - steve > -- Steve Thank you for your reply All that I want is this: I download ( via Python) some pictures from internet and I want to add all these pictures into one =one file/ So far, I managed to download pictures but I do not know how to add i them nto one file. How can I do that? Thank you for reply and help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
> > All that I want is this: > > I download ( via Python) some pictures from internet and I want to add > > all these pictures into one =one file/ > > So far, I managed to download pictures but I do not know how to add i > > them nto one file. > > How can I do that? > > Thank you for reply and help > > L. > > > Zip file? Image file? "Add all these pictures into one file" isn't (fro > me) a sufficient specification. I want to to do that as easy as possible. I think the easest way could be add( append) an image to another into an image file so that I can use an image browser and see all pictures in one file. Is that possible? Thank you for reply L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
[EMAIL PROTECTED] wrote: > Lad wrote: > > I want to to do that as easy as possible. > > But not even more easy. > > > > I think the easest way could be add( append) an image to another > > into an image file so that I can use an image browser and see all > > pictures in one file. Is that possible? > > Well, you can do it with PIL, creating a very big white image and > putting on it all the images, as tiles. > But probably you want to do something different. > Maybe you can use PyUNO to create a PowerPoint-like (Presentation) file > with an image on each page. > If you are on Win another easy way is to create an Html page that shows > all the pics, open it with Explorer and save it as a single HMT file. > Probably there are other solutions. I was thinking about much less complicated task. I thought about this: Open a picture file( download it from internet) and write it in a result file( being open in binary mode). Then download another file and append to the result file. And so on... But is it possible? Will be the pictures in the result file seen well?? regards, L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Fredrik Lundh wrote: > Lad wrote: > > > Open a picture file( download it from internet) and write it in a > > result file( being open in binary mode). > > Then download another file and append to the result file. > > And so on... > > But is it possible? Will be the pictures in the result file seen > > well?? > > the internal structure of an image file is quite a bit more complicated > than the internal structure of a text file, so it's not very likely that > you would get very far with that approach. > > why not just put all the files in a directory, and use an image viewer > with collage or slideshow support ? > Fredrik, Thank you for your reply. I really would like to have ALL pictures in one file. So, what would be the easiest/best way how to do that? Thank you for your reply regards, L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Fredrik Lundh wrote: > Lad wrote: > > > I really would like to have ALL pictures in one file. > > So, what would be the easiest/best way how to do that? > > do you want to look at the images as a slideshow or as a collage? > > As a collage only -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
K.S.Sreeram wrote: > Lad wrote: > > I really would like to have ALL pictures in one file. > > import Image > > def merge_images( input_files, output_file ) : > img_list = [Image.open(f) for f in input_files] > out_width = max( [img.size[0] for img in img_list] ) > out_height = sum( [img.size[1] for img in img_list] ) > out = Image.new( 'RGB', (out_width,out_height) ) > y = 0 > for img in img_list : > w,h = img.size > out.paste( img, (0,y,w,y+h) ) > y += h > out.save( output_file ) > > Use like this: > >>> merge_images( ['1.jpg','2.jpg','3.jpg'], 'output.jpg' ) > > Regards Sreeram, Thanks a lot > > > --enig1BF4CF77824C603826EE139D > Content-Type: application/pgp-signature > Content-Transfer-Encoding: base64 > Content-Disposition: inline; > filename="signature.asc" > Content-Description: OpenPGP digital signature > X-Google-AttachSize: 253 -- http://mail.python.org/mailman/listinfo/python-list
PIL problem after installation
I installed PIL under Linux but now when I try it I get the error: decoder jpeg not available How can I correct that problem? Thank you for help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL problem after installation
Fredrik Lundh wrote: > Lad wrote: > > > I installed PIL under Linux but now when I try it I get the error: > > > > decoder jpeg not available > > How can I correct that problem? > > if you built PIL yourself, the setup script told you how to fix this. > > - make sure you have right libraries installed (see the >"prerequisites" section in the README) > > - run setup and read the BUILD SUMMARY report carefully > > - if the setup script cannot find a component, you'll have to edit >the setup.py file and set the appropriate ROOT variable. see in- >structions in the setup.py file for details. Fredrik, Thank you for the reply. So I did the following: 1. I downloaded jpeg (from ftp://ftp.uu.net/graphics/jpeg/ ) source libraries( file jpegsrc.v6b.tar.gz) and installed them. Now in /usr/local/lib I have the following files: cjpeg ,djpeg,jpegtran,rdjpgcom and wrjpgcom 2. I opened setup.py file in Imaging 1.1.5 directory and changed JPEG_ROOT =None into JPEG_ROOT = "/usr/local/lib/" 3.ran python setup.py build_ext -i but it still says *** JPEG support not available What did I wrong? Can you please help? Thank you L. -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL problem after installation
Fredrik Lundh wrote: > Lad wrote: > > > I downloaded jpeg (from ftp://ftp.uu.net/graphics/jpeg/ ) source > > libraries( file jpegsrc.v6b.tar.gz) and installed them. Now in > > /usr/local/lib I have the following files: cjpeg > > ,djpeg,jpegtran,rdjpgcom and wrjpgcom > > cjpeg, djpeg etc are executables, not libraries. if you have them under > /usr/local/lib, something's not quite right. > > to save some time, I suggest looking for a jpeg-dev or jpeg-devel > package in the package repository for your platform. > > Hello Fredrik, Thank you for your reply. I installed jpeg-devel package and now selftest.py worked! But I want to use PIL in my Python program( Django) running under Apache. What permissions must I use for which files? Thank you very much for your help. regards, L, -- http://mail.python.org/mailman/listinfo/python-list
Blog source code in Python
Is there a blog application source available in Python? Thank you for reply L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Blog source code in Python
Frederic and Klaus, Thank you for the reply L. Klaus Alexander Seistrup wrote: > Lazy Lad wrote: > > > Is there a blog application source available in Python? > > Several. Did you try Google before you posted your question? The search > term "python blog" has <http://wiki.python.org/moin/PythonBlogSoftware> > within the first 10 hits. > > Cheers, > > -- > Klaus Alexander Seistrup > Copenhagen, Denmark > http://surdej.dk/ -- http://mail.python.org/mailman/listinfo/python-list
Is there a way to find IP address?
Normaly I can log user's IP address using os.environ["REMOTE_ADDR"] . If a user is behind a proxy, I will log proxy's IP address only. Is there a way how to find a real IP user's address? Thank you for help. LL. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to find IP address?
Fredrik Lundh wrote: > Lad wrote: > > > Normaly I can log user's IP address using os.environ["REMOTE_ADDR"] . > > If a user is behind a proxy, I will log proxy's IP address only. > > Is there a way how to find a real IP user's address? > > os.environ["HTTP_X_FORWARDED_FOR"] > > (but that can easily be spoofed, and is mostly meaningless if the user > uses local IP addresses at the other side of the proxy, so you should > use it with care) > > Hello Fredrik, Thank you for your reply. How can be HTTP_X_FORWARDED_FOR easily spoofed? I thought that IP address is not possible change. Thank you for your reply L. -- http://mail.python.org/mailman/listinfo/python-list
Is it possible to change a picture resolution with Python?
Is it possible to change a picture resolution with Python? Let's say I have a picture with a resolution of 96 dpi and I would like to increase to 256dpi or higher. Thank you for your reply. LL -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to change a picture resolution with Python?
from > image: > http://www.pythonware.com/library/pil/handbook/image.htm > > This is some example code: > > from PIL import Image > im = Image.open("1.jpg") > nx, ny = im.size > im2 = im.resize((int(nx*1.5), int(ny*1.5)), Image.BICUBIC) > im2.save("2.png") > > Bye, bearophile, Thank you for your reply. But the above code increases size only , but not DPI resolutions( vertical nad horizontal).I need a higher vertical and horisontal resolutions. Any idea how to do that? Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to change a picture resolution with Python?
Tim Roberts wrote: > "Lad" <[EMAIL PROTECTED]> wrote: > > >from > >> image: > >> http://www.pythonware.com/library/pil/handbook/image.htm > >> > >> This is some example code: > >> > >> from PIL import Image > >> im = Image.open("1.jpg") > >> nx, ny = im.size > >> im2 = im.resize((int(nx*1.5), int(ny*1.5)), Image.BICUBIC) > >> im2.save("2.png") > >> > >> Bye, > > bearophile, > >Thank you for your reply. > >But the above code increases size only , but not DPI resolutions( > >vertical nad horizontal).I need a higher vertical and horisontal > >resolutions. > > I'm not convinced that you know what you are asking for. > > Let's say you have an image that is 300x300 pixels, that is tagged as being > 100 dpi. Such an image is expected to be printed at a 3" x 3" size. > > Now, if you want to increase the dpi to 300 dpi, what does that mean? Does > it mean you want that same picture to be printed at a 1" x 1" size? If so, > then all you need to change is the picture header. It will still be > 300x300 pixels, and the file will be the same number of bytes. > > Or, do you mean that you want the picture to continue to print as 3" x 3", > but to have three times as many pixels in each direction? That means you > have to increase the number of pixels to 900x900. That's exactly what the > code above is doing. The image file will be 9 times larger. Tim , Thank you for the explanation, And I must also thank you all you others, who helped me. Particularly, bearophile and Max. Now I use the following code , that provided bearophile, from PIL import Image im = Image.open("output3.jpg") nx, ny = im.size im2 = im.resize((int(nx*2.5), int(ny*2.5)), Image.BICUBIC) im2.save("2000.png",dpi=(520,520)) and very important thing was dpi=(520,520) that provided Max, L. -- http://mail.python.org/mailman/listinfo/python-list
Is there a regular expression for finding email address ?
Did anyone try to find out a regular expression for finding an email address in a text? Thank you for the reply L. -- http://mail.python.org/mailman/listinfo/python-list
Video feature
I would like to add on my website a possibility for visitors to upload video and watch other user's video. How much difficult would it be with Python? Thank you any for idea. L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Video feature
Hello Tim, Thank you for your reply. Yes, my site uses Python. Do you have any idea how to add video playing ( video streaming feature)to my webiste? Thank you for help L. Tim Roberts wrote: > "Lad" <[EMAIL PROTECTED]> wrote: > > > >I would like to add on my website a possibility for visitors to > >upload video and watch other user's video. How much difficult would it > >be with Python? > > It's not all that hard, although you can probably download something that > will do most of the job, probably in PHP. Is your website already using > Python? > -- > Tim Roberts, [EMAIL PROTECTED] > Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Video stream server
Hello, Does anybody know about a video stream server that serves up HTML pages with links to video files, and then serving out those video files. L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Video stream server
Fredrik, Thank you for your reply. If I use the YOUTUBE.com server , I would have to connect to THEIR computers whenever a user will come to MY website to play a video stream on MY website. Is it so? Regards, L. Lundh wrote: > Lad wrote: > > > Does anybody know about a video stream server that > > serves up HTML pages with links to video files, and then serving out > > those video files. > > http://www.youtube.com/ seems to match your specification pretty well. > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Video stream server
Fredrik, Thank you for your reply > > but I think you're missing the point; you need to provide more > information about your specific requirements than just "a HTML > page that links to a video file". like, say, in what way this > is related to Python, what software you're using today, what > kind of videos we're talking about, etc. The most important thing now is how to add a support for video files. As to kind of videos, it is not too much important because I can allow user to upload/play a certain kinds of videos only or transform some kinds of videos into the correct types > what way this is related to Python, I love Python so I would like to implement video support in Python. That is how it is related to Python only L. > > -- http://mail.python.org/mailman/listinfo/python-list
PyMedia - some questions
Hi, Can anyone answer the following questions? Question 1. Can pyMedia create/convert FLV format? I explain in details. As I would like to publish videos for viewing in a browser , I need a good video format. I learned that FLV (Flash(tm) Video) format could be a good choice. Or does anybody suggest a better format??? Question 2 . So, I need to convert a file captured from a video camera into that FLV (Flash(tm) Video) format . Can pyMedia do that or must I use ffmpeg directly like this( to convert from avi to FLV ) ffmpeg -i [sourcefile.avi] -acodec mp3 -ar 22050 -ab 32 -f flv -s 320×240 [destfile.flv] Question 3, This command creates a simple FLV format file, containing the video and audio streams. In addition, FLV files need meta-information such as duration, frames, etc. FLV movie players use this information to calculate progress bar sliders and allow the user to fast-forward or reverse through the video. Can PyMedia add such meta- information? Thank you for help Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Video stream server
Fredrik Lundh wrote: > Lad wrote: > > > I love Python so I would like to implement video support in Python. > > maybe this might be helpful? > > http://blog.go4teams.com/archives/video-blogging-using-django-and-flashtm-video-flv/56 > > Yes, it is very good link. Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: Video stream server
Hi Paul, I checked your video strem server.It seems interesting for me. Can you please answer these questions? 1. What is a price? 2.Do you support FLV format files, if not, why? 3. How many users do already use the server? 4. Can you name any of your customers ? Thank you Lad, Paul Boddie wrote: > Lad wrote: > > > > I love Python so I would like to implement video support in Python. > > That is how it is related to Python only > > I'm not sure if this is too low-level, but there's always the Flumotion > platform [1]: an open source streaming solution based on Python, > GStreamer and Twisted, and there's a Java applet for viewing in Web > pages (I'll save my rant about Flash for another time). This PyCon 2005 > presentation slide takes you to the key points: > > http://www.flumotion.net/doc/flumotion/presentation/pycon2005/html/img4.html > > Of course, this is more about streaming than just video uploads and > downloads, but if you're considering streaming (or if anyone else > reading is), it's probably worth looking into. > > Paul > > [1] http://www.flumotion.net/ -- http://mail.python.org/mailman/listinfo/python-list
SSH File Transfer Protocol or SFTP
Is there a module in Python available that I can use for uploading files via SFTP (SSH File Transfer Protocol)? Or do you think that FTP protocol for files uploading is OK? Thank you for replies Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: SSH File Transfer Protocol or SFTP
Avell Diroll wrote: > Lad wrote: > > Is there a module in Python available that I can use for uploading > > files via > > SFTP (SSH File Transfer Protocol)? > > Or do you think that FTP protocol for files uploading is OK? > > Thank you for replies > > Lad. > > > > I believe there are many of those, personally i am using paramiko : > > http://www.lag.net/paramiko/ > Thank you ALL for help. Paramiko seems the best for my needs. Lad. -- http://mail.python.org/mailman/listinfo/python-list
How to upload a file
Users needs to upload big files upto 100MB.So I think that FTP protocol would be a solution, but how can I allow users to select the right file ,on their local disk, via a file dialog ? Thank you for your ideas L. -- http://mail.python.org/mailman/listinfo/python-list
Large files uploading
If a user will upload large files via FTP protocol, must the user have an FTP client on his computer or is it possible to use a similar way to "http form" comunication? Or is there another way( besides FTP) how to upload large files to server? Thank you he help Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: YouTube written in Python
Speaking of YouTube, does anyone know how they uploads big files( 100MB) I need to solve that problem ( in Python of course) and YouTube is a good sample of that. Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Large files uploading
> to use any communications protocol (including HTTP), both ends must have > programs that can talk that protocol... > Sure, but browsers have FTP support. But how to call the FTP API from Python? Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Large files uploading
Fredrik, Thank you for your reply I need to upload large files ( about 100MB ). HTTP protocol provides FORMs for uploading which is elegant and good solution for small files but using HTTP protocol for large files is not good ( server's timeouts, big memory consumption on server's side, etc.). So,I was thinking about FTP protocol, but there may be better solutions too. (FTP server would be running on server) I am sure, it can be done this or that way in Python too. (YouTube.com is a good example) Do you have any idea how to do that? Thank you Lad, As I mentioned YouTube also uses Python , so I thi > > > But how to call the FTP API from Python? > > if you want the users to upload things using FTP, why do *you* need > to call "the FTP API" (whatever that is) from Python ? why not just > set up a server? > -- http://mail.python.org/mailman/listinfo/python-list
How to replace a comma
In a text I need to add a blank(space) after a comma but only if there was no blank(space) after the comman If there was a blank(space), no change is made. I think it could be a task for regular expression but can not figure out the correct regular expression. Can anyone help, please? Thank you L. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to replace a comma
Thank you for ALL for help. Hendrik, your solution works great but what is `_` in _.replace(',',', ') for? Thank you La. > re's are a pain. Do this instead: > > >>> s = "hello, goodbye,boo" > >>> s.replace(', ',',') > 'hello,goodbye,boo' > >>> _.replace(',',', ') > 'hello, goodbye, boo' > >>> > > Hope this helps - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: How to replace a comma
Nick Craig-Wood wrote: > Lad <[EMAIL PROTECTED]> wrote: > > In a text I need to add a blank(space) after a comma but only if > > there was no blank(space) after the comman If there was a > > blank(space), no change is made. > > > > I think it could be a task for regular expression but can not > > figure out the correct regular expression. > > You can do it with a zero width negative lookahead assertion, eg > > >>> import re > >>> s="One, Two,Three,Four, File" > >>> re.sub(r",(?!\s)", ", ", s) > 'One, Two, Three, Four, File' > >>> > > From the help :- > > (?!...) > Matches if ... doesn't match next. This is a negative lookahead > assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if > it's not followed by 'Asimov' > > Or in a more straightforward but less efficient and accurate style - > this matches the next character which gets added back into the string. > > >>> re.sub(r",([^\s])", r", \1", s) > 'One, Two, Three, Four, File' > >>> > > This shows a fundamental difference between the two methods > > >>> t = "," > >>> re.sub(r",(?!\s)", ", ", t) > ', , , , , ' > >>> re.sub(r",([^\s])", r", \1", t) > ', ,, ,,' > >>> Nick, Thanks a lot.It works GREAT! La. -- http://mail.python.org/mailman/listinfo/python-list
Can Python help?
On my website I allow users to upload files. I would like a user to see how much time is left before a file is uploaded. So, I would like to have a progress bar during a file uploading. Can Python help me with that?Or how can be a progress bar made? Thank you for ideas. La. -- http://mail.python.org/mailman/listinfo/python-list
Mod_python
In my web application I use Apache and mod_python. I allow users to upload huge files( via HTTP FORM , using POST method) I would like to store the file directly on a hard disk and not to upload the WHOLE huge file into server's memory first. Can anyone suggest a solution? Thank you LB -- http://mail.python.org/mailman/listinfo/python-list
Re: Mod_python
Maxim Sloyko wrote: > Lad wrote: > > In my web application I use Apache and mod_python. > > I allow users to upload huge files( via HTTP FORM , using POST method) > > I would like to store the file directly on a hard disk and not to > > upload the WHOLE huge file into server's memory first. > > Can anyone suggest a solution? > > The only solution you need is Apache and mod_python :) > I mean, Apache won't load a huge POST request into its memory no > matter what. All file uploads will be stored in temporary files. Under > mod_python (provided you use FieldStorage) you'll need to deal only > with 'file' objects. Maxim , Thank you for your reply. Here is an example: If a user uploads 100MB file , what will be a consumption of memory, when the upload is complete? Or does it mean that Apache will read a part of a file , store it in a temporary file, then read another part and adds this part to the temporary file and so on until the whole uploaded file is read? Thank you for the reply. Lad -- http://mail.python.org/mailman/listinfo/python-list
Pythonwin - problem with non English character
Hello, is there a way how to use PythonWin for editting of Python files that consist non English characters? In my Python scripts I need to use( print) Cyrilic characters and with PythonWin it is not possible . I use PythonWin 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32. Thank you L. -- http://mail.python.org/mailman/listinfo/python-list
What editor shall I use?
What editor shall I use if my Python script must contain utf-8 characters? I use XP Thank you for reply l.b. -- http://mail.python.org/mailman/listinfo/python-list
Re: What editor shall I use?
is vim for XP? -- http://mail.python.org/mailman/listinfo/python-list
Re: What editor shall I use?
I did not find where I can set encoding type in vim -- http://mail.python.org/mailman/listinfo/python-list
How to check...
Hello, How can I check that a string does NOT contain NON English characters? Thanks L. -- http://mail.python.org/mailman/listinfo/python-list
Encoding
I have a script that uses utf-8 encoding. Now I would like to send some data to an application ( on another server) that uses 1250 encoding. How can I tell the server that the coming data will be in utf-8 code? I tried this params='some data' h = httplib.HTTP(self.host) h.putheader("Content-type", "multipart/form-data; boundary=---7d329422844") h.putheader("Content-length", "%d" % len(params)) h.putheader("Accept-Language", "us-en") h.putheader('Accept', 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*') h.putheader('User-Agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)') h.putheader('Host', 'server') h.endheaders() . but it doesn't work. The data are not encoded properly Thanks for help L.B. -- http://mail.python.org/mailman/listinfo/python-list