First, convert the integer to a string by using str(), then convert the
string to a list by using list()
--
Message: 6
Date: Mon, 3 Jan 2005 17:17:36 -0500
From: "kilovh" <[EMAIL PROTECTED]>
Subject: [Tutor] Breaking down integers?
To:
Message-ID: <[EMAIL PROTECTED]>
> I don't quite grasp "automated testing". And yes, I test in place
> constantly, but it only ever gets tedious when I cant figure out why
a
> thing doesn't work. ;)
Think about writing a moduule and testing it at the >>> prompt.
What you are doing is typing a series of python commands into
the
Bill:
Sometimes seeing something simple like this can make all the difference. Glad to be able to help.
Bob
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
aint=1077
list_of_aint_as_string=list(str(1077))
print list_of_aint_as_string #['1', '0', '7', '7']
#turn it into a list of integers
#doc for map() found on
http://docs.python.org/lib/built-in-funcs.html
list_of_aint_as_integer=map(int,list_of_aint_as_string)
print list_of_aint_as_integer #[1, 0, 7
Rich,
That worked although I had to set the address to :-
http://127.0.0.1:8000/friends1.html
Thanks.
___
ALL-NEW Yahoo! Messenger - all new features - even more fun!
http://uk.messenger.yahoo.com
__
Hi,
Sorry if I missed something obvious, but how do I execute a python
script file in the interpreter? I have "Using the Python Interpreter" in
the Python tutorial but not much is said...
(this might be a lame quesiton but so far I always used either the
PythonWin interpreter wich has the Import
Hi Bernard...
The most basic form is to type "python" followed by the script you want
to run. If your script is not in the system path, you'll either need to cd to
the directory, or give a full pathname: (the pythonpath doesn't come into
play until the interperter is running.
python /usr/loca
Bernard,
If you're new to Linux you might not be aware of an additional method to run
python scripts. If the first line of your script is:
#!/usr/bin/python
And you've set your script permissions to be executable (chmod 700
myscript.py) then you can run your script just like any other program.
Okay sorry I meant once you're in Python.
I'm in Bash console, type Python, enter the Python interpreter.
Then I add my custom path to the sys.path list (because my user
permissions do not allow my to put anything in the Lib directory) and
then I try an
import /home/bernardl/python/myScript.py
bu
Hello,
I'm having erratic results with a regex. I'm hoping someone can
pinpoint the problem.
This function removes HTML formatting codes from a text email that is
poorly exported -- it is supposed to be a text version of an HTML
mailing, but it's basically just a text version of the HTML page.
On Monday 03 January 2005 11:09 pm, Jacob S. wrote:
> You're thinking right. The syntax is supposed to be something like
>
> [ altereditem for item in iterable if condition ]
>
> So,
> to get all the even numbers between 1 & 10
>
> >>> a = [x for x in range(1,11) if x % 2 == 0]
> >>> print a
>
> [2
I'm not sure why it fails "of course". How do you know it's failing at the
first slash? Also you might want to look at your .profile file in your home
directory and modify your path there.
John Purser
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Ber
HI Bernard...
I think I see what you might mean
I'm guessing your session goes something like this:
>>> import sys
>>> sys.path.append(' /home/bernardl/python/')
>>> import /home/bernardl/python/myScript
File "", line 1
import /home/bernardl/python/myScript
^
SyntaxError
David Holland wrote:
Rich,
That worked although I had to set the address to :-
http://127.0.0.1:8000/friends1.html
Thanks.
Good catch, sorry about that. I noticed you had spaces in the "how many"
field in your form. Did your cgi still work? If not, I guess you figured
that out by now too.
Intere
Hi all,
Just playing with Pygame, attempting to build a version of Scorched
Earth if you remember it.
I want to represent dirt, and so far I've come up with using a surface array -
0 644120 64412 64412
00 64412 64412 64412
0 644120
Thanks to Patric Michael and Alan Gauld for helpful responses.
The mailman "config_list" command was perfect for my near-term needs.
A bit more digging led me to juicier info on pickles, for my longer
term nourishment and development.
Lots of documentation is in /usr/lib/python2.3/pickletools.py
Sorry rephrase -
So I have a list -
[0,0,0,0,0,1,1,1,0,1,1,0,1,0]
I want to move all the 1's move to the right, 1 index at a time,
preserving any spacing.
i.e.
[1,0,0,0,0,1,1,1,0,1,1,0,1,0]
[0,1,0,0,0,0,1,1,1,0,1,1,0,1]
[0,0,1,0,0,0,0,1,1,1,0,1,1,1]
[0,0,0,1,0,0,0,0,1,1,1,1,1,1]
[0,0,0,0
Hi Michael,
Is a non regex way any help? I can think of a way that uses string methods -
space=" "
stringStuff="Stuff with multiple spaces"
indexN = 0
ranges=[]
while 1:
try:
indexN=stringStuff.index(space, indexN)
if indexN+1 == space:
indexT = indexN
while
Michael Powe wrote:
Hello,
I'm having erratic results with a regex. I'm hoping someone can
pinpoint the problem.
This function removes HTML formatting codes from a text email that is
poorly exported -- it is supposed to be a text version of an HTML
mailing, but it's basically just a text version o
You might want to try IDLE. You can open your file in an editing window and run it from there. I
don't know how to start IDLE on Linux though...you need to run Lib/idlelib/idle.pyw
Kent
Bernard Lebel wrote:
Hi,
Sorry if I missed something obvious, but how do I execute a python
script file in the
On Tue, 4 Jan 2005, Michael Powe wrote:
> def parseFile(inFile) :
> import re
> bSpace = re.compile("^ ")
> multiSpace = re.compile(r"\s\s+")
> nbsp = re.compile(r" ")
> HTMLRegEx =
>
> re.compile(r"(<|<)/?((!--.*--)|(STYLE.*STYLE)|(P|BR|b|STRONG))/?(>|>)
> ",re.I)
>
>
Hi,
I'm using SUSE x86_64 Linux and unable to compile the KInterbasdb interface
for Python. I'm wondering if anyone has it compiled on either a 32bit or
64bit linux. Of course I'm hoping someone is willing to post it. Or tell me
where I might get it. Thanks in advance.
John
> Sorry if I missed something obvious, but how do I execute a python
> script file in the interpreter? I have "Using the Python
Interpreter" in
> the Python tutorial but not much is said...
You can import a script at the >>> prompt as you would under
Pythonwin.
Or you can run IDLE much as you did
> Then I add my custom path to the sys.path list (because my user
> permissions do not allow my to put anything in the Lib directory)
and
YOu should be able to create a personal startup script in your
homedir.
I've not done it but I'm sure I remember reading about it, and its
pretty standard LInux
> This function removes HTML formatting codes from a text email
Using regex to remove HTML is usually the wrong approach unless
you can guarantee the format of the HTML in advance. The
HTMLparser is usually better and simpler. I think theres an example
in the module doc of converting HTML to pl
> Finally, another serialization format that is eminently readable is
> YAML ("YAML Ain't Markup Language"). Besides Python, it works for
> Ruby et al., can be used as an alternative to xml, etc.
A new one on me but I'll take a klook, thanks for posting.
Alan G.
(Who hates XML almost as much as
> I want to move all the 1's move to the right, 1 index at a time,
> preserving any spacing.
So you want to insert a zero at the front and delete the first
zero from the back? That doesn't require iterating over all
the entries just enough to find the first zero...
> [1,0,0,0,0,1,1,1,0,1,1,0,1,
27 matches
Mail list logo