Re: Using a Callback Function - ftplib

2009-08-18 Thread Nitebirdz
On Mon, Aug 17, 2009 at 11:10:25AM -0700, seldan24 wrote:
> 
> I didn't even notice the higher level methods.  I changed the
> retrieval line to:
> 
> ftp.nlst("testfile*.txt")
> 
> This works great.  The result is even captured in an array.  I really
> have no idea what the difference between a LIST and NLST is within
> FTP.  Never delved that deep into it.  I did notice that an NLST will
> return a specific FTP code if a file doesn't exist, whereas a LIST
> doesn't.  So, I ended up using NLST as that'll generate an
> ftplib.error_perm exception.  Based on if the job cares if a file is
> not available or not (some do, some don't), I'll either exit, or
> continue on with the file loop.
> 

The following thread from a NetBSD mailing list may help clarify this
issue:

http://mail-index.netbsd.org/netbsd-users/2001/01/30/0016.html


NLST returns a machine-readable list of names, while LIST returns a
human-readable list.  Hene the presence of the FTP code in the case of
NLST.  

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using a Callback Function - ftplib

2009-08-19 Thread nitebirdz
On Mon, Aug 17, 2009 at 11:10:25AM -0700, seldan24 wrote:
> 
> I didn't even notice the higher level methods.  I changed the
> retrieval line to:
> 
> ftp.nlst("testfile*.txt")
> 
> This works great.  The result is even captured in an array.  I really
> have no idea what the difference between a LIST and NLST is within
> FTP.  Never delved that deep into it.  I did notice that an NLST will
> return a specific FTP code if a file doesn't exist, whereas a LIST
> doesn't.  So, I ended up using NLST as that'll generate an
> ftplib.error_perm exception.  Based on if the job cares if a file is
> not available or not (some do, some don't), I'll either exit, or
> continue on with the file loop.
> 

The following thread from a NetBSD mailing list may help clarify this
issue:

http://mail-index.netbsd.org/netbsd-users/2001/01/30/0016.html


NLST returns a machine-readable list of names, while LIST returns a
human-readable list.  Hene the presence of the FTP code in the case of
NLST.  

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What file is foo in package bar in ?

2009-08-20 Thread Nitebirdz
On Thu, Aug 20, 2009 at 01:06:00AM +0200, Christian Heimes wrote:
> northof40 wrote:
>> Given an arbitary package is there some programmatic way to 'ask' what
>> file the method/function is implemented in ?
>
> Indeed, the inspect module contains several useful functions for the  
> job, for example
> http://docs.python.org/library/inspect.html#inspect.getfile
>

Stupid question from someone who ignores it all: since the OP is reading
code from an existing tree in order to learn from it, wouldn't it make
more sense to use something like Cscope?  Assuming it works with Python,
of course.  If it doesn't, is there a similar tool that can be used?  A
related question too is whether any of these tools actually help in an
object-oriented environment.  

http://cscope.sourceforge.net/

http://www.linux.com/archive/feature/114237

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Blank Line at Program Exit

2009-08-22 Thread Nitebirdz
On Thu, Aug 20, 2009 at 01:31:14PM +0800, Steven Woody wrote:
> Hi,
> Any python program, even that does absolutely nothing in the code, will
> cause a blank line printed out when the program exit.  What's the reason?
>  Thanks.
> 

Chances are it is related to whichever operating system and/or shell you
are using.  For instance, this is taken from a system running Ubuntu
Linux 8.04:

-
laptop:$ cat hello.py
#!/usr/bin/env python

print "Hello, there!"
laptop:$ ./hello.py
Hello, there!
laptop:$ cat nothing.py 
#!/usr/bin/env python

laptop:$ ./nothing.py 
laptop:$ 
-


As you can see, no blank line was printed out. 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Blank Line at Program Exit

2009-08-29 Thread Nitebirdz
On Sun, Aug 23, 2009 at 09:07:53PM +0800, Steven Woody wrote:
> 
> Hi,
> I am using cywin on XP.
> 

Sorry for the late reply.  I've been too busy with some personal
matters.  It'd seem to me that you're better off taking this issue to
the Cygwin mailing lists, since it doesn't seem to be related to Python
itself.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestion

2009-08-31 Thread Nitebirdz
On Sat, Aug 29, 2009 at 02:42:36PM +0530, Thangappan.M wrote:
> Dear all,
> 
>  I am in the process of learning Python programming language. I know
> Perl,PHP. Compare to both the language Python impressed me because here
> there is no lexical variables and all.Now I need suggestion saying that ,
> What online book can I follow?
> 
>  I have not yet learnt any advanced programming stuffs in Python.
> Please suggest some book? or tutorial. net net my goal is that I will be
> able to do the project in any languages(Python,Perl,PHP).So I need to learn
> more depth knowledge of Python.
> 
> So Please help me?
> 

Thangappan,


I'm no expert, but perhaps the following book will be of some help:

http://diveintopython.org/


There are plenty of tutorials on the web too.  Just do a quick search
for something like "python tutorial".  


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a popen command line question

2009-08-31 Thread Nitebirdz
On Sat, Aug 29, 2009 at 01:13:12PM -0700, Joni Lee wrote:
> Hi all,
> 
> I write a small script
> 
> status = os.popen('top').readlines()
> print status
> 
> It calls the command line "top" and will print out the status.
> But I have to press the keyboard "q" to quit "top", then the status
> will be printed, otherwise it just stands by with blank.
> 
> Question is. Do you know how to give "q" into my python script so that
> "top" is automatically quit immediately or maybe after 1s (for
> gathering information)
> 

Why not run the actual 'top' command in batch mode with only one
iteration?  It's in the man page.  I'm referring to this:

  status = os.popen('top -b -n 1').readlines()


Also, the following approach seems to display a nicer output:

-
#!/usr/bin/env python

import os

status=os.popen('top -b -n 1')
for i in status.readlines():
  print i
-


Or how about the following?

-
#!/usr/bin/env python

import commands

status=commands.getoutput('top -b -n 1')
print status
-


Mind you, I'm just suggesting different approaches.  I'm new to Python
and don't necessarily know what I'm doing.  Other more experienced
people may be able to suggest something better.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python word to text

2009-09-01 Thread Nitebirdz
On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJörn Lindqvist wrote:
> Hello everybody,
> 
> I'm looking for a pure Python solution for converting word documents
> to text. App Engine doesn't allow external programs, which means that
> external programs like catdoc and antiword can't be used. Anyone know
> of any?
> 

A quick search returned this:

http://code.activestate.com/recipes/279003/


Did you give it a try?  


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python word to text

2009-09-01 Thread Nitebirdz
On Tue, Sep 01, 2009 at 03:20:29PM +0200, Tino Wildenhain wrote:
>>
>> A quick search returned this:
>>
>> http://code.activestate.com/recipes/279003/
>>
>>
>> Did you give it a try?
>
> Thats a funny advice. Did you read that receipe? ;-)
> "Requires the Python for Windows extensions, and MS Word."
> how does this match with "App Engine doesn't allow external programs"? :-)
>

