Re: [Tutor] Question

2005-08-02 Thread Alan G
> Just curious to wonder if Python can be used to write a 
> program to check an HTTP mail server for mail, 

Yes, you would probably use the urllib module for that.

> and check more than one server, 

Yes that would be a fairly typical use for Python as 
a web client.

> even if they are using different proxies, 
> i.e. HTTP for one and SMTP for the other.

Proxies are servers that hide the real server, 
they act as pass through servers either to filter
or cache the data or to protect the recipient or 
sender.

http and smtp are protocols not proxies.

Python can deal with multiple protocols fairly 
easily - there are even modules specifically for each
but dealing with proxies is more difficult, it 
will rely on the proxies working like regular servers
- which they should! But trying to access the real 
server behind the proxy may be impossible.

Thanks,
Nathan Pinno,
Crew, Camrose McDonalds and owner/operator of Woffee
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question about BASIC and Python

2005-08-02 Thread Alan G
> I had a co-worker say to me at work that Python was related 
> to or based upon BASIC. Is this true, and if not, how can I 
> tell my friend why they are similar?

Both Python and BASIC are interpreted languages intended to 
be used (amongst other things) to learn how to program.

There the similarity ends. Python is very different to BASIC.
Its different in the way it is interpreted, in the structure 
of the programs, the way functions operate, the type system,
in fact just about every conceivable way.

There are more similarities between Visual Basic - which is 
very different to the original BASIC - and Python, but they 
are still significantly different languages. Thats why I use 
VBScript (a lightweight VB) as a comparison with Python in 
my tutor - to illustrate how a *different* language does the 
same thing. Take a look at some of the topics in my tutor
to see the differences.

If Python is based on any other language its probably Lisp!

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I've run into a jam on the exercise on file I/O

2005-08-02 Thread Alan G

> What if I were to use ID's for the students and use the ID's as the 
> sequence
> index, and link the students and their grades to the IDs?

Its not necessary for what you are doing but it's how you'd normally 
do it
in a relational database, so if you ever needed to turn your file 
based
program into a full blown database then using IDs would actually help!

The other thing you could do is hold all the data for a single student
in one structure. Thus instead of having lots of lists all linked by
a common index (or ID) you have one collection of students (probably
a dictionary keyed by name) each with all of its own data. This
involves a more complex data structure and is a move in the direction
of object oriented programming but without actual classes and objects
being involved. This might also allow you to use the shelve moduile
to save/restore your data to file easily.

Just a thought,

Alan G. 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need advice.

2005-08-02 Thread Alan G
> I want to write a program that will convert time in any other 
> time zone to my time zone. 

This is a deceptively complex task. There are around 40 timezones
varying by anything from 15 minutes to 2 hours. And some places 
change timezone throughout the year. Others have multiple daylight 
saving dates etc etc.

> Would it be better to use the Python time molecule 

Use the force Luke...
If a standrad module exists then its almost certain that more 
thought and debugging has gone into it than you want to expend!
Use what's there and tweak it to suit your needs.

HTH,

Alan G.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need advice.

2005-08-02 Thread Alan G

> I forgot to tell that I use Python 2.2.3. When I first got Python, I 
> got
> 2.4.1, but it refused to run the second time. So I went and got 
> 2.2.3. Your answer would make sense if I had 2.4.1, but I don't.

Version 2.3 should work and has the datetime stuff I think
- just checked and it does...

But 2.4 should work too, although I confess I haven't tried 2.4 yet 
except
for cygwin. So it might be worth having another go at installing 2.4.

Alan G.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] QUESTION

2005-08-02 Thread Alan G
Hi Jane,

> I'd like to know what kind of Python I can download. I've tried but 
> in vain!
> My computer is windows xp servixe pack 1, version 2002.

There are two main possibilities, either the generuc Python designed 
for
any computer or the ActiveSTate vesion witch is the generic version 
with
some Windows specifics added in.

Since you are on Windows I'd recommend the ActiveState version:

http://www.activestate.com/Products/ActivePython/

However it doesn't seem to work for me using Firefox - I suspect you
need IE...

So the alternative is the generic Python site:

http://www.python.org/download/

Just click on the Windows installer

Python 2.4.1 Windows installer (Windows binary -- does not include 
source)

That should download an executable file to your computer.
(Make a note of where it gets stored!) Execute that file and Python 
will
be installed on your PC. You will find a new menu under 
Start->Programs
Within that menu start off with "Python GUI" or "IDLE" or something 
similar
 - they keep changing the exact wording...

When you wind up with a window containing a nearly blank screen and a 
 >>>
prompt, congratulations! you have started Python and you can start 
working your
way through one of the non programmers tutorials - I am assuming you 
are
a non programmer?

HTH

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] mailman

2005-08-02 Thread Damien




Mohammad Moghimi a écrit :
[...]
checking that Python has a working distutils... configure: error:
  
* Distutils is not available or is incomplete for /usr/bin/python
* If you installed Python from RPM (or other package manager)
* be sure to install the -devel package, or install Python
* from source.  See README.LINUX for details
  
I downloaded Distutil from python.org
  http://www.python.org/sigs/distutils-sig/download/Distutils-1.0.2.tar.gz
  
I wanted to install this one but I got another error message in running
python setup.py install
  
Traceback (most recent call last):
  File "setup.py", line 30, in ?
    packages = ['distutils', 'distutils.command'],
  File
"/home/soccer/mohammad/python/Distutils-1.0.2/distutils/core.py", line
101, in setup
    _setup_distribution = dist = klass(attrs)
  File
"/home/soccer/mohammad/python/Distutils-1.0.2/distutils/dist.py", line
130, in __init__
    setattr(self, method_name, getattr(self.metadata, method_name))
AttributeError: DistributionMetadata instance has no attribute
'get___doc__'
  
How can I solve this problem?!
-- Mohammad

Hi all,
This problem is not about mailman, but about the Distutils. I
have the same bug on Windows. It'is very boring because py2exe needs
the distutils. The bug needs to be fixed manually in the source of the
distutils in :
"distutils/dist.py", line 130, in __init__"
The bug is easy to fix (I will post the solution later, if I can found
it).
I hope this information will help you.
Nobody else has this bug with the Distutils ?


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] terminology question

2005-08-02 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
> Quoting Dick Moores <[EMAIL PROTECTED]>:
> 
> 
>>Why are list comprehensions called that?
> 
> 
> Because that's what they're called in Haskell, I guess..
> 
> It's historical, based on the term "set comprehension" from mathematics, also
> known as "set builder notation": 
> http://en.wikipedia.org/wiki/Set_comprehension

The Wikipedia page on "list comprehension" explicitly makes the connection to 
"set comprehension" and shows how the math notation and Haskell syntax resemble 
each other.
http://en.wikipedia.org/wiki/List_comprehension

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Corrupt files

2005-08-02 Thread Øyvind
Hello.

I have created a program that automatically downloads some files I need.
It can be .zip, .jpg, .mpg or .txt. However, a lot of the time urlretrieve
downloads the file, gives no error, but the downloaded file is corrupted.
I use a simple check for the size of the file. If it is way too small, I
automatically remove it. The files are ok on the server.

Is there some function/modulte that checks a files integrity wheter or not
the file is corrupt or not?

Thanks in advance.

-- 
This email has been scanned for viruses & spam by Decna as - www.decna.no
Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Color text in Text widget

2005-08-02 Thread sunny sunny
Thanks.
Its works very well.
Santosh.

On 8/1/05, Jorge Louis de Castro <[EMAIL PROTECTED]> wrote:
> I found a way to do it but I'm not sure it is the cleanest. Maybe someone
> else on this list can offer a better solution.
> 
> I use the text's configuration to define tags that I apply to sections of
> the text. For example:
> 
> txtBox = Text(self, width=80, height=20)
> # configuration for red
> txtBox.tag_config("r", foreground="red")
> # configuration for blue
> txtBox.tag_config("b", foreground="blue")
> 
> txtBox.insert(END,"I am red ", "r")
> txtBox.insert(END,"and I am blue\n", "b")
> 
> Hope that helps
> jorge
> 
> >From: sunny sunny <[EMAIL PROTECTED]>
> >To: tutor@python.org
> >Subject: [Tutor] Color text in Text widget
> >Date: Mon, 1 Aug 2005 15:35:52 -0400
> >
> >Hi all,
> >
> >How do I add color to the text in the Text widget? I tried using the
> >ASCII sequence but it didnt work.
> >
> >For example, I want to add:
> >  This is  red , but this is  blue 
> >
> >Thanks.
> >Santosh.
> >___
> >Tutor maillist  -  Tutor@python.org
> >http://mail.python.org/mailman/listinfo/tutor
> 
> 
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Directory or File ?

2005-08-02 Thread Damien
Hi all,
I want to know if a file is a directory or a simple file.
I have done a little ugly script :
# i is my filename, os is imported
old = os.getcwd()
try:
chdir(i)
is_dir = True
except:
is_dir = False
os.chdir(old)
return is_dir

But maybe there is a better way ?
If you know a better way, please tell me.

Thanks,
Damien G.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Directory or File ?

2005-08-02 Thread Kent Johnson
Damien wrote:
> Hi all,
> I want to know if a file is a directory or a simple file.

Look at os.path.isdir()

Kent

> I have done a little ugly script :
> # i is my filename, os is imported
> old = os.getcwd()
> try:
> chdir(i)
> is_dir = True
> except:
> is_dir = False
> os.chdir(old)
> return is_dir
> 
> But maybe there is a better way ?
> If you know a better way, please tell me.
> 
> Thanks,
> Damien G.
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Directory or File ?

2005-08-02 Thread Wolfram Kraus
Damien wrote:
> Hi all,
> I want to know if a file is a directory or a simple file.
> I have done a little ugly script :
> # i is my filename, os is imported
> old = os.getcwd()
> try:
> chdir(i)
> is_dir = True
> except:
> is_dir = False
> os.chdir(old)
> return is_dir
> 
> But maybe there is a better way ?
> If you know a better way, please tell me.
> 
> Thanks,
> Damien G.

Use os.path.isdir:
http://python.org/doc/2.4.1/lib/module-os.path.html#l2h-1739

HTH,
Wolfram

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Directory or File ?

2005-08-02 Thread Damien




Ok, sorry. In the future, I will look more closely the module before
sending my question.
Thanks.

Kent Johnson a écrit :

  Damien wrote:
  
  
Hi all,
I want to know if a file is a directory or a simple file.

  
  
Look at os.path.isdir()

Kent

  
  
I have done a little ugly script :
# i is my filename, os is imported
old = os.getcwd()
try:
chdir(i)
is_dir = True
except:
is_dir = False
os.chdir(old)
return is_dir

But maybe there is a better way ?
If you know a better way, please tell me.

Thanks,
Damien G.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


  
  
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

  




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] time.sleep() error

2005-08-02 Thread sunny sunny
Hi all,

I am using time.sleep to stop my program execution for some time. I
have imported time and am able to use it sucessfully in the main
program.

However if I use it in any function I get the following error:

the time.sleep(1) command generates this error :
TypeError : 'int' object is not callable 

I have tried to add import time after the function definition, it
still does not work. Please help.

Thanks.
Santosh
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] time.sleep() error

2005-08-02 Thread Kent Johnson
sunny sunny wrote:
> Hi all,
> 
> I am using time.sleep to stop my program execution for some time. I
> have imported time and am able to use it sucessfully in the main
> program.
> 
> However if I use it in any function I get the following error:
> 
> the time.sleep(1) command generates this error :
> TypeError : 'int' object is not callable 
> 
> I have tried to add import time after the function definition, it
> still does not work. Please help.

It looks like somehow the name time.sleep has been bound to an integer. Please 
post the code and the full error trace.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] time.sleep() error

2005-08-02 Thread sunny sunny
Some additional information:

I am calling this function from a thread and I get the error. 
However if I call the function from the main program it works fine. 

I am using thread.start_new_thread() to start the thread. 

Thanks.
Santosh.

On 8/2/05, sunny sunny <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I am using time.sleep to stop my program execution for some time. I
> have imported time and am able to use it sucessfully in the main
> program.
> 
> However if I use it in any function I get the following error:
> 
> the time.sleep(1) command generates this error :
> TypeError : 'int' object is not callable
> 
> I have tried to add import time after the function definition, it
> still does not work. Please help.
> 
> Thanks.
> Santosh
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] time.sleep() error

2005-08-02 Thread geon
sunny sunny napsal(a):

>Hi all,
>
>I am using time.sleep to stop my program execution for some time. I
>have imported time and am able to use it sucessfully in the main
>program.
>
>However if I use it in any function I get the following error:
>
>the time.sleep(1) command generates this error :
>TypeError : 'int' object is not callable 
>
>  
>

Dont you actually have something like this?:

from time import *

# somewhere you use sleep like this
sleep=10

# and then
sleep(1)

# you get:
#sleep(1)
#TypeError: 'int' object is not callable

In this case you "overwrite" the original function sleep() with your/my
variable sleep
Solution: rename your/my variable sleep to f.e. notAwake=10 :-)

-- 
geon



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] fourier transform

2005-08-02 Thread Christian Meesters
Hi

Pawel Kraszewski wrote:

> 4. The answer is symmetrical - usually you take only half of it. I 
> don't
> remember the exact difference between the halves, but you may find it 
> in any
> article on FFT.
The real part is identical the imaginary part has the opposite sign 
("same amplitude, opposite phase").

Jeff Peery wrote:
> thanks for the help. I think I'm understanding this a bit better. 
> although I still don't completely understand the output. here is an 
> example... for the input I have 1024 samples taken from a 1 Hz square 
> wave with amplitude = 1.  for the output I would expect an infinite 
> number of frequencies. the output from FFT.fft(myData).real is this:
>
> .
> .
> .
> -0.498 1
> 0.0 2
> -0.498 3
> 0.0 4
> -0.498 5
> 0.0 6
> -0.498 7
> 0.0 8

Frankly, I don't understand this. After your description I thought your 
input is like "array([0, 1, 0, ..., 1, 0, 1])". But this can't be. 
Could you show us how exactly your input array looks like?
And how do we have to read your output? Is this a 1d-array? What do the 
two numbers per line mean?

Cheers
Christian

PS Sorry for the late reply.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need advice.

2005-08-02 Thread Nathan Pinno
I think I'll leave this one for someone else. I got too confused too quick.
- Original Message - 
From: "Alan G" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>; "Tutor mailing list" 

Sent: Tuesday, August 02, 2005 1:47 AM
Subject: Re: [Tutor] I need advice.


>> I want to write a program that will convert time in any other time zone 
>> to my time zone.
>
> This is a deceptively complex task. There are around 40 timezones
> varying by anything from 15 minutes to 2 hours. And some places change 
> timezone throughout the year. Others have multiple daylight saving dates 
> etc etc.
>
>> Would it be better to use the Python time molecule
>
> Use the force Luke...
> If a standrad module exists then its almost certain that more thought and 
> debugging has gone into it than you want to expend!
> Use what's there and tweak it to suit your needs.
>
> HTH,
>
> Alan G.
> 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2005-08-02 Thread Greg Janczak
This is a totally unrelated question but does anyone know a good free iso 
image burner?

greg

_
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2005-08-02 Thread Kristian Rink
Greg Janczak schrieb:
> This is a totally unrelated question but does anyone know a good free iso 
> image burner?

Well, what don't you like about cdrecord? Otherwise, specifying which
operating system you're intending to use this on would be quite a good
idea. ;)

Cheers,
Kris

-- 
"Sei Du selbst die Veränderung, die Du Dir wünschst
für diese Welt." (Gandhi)
-| Kristian Rink icq# 48874445 jab# [EMAIL PROTECTED]
-| http://www.zimmer428.net ** http://www.fotolog.net/kawazu


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] time.sleep() error

2005-08-02 Thread geon




geon napsal(a):

  sunny sunny napsal(a):

  
  
Hi all,

I am using time.sleep to stop my program execution for some time. I
have imported time and am able to use it sucessfully in the main
program.

However if I use it in any function I get the following error:

