Re: [Tutor] Decoding from strange symbols

2011-01-19 Thread Alan Gauld
"Oleg Oltar" wrote I am trying to decode a string I took from file: file = open ("./Downloads/lamp-post.csv", 'r') I assume you know what its supposed to represent? What the columns etc are intended to be? Otherwise it will be a challenge! There is a section here that looks like the mon

Re: [Tutor] Decoding from strange symbols

2011-01-19 Thread Steven D'Aprano
Oleg Oltar wrote: Hi, I am trying to decode a string I took from file: [...] How do I convert this to something human readable? In general, you can't unless you know the encoding. A file filled with arbitrary bytes could be anything. However, you can sometimes guess the encoding, either b

Re: [Tutor] Decoding from strange symbols

2011-01-19 Thread Peter Otten
Oleg Oltar wrote: > I am trying to decode a string I took from file: > > file = open ("./Downloads/lamp-post.csv", 'r') > data = file.readlines() > data[0] > > '\xff\xfeK\x00e\x00y\x00w\x00o\x00r\x00d\x00\t\x00C\x00o\x00m\x00p\x00e\x00t\x00i\x00t\x00i\x00o\x00n\x00\t\x00G\x00l\x00o\x00b\x00a\x0

[Tutor] Decoding from strange symbols

2011-01-19 Thread Oleg Oltar
Hi, I am trying to decode a string I took from file: file = open ("./Downloads/lamp-post.csv", 'r') data = file.readlines() data[0] '\xff\xfeK\x00e\x00y\x00w\x00o\x00r\x00d\x00\t\x00C\x00o\x00m\x00p\x00e\x00t\x00i\x00t\x00i\x00o\x00n\x00\t\x00G\x00l\x00o\x00b\x00a\x00l\x00 \x00M\x00o\x00n\x00t\x

Re: [Tutor] Decoding MIME Attachments

2010-04-01 Thread Wayne Werner
On Thu, Apr 1, 2010 at 5:47 PM, wrote: > Hi, all; > > I am a longtime linux sysadmin that is fairly new to Python. I've got a > project for which Python seems to be perfect (or, at least, I've found a > way to integrate my learning :-) Welcome to Python! I highly recommend this book by Noah G

[Tutor] Decoding MIME Attachments

2010-04-01 Thread jneiss
Hi, all; I am a longtime linux sysadmin that is fairly new to Python. I've got a project for which Python seems to be perfect (or, at least, I've found a way to integrate my learning :-) I receive log files via email from an outside vendor. We use Splunk to generate reports based on these and

Re: [Tutor] Decoding

2007-08-12 Thread Kent Johnson
bhaaluu wrote: > Greetings, > >>From what I can tell of this "decoding" function, it uses > the chr() function to return the ascii character: > print chr(eval('65')) > A There is no need to use eval() here. Since the expected values are integers, just use int(): In [6]: chr(int('65')) Out[

Re: [Tutor] Decoding

2007-08-12 Thread Eric Walker
--- bhaaluu <[EMAIL PROTECTED]> wrote: > Greetings, > > From what I can tell of this "decoding" function, it > uses > the chr() function to return the ascii character: > > >>> print chr(eval('65')) > A > > >>> print ord('A') > 65 > > In this textbook example, the "code" is simple a > string o

Re: [Tutor] Decoding

2007-08-12 Thread Eric Walker
--- bhaaluu <[EMAIL PROTECTED]> wrote: > Greetings, > > From what I can tell of this "decoding" function, it > uses > the chr() function to return the ascii character: > > >>> print chr(eval('65')) > A > > >>> print ord('A') > 65 > > In this textbook example, the "code" is simple a > string of

Re: [Tutor] Decoding

2007-08-12 Thread bob gailer
Eric Walker wrote: > newbie here, > Welcome > I just tried playing around with the dec function and > I get errors. Please always post the traceback (error message), and the code you are using. > Correct me if I am wrong. After getting > the input, What input is dec() expecting? As I read it

Re: [Tutor] Decoding

2007-08-12 Thread bhaaluu
Greetings, >From what I can tell of this "decoding" function, it uses the chr() function to return the ascii character: >>> print chr(eval('65')) A >>> print ord('A') 65 In this textbook example, the "code" is simple a string of the ASCII characters' numeric values. Nothing fancy. What does th

Re: [Tutor] Decoding

2007-08-12 Thread Eric Walker
newbie here, I just tried playing around with the dec function and I get errors. Correct me if I am wrong. After getting the input, the string.split will parse the string across whitespace chars so in other words you get a list of each word entered. Then when it does the eval(x) part it dies. I tri

Re: [Tutor] Decoding

2007-08-12 Thread Khamid Nurdiev
Thanks, it really works. On 8/13/07, bhaaluu <[EMAIL PROTECTED]> wrote: > > Greetings, > > Disclaimer: I'm a Python Noob, > so use the code snippets > in this post, at your own risk! > > Is this what you're looking for? > > def dec(a): > import string > result='' > for x in string.spl

Re: [Tutor] Decoding

2007-08-12 Thread Dick Moores
At 02:12 PM 8/12/2007, Dick Moores wrote: At 01:15 PM 8/12/2007, Khamid Nurdiev wrote: Hello All,  I am currently learning python with the book "Python programming: An introduction to CS" by John M. Zelle and have come the section where he speaks of encoding messages. Currently the basic snippet

Re: [Tutor] Decoding

2007-08-12 Thread Dick Moores
At 01:15 PM 8/12/2007, Khamid Nurdiev wrote: Hello All,  I am currently learning python with the book "Python programming: An introduction to CS" by John M. Zelle and have come the section where he speaks of encoding messages. Currently the basic snippet looks like this: def dec():     import

Re: [Tutor] Decoding

2007-08-12 Thread bhaaluu
Greetings, Disclaimer: I'm a Python Noob, so use the code snippets in this post, at your own risk! Is this what you're looking for? def dec(a): import string result='' for x in string.split(a): result=result+chr(eval(x)) return result print dec(raw_input("Enter the messa

[Tutor] Decoding

2007-08-12 Thread Khamid Nurdiev
Hello All, I am currently learning python with the book "Python programming: An introduction to CS" by John M. Zelle and have come the section where he speaks of encoding messages. Currently the basic snippet looks like this: def dec(): > > import string > > message=raw_input("Enter the m

Re: [Tutor] Decoding decleration

2005-11-02 Thread Kent Johnson
Johan Geldenhuys wrote: > I receive this error when executing a file: > "Non-ASCII character '\x8b' in file task.py on line 1, but no encoding > declared". > > Can anybody tell me what the encoding is supposed to look like and is it > standard on all files that is trying to use Non-ASCII charact

[Tutor] Decoding decleration

2005-11-02 Thread Johan Geldenhuys
I receive this error when executing a file: "Non-ASCII character '\x8b' in file task.py on line 1, but no encoding declared". Can anybody tell me what the encoding is supposed to look like and is it standard on all files that is trying to use Non-ASCII characters? Thanks, Johan