Re: [Tutor] word replace

2009-08-30 Thread Alan Gauld
"j booth" wrote I have been experiencing such difficulty with something that should be easy-- pretty new to programming.. Need to: (1) open a text file (2) iterate through it word by word And here lies the first problem. Programming languages in general don't know much about words(*) (or p

Re: [Tutor] update html pages using python

2009-08-30 Thread Alan Gauld
"Stefan Behnel" wrote "pedro" wrote Hi, I was wondering if anyone could point me in the right direction as far as the best way to use python to update html. There are a number of modules in the standard library that can help but the best known module for this is BeautifulSoup I would ca

[Tutor] word replace

2009-08-30 Thread j booth
Hello, I have been experiencing such difficulty with something that should be easy-- pretty new to programming.. Need to: (1) open a text file (2) iterate through it word by word (3) replace each word with an alternative word and close the file. **I don't know what the alternative word will be b

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Kent Johnson
On Sun, Aug 30, 2009 at 11:59 AM, Skipper Seabold wrote: > Hello all, > > Fair warning, I didn't know what a bitfield was a few hours ago. > > I am working with a program via the dbus module and I am wondering if > there is built-in support to deal with bitfields in Python.  I query > my applicatio

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Skipper Seabold
On Sun, Aug 30, 2009 at 1:58 PM, Alan Gauld wrote: > > "Skipper Seabold" wrote > >> You can just do a binary AND with your consts and your bitfield value to >> get >> > each bit. The values will be the actual value (2, 4, 8, etc.) but if > >> > you >> > use these as a boolean it won't matter. >> N

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Alan Gauld
"Skipper Seabold" wrote You can just do a binary AND with your consts and your bitfield value to get > each bit. The values will be the actual value (2, 4, 8, etc.) but if > you > use these as a boolean it won't matter. No that's perfect. It looks like I need to read up a bit more (pun not

Re: [Tutor] update html pages using python

2009-08-30 Thread Stefan Behnel
Alan Gauld wrote: > "pedro" wrote >> Hi, I was wondering if anyone could point me in the right direction as >> far as the best way to use python to update html. > > There are a number of modules in the standard library that can help but > the best known module for this is BeautifulSoup I would

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Luke Paireepinart
You can just do a binary AND with your consts and your bitfield value to get each bit. The values will be the actual value (2, 4, 8, etc.) but if you use these as a boolean it won't matter.I.E. >>> bitfield = 119 >>> seek = bitfield & CAN_SEEK >>> seek 16 >>> if seek: print "Hello" Hello >>> if

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Skipper Seabold
On Sun, Aug 30, 2009 at 1:25 PM, Luke Paireepinart wrote: > You can just do a binary AND with your consts and your bitfield value to get > each bit.  The values will be the actual value (2, 4, 8, etc.) but if you > use these as a boolean it won't matter. > I.E. bitfield = 119 seek = bitfi

[Tutor] Dealing with bitfields in Python

2009-08-30 Thread Skipper Seabold
Hello all, Fair warning, I didn't know what a bitfield was a few hours ago. I am working with a program via the dbus module and I am wondering if there is built-in support to deal with bitfields in Python. I query my application and it returns a bitfield 119. The bitfield "key" is NONE

Re: [Tutor] How to convert binary files back to text files?

2009-08-30 Thread Kent Johnson
On Sun, Aug 30, 2009 at 6:32 AM, prasad rao wrote: > I want to examine pyc files.(ex:itertools). > itertools.py is not available inPython26. > pyc files are binaryfiles.Isn't it. itertools is written in C. All the Python source code is freely available for you to read. Download the entire source

Re: [Tutor] How to convert binary files back to text files?

2009-08-30 Thread prasad rao
> . > > >I don't understand what you are trying to do. Do you mean compiled > >Python files, e.g. .pyc files? > > ?Kent > Yes I want to examine pyc files.(ex:itertools). itertools.py is not available inPython26. pyc files are binaryfiles.Isn't it. ___ Tu