Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with printing contents of a list
    text
    copied!<p>I'm having a somewhat odd problem with Python(2.6.2) <del>that I've come to the conclusion is a bug in the Vista port (I cant replicate it in XP or Linux).</del></p> <p>I have a list of users, encrypted passwords, and their host that I am storing in a larger list (it's acting as a sort of database).</p> <p>This all works fine and dandy, except for that there is an inconsistency in how a single user's data is stored and how the group is stored.</p> <p>created by the 'create_user' method</p> <blockquote> <p>['localhost', 'demo', 'demouserpasswordhash']</p> </blockquote> <p>created by the 'create_database' method</p> <blockquote> <p>['\xff\xfel\x00o\x00c\x00a\x00l\x00h\x00o\x00s\x00t\x00', '\x00d\x00e\x00m\x00o\x00', '\x00d\x00e\x00m\x00o\x00u\x00s\x00e\x00r\x00p\x00a\x00s\x00s\x00w\x00o\x00r\x00d\x00h\x00a\x00s\x00h\x00\r\x00\n']</p> </blockquote> <p>I don't understand why it's doing this, given how simple the code for it is:</p> <pre><code># ----- base functions def create_user ( user_data ): return user_data.split(":") def show_user ( user_data ): print "Host: ", user_data[0] print "Username: ", user_data[1] print "Password: ", user_data[2] print def create_database ( user_list ): database = [] for user in user_list: database.append( create_user( user ) ) return database def show_database( database ): for row in database: show_user( row ) # ----- test area users = open( "users.txt" ) test_user = create_user( "localhost:demo:demouserpasswordhash" ) db = create_database( users ) print db[0] print test_user # ----- </code></pre> <p>Anyone have any similar experiences with this or is it just me?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload