Python-list Digest, Vol 35, Issue 501
alper soyler
alpersoyler at yahoo.com
Thu Aug 31 10:24:26 EDT 2006
Trying to split the directories gave me the same error message with the previous one?
Alper
----- Original Message ----
From: python-list-request at python.org
To: python-list at python.org
Sent: Thursday, August 31, 2006 4:40:03 PM
Subject: Python-list Digest, Vol 35, Issue 501
Send Python-list mailing list submissions to
python-list at python.org
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
python-list-request at python.org
You can reach the person managing the list at
python-list-owner at python.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."
Today's Topics:
1. Tkinter listbox question (vedran_dekovic at yahoo.com)
2. Re: Using eval with substitutions (Peter Otten)
3. Re: a question about my script (alper soyler)
4. Re: a question about my script (Fredrik Lundh)
5. Re: Using eval with substitutions (Duncan Booth)
6. Re: a question about my script (alper soyler)
7. simultaneous copy to multiple media (lannsjo at gmail.com)
From: vedran_dekovic at yahoo.com
Precedence: list
MIME-Version: 1.0
To: python-list at python.org
Date: 31 Aug 2006 05:41:43 -0700
Message-ID: <1157028103.075184.149250 at i3g2000cwc.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"
Subject: Tkinter listbox question
Message: 1
Hi,
I need help about Tkinter listbox widget.I want,when somebody click on
any item(file) in Listbox,then in new Label widget text must be
selected item from server.
my program (wrong example):
import ftputil
import Tkinter
root=Tkinter.Tk()
ftp=ftputil.FTPHost('some imaginary server')
def LabelWidget(event):
a=Tkinter.Label(root,text=) # Text must be only name and file
format,example: sun.gif
a.grid()
b=Tkinter.Listbox(root)
b.insert(Tkinter.END,ftp._dir(''))
b.place()
c=Tkinter.Button(root,text='PRINT THIS FILE IN NEW LABEL WIDGET')
c.bind('<Button-1>',LabelWidget)
c.grid()
root.mainloop()
THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Content-Transfer-Encoding: 7Bit
From: Peter Otten <__peter__ at web.de>
Precedence: list
MIME-Version: 1.0
To: python-list at python.org
References: <1157022920.299174.22860 at m73g2000cwd.googlegroups.com>
<mailman.10170.1157023945.27775.python-list at python.org>
<1157027285.805711.24610 at m79g2000cwm.googlegroups.com>
Date: Thu, 31 Aug 2006 14:54:50 +0200
Message-ID: <ed6m5q$4gc$02$1 at news.t-online.com>
Content-Type: text/plain; charset=us-ascii
Subject: Re: Using eval with substitutions
Message: 2
abhishek at ocf.berkeley.edu wrote:
> Fredrik Lundh wrote:
>> (I'm afraid I don't really understand the point of your examples; what
>> is it you're really trying to do here ?)
>
> A function is passed a bunch of string expressions like,
> x = "a+b"
> y= "x*a"
> z= "x+y"
>
> where a and b are assumed to have been assigned values in the local
> namespace. Now I have to evaluate another string such as,
> "z+y+x"
>
> So as you say, I could do:
> x=eval(x), y=eval(y), z=eval(z) and finally eval("z+y+x") but the
> problem is that the initial strings are in no particular order, so I
> don't know the sequence in which to perform the first 3 evaluations. I
> was wondering if there was a simple way to 'pattern-match' so that the
> required substitutions like z->x+y->x+x*a->(a+b)+(a+b)*a could be done
> automatically.
Here is something to start with:
class EvalDict(object):
def __init__(self, namespace):
self.namespace = namespace
def __getitem__(self, key):
value = self.namespace[key]
if isinstance(value, str):
self.namespace[key] = value = eval(value, {}, self)
return value
def smart_eval(expr, namespace):
return eval(expr, {}, EvalDict(namespace))
def f():
a = 2
b = 3
x = "a+b"
y = "x*a"
z = "x+y"
return smart_eval("x + y + z", locals())
if __name__ == "__main__":
print f()
Beware of infinite recursion:
# RuntimeError: maximum recursion depth exceeded
smart_eval("a + b", dict(a="b", b="a"))
Peter
From: alper soyler <alpersoyler at yahoo.com>
Precedence: list
MIME-Version: 1.0
To: Python-list at python.org
In-Reply-To: <7.0.1.0.0.20060829041316.03da8e20 at yahoo.com.ar>
Date: Thu, 31 Aug 2006 06:01:09 -0700 (PDT)
Reply-To: alper soyler <alpersoyler at yahoo.com>
Message-ID: <20060831130109.54725.qmail at web56501.mail.re3.yahoo.com>
Content-Type: multipart/alternative; boundary="0-620705374-1157029269=:50849"
Subject: Re: a question about my script
Message: 3
Hi,
I changed the script as you wrote below:
from ftplib import FTP
def handleDownload(block):
file.write(block)
print ".",
ftp = FTP('ftp.genome.jp')
print ftp.login()
directory = 'pub/kegg/genomes'
ftp.cwd(directory)
k=0
for direct in ftp.nlst():
curdir = '%s/%s' % (directory, direct)
ftp.cwd(curdir)
for filename in ftp.nlst():
if not filename.endswith('.pep'): continue
file = open(filename, 'wb')
ftp.retrbinary('RETR %s/%s' % (curdir, filename), handleDownload)
file.close()
k=k+1
print ftp.close()
However, it gave the same error message:
230 Anonymous access granted, restrictions apply.
Traceback (most recent call last):
File "ftp1.0.py", line 18, in ?
ftp.cwd(curdir)
File "/usr/lib/python2.4/ftplib.py", line 494, in cwd
return self.voidcmd(cmd)
File "/usr/lib/python2.4/ftplib.py", line 246, in voidcmd
return self.voidresp()
File "/usr/lib/python2.4/ftplib.py", line 221, in voidresp
resp = self.getresp()
File "/usr/lib/python2.4/ftplib.py", line 216, in getresp
raise error_perm, resp
ftplib.error_perm: 550 pub/kegg/genomes/aae: No such file or directory
However, in ftp.genome.jp/pub/kegg/genomes/ site, there is 'aae' directory. What can be the reason?
regards,
alper
----- Original Message ----
From: Gabriel Genellina <gagsl-py at yahoo.com.ar>
To: alper soyler <alpersoyler at yahoo.com>
Cc: Python-list at python.org
Sent: Tuesday, August 29, 2006 10:26:57 AM
Subject: Re: a question about my script
At Tuesday 29/8/2006 03:55, alper soyler wrote:
>I am trying to get some files from an ftp site by ftplib module and
>I wrote the below script. However I have a problem. With my script,
>I login to ftp.genome.jp site. then, I am changing the directory to
>pub/kegg/genomes/afm and I am downloading "a.fumigatus.pep" file.
>However, what I want is to connect pub/kegg/genomes directory and in
>this directory there are 3 letters name files
3 letters *files*? or 3 letters *directories*?
>e.g. 'afm' and in each of these 3 letters files there is a file with
>the extension of '.pep' like a.fumigatus.pep. I want to get these
>'.pep' files from the 3 letter named files. If you help me I will be
>very glad. Thanks you in advance.
Do a cwd() starting one level above (that is, pub/kegg/genomes);
using ftp.dir() you can get the subdirectories, then iterate over all
of them, using another dir() to find the .pep files needed.
>directory = 'pub/kegg/genomes/ afm'
Is that whitespace intentional?
(If you just want to download the files and don't need really a
Python script, try wget...)
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
From: lannsjo at gmail.com
Precedence: list
MIME-Version: 1.0
To: python-list at python.org
Date: 31 Aug 2006 06:35:19 -0700
Message-ID: <1157031319.315438.4950 at b28g2000cwb.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"
Subject: simultaneous copy to multiple media
Message: 7
I need a program that simultaneously can copy a single file (1 GB) from
my pc to multiple USB-harddrives.
I have searched the internet and only found one program that does this
on
http://mastermind.com.pl/multicopy/
but this link doesnt work anymore???? somebody that can help me, is
there any other programs out there.
--
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060831/26244739/attachment.html>
More information about the Python-list
mailing list