A few python questions 
Author Message
 A few python questions

    I've been trying to learn how to program in python and as
an exercise been trying to write a simple database app.  However,
I've that a few questions that don't seem to be answered in the
library reference, tutorial or reference.  
    The first problem I've encountered is trying to determine
the size of a file.  The file type doesn't seem to have any
function that returns the length of a file.  I've been seeking
to the end of the file and then using tell.  However this seems
kind of inelegant, is there a way to get the file size of a file
without doing this or using the stat function from the os module?
    Also is it possible to use PyKDE or PyQT without installing SIP?
I already have SWIG and don't really want to install another tool
that has basically the same functionality.
    Finally, is there some documentation for the python interface
to postgresql?  The rpm package that comes with redhat 6.2 doesn't
have any documentation.

--
------------------------------------------------------------------

Suchandra S. Thapa

------------------------------------------------------------------



Sat, 07 Dec 2002 03:00:00 GMT  
 A few python questions

Quote:

>     The first problem I've encountered is trying to determine
> the size of a file.  The file type doesn't seem to have any
> function that returns the length of a file.  I've been seeking
> to the end of the file and then using tell.  However this seems
> kind of inelegant, is there a way to get the file size of a file
> without doing this or using the stat function from the os module?

os.stat(path) returns a stat tuple.  The seventh element is the file
size in bytes.

Quote:
>     Finally, is there some documentation for the python interface
> to postgresql?  The rpm package that comes with redhat 6.2 doesn't
> have any documentation.

The PyGreSQL package ftp://ftp.druid.net/pub/distrib/PyGreSQL.tgz
(Latest released version) has a tutorial directory.

--
+----------------------------------------------------------------------+
| Rod Haper, Senior Systems Analyst      |  Neles Automation           |
| Phone: 713-346-0652 - direct           |  SCADA Solutions, Inc.      |
|        713-939-0393 - fax              |  7000 Hollister             |

+----------------------------------------------------------------------+



Sat, 07 Dec 2002 03:00:00 GMT  
 A few python questions

    Suchandra> The first problem I've encountered is trying to
    Suchandra> determine the size of a file.

os.path.getsize(path)

    Suchandra> is there a way to get the file size of a file without
    Suchandra> doing this or using the stat function from the os
    Suchandra> module?

that works too, the indexing constants are in the stat module:
os.stat(path)[stat.ST_SIZE]

    Suchandra> Also is it possible to use PyKDE or PyQT without
    Suchandra> installing SIP?

(no idea)

    Suchandra> Finally, is there some documentation for the python
    Suchandra> interface to postgresql?  The rpm package that comes
    Suchandra> with redhat 6.2 doesn't have any documentation.

yes, the README that comes with the module documents the
postgresql-specific api. the most recent versions support DB-API
also. get it from <URL:ftp://ftp.druid.net/pub/distrib/>.

  -- erno



Sat, 07 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. a few more questions on XML and python

2. Few questions about new features in Python 2.2

3. Some questions on elided text in the text widget (and a few other text widget questions)

4. Summiteers: Few new Ada sales if few new Ada hires

5. A few words about Python interfaces

6. [Fwd: A few words about Python interfaces]

7. Wanted to Hire Python programmer. few hours

8. A few more quick observations on speed of Python

9. A few more quick observations on speed of Python

10. A few python.org developments, particularly newsgroup search

11. Why so few Python jobs?

12. A few more newbie questions..

 

 
Powered by phpBB® Forum Software