On 25/09/05, Andrei <[EMAIL PROTECTED]> wrote:
> > Think the mail system screwed up the formatting! But am fairly sure
> > that I have indented it correctly in the console. Try and Except are
> > in the column. Any other hints?
>
> Yes :). Compare:
>
> >>> try:
> ... os.system('cls')
> ... excep
Didn't go through everything, but why do you do:
>for phrase in string.split(phrase):
> acronym = string.upper(phrase[0])
you are iterating with the name of the list? bad juju
try something like
acronym = ""
for word in string.split(phrase):
acronym = acronym + string.upper(wor
Hello
How could I get the following program to output UDP from the user entering user datagram protcol or IP if internet protocla was entered?
currently it only prints out on letter
import string
def main():
phrase = (raw_input("Please enter a phrase:"))
acr1 = string.split(phrase)
Thanks,
This is the other 'work around'. I take there is no way to tell 'print' to
do it, correct?
Marcin
- Original Message -
From: "R. Alan Monroe" <[EMAIL PROTECTED]>
To: "python-tutor"
Sent: Sunday, September 25, 2005 10:29 AM
Subject: Re: [Tutor] 'print' without newline or space
Sorry! Found the typo.
- Jan
Jan Eden wrote on 25.09.2005:
>Hi,
>
>I experienced a strange side effect using a custom __getattr__ method.
>
>For a certain attribute, I'd like to return the value of another attribute if
>the former is not present. So I wrote:
>
>def __getattr__(self, attrname):
Hi,
I experienced a strange side effect using a custom __getattr__ method.
For a certain attribute, I'd like to return the value of another attribute if
the former is not present. So I wrote:
def __getattr__(self, attrname):
if attrname == 'own_type': return self.child_type
else: Attrib
> Think the mail system screwed up the formatting! But am fairly sure
> that I have indented it correctly in the console. Try and Except are
> in the column. Any other hints?
Yes :). Compare:
>>> try:
... os.system('cls')
... except:
... print "Foo"
...
Foo
>>> print "Bar"
Bar
With (what y
On Sun, 2005-09-25 at 19:44 +0530, Krishna wrote:
> Think the mail system screwed up the formatting! But am fairly sure
> that I have indented it correctly in the console. Try and Except are
> in the column. Any other hints?
Make sure you're not mixing "tabs" and "spaces". A lot of editors uses
> Hello,
> This statement:
> for c in 'hello': print c
> will generate following output:
> h
> e
> l
> l
> o
> and by adding comma at the end of the print statement:
> for c in 'hello': print c,
> we get this output:
> h e l l o
> How do I output something using 'print' such that t
Hello,
This statement:
for c in 'hello': print c
will generate following output:
h
e
l
l
o
and by adding comma at the end of the print statement:
for c in 'hello': print c,
we get this output:
h e l l o
How do I output something using 'print' such that there is no new line or
spac
On 25/09/05, ZIYAD A. M. AL-BATLY <[EMAIL PROTECTED]> wrote:
> On Sun, 2005-09-25 at 18:55 +0530, Krishna wrote:
> > When I try to run the following piece of code, I get a SyntaxError,
> > can someone help me out on this?
> >
> > try:
> > ... os.system("cls")
> > ... except:
> > ... print "Foo"
On Sun, 2005-09-25 at 18:55 +0530, Krishna wrote:
> When I try to run the following piece of code, I get a SyntaxError,
> can someone help me out on this?
>
> try:
> ... os.system("cls")
> ... except:
> ... print "Foo"
> ... print "Bar"
> Traceback ( File "", line 5
> print "Bar"
>
When I try to run the following piece of code, I get a SyntaxError,
can someone help me out on this?
try:
... os.system("cls")
... except:
... print "Foo"
... print "Bar"
Traceback ( File "", line 5
print "Bar"
^
SyntaxError: invalid syntax
What am I missing?
Thanks in advan
Hi Garry,
break is essential for while loops like that one. You'll see that
construct often enough in Python.
While 1 or While True followed by an if : break
Bit awkward, makes me miss the do - while construct.
continue is very useful in for loops.
Let's say I have a set of numbers, but I don
[EMAIL PROTECTED] wrote:
> How would I get the following program to accept inputs of exam scores
> from 0-100 with A being 100-90, B being 89-80, C being 79-70, D being
> 69-60, and F being everything less than 60?
>
> import string
There's no point in importing string.
> def main():
>
> sc
Hi Garry,
dau_version = None
while dau_version not in ("2.8", "2.1"):
dau_version = raw_input("\n\tIs the DAU a version 2.1 or 2.8, please
enter only 2.1 or 2.8 ")
print"\n\t\aError! - please enter only 2.1 or 2.8."
el
I will use simple function:
def getscore(val): if 90 < val <=100: return 'A' elif val >= 80: return 'B' elif val >= 70: return 'C' elif val >= 60: return 'D'
else: return 'F' def main(): g = input('Enter score:') print 'the score of the
Garry Rowberry wrote:
> def ask_dau_version():
> """Determine the product issue of the DAU."""
> dau_version = None
> while dau_version not in ("2.8", "2.1"):
> dau_version = raw_input("\n\tIs the DAU a version 2.1 or 2.8, please
> enter only 2.1 or 2.8 ")
> print"\n\t\a
On Sun, 2005-09-25 at 01:06 -0400, [EMAIL PROTECTED] wrote:
> How could I change the program to accept something like: John Bob
> Zelle Python or Kip Rada?
>
If it works for you with one word, all you need to make it accepts more
is to add the space character " " with a weight of zero to "table".
I have a call which needs to reply 2.1 or 2.8 and report an error if not:
def ask_dau_version():
"""Determine the product issue of the DAU."""
dau_version = None
while dau_version not in ("2.8", "2.1"):
dau_version = raw_input("\n\tIs the DAU a version 2.1 or 2.8, please
enter
> Oh wait, I get it - you are passing bound methods to property(). So um is
> bound to the instance when you access self.getA. Use Strange.getA instead of
> self.getA, then use the normal signatures.
Ahh... I get it.
> But I don't get why you are doing this at all?
Because some of the objects
21 matches
Mail list logo