LinuxQuestions.org
Review your favorite Linux distribution.
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 10-28-2008, 01:06 PM   #16
abolishtheun
Member
 
Registered: Mar 2008
Posts: 183

Rep: Reputation: 31

Quote:
Originally Posted by ghostdog74 View Post
you judge for yourself.
Yet yours is less powerful than the example I gave, which can take in input from either STDIN or arbitrarily many files given at the command line.
 
Old 10-28-2008, 01:07 PM   #17
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by ghostdog74 View Post
Code:
linenumbers = open("file_num").readlines()
linenumbers = [i.strip() for i in linenumbers]
for line in open("file_data"):
    num,content = line.split(":")
    if num in linenumbers:
        print line.strip()
you judge for yourself.


that's quite true (although i don't quite like the way you put your braces). however, with the help of language syntax and features, it CAN be even clearer.
Again, it's people - "i" is unreadable in "[i.strip() for i in linenumbers]" - if I understand Python correctly, it should be

linenumbers = [line.strip() for line in linenumbers]
.

Regarding my braces - if you just ignore them, you'll get the same indentation as Python forces you to use.
 
Old 10-28-2008, 01:27 PM   #18
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by abolishtheun View Post
Yet yours is less powerful than the example I gave, which can take in input from either STDIN or arbitrarily many files given at the command line.
do you need me to make it more "powerful"?
 
Old 10-28-2008, 01:31 PM   #19
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by Sergei Steshenko View Post
Regarding my braces - if you just ignore them, you'll get the same indentation as Python forces you to use.
try ignoring them for big projects with few thousand LOC. I am also not about to get deeper into this, so you all can carry on, i'm out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
read a line from text file and extracting the details needed pdklinux79 Linux - Newbie 6 06-06-2008 11:41 PM
extracting data from html files into one text file adityavpratap Slackware 9 05-10-2007 11:30 AM
extracting a chunk of text from a large text file lothario Linux - Software 3 02-28-2007 09:16 AM
Grab text lines in text file LULUSNATCH Programming 1 12-02-2005 11:55 AM
Assistance with extracting a series of lines from a log file katsal Linux - General 1 06-21-2005 07:55 PM


All times are GMT -5. The time now is 03:17 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration