Re: [Tutor] convert hex number to decimal

2007-03-17 Thread Johan Geldenhuys

 ord('\x0D')
13 

Johan

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Rikard Bosnjakovic
Sent: 16 March 2007 01:12 PM
To: Tutor@python.org
Subject: Re: [Tutor] convert hex number to decimal

On 3/16/07, ammar azif [EMAIL PROTECTED] wrote:

 Is there any built-in function to convert a hex number to a decimal
number?

 int(ff, 16)
255



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

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.10/720 - Release Date: 2007/03/12
07:19 PM
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.10/720 - Release Date: 2007/03/12
07:19 PM
 

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


Re: [Tutor] Hi

2007-03-17 Thread Rikard Bosnjakovic
On 3/16/07, Ben [EMAIL PROTECTED] wrote:

 Is anyone can point me where I can find a good tutorial about pywin for
 someone like me?

Pywin itself is not a package for making GUIs, it's merely a IDE for
Windows and got the win32all-package included.

For GUIs, you want to look at wxPython, pygtk or similiar packages.
Those will let you do what you are looking for.


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


[Tutor] Is generator function reusable?

2007-03-17 Thread ammar azif
Lets say a generator function instance is created and has finished its 
iteration.
Can that instance be reused again? can it accept anymore values? or we should 
discard it and create a new generator instance.

Thanks

 
-
Need Mail bonding?
Go to the Yahoo! Mail QA for great tips from Yahoo! Answers users.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is generator function reusable?

2007-03-17 Thread Kent Johnson
ammar azif wrote:
 Lets say a generator function instance is created and has finished its 
 iteration.
 Can that instance be reused again? can it accept anymore values? or we 
 should discard it and create a new generator instance.

In general, no, you can't reuse any iterator, including the generator 
created by calling a generator function. Iterators go through their 
values once, then raise StopIteration on any further accesses.

In Python 2.5 you can pass values into a generator by calling next() 
with a value. You could use this to create a generator that can be 
reset. But more commonly you would just call the generator function 
again and create a new generator instance.

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


Re: [Tutor] cookie expiration date format

2007-03-17 Thread Tim Johnson
On Saturday 17 March 2007 02:31, Luke Paireepinart wrote:
 Tim Johnson wrote:
 
  I'm not clear what datatype is needed here.
  Can anyone clarify this for me?

 Sounds like it's an integer or float, such as returned by time.time()

 I shouldn't have used the word 'datatype', 'cuz I'm sure that it is a string.
 -having built cookie functions from scratch in other languages, according
to RFC 2965.
 I think I found what I am looking for at 
http://pleac.sourceforge.net/pleac_python/cgiprogramming.html
and look for keyword
time_format

I'll try and implement later today and report back on success or failure
Thanks Luke
tim

-- 
Tim Johnson [EMAIL PROTECTED]
Palmer, Alaska, USA
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] cookie expiration date format

2007-03-17 Thread Tim Johnson
On Saturday 17 March 2007 08:13, Tim Johnson wrote:
 On Saturday 17 March 2007 02:31, Luke Paireepinart wrote:
  Tim Johnson wrote:
   I'm not clear what datatype is needed here.
   Can anyone clarify this for me?
 
  Sounds like it's an integer or float, such as returned by time.time()

  I shouldn't have used the word 'datatype', 'cuz I'm sure that it is a
 string. -having built cookie functions from scratch in other languages,
 according to RFC 2965.
  I think I found what I am looking for at
 http://pleac.sourceforge.net/pleac_python/cgiprogramming.html
 and look for keyword
 time_format

 I'll try and implement later today and report back on success or failure
 Thanks Luke
Here we go
import datetime
time_format = %a, %d %b %Y
expires = %s % ((datetime.datetime.now()
+ datetime.timedelta(-1)).strftime(time_format))
#  ^
#   -1 references previous day  ---|
Thus the cookie directive in toto looks something like this:
note that it should all on one line so I'm delimiting with two lines of 
asterisks

Set-Cookie: kbcpCookie= (password|mypwd)(mylogin); 
Domain=.linus.johnson.com; expires=Fri, 16 Mar 2007; Path=/cgi-bin/ 

I don't think the rfc is touchy about spaces following semicolons, but the 
exact format of the date (minutes and seconds optional) is important

Just a comment:
 I've used python for years and am always impressed with the
great amount of resources and the care taken to vet and document libraries, 
but I must say, in the case of the cookies library, module `Cookie', that the
documentation is a bit lacking and could use more, and some examples - as 
well.
MTCW
Tim

-- 
Tim Johnson [EMAIL PROTECTED]
Palmer, Alaska, USA
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor