Often, when I am developing code, I get an error message saying that
"IDLE's subprocess can't make connection"
Sometimes this happends when I have IDLE open, and am about to hit F5
to run a program-in-process.
Sometimes it happens when I opne up IDLE the first time.
It's often fixed on restar
I have a number-to-Roman numeral program that churns out ValueError
messages with a few improper input cases:
1. not an integer
2. larger than 3999
3. smaller than 0
When I run the program via IDLE, and I give one of these improper
inputs, the interpreter closes down the program and then disp
I have a program producing a list of multiple strings.
The amount of strings in the list varies.
I want to assemble a string that is:
list item 0 + space + list item 1 + space,
and so on, going through every string in the list.
--
"Computers were the first God-Satan collaboration project."
"Blind
Given a string, how would I?:
1. Make sure only the first letter string_name[0], is capitalized.
This would involve using string_name.lower() to lowercase everything
else, but how do I use .upper(), or some other method, to capitalize
only the first character?
2. Make sure that there are no s
My programs often have long, detailed loops in them, and would like
to, as I'm executing the loop, view what part of the loop Python is
currently processing.
Thus, if my program gets stuck in one part of the loop, I would see that.
Thus, if one part of my loop is never triggered, I would see t
How do you 'tell' Python to repeat a certain action X amount of times,
and then stop.
I could use a 'counter' (see below), but that seems kind of clunky.
counter = 0
example = True
while example:
print "Do something"
counter += 1
if counter == 100:
example = False
__
Quoting Kent Johnson <[EMAIL PROTECTED]>:
> Alan Gilfoy wrote:
>> My programs often have long, detailed loops in them, and would like
>>to, as I'm executing the loop, view what part of the loop Python
>> is currently processing.
>>
>> Thus,
What is the best (only?) way to set up an array in Python.
I've heard they can be quite good for certain types of data you need
to organize...
What IS the best reason(s) to be using an array?
Apologies, if Python has something similar by a different name.
Ah, a simple concept. Good. :)
I'm already familiar in working with lists.
Here's a case of a simple two-dimensional array (the simplest
possible), ran in the IDLE interpreter:
>>> array = [["1.1", "1.2"], ["2.1", "2.2"]]
>>> array[1[2]]
Traceback (most recent call last):
File "", line 1, i
Why Python starts counting at [0] instead of at [1] is a whole other issue. :D
array = [["0.0", "0.1"], ["1.0", "1.1"]]
array[0[1]] seems right, although it isn't, because the index (0) and
the subindex(1) are nested in 'array[0[1]]' much like the list and
sublist that I'm "calling" from with
I'm not quite there yet, but I want to get into using GUIs in Python
soon, and I plan to use wxPython to do so. What, do you think, is the
best tutorial out there for wxPython?
Also, what happens when you code for some GUI feature and run the
script in your IDE, such as IDLE? Will the graphi
I want to work with simple ASCII text files, here..
I know you get them loaded into Python with file() or open()
The arguments for file() and open() are: (filename, mode, buffering).
How do you refer to the filename? Do you put it in quotes? Do you put
in the file's full directory path? Or do f
-code block-
number = 3
running = True
while running:
guess = int(raw_input("Please enter a number : ")) #lets user guess a number
if guess == number:
print "Yay, you got the right number, good for you. But you
don't get any prizes. Do I look like a walking ATM to you?"
runn
I am a senior at the School Without Walls in Rochester, NY. As such, I
get to do a senior project. I decided to work on computer programming,
since that is sometihng that I certianly think can hold my interest
throughout the school year.
(despite my compute rinteresat, I've never done anything
Yeah, that's what the wiki-based tutorial mentioned.
In fact, Lee Harr (my community adviser) also suggested using a random number.
Quoting Luke Paireepinart <[EMAIL PROTECTED]>:
> Alan Gilfoy wrote:
(the start of the code for my number-guessing thingamajig)
>>
>> els
Hello All.
I've been concocting some simple programs based on an online tutorial,
and I, of course, save a program as a .py file.
When running my program via IDLE, once I've cleaned out the bugs, it
works as I expect it to.
But I noticed something else:
Clicking directly on the file's icon h
Hey! Glad to hear that using raw_input() at the end is the actual
solution, not just a jury-rigged workaround. :)
So sleep(10) would simply be a shorter snippet of code for that purpose?
The \n thing might be handy if I was short on space, but I don't mind
separate 'print' lines, I find that m
This, I heard, is more difficult than digital-to-Roman, since you have
to "read" the subtractive cases, with a smaller numeral placed before
a larger numeral, without simply adding all the numerals' values up
I'm going to use a raw_input prompt to ask the user which Roman
numeral he/she want
Quoting Bob Gailer <[EMAIL PROTECTED]>:
> Make sure each step
> is one simple operation. Walk thru the steps to verify that you have
> them correct.
Bob, your email did inspire me on how I would express the process in
computer-processing terms.
Here's how I'd break down the steps, using "pseud
Quoting Bob Gailer <[EMAIL PROTECTED]>:
>>
>> Digital to Roman pseudocode:
>>
>> 1. if digital_input is greater than 1000:
>> subtract 1000 from it and add "M" to string roman_result
>> # How do you do that, add one character to the end of an existing string?
>>
> Start with an empty string:
>
> r
Roman Numeral - To - Digital Converter
So far, I'm coming along OK with the code that runs the conversions,
assuming the user gives me a proper input. (A string of capital
letters I, V, X, L, C, D, M)
However, not every input someone gives the function is goign to be
properly formatted like
#start of triple-letter processing block
if len(roman_input) > 2 and roman_input[0] + roman_input[1] +
roman_input[2] == "MMM":
digital_result += 3000
roman_input = #something to remove those "M"'s from the string
continue
--
My question here boils down to, "Is there a way to rem
Hi. I want to learn how to "break down" a string into its component
words, and then process each word somehow.
Is there a way in Python to separate a string into its component words.
Like this:
"I would like to convert an English string (sentence) into Pig Latin."
The Pig Latin conversion I th
Awesome! (I was hoping it would be a 1-line solution. :)
Thanks to batteries beign included, I don't necessarily need to worry
about why and how .spilt() works. :)
Quoting Bob Gailer <[EMAIL PROTECTED]>:
> Alan Gilfoy wrote:
>> Hi. I want to learn how to "brea
One of my for-fun Python products is a booster-pack generator for
trading card games (specifically, Magic the Gathering, the one game of
the genre that I play heavily)
Somewhat like baseball cards, the cards in a pack are a
somewhat-random selection of cards from the set in question, broken
Quoting W W <[EMAIL PROTECTED]>:
The number of items I want from a list is smaller than the population
(number of items) in the list, so it should work.
In this specific case, I'm asking for one item from a five-item list.
Are you sure?
change this:
for card in random.sample(SpecialA, SA):
The booster pack generator (my use of random.sample as described in a
previous message) is working as intended now.
There was a rather stupid typo in my code that was causing it to go wonky.
Y'all still helped, though. A few people replied, but a bit of advice
from: W W <[EMAIL PROTECTED]> p
hadn't detected the problems with the lines
that the traceback was pointing to.
Quoting Kent Johnson <[EMAIL PROTECTED]>:
On Thu, Aug 28, 2008 at 11:49 AM, Alan Gilfoy
<[EMAIL PROTECTED]> wrote:
The booster pack generator (my use of random.sample as described in a
previou
I shouldn't get the same card twice in the same batch, no.
Of course, in separate trials, I may get the same card again.
Basically, I type the names of relevant cards in a list, and proceed
to "tell" my program which list to read, and how many cards to pick
from that list.
Normally, I put e
In this case, I was trying to pull 1 card from a 5-card pool, which
should have worked. There was a typo in my code that I have since
fixed, and it is working.
I have to make sure manually that I'm not telling the program to pick
more cards than exist in the list. I can do this two ways: Ma
# http://code.activestate.com/recipes/65212/
# The function code is from that page
# User Interface + comments created by Alan Gilfoy, 2007-2008
def baseconvert(n, base):
"""convert positive decimal integer n to equivalent in another
base (2-36)&
31 matches
Mail list logo