Sorry, you're absolutely right.  I did notice it required Windows, but
didn't see any comments in the original message that this wasn't to be
run on Windows.  As for the issue regarding external programs, I assumed
it only referred to the ones explictly mentioned or similar (catdoc,
antiword, etc.).  

My apologies.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem w/ mysqldump

2009-09-02 Thread Nitebirdz
On Wed, Sep 02, 2009 at 06:43:12AM -0400, Victor Subervi wrote:
> Hi:
> I have the following python code:
> import os
> os.system("mysqldump -u root -pPASSWORD --opt spreadsheets > dump.sql")
> This nicely creates the file...but the file is empty! The database exists
> and has lots of data, I double-checked it. If there is nothing wrong with my
> code, is there some way to do the same thing from within MySQL? Can I at
> least print everything to screen and copy it? Where would I find my database
> in Windoze?

Are you sure the password you entered is correct?  I tested the code and
it worked fine for me.  However, when I used an incorrect password, it
returned an error and did create an empty file, just as you describe.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem w/ mysqldump

2009-09-02 Thread Nitebirdz
On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote:
>
> Obviously I'm sure. It created the file. But the file was blank. How can I
> do a mysqldump in mysql itself?
> 

As I said, I only got a blank file when the actual command itself
failed.  How do you dump the MySQL database itself without using Python?
Just run the 'mysqldump' command from the prompt.  Is that what you are
asking?  

Are you running this on Windows?  What OS?  You do have the 'mysqldump'
command available from the shell prompt and in your path, right?  

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem w/ mysqldump

2009-09-03 Thread Nitebirdz
On Wed, Sep 02, 2009 at 04:45:02PM -0400, Victor Subervi wrote:
>
> I tried running it like you said, got this error:
> 'mysqldump' is not a recognized internal or external command.
> If I could just figure out in what file the data were stored, I could copy
> it and try it in another computer. Any ideas?
> 

OK, that makes more sense now.  It's not truly a Python problem at all,
but rather an issue with the MySQL install/config on Windows.  As
somebody else pointed out, you are supposed to run the 'mysqldump'
command from the command prompt, which in the case of Windows is the
"cmd.exe", as far as I remember:

  Start --> Run --> command


I'm not familiar enough with Windows though.  I haven't run it in years.
However, the following URL may be of some help:

http://www.vbulletin.com/forum/showthread.php?t=68822


Judging by that, MySQL's binaries may not be in your path by default
when you run it on Windows.  If that's the case, you may have to add it
(search around for info on how to add new directories to your path in
Windows' terminal) or simply specify the absolute path to the command in
the Python script, instead of just passing 'mysqldump'.  

This other exchange from a forum may also help:

http://forums.mysql.com/read.php?35,144934,144960#msg-144960


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Entry Level Python Jobs

2009-09-03 Thread Nitebirdz
On Wed, Sep 02, 2009 at 08:31:20AM -0700, JonathanB wrote:
>
> I am a self-taught Python programmer with a liberal arts degree (Cross-
> cultural studies). I have been programming for several years now and
> would like to get a job as a python programmer. Unfortunately most of
> the job posts I have seen are for CS Majors or people with experience.
> 
> Is there a place I can look for job posts for entry level positions
> requiring no experience? For the hiring managers, if the job post said
> "CS Major" in the requirements, would you consider a liberal arts
> major at all?
> 

I have a liberal arts degree and have been working in the field for
years now, not as a programmer but as a high-level technical support
engineer (doing core dump analysis and the like).  While I opted for not
working as a programmer, other co-workers without a CompSci degree have
managed to do so without major problems.

It seems to me that most managers are willing to hire someone based on
his/her experience and proven knowledge, and not so much on the actual
degree you have.  Obviously, this means you will need to get some
experience before moving into actual programming.  

So, what would I recommend?  

First of all, make sure you get your foot in the door.  Apply for an
entry-level position at a company that works in the technology field,
even if it's doing technical support or writing documentation.  Once you
are in, work hard, show an interest in learning programming skills, talk
to the developers in the company, survey people around and try to figure
out where there is a need that can be met with a not-yet-written
application and put it together yourself, then show it to your manager
and try to convince him/her to deploy it as an official tool for your
team.  I've seen this work many times.  

Second, search around for open source projects that may look interesting
to you, download the source code, study it, subscribe to their
development mailing list, check out standing bugs and see if you can fix
them.  This is something you can definitely add to your resume.  


-- 
http://mail.python.org/mailman/listinfo/python-list