the time.sleep(1) command generates this error :
TypeError : 'int' object is not callable 

 


  
  
Dont you actually have something like this?:

from time import *

# somewhere you use sleep like this
sleep=10

# and then
sleep(1)

# you get:
#sleep(1)
#TypeError: 'int' object is not callable

In this case you "overwrite" the original function sleep() with your/my
variable sleep
Solution: rename your/my variable sleep to f.e. notAwake=10 :-)

  

Solution2: do not use from time import *.  Prefer import time. Now you
know why :-)
Its not a waste of time still to rewrite you code in this way. 

-- 
geon




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Question about resetting values

2005-08-02 Thread Nathan Pinno



I am writing a Blackjack program, and was wondering how to reset the values 
to zero, e.g. cash = 0?
 
Thanks,
Nathan Pinno,Crew, Camrose McDonalds and owner/operator of 
Woffee
BEGIN:VCARD
VERSION:2.1
N:Pinno;Nathan;Paul;Mr.
FN:Pinno, Nathan Paul
ORG:Woffee;Executive
TITLE:Owner/operator
TEL;CELL;VOICE:7806085529
ADR;WORK:;President/CEO
LABEL;WORK:President/CEO
ADR;HOME:;;Box 1783;Camrose;Alberta;T4V1X7;Canada
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:Box 1783=0D=0ACamrose, Alberta T4V1X7=0D=0ACanada
X-WAB-GENDER:2
URL;HOME:http://falcon3166.tripod.com
URL;WORK:http://falcon3166.tripod.com/Woffee.htm
BDAY:19850221
EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
REV:20050802T180836Z
END:VCARD
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] JBUS and Python which way

2005-08-02 Thread Miguel Lopes
pyserial provides serial communication but I think I require an interface that 
would abstract/simplify the JBUS/MODBUS protocol.

Thanks Danny and Alan for all the help.
Will check out comp.lang.python for advice.

Best Miguel

---
Chegou o Clix ADSL até 16 Megas
Internet + Telefone desde € 22,5/mês
Acabe de vez com os € 15 da assinatura telefónica!
Saiba mais em http://adsl.clix.pt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Corrupt files

2005-08-02 Thread Danny Yoo


On Tue, 2 Aug 2005, [iso-8859-1] �yvind wrote:

> Is there some function/modulte that checks a files integrity wheter or
> not the file is corrupt or not?

Hello!

A general technique that people have used before is to provide file
"checksums" of large files.  These checksums can be used to verify that
the file passed through fine over the wire.

As a concrete example, the large Python 2.41 installer file is paired with
a "md5" checksum, listed below under "Files, MD5 checksums, signatures,
and sizes:" at the bottom of:

http://www.python.org/2.4.1/

So the idea is to take the downloaded file, run the standard 'md5sum'
checksum program, and see that the checksums match the published one.
(If you don't have this utility: http://www.python.org/2.4.1/md5sum.py)
If the checksums don't match up, there's definitely file corruption.


Hope this helps!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Corrupt files

2005-08-02 Thread geon
Øyvind napsal(a):

>Hello.
>
>I have created a program that automatically downloads some files I need.
>It can be .zip, .jpg, .mpg or .txt. However, a lot of the time urlretrieve
>downloads the file, gives no error, but the downloaded file is corrupted.
>I use a simple check for the size of the file. If it is way too small, I
>automatically remove it. 
>

remove it and try to download it again, lets say , 3times until you get 
correct copy...

>The files are ok on the server.
>
>Is there some function/modulte that checks a files integrity wheter or not
>the file is corrupt or not?
>
>  
>

Until you are provided with, say, md5 checksum, there is no other way 
than comparing sizes, I think ...

-- 
geon


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] For Damien

2005-08-02 Thread Enrique Acosta Figueredo
rk.
>> >
>> >For example, I want to add:
>> >  This is  red , but this is  blue 
>> >
>> >Thanks.
>> >Santosh.
>> >___
>> >Tutor maillist  -  Tutor@python.org
>> >http://mail.python.org/mailman/listinfo/tutor
>>
>>
>>
>
>
> --
>
> Message: 4
> Date: Tue, 02 Aug 2005 16:11:20 +0200
> From: Damien <[EMAIL PROTECTED]>
> Subject: [Tutor]  Directory or File ?
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi all,
> I want to know if a file is a directory or a simple file.
> I have done a little ugly script :
> # i is my filename, os is imported
> old = os.getcwd()
> try:
> chdir(i)
> is_dir = True
> except:
> is_dir = False
> os.chdir(old)
> return is_dir
>
> But maybe there is a better way ?
> If you know a better way, please tell me.
>
> Thanks,
> Damien G.
>
>
> --
>
> Message: 5
> Date: Tue, 02 Aug 2005 10:21:10 -0400
> From: Kent Johnson <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Directory or File ?
> Cc: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Damien wrote:
>> Hi all,
>> I want to know if a file is a directory or a simple file.
>
> Look at os.path.isdir()
>
> Kent
>
>> I have done a little ugly script :
>> # i is my filename, os is imported
>> old = os.getcwd()
>> try:
>> chdir(i)
>> is_dir = True
>> except:
>> is_dir = False
>> os.chdir(old)
>> return is_dir
>>
>> But maybe there is a better way ?
>> If you know a better way, please tell me.
>>
>> Thanks,
>> Damien G.
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
>
> --
>
> Message: 6
> Date: Tue, 02 Aug 2005 16:27:19 +0200
> From: Wolfram Kraus <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Directory or File ?
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=us-ascii; format=flowed
>
> Damien wrote:
>> Hi all,
>> I want to know if a file is a directory or a simple file.
>> I have done a little ugly script :
>> # i is my filename, os is imported
>> old = os.getcwd()
>> try:
>> chdir(i)
>> is_dir = True
>> except:
>> is_dir = False
>> os.chdir(old)
>> return is_dir
>>
>> But maybe there is a better way ?
>> If you know a better way, please tell me.
>>
>> Thanks,
>> Damien G.
>
> Use os.path.isdir:
> http://python.org/doc/2.4.1/lib/module-os.path.html#l2h-1739
>
> HTH,
> Wolfram
>
>
>
> --
>
> Message: 7
> Date: Tue, 02 Aug 2005 18:00:07 +0200
> From: Damien <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Directory or File ?
> To: Kent Johnson <[EMAIL PROTECTED]>, Wolfram Kraus
>   <[EMAIL PROTECTED]>
> Cc: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Ok, sorry. In the future, I will look more closely the module before
> sending my question.
> Thanks.
>
> Kent Johnson a ?crit :
>
>>Damien wrote:
>>
>>
>>>Hi all,
>>>I want to know if a file is a directory or a simple file.
>>>
>>>
>>
>>Look at os.path.isdir()
>>
>>Kent
>>
>>
>>
>>>I have done a little ugly script :
>>># i is my filename, os is imported
>>>old = os.getcwd()
>>>try:
>>>chdir(i)
>>>is_dir = True
>>>except:
>>>is_dir = False
>>>os.chdir(old)
>>>return is_dir
>>>
>>>But maybe there is a better way ?
>>>If you know a better way, please tell me.
>>>
>>>Thanks,
>>>Damien G.
>>>___
>>>Tutor maillist  -  Tutor@python.org
>>>http://mail.python.org/mailman/listinfo/tutor
>>>
>>>
>>>
>>
>>___
>>Tutor maillist  -  Tutor@python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
>>
>
> -- next part --
> An HTML attachment was scrubbed...

Re: [Tutor] I need advice.

2005-08-02 Thread Nathan Pinno
I am now using Python 2.4.1, but decided to abandon it. It got too confusing 
too fast. I'm better off writing simple games and apps for now.
- Original Message - 
From: "Nathan Pinno" <[EMAIL PROTECTED]>
To: "Danny Yoo" <[EMAIL PROTECTED]>
Cc: "Tutor mailing list" 
Sent: Tuesday, August 02, 2005 12:02 AM
Subject: Re: [Tutor] I need advice.


>I forgot to tell that I use Python 2.2.3. When I first got Python, I got
> 2.4.1, but it refused to run the second time. So I went and got 2.2.3. 
> Your
> answer would make sense if I had 2.4.1, but I don't.
> - Original Message - 
> From: "Danny Yoo" <[EMAIL PROTECTED]>
> To: "Nathan Pinno" <[EMAIL PROTECTED]>
> Cc: "Tutor mailing list" 
> Sent: Monday, August 01, 2005 11:41 PM
> Subject: Re: [Tutor] I need advice.
>
>
>>
>>
>> On Mon, 1 Aug 2005, Nathan Pinno wrote:
>>
>>> I want to write a program that will convert time in any other time zone
>>> to my time zone. Would it be better to use the Python time molecule or
>>> just a whole bunch of if statements?
>>
>> Hi Nathan,
>>
>> I'd recommend looking at the 'datetime' Python module.  Getting this 
>> stuff
>> right is hard, so unless you really want to learn how time conversions
>> work, take advantage of the library.  There's something there that does 
>> do
>> time zones:
>>
>>http://www.python.org/doc/lib/datetime-tzinfo.html
>>http://www.python.org/doc/lib/tzinfo-examples.txt
>>
>> Good luck!
>>
>>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] print a line in IDLE as bold, italics or a color

2005-08-02 Thread Victor Reijs
Hello all of you,

I am trying to simply(?) print some text in a print statement as bold 
(or itlaics or an certain color). How do I do this in python?
Browsing the web gives we all kind of soluation, but non seem to work (a 
lot are related when printing on the web).

Say I want to print the text (in the mentioned format):
This is bold, red, blue, italics

How do I do this in python 2.2 and using IDLE?

Thanks for your help.

All the best,


Victor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Corrupt files (fwd)

2005-08-02 Thread Danny Yoo


-- Forwarded message --
Date: Tue, 2 Aug 2005 22:12:34 +0200 (CEST)
From: "[iso-8859-1] �yvind" <[EMAIL PROTECTED]>
To: Danny Yoo <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Corrupt files

Hello and thank you.

I don't really think that will help. The files are mostly smaller ones of
for example jpg, avi, txt, doc and xls files. It is not published any MD5
checksums. Is there any way to check for example that a jpg file is
completed without opening it? Or, is there some way to check the filesize
on the server thru http (urlretrieve) and compare with the filesize of the
downloaded file? Do you think that would work?

Thanks in advance


>
>
> On Tue, 2 Aug 2005, [iso-8859-1] �yvind wrote:
>
>> Is there some function/modulte that checks a files integrity wheter or
>> not the file is corrupt or not?
>
> Hello!
>
> A general technique that people have used before is to provide file
> "checksums" of large files.  These checksums can be used to verify that
> the file passed through fine over the wire.
>
> As a concrete example, the large Python 2.41 installer file is paired with
> a "md5" checksum, listed below under "Files, MD5 checksums, signatures,
> and sizes:" at the bottom of:
>
> http://www.python.org/2.4.1/
>
> So the idea is to take the downloaded file, run the standard 'md5sum'
> checksum program, and see that the checksums match the published one.
> (If you don't have this utility: http://www.python.org/2.4.1/md5sum.py)
> If the checksums don't match up, there's definitely file corruption.
>
>
> Hope this helps!
>
>
> --
> This email has been scanned for viruses & spam by Decna as - www.decna.no
> Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no
>
>


-- 
This email has been scanned for viruses & spam by Decna as - www.decna.no
Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question about resetting values

2005-08-02 Thread Alan G
> I am writing a Blackjack program, and was wondering how to 
> reset the values to zero, e.g. cash = 0?

Yes, that's how you do it. Now what is the bit you don't 
understand?

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Corrupt files

2005-08-02 Thread Alan G
>>I have created a program that automatically downloads some files I 
>>need.
>>It can be .zip, .jpg, .mpg or .txt. However, a lot of the time 
>>urlretrieve
>>downloads the file, gives no error, but the downloaded file is 
>>corrupted.
>>I use a simple check for the size of the file. If it is way too 
>>small, I
>>automatically remove it.

Is it possible you are downloading a binary file as a text file?
If so the EOF character may be present and this is what truncates
the file. A sign that this is the problem is if the same file
always stops after the same number of bytes.

I've never used urlretrieve but its a common problewm with ftp, and I 
assume
url is the same. Is there a flag/parameter you can set to fetch in 
binary mode?

Just guessing,

Alan G. 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Corrupt files

2005-08-02 Thread Roger Merchberger
Rumor has it that geon may have mentioned these words:
>Øyvind napsal(a):
>
> >Hello.
> >
> >I have created a program that automatically downloads some files I need.
> >It can be .zip, .jpg, .mpg or .txt. However, a lot of the time urlretrieve
> >downloads the file, gives no error, but the downloaded file is corrupted.
> >I use a simple check for the size of the file. If it is way too small, I
> >automatically remove it.
> >
>
>remove it and try to download it again, lets say , 3times until you get
>correct copy...

Or, depending on it's extension, try to open the newly downloaded file with 
the corresponding Python extension, i.e. (.jpg|.gif|.png) try to open with 
PIL[1], .zip files with the python zipfile module, etc. I *think* there's 
modules for .mpgs and maybe .avi's... but .txt files might be tough to 
authenticate, as there's no actual 'file format.'

This python pseudocode might explain more:

=-=-=-=-=-=-= snip here =-=-=-=-=-=-=

def openzip(filename):
 import zipfile
 try:
   filebuf = zipfile.open(filename)
 except:
   return "Error 99: cannot open file; corrupted zipfile."

 filebuf.close()
 return None

if __name__ == '__main__':

 if filename[:-4] == '.zip':
 retcode = openzip(filename)
 if retcode != None:
 print "Corrupt File - Try to download again!"

=-=-=-=-=-=-= snip here =-=-=-=-=-=-=

Just put an 'openzip' or 'openjpg' type of function for each type of file 
you'll need to authenticate.

[[ This code will *not* run -- it certainly won't run in Eudora (where it's 
being typed), so it's only for showing the general idea... YMMV, UAYOR, 
etc. ;-) ]]

Hope this helps,
Roger "Merch" Merchberger

[1] PIL == Python Image Library; it will open almost any type of static 
graphic image available.

--
Roger "Merch" Merchberger   | "Bugs of a feather flock together."
sysadmin, Iceberg Computers |   Russell Nelson
[EMAIL PROTECTED]  |

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Deleting an entry from a dictionary

2005-08-02 Thread Greg Lindstrom
Hello-
This must be simple, but for the life of me I can't figure out how to 
delete an entry from a dictionary.  For example,

meals = {}
meals['breakfast'] = 'slimfast'
meals['lunch'] = 'slimfast'
meals['dinner'] = 'something sensible'

How do I eliminate 'lunch' from the dictionary so that I only have 
'breakfast' and 'dinner'?

Thanks!
--greg

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Deleting an entry from a dictionary

2005-08-02 Thread Danny Yoo


On Tue, 2 Aug 2005, Greg Lindstrom wrote:

> This must be simple, but for the life of me I can't figure out how to
> delete an entry from a dictionary.  For example,
>
> meals = {}
> meals['breakfast'] = 'slimfast'
> meals['lunch'] = 'slimfast'
> meals['dinner'] = 'something sensible'
>
> How do I eliminate 'lunch' from the dictionary so that I only have
> 'breakfast' and 'dinner'?


Hi Greg,

Actually, it isn't obvious at all, so don't be too discouraged.  The 'del'
statement should do the trick:

##
>>> d = {'a': 'Alpha', 'b' : 'Beta'}
>>> del d['a']
>>> d
{'b': 'Beta'}
##


Here's a reference list of all the things you can do to a dictionary:

http://www.python.org/doc/lib/typesmapping.html


Good luck!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Deleting an entry from a dictionary

2005-08-02 Thread Adam Bark
meals.pop(key) will do it.
Example:
>>> meals = {}
>>> meals['breakfast'] = 'slimfast'
>>> meals['lunch'] = 'slimfast'
>>> meals['dinner'] = 'something sensible'
>>> meals
{'lunch': 'slimfast', 'breakfast': 'slimfast', 'dinner': 'something sensible'}
>>> meals.pop("breakfast")
'slimfast'
>>> meals
{'lunch': 'slimfast', 'dinner': 'something sensible'}On 8/2/05, Greg Lindstrom <[EMAIL PROTECTED]
> wrote:Hello-This must be simple, but for the life of me I can't figure out how to
delete an entry from a dictionary.  For example,meals = {}meals['breakfast'] = 'slimfast'meals['lunch'] = 'slimfast'meals['dinner'] = 'something sensible'How do I eliminate 'lunch' from the dictionary so that I only have
'breakfast' and 'dinner'?Thanks!--greg___Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] print a line in IDLE as bold, italics or a color

2005-08-02 Thread Danny Yoo


On Tue, 2 Aug 2005, Victor Reijs wrote:

> I am trying to simply(?) print some text in a print statement as bold
> (or itlaics or an certain color). How do I do this in python? Browsing
> the web gives we all kind of soluation, but non seem to work (a lot are
> related when printing on the web).
>
> Say I want to print the text (in the mentioned format): This is bold,
> red, blue, italics
>
> How do I do this in python 2.2 and using IDLE?


Hi Victor,

You may need to open up a special window for doing text displays with some
variety.  The Tkinter system provides one, which can be opened up like
this:

##
import Tkinter
txtBox = Text()
##


We had some discussion about this just yesterday, and Jorge Louis de
Castro showed how to selectively insert colored text into that txtBox:

http://mail.python.org/pipermail/tutor/2005-August/040244.html


Hope this helps!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] substituting empty line with stuff

2005-08-02 Thread Srinivas Iyyer
Hello group:

I have a file (3339203 lines) that looks like this:

(col:1)(col:2) (col:3)
AD134KL
X   X
X   X
X   X

AD144KL
Y   Y
Y   Y

Now I have to fill the rows in column 1 with their
designated stuff:

AD134KL
AD134KL X   X
AD134KL X   X
AD134KL X   X
AD144KL
AD144KL Y   Y
AD144KL Y   Y



My code: 

f1 = open('xx','r')
meat = f1.readlines()

mind = []

for i in range(len(meat)):
  if meat[i].startswith('AD'):
   mind.append(i)

mind = [0,4]

for i in range(len(mind)):
  k = i+1
  l = mind[i]+1
  j = mind[k]-1
  print l,j

1 3

Logic: Now I want to substitute 'AD134KL' between 0
and 4 which is 1,2,and 3.  and move on..

After coming to this stage, I lost grip and I do not
know what to do.. 

Can experts help me please. 

thank you
srini 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] print a line in IDLE as bold, italics or a color

2005-08-02 Thread Danny Yoo


On Tue, 2 Aug 2005, Victor Reijs wrote:

> This is in a seperate text box, but I want to have the colors
> (bold/italics) in the default IDLE window.

[Note: please use Reply-to-all]

This will probably be more difficult.  I don't believe IDLE itself allows
a user's program to set its own fonts and colors within the running IDLE
window.

I'm sure it's technically possible, but not without some significant
hacking at the IDLE interface.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] print a line in IDLE as bold, italics or a color

2005-08-02 Thread Victor Reijs
Hello Danny,

Danny Yoo wrote:
>>This is in a seperate text box, but I want to have the colors
>>(bold/italics) in the default IDLE window.
> 
> This will probably be more difficult.  I don't believe IDLE itself allows
> a user's program to set its own fonts and colors within the running IDLE
> window.
> 
> I'm sure it's technically possible, but not without some significant
> hacking at the IDLE interface.

Error messages in IDLE also get a color (red), so it loooks to be 
standard 'IDLE'/python;-)
Also IDEL recognize keywords while typing and changes the color (to 
orange), so it is quite normal in IDLE...
But now; how can user's python program use it?

All the best,


Victor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] fourier transform

2005-08-02 Thread Jeff Peery
Hi Christian, 
 
sorry for the lack of detail. how about I use a sine wave because I know what the output should look like - amplitude of one at frequency equal to the frequency of the sine wave. 
 
one period of a sin wave that cycles at one hertz:
period = 1
input = sin(arange(0,64)*3.14159*2/64.0)
 
do the fft:myFFT = FFT.real_fft(myData)
the change in time between elements is:
delta_time = period/64
 
inverse of time is the frequency:
delta_freq = 1/delta_time
 
print the results:
for i in range(1,len(myFFT)):    print myFFT[i], delta_freq*i
 
hope this is more clear. from the output I would expect that two spikes appear with amplitude = 1.  one spike is the positive frequency (first half of the fft) and another spike is the negative frequency (second half), the first half and second half are symmetrical about the midpoint of the fft. but this is what I get:
 
-8.22612478587e-005 64.02.65354186171e-006 128.02.65357174311e-006 192.02.65358011376e-006 256.02.65358370024e-006 320.02.65358557785e-006 384.02.65358668451e-006 448.02.65358739808e-006 512.02.65358788076e-006 576.02.65358822231e-006 640.0
.
.
.
I don't understand the output amplitudes. they should all be zero except for at one herz it should be one. not sure about the frequency for that matter either. I gotta dig up my math book and figure this out. in the meantime any suggestions for what this is outputing would be greatly appreciated! thanks.
 
Jeff
Christian Meesters <[EMAIL PROTECTED]> wrote:
HiPawel Kraszewski wrote:> 4. The answer is symmetrical - usually you take only half of it. I > don't> remember the exact difference between the halves, but you may find it > in any> article on FFT.The real part is identical the imaginary part has the opposite sign ("same amplitude, opposite phase").Jeff Peery wrote:> thanks for the help. I think I'm understanding this a bit better. > although I still don't completely understand the output. here is an > example... for the input I have 1024 samples taken from a 1 Hz square > wave with amplitude = 1. for the output I would expect an infinite > number of frequencies. the output from FFT.fft(myData).real is this:>> .> .> .> -0.498 1> 0.0 2> -0.498 3> 0.0 4> -0.498 5&g!
 t; 0.0
 6> -0.498 7> 0.0 8Frankly, I don't understand this. After your description I thought your input is like "array([0, 1, 0, ..., 1, 0, 1])". But this can't be. Could you show us how exactly your input array looks like?And how do we have to read your output? Is this a 1d-array? What do the two numbers per line mean?CheersChristianPS Sorry for the late reply.___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need advice.

2005-08-02 Thread Don Parris
On Tue, 2 Aug 2005 10:12:28 +0100
"Alan G" <[EMAIL PROTECTED]> wrote:

> 
> > I forgot to tell that I use Python 2.2.3. When I first got Python, I 
> > got
> > 2.4.1, but it refused to run the second time. So I went and got 
> > 2.2.3. Your answer would make sense if I had 2.4.1, but I don't.
> 
> Version 2.3 should work and has the datetime stuff I think
> - just checked and it does...
> 
> But 2.4 should work too, although I confess I haven't tried 2.4 yet 
> except
> for cygwin. So it might be worth having another go at installing 2.4.
> 
> Alan G.
> 
> 

I use 2.4 on the 'Doze box at work.  I have no problems with it so far.  Of
course, I can't install my own RDBMS (they would freak!), but I've managed
to get away with Python. :-)  I'm running Python 2.3 on my SUSE 9.2 box.

Don
-- 
evangelinuxGNU Evangelist
http://matheteuo.org/   http://chaddb.sourceforge.net/
"Free software is like God's love - you can share it with anyone anytime
anywhere."
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question about resetting values

2005-08-02 Thread Nathan Pinno
Never mind all. I was just being stupid as usual. I thought that there might 
be a Python command for resetting and wanted to find out if that was the 
case.
- Original Message - 
From: "Alan G" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>; "Tutor mailing list" 

Sent: Tuesday, August 02, 2005 2:45 PM
Subject: Re: [Tutor] Question about resetting values


>> I am writing a Blackjack program, and was wondering how to reset the 
>> values to zero, e.g. cash = 0?
>
> Yes, that's how you do it. Now what is the bit you don't understand?
>
> Alan G
> Author of the Learn to Program web tutor
> http://www.freenetpages.co.uk/hp/alan.gauld
> 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] I need advice about which way to go.

2005-08-02 Thread Nathan Pinno



Hi all,
 
I am writing a poker game and a blackjack game. I was wondering which way 
would be Python smart and work properly. I am trying to figure out whether or 
not to use t(n) as a card indicator, when n = randomly drawn number. I could go 
that way, or code it as t1, t2, t3, etc. Which way is the right and correct way 
to go? Also for blackjack, I want to use it as playertotal = playertotal + n, 
and computertotal = computertotal + n. or 1,2,3, etc. Which is better?
 
Thanks,
Nathan Pinno,Crew, Camrose McDonalds and owner/operator of 
Woffee
BEGIN:VCARD
VERSION:2.1
N:Pinno;Nathan;Paul;Mr.
FN:Pinno, Nathan Paul
ORG:Woffee;Executive
TITLE:Owner/operator
TEL;CELL;VOICE:7806085529
ADR;WORK:;President/CEO
LABEL;WORK:President/CEO
ADR;HOME:;;Box 1783;Camrose;Alberta;T4V1X7;Canada
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:Box 1783=0D=0ACamrose, Alberta T4V1X7=0D=0ACanada
X-WAB-GENDER:2
URL;HOME:http://falcon3166.tripod.com
URL;WORK:http://falcon3166.tripod.com/Woffee.htm
BDAY:19850221
EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
REV:20050803T063928Z
END:VCARD
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Corrupt files (fwd)

2005-08-02 Thread ZIYAD A. M. AL-BATLY
On Tue, 2005-08-02 at 13:22 -0700, Danny Yoo wrote:
> 
> -- Forwarded message --
> Date: Tue, 2 Aug 2005 22:12:34 +0200 (CEST)
> From: "[iso-8859-1] yvind" <[EMAIL PROTECTED]>
> To: Danny Yoo <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Corrupt files
> 
> Hello and thank you.
> 
> I don't really think that will help. The files are mostly smaller ones of
> for example jpg, avi, txt, doc and xls files. It is not published any MD5
> checksums. Is there any way to check for example that a jpg file is
> completed without opening it? Or, is there some way to check the filesize
> on the server thru http (urlretrieve) and compare with the filesize of the
> downloaded file? Do you think that would work?
> 
> Thanks in advance
> 
I'm not sure what this is all about, but here's something you might find
it useful.

An HTTP "HEAD" request is like an HTTP "GET" (or normal retrieval) but
the server will not send any data, only the header part.  This might be
useful to you to compare the size and modification date of the files.
Of course, this all assume that the server does send such information
(sadly, some badly programmed/configured HTTP server don't do that!).

For more information about "GET" and "HEAD", search the web or ask here
again.

Ziyad.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor