>How do I split a string like "Hans" into a list of characters
> ['H','a','n','s']?
>>> list('fred')
['f', 'r', 'e', 'd']
>>>
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tu
Bingo :)
Thanks Rick
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Pasotto
Sent: Tuesday, 23 August 2005 1:55 p.m.
To: tutor@python.org
Subject: Re: [Tutor] Split a string into characters
On Tue, Aug 23, 2005 at 01:18:43PM +1200, Hans Dushanthakum
Quoting Jonas Melian <[EMAIL PROTECTED]>:
> Thank you very much!.
>
> I didn't want to make it using the old-style programming because it's
> more large and I'm supposed that slower that using a list comprehension
> solution.
Well, we can investigate, to find out the truth :-)
Hopefully you ca
I am writing a resource manager like program !
the files of directory is display on canvas and taged.
the tag and file name is keep in a dictionary!
The tag is a increaseing number from 1,so I build the
dictionary like (1:file1,2:file2,..).
While geting into another directory,I try to remov
Jeff Peery wrote:
> hello, can python read excel and access files? If so where do I go to
> read about how this would work? thanks.
There are some resources here that might be helpful:
http://www.python.org/pypi?%3Aaction=search&name=&version=&summary=&description=&keywords=excel&_pypi_hidden=0
ZIYAD A. M. AL-BATLY wrote:
> On Mon, 2005-08-22 at 18:57 +0100, Alan G wrote:
>
>>>hello, can python read excel and access files?
>>
You might also have a look at http://sourceforge.net/projects/pyexcelerator
--
Poor Yorick
___
Tutor maillist - Tuto
Jonas Melian wrote:
> best = [ [1024, 768], [800, 600], [640, 480] ] (it's larger)
>
> modes = [
> (24, [1280, 1024]),
> (24, [1024, 768]),
> (24, [640, 480]),
> (16, [1600, 1200]),
> (16, [1280, 1024]),
> (15, [320, 200]),
> ]
>
> I want to create a list with ALL elements of 'modes', but follow
ZIYAD A. M. AL-BATLY wrote:
> On Mon, 2005-08-22 at 18:57 +0100, Alan G wrote:
>
>>>hello, can python read excel and access files?
>>
You might also have a look at http://sourceforge.net/projects/pyexcelerator
--
Poor Yorick
___
Tutor maillist - Tut
On Tue, Aug 23, 2005 at 01:18:43PM +1200, Hans Dushanthakumar wrote:
> Hi,
>A quick one...
>How do I split a string like "Hans" into a list of characters
> ['H','a','n','s']?
> Note that there are no spaces in the original string.
>Str.split() without any arguments looks for whitespace
> How do I split a string like "Hans" into a list of characters
> ['H','a','n','s']?
[snip]
well you could write your own function...
def splititems(itemlist):
templist = []
for item in itemlist:
templist.append(item)
return templist
print splititems("Hello")
or even
def
Hi,
A quick one...
How do I split a string like "Hans" into a list of characters
['H','a','n','s']?
Note that there are no spaces in the original string.
Str.split() without any arguments looks for whitespace as splitting
character. So, this doesn't serve the purpose.
And str.split("") app
Quoting Jonas Melian <[EMAIL PROTECTED]>:
> best = [ [1024, 768], [800, 600], [640, 480] ] (it's larger)
>
> modes = [
> (24, [1280, 1024]),
> (24, [1024, 768]),
> (24, [640, 480]),
> (16, [1600, 1200]),
> (16, [1280, 1024]),
> (15, [320, 200]),
> ]
>
> I want to create a list with ALL elements
On Mon, 22 Aug 2005, ZIYAD A. M. AL-BATLY wrote:
> Someone posted this link on this list a while ago (sorry, I can't
> remember who). I found it very useful under Win32:
>
> http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx
What a great resource. Thanks for posting the U
>> on Win32" gives several examples. But basically COM programming is
>> a
>> pain in the neck and involves lots of trial and error. OTOH If you
>> have ever done it from VB you will know that already1
>>
> Someone posted this link on this list a while ago (sorry, I can't
> remember who). I found
> Is there a name for this type of number? I'm assuming the \x means
> it's hex, but then you have things like \x00h, and \x007p^.
It's a sequence of bytes and you've asked Python to print its
string representation. So where the bytes are unprintable
ascii codes it shows you the hex, thus:
'
Byron wrote:
> Hi Danny,
>
> I agree 100% with your statement. The reason why I left it in its
> "fragile" state was to help keep the example provided simple and
> straight forward. Since this is a "beginners" group, I wanted to
> confuse by adding extra protection to it. ;-)
>
> Byron
> ---
Danny Yoo wrote:
>
>
>>It's actually fairly simply and straight forward... Here's how to do
>>it: (I haven't officially tested this code for bugs, but I believe it
>>is correct.)
>>
>>file = open("datafile.txt", "r")
>>filedata = file.read()
>>file.close()
>>
>>newLine = "Your new line of data
> What does it mean when you write the [0] after the return statement?
> e.g. return struct.unpack("!h", bytes)[0]
Its just indexing the list returned by struct.unpack(),
specifically extracting tghe first element.
For more on using struct() see the bottom section of my file handling
topic... (no
On Mon, 2005-08-22 at 13:18 -0500, Lane, Frank L wrote:
> Hi List,
>
>
>
> I cut and pasted a dump from recvfrom below. I can’t read it and
> don’t where to look in the documentation to figure out how to read
> this.
>
>
>
> Is there a name for this type of number? I’m assuming the \x mea
On Mon, 2005-08-22 at 18:57 +0100, Alan G wrote:
> > hello, can python read excel and access files?
>
> Yes
>
> > If so where do I go to read about how this would work? thanks.
>
> You need to use COM to do it, Mark Hammonds book "Python Programming
> on Win32" gives several examples. But basica
> 1. I know squat about Python network Programming
I'll let others answer this bit.
> 2. I know nothing about networks
There's a really neat intro to networks on my company's web site
albeit rather well hidden. It's not techniccal at all but aimed
at the general public, however it's short and a
Hi List,
I cut and pasted a dump from recvfrom below. I can’t
read it and don’t where to look in the documentation to figure out how to
read this.
Is there a name for this type of number? I’m
assuming the \x means it’s hex, but then you have things like \x00h, and
\x007p^.
Any
> It's actually fairly simply and straight forward... Here's how to do
> it: (I haven't officially tested this code for bugs, but I believe it
> is correct.)
>
> file = open("datafile.txt", "r")
> filedata = file.read()
> file.close()
>
> newLine = "Your new line of data with the time stamp goe
On Mon, 22 Aug 2005, Jorge Louis de Castro wrote:
> Anyone knows how to setDaemon(True) or pass it as an argument to
> start_new_thread() with the code snippet below?
>
> server.listen(1)
> thread.start_new_thread(run_server,(server,))
>
> Otherwise the thread stops running when I close the teln
best = [ [1024, 768], [800, 600], [640, 480] ] (it's larger)
modes = [
(24, [1280, 1024]),
(24, [1024, 768]),
(24, [640, 480]),
(16, [1600, 1200]),
(16, [1280, 1024]),
(15, [320, 200]),
]
I want to create a list with ALL elements of 'modes', but following the
order of list 'best' (if exist the
Michael Lange wrote:
>On Sun, 21 Aug 2005 16:23:20 -0500
>nephish <[EMAIL PROTECTED]> wrote:
>
>
>
>>Hey there,
>>i have a simple question about getting a script to do
>>two things at once.
>>like this.
>>
>>
>>for i in range(100):
>>print i
>>time.sleep(.2)
>>if i == 15:
>>o
On Mon, 22 Aug 2005, Kent Johnson wrote:
> > Is there any way more efficient for run a nested loop?
> >
> > --
> > for a in list_a:
> > for b in list_b:
> > if a == b: break
Hi Jonas,
Depends on what we're trying to do. Is it necessary to have a nested loop
here? What kind of
On Sun, 21 Aug 2005 16:23:20 -0500
nephish <[EMAIL PROTECTED]> wrote:
> Hey there,
> i have a simple question about getting a script to do
> two things at once.
> like this.
>
>
> for i in range(100):
> print i
> time.sleep(.2)
> if i == 15:
> os.system('python /home/me/ipupd
> """ Parse the xml file """
> xmlDocument = minidom.parse(self.configFile)
[code cut]
> Now I want to change a string that a retrieved from the file and write
> it back to where it was. So, I get something, change it and write it
> back.
>
> How do I put the new string in the place
> hello, can python read excel and access files?
Yes
> If so where do I go to read about how this would work? thanks.
You need to use COM to do it, Mark Hammonds book "Python Programming
on Win32"
gives several examples. But basically COM programming is a pain in the
neck
and involves lots of
> Is there any way more efficient for run a nested loop?
>
> --
> for a in list_a:
if a in list_b:
break
Should help a bit,
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi Gang,
Thanks to Danny Yoo for a great answer. The answer given is a little
advanced so I have to ask the following follow-up.
What does it mean when you write the [0] after the return statement?
e.g. return struct.unpack("!h", bytes)[0]
I'm really green here but can tell I'm going to love
Bob Gailer wrote:
>At 08:09 AM 8/22/2005, Byron wrote:
>
>
>>Hi Johan,
>>
>>It's actually fairly simply and straight forward... Here's how to do
>>it: (I haven't officially tested this code for bugs, but I believe it
>>is correct.)
>>
>>file = open("datafile.txt", "r")
>>
>>
>
>This is an
At 08:09 AM 8/22/2005, Byron wrote:
>Hi Johan,
>
>It's actually fairly simply and straight forward... Here's how to do
>it: (I haven't officially tested this code for bugs, but I believe it
>is correct.)
>
>file = open("datafile.txt", "r")
This is an example of rebinding to a name originally bou
Byron wrote:
>Hi Johan,
>
>It's actually fairly simply and straight forward... Here's how to do
>it: (I haven't officially tested this code for bugs, but I believe it
>is correct.)
>
>file = open("datafile.txt", "r")
>filedata = file.read()
>file.close()
>
>newLine = "Your new line of data wit
mailing list wrote:
> Hi all,
>
> I've got some source code which will be handling non-ASCII chars like
> umlauts and what not, and I've got a testing portion stored in the
> code.
>
> I get this deprecation warning when I run my code -
> __main__:1: DeprecationWarning: Non-ASCII character '\xf
hello, can python read excel and access files? If so where do I go to read about how this would work? thanks.
Jeff___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi Johan,
It's actually fairly simply and straight forward... Here's how to do
it: (I haven't officially tested this code for bugs, but I believe it
is correct.)
file = open("datafile.txt", "r")
filedata = file.read()
file.close()
newLine = "Your new line of data with the time stamp goes her
John Walton wrote:
> Hello, everyone. I just began school, and they
> already assigned us science fair. Since I'm in 8th
> grade, I get to do demonstrations for our projects. >
> I'm probably going to demonstrate Python's networking>
> capabilities by writing a simple instant messenger
> progra
Jorge Louis de Castro wrote:
> Are these two equivalent:
>
> def run_server(socket):
> ...
>
> 1)
> thread = Thread(target=run_server, args=(server,))
> #thread.setDaemon(True)
> thread.start()
>
> 2)
> server.listen(1)
> thread.start_new_thread(run_server,(server,))
They both start thread
Well, I don't know how it works on Windows, but on UNIX, if you want to
create a deamon able to stay alive when you deconnect you "just" have to
catch the HUP signal and ... do nothing of it :) By default this signal
exit the application.
You have two ways of doing so :
1 - use the standard signa
> I want to write to a text file with a timestamp, but I want to
> newest
> entry at the top. So I want to insert the next entry to the file at
> the
> beginning.
You will need to create a new file. Basically you need to:
Read the current file into a list or string.
Rename the old file (foo.ba
Ok, better question.
Are these two equivalent:
def run_server(socket):
...
1)
thread = Thread(target=run_server, args=(server,))
#thread.setDaemon(True)
thread.start()
2)
server.listen(1)
thread.start_new_thread(run_server,(server,))
So that I can uncomment the setDaemon() method?
chrs
j
Hi,
Anyone knows how to setDaemon(True) or pass it as an argument to
start_new_thread() with the code snippet below?
server.listen(1)
thread.start_new_thread(run_server,(server,))
Otherwise the thread stops running when I close the telnet client (even
using Unix's & operator for background ru
Jonas Melian wrote:
> Is there any way more efficient for run a nested loop?
>
> --
> for a in list_a:
> for b in list_b:
> if a == b: break
efficient in running time? lines of code? What you have is pretty simple, what
don't you like about it?
In Python 2.4 you could use a gene
> Hello. It's me again. Thanks for all the help with
> the Python Networking Resources, but does anyone know
> what I'll need to know to write a paper on Network
> Programming and Python. Like terminology and all
> that. Maybe I'll have a section on socketets, TCP,
> Clients (half of the stuff I
Is there any way more efficient for run a nested loop?
--
for a in list_a:
for b in list_b:
if a == b: break
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi all,
I use minidom to parse xml data from a file.
I know how to get the data:
"""
""" Parse the xml file """
xmlDocument = minidom.parse(self.configFile)
""" Parse xml main section """
mainSection = xmlDocument.getElementsByTagName('Config')
"
>v = "64x43x12" -> '64x43', '12'
>
> How split it by the las 'x'?
[snip]
>>>v = "64x43x12"
>>>temp = v.split("x")[-1:]
>>>print temp
['12']
that's the best I can do for now.
HTH,
-Luke
___
Tutor maillist - Tutor@python.org
http://mail.python.org/m
Am Montag, den 22.08.2005, 09:30 +0200 schrieb Johan Geldenhuys:
> Hi all,
> I want to write to a text file with a timestamp, but I want to newest
> entry at the top. So I want to insert the next entry to the file at
> the beginning.
> I can create and append to a file and then the latest entry is
Hi all,
I want to write to a text file with a timestamp, but I want to newest entry at the top. So I want to insert the next entry to the file at the beginning.
I can create and append to a file and then the latest entry is at the bottom.
Any ideas how this is done please?
Thanks,
Johan
__
>ImportError: No module named win32file
>>>
> Is there something else that I need to specify?
Do you have the winall package installed? Its a separate download
to the official Python package or comes prebundled in the
ActiveState version of Python.
> 2) I want to send data (ascii text) to a ser
52 matches
Mail list logo