LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-11-2006, 06:38 PM   #1
dudeman41465
Member
 
Registered: Jun 2005
Location: Kentucky
Distribution: Debian
Posts: 794

Rep: Reputation: 56
Python ASCII Converter


I'm learning python and I decided to embark on a little project of my own, I've written a program that will convert back and forth between ASCII and plain text. It converts "to" ASCII just fine, but for some reason I can't figure out what I'm doing wrong in my loop that converts "from" ASCII. Can somebody look over this and correct that function and explain what exactly you did?
Sourcecode here
 
Old 04-11-2006, 07:38 PM   #2
astorm
LQ Newbie
 
Registered: Nov 2005
Distribution: Slackware
Posts: 23

Rep: Reputation: 15
Your code is correct - you're probably using the wrong input. In your function to convert to ASCII, you're outputting a space-separated list of ints. If you input that ("104 101 108 108 111") back into your function to decode to text, it will fail. The input() function that your decode function uses to read input evaluates the command-line input as a python expression, so if you enter "[104, 101, 108, 108, 111]", it should work. If you want to work with the raw string, use the raw_input() that you use in your main function.

Also, pausing for several seconds between menu options isn't very good form in command-line interfaces.

By the way, it's a good idea to copy and paste your code into your post, embedded in [code] tags.

Last edited by astorm; 04-11-2006 at 07:59 PM.
 
Old 04-12-2006, 03:54 AM   #3
dudeman41465
Member
 
Registered: Jun 2005
Location: Kentucky
Distribution: Debian
Posts: 794

Original Poster
Rep: Reputation: 56
Thanks for the help. I'm a beginning programmer, this is my first language. I'll take out the waiting periods, my logic was to give them time to read one line before another one came up, but printing a blank line would avoid the clutter I don't want and still not keep them waiting. Again, thanks for helping.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
image to ascii arts converter, anyone? chunlee Linux - Software 6 02-01-2019 12:49 PM
python: converting a 3 character octal string into and ASCII char llama_meme Programming 1 07-06-2010 02:00 PM
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
python problem - compiled from source - python -V still showing old version txm123 Linux - Newbie 1 02-15-2006 11:05 AM
Binary to Hex Ascii converter carboncopy Slackware 1 05-28-2004 09:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration