Sponsored Content
Full Discussion: Python: Compare 2 word lists
Top Forums Programming Python: Compare 2 word lists Post 302533843 by alister on Friday 24th of June 2011 10:13:24 PM
Old 06-24-2011
Quote:
Originally Posted by yazu
Hey, it is under the comment:
# DON'T DO THIS.
I don't think the "DON'T DO THIS" is intended to indicate that the code gives an erroneous result, but rather to indicate that it's not a very pythonic approach. The fact that the very next "DON'T DO THIS" section gives the correct result would seem to support my supposition.

I point this out mostly for the original poster. It's frustrating (especially for a newbie) to get hung up on a code sample only to find out later, after much facepalming, that it was the teaching material that was the problem.

Regards,
Alister

Last edited by alister; 06-24-2011 at 11:30 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare lists of files

If I had a list of numbers in two different files, what would be the fastest and easiest way to find out which numbers in list B are not in list A without reading each number in list B one at a time and using grep thousands of times against list A? I have two very long lists of numbers and the... (4 Replies)
Discussion started by: keelba
4 Replies

2. UNIX for Dummies Questions & Answers

compare 2 very large lists of different length

I have two very large datasets (>100MB) in a simple vertical list format. They are of different size and with different order and formatting (e.g. whitespace and some other minor cruft that would thwart easy regex). Let's call them set1 and set2. I want to check set2 to see if it contains... (2 Replies)
Discussion started by: uiop44
2 Replies

3. UNIX for Dummies Questions & Answers

Compare 2 lists using a full and/or partial match at beginning of line?

hello all, I wonder if anybody might be able to help with this. I have file 1 and file2. Both files may contain thousands of lines that have variable contents. file1 234GH 5234BTW 89er 678tfg 234 234YT tfg456 wert 78gt gh23444 (7 Replies)
Discussion started by: Garrred
7 Replies

4. Shell Programming and Scripting

Bash script to compare two lists

Hi, I do little bash scripting so sorry for my ignorance. How do I compare if the two variable not match and if they do not match run a command. I was thinking a for loop but then I need another for loop for the 2nd list and I do not think that would work as in the real world there could... (2 Replies)
Discussion started by: GermanJulian
2 Replies

5. Shell Programming and Scripting

Compare two lists with perl

Hi everybody! I'm trying to delete some elements from a list with two elements on each row agreeing with the elements in another list. Pratically I want a perl script able to take each element of the second list (that is a single column list), compare it with both elements of each row from the... (3 Replies)
Discussion started by: gabrysfe
3 Replies

6. Shell Programming and Scripting

compare two lists on two files

I have two files A and B listing ip addresses and all the ip addresses in B are in A, and A includes other ip addresses now I want to get the list of the ip addresses that are in A but not in B how to achieve this? thanks (1 Reply)
Discussion started by: esolvepolito
1 Replies

7. Homework & Coursework Questions

[Python] Compare 2 lists

Hello, I'm new to the python programming, and I have a question. I have to write a program that prints a receipt for a restaurant. The input is a list which looks like: product1 product3 product8 .... In the other input file there is a list which looks like: product1 coffee 5,00... (1 Reply)
Discussion started by: dagendy
1 Replies

8. Shell Programming and Scripting

Separate Text File into Two Lists Using Python

Hello, I have a pretty simple question, but I am new to Python and am trying to write a simple program. Put simply, I want to take a text file that looks like this: 11111 22222 33333 44444 55555 66666 77777 88888 and produce two lists, one containing the contents of the left column, one the... (0 Replies)
Discussion started by: Tyler_92
0 Replies

9. Programming

Populating Lists in Def using Python

Dipping around in python again and need to create a def that will populate a list(content) with the files that os.walk finds from within this directory and then I will re.search through each files looking for content. In learning Python, can someone point me in the right direction. This is what I... (3 Replies)
Discussion started by: metallica1973
3 Replies

10. Programming

Python Concatenating 2 Lists

I am just trying to concatenate two lists together, but I am not sure what is wrong with my code, it won't run. Thank you for any help. #!/usr/bin/python # Takes two lists and returns a list that is the concatenation of both of # them. A = B = def list_concat( A, B): print(A) ... (2 Replies)
Discussion started by: totoro125
2 Replies
Htpasswd(3pm)						User Contributed Perl Documentation					     Htpasswd(3pm)

NAME
Apache::Htpasswd - Manage Unix crypt-style password file. SYNOPSIS
use Apache::Htpasswd; $foo = new Apache::Htpasswd("path-to-file"); $foo = new Apache::Htpasswd({passwdFile => "path-to-file", ReadOnly => 1} ); # Add an entry $foo->htpasswd("zog", "password"); # Change a password $foo->htpasswd("zog", "new-password", "old-password"); # Change a password without checking against old password $foo->htpasswd("zog", "new-password", {'overwrite' => 1}); # Check that a password is correct $foo->htCheckPassword("zog", "password"); # Fetch an encrypted password $foo->fetchPass("foo"); # Delete entry $foo->htDelete("foo"); # If something fails, check error $foo->error; # Write in the extra info field $foo->writeInfo("login", "info"); # Get extra info field for a user $foo->fetchInfo("login"); DESCRIPTION
This module comes with a set of methods to use with htaccess password files. These files (and htaccess) are used to do Basic Authentication on a web server. The passwords file is a flat-file with login name and their associated crypted password. You can use this for non-Apache files if you wish, but it was written specifically for .htaccess style files. FUNCTIONS Apache::Htpasswd->new(...); As of version 1.5.4 named params have been added, and it is suggested that you use them from here on out. Apache::Htpasswd->new("path-to-file"); "path-to-file" should be the path and name of the file containing the login/password information. Apache::Htpasswd->new({passwdFile => "path-to-file", ReadOnly => 1, UseMD5 => 1, }); This is the prefered way to instantiate an object. The 'ReadOnly' param is optional, and will open the file in read-only mode if used. The 'UseMD5' is also optional: it will force MD5 password under Unix. If you want to support plain un-encrypted passwords, then you need to set the UsePlain option (this is NOT recommended, but might be necesary in some situations) error; If a method returns an error, or a method fails, the error can be retrieved by calling error() htCheckPassword("login", "password"); Finds if the password is valid for the given login. Returns 1 if passes. Returns 0 if fails. htpasswd("login", "password"); This will add a new user to the password file. Returns 1 if succeeds. Returns undef on failure. htDelete("login") Delete users entry in password file. Returns 1 on success Returns undef on failure. htpasswd("login", "new-password", "old-password"); If the old-password matches the login's password, then it will replace it with new-password. If the old-password is not correct, will return 0. htpasswd("login", "new-password", {'overwrite' => 1}); Will replace the password for the login. This will force the password to be changed. It does no verification of old-passwords. Returns 1 if succeeds Returns undef if fails fetchPass("login"); Returns encrypted password if succeeds. Returns 0 if login is invalid. Returns undef otherwise. fetchInfo("login"); Returns additional information if succeeds. Returns 0 if login is invalid. Returns undef otherwise. fetchUsers(); Will return either a list of all the user names, or a count of all the users. The following will return a list: my @users = $Htpasswd->fetchUsers(); The following will return the count: my $user_count = $Htpasswd->fetchUsers(); writeInfo("login", "info"); Will replace the additional information for the login. Returns 0 if login is invalid. Returns undef otherwise. CryptPasswd("password", "salt"); Will return an encrypted password using 'crypt'. If salt is ommitted, a salt will be created. INSTALLATION
You install Apache::Htpasswd, as you would install any perl module library, by running these commands: perl Makefile.PL make make test make install make clean If you are going to use MD5 encrypted passwords, you need to install Crypt::PasswdMD5. If you need to support SHA1 encrypted passwords, you need to install Digest::SHA and MIME::Base64. DOCUMENTATION
POD style documentation is included in the module. These are normally converted to manual pages and installed as part of the "make install" process. You should also be able to use the 'perldoc' utility to extract and read documentation from the module files directly. AVAILABILITY
The latest version of Apache::Htpasswd should always be available from: $CPAN/modules/by-authors/id/K/KM/KMELTZ/ Visit <URL:http://www.perl.com/CPAN/> to find a CPAN site near you. CHANGES
Revision 1.8.0 Added proper PREREQ_PM Revision 1.7.0 Handle SHA1 and plaintext. Also change the interface for allowing change of password without first checking old password. IF YOU DON'T READ THE DOCS AND SEE I DID THIS DON'T EMAIL ME! Revision 1.6.0 Handle Blowfish hashes when that's the mechanism crypt() uses. Revision 1.5.9 MD5 for *nix with new UseMD5 arg for new() Revision 1.5.8 Bugfix to htpasswd(). Revision 1.5.7 MD5 for Windows, and other minor changes. Revision 1.5.6 Minor enhancements. Revision 1.5.5 2002/08/14 11:27:05 Newline issue fixed for certain conditions. Revision 1.5.4 2002/07/26 12:17:43 kevin doc fixes, new fetchUsers method, new ReadOnly option, named params for new(), various others Revision 1.5.3 2001/05/02 08:21:18 kevin Minor bugfix Revision 1.5.2 2001/04/03 09:14:57 kevin Really fixed newline problem :) Revision 1.5.1 2001/03/26 08:25:38 kevin Fixed another newline problem Revision 1.5 2001/03/15 01:50:12 kevin Fixed bug to remove newlines Revision 1.4 2001/02/23 08:23:46 kevin Added support for extra info fields Revision 1.3 2000/04/04 15:00:15 meltzek Made file locking safer to avoid race conditions. Fixed typo in docs. Revision 1.2 1999/01/28 22:43:45 meltzek Added slightly more verbose error croaks. Made sure error from htCheckPassword is only called when called directly, and not by $self. Revision 1.1 1998/10/22 03:12:08 meltzek Slightly changed how files lock. Made more use out of carp and croak. Made sure there were no ^M's as per Randal Schwartz's request. BUGS
None known at time of writting. AUTHOR INFORMATION
Copyright 1998..2005, Kevin Meltzer. All rights reserved. It may be used and modified freely, but I do request that this copyright notice remain attached to the file. You may modify this module as you wish, but if you redistribute a modified version, please attach a note listing the modifications you have made. This is released under the same terms as Perl itself. Address bug reports and comments to: kmeltz@cpan.org The author makes no warranties, promises, or gaurentees of this software. As with all software, use at your own risk. SEE ALSO
Apache::Htgroup, Crypt::PasswdMD5, Digest::SHA, MIME::Base64 perl v5.12.4 2011-08-20 Htpasswd(3pm)
All times are GMT -4. The time now is 05:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy