[Yum] Ooops ;)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



		Hi, seth!

>>>>> "sv" == seth vidal <skvidal@xxxxxxxxxxxx> writes:

>> @@ -109,13 +109,8 @@
>>      return (epoch, version, release)
>>
>>  def HeaderInfoNevralLoad(filename, nevral, serverid):
>> -    info = []
>>      in_file = open(filename, 'r')
>> - while 1:
>> - in_line = in_file.readline()
>> - if in_line == '':
>> - break
>> - info.append(in_line)
>> +    info = in_file.readlines()
>>      in_file.close()
>>

 sv> Honestly didn't know readlines existed. I was working from the python
 sv> docs on line and well, I had a hard time finding it even when I knew
 sv> it existed :)

 easy way - interactive python prompt.  Just try:
 
 >>> in_file = open('some_file.txt')
 >>> dir(in_file)
 
 
 You don't need read many manuals, references, guides.  Just try work with
 object, read docstrings...
 
In [19]: print in_file.readlines.__doc__
readlines([size]) -> list of strings, each a line from the file.

Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines returned.

 I recoment use IPython (http://www-hep.colorado.edu/~fperez/ipython) 
 - pretty and powerful ineractive python extension 
 
 for example, docsctring can be readed by

In [20]: ?in_file.readlines 
Type:           builtin_function_or_method
Base Class:     <type 'builtin_function_or_method'>
String Form:    <built-in method readlines of file object at 0x82ba290>
Namespace:      Currently not defined in user session.
Docstring:
    readlines([size]) -> list of strings, each a line from the file.
    
    Call readline() repeatedly and return a list of the lines so read.
    The optional size argument, if given, is an approximate bound on the
    total number of bytes in the lines returned.

-- 
		Bor.


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux