f the '\n'
but kept getting an error of :
AttributeError: 'list' object has no attribute 'rstrip'
rstrip is a string method, not a list method. You must apply it to each
element in the list. One way is:
print [item.rstrip() for iten in mylist]
--
Bob Gailer
919-6
supported operand type(s) for *: 'int' and 'vector'
I'm using python 3.1.
Thanks.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscri
imes should it be printed?")
print snumber
A good robust alternative is to try int() and capture / report the failure:
text = str(input("Type in some text: "))
snumber = input("How many times should it be printed?")
try:
number = int(snumber)
except ValueError:
s a special function key, this will return '\000' or '\xe0'; the next
call will return the keycode. The Control-C keypress cannot be read with
this function."
IOW - getch always returns 1 character.
You are testing for a 0 length string. Will never happen.
What keystrok
run only and produces the output I expect.
Then your expectation is misguided, given my comments regarding multiple
calls to flipCoin! You don't actually know how many tosses were made!
[snip]
--
Bob Gailer
919-636-4239
Chapel Hill NC
__
foo' in sys.modules:
foo = sys.modules['foo']
else:
compile foo.py
if successful:
execute the compiled code thus creating a module object
if successful:
sys.modules['foo'] = the new module object
foo = sys.modules['foo'
of
writing them to files?
Take a look at the stringIO module.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
x27;m executing from IDLE. Is there a way to just return to the >>>
prompt there?
def finish():
print; print "Bye"
print
raw_input('Press Enter to quit')
sys.exit()
--
Bob Gailer
919-636-4239
Chapel Hill NC
__
n data = scope
Then you reassign data = data.getAttr(key) OR data = data.getItem(key)
data no longer refers to scope! Hence the error.
How can it branch to the "getItem" side of the choice?
Denis
____
vit esse est
y other way I can
make it fast.
In file 1, how a dictionary can be made. I mean unique keys that are common to
file 1 and 2.
thanks
Kumar.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.
lly, they
*are* code nodes). 'w' is a kind of global scope -- say the state of the
running program. Indeed, most code objects need to read/write in w.
Any comments on this model welcome. I have few knowledge on implementation of
languages.
________
vit esse estrany ☣
ppens
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
**
IDLE 2.6.3
>>> import sys
>>> for i in sys.path:
print i
C:\Python26\Lib\idlelib
C:\Windows\system32\python26.zip
C:\Python26\DLLs
C:\Python26\lib
C:\Python26\lib\plat-win
C:\Python26\lib\lib-tk
C:\Python26
C:\Python
Traceback (most recent call last):
File "geek_translator3.py", line 4, in
import pickle
File "/usr/local/lib/python2.5/pickle.py", line 13, in
AttributeError: 'module' object has no attribute 'dump'
I suspect that file is not the one packaged with Python. Try renaming it
and rerun the program.
I don't understand, I don't write anything about pickle.py, why it mentioned?
what's wrong with "import pickle"? I read many examples online whose
has "import pickle", they all run very well.
Thank you!
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
matches records that do NOT match zipcodes. How do I get this
running so that it matches zips?
Thanks
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ts. What is the exact
program that you want me to run?
#!/usr/bin/env python
infile = open("filex")
match_zips = open("zippys")
[line for line in infile if line in match_zips]
print line
I did what you said and I get '345' output both times.
Sorry - my mistake - try:
match_zips = zips.readlines()
lines = [ line for line in infile if line[149:154] in match_zips ]
outfile.write(''.join(lines))
#print line[149:154]
print lines
infile.close()
outfile.close()
main()
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
ation" in line:
lines_to_be_read.append(lineno + 25)
if lineno in lines_to_be_read:
# process this line
lines_to_be_read.pop(0)
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change s
You have the solution. Good.
I beg you to avoid colored text. I find it hard to read.
Just use good old plain text. No fancy fonts, sizes, colors.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or
arse it, it keeps giving errors.
I am frustrated with the lack of clarity and completeness. Please
respect our time as volunteers by giving complete explicit informaion.
Show us the resultant file.
Tell us what parsing tool you are using.
Show us the exact errors.
[snip]
--
Bob Gailer
919-636-423
s raw string marker, as my
problem must be solved differently?
Can you help me?
Kind regards,
Neven
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
spaceDict = collections.defaultdict(0)
adjustedSpaceDict = {}
If you use enumerate then you can replace timetable[i] with key
for i, key in enumerate(timetable):
numDict[key] += 1
Something is wrong in the following if statement, as both paths execute
the same code.
if spaceDict['1st'+key] == 0:
spaceDict['nth'+key] = i
else:
spaceDict['nth'+key] = i
for form in forms:
adjustedSpaceDict[form] = spaceDict['nth'+form] - \
spaceDict['1st'+form]
return (numDict, adjustedSpaceDict)
# End example
This function works fine, but I think that using range(len(timetable))
is clumsy. On the other hand, I need the indexes to track the number
of spaces between instances of each form. Without using another loop
(so not using list.index), is there a way of getting the index of the
list entries?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
s replaced this module.
So either way is OK for now, but the sets module might go away in a
newer version.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.
howcome does math.sqrt not do square roots on a simple
number like 4???
O but it does, as others have pointed out
>>> math.sqrt(4)
2.0
I am now officiciously pissed.
Help?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor mailli
import statement.
And what is the purpose of the following line?
from tables.report_db_engine import *
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http
t;> # note the leading whitespace that has not been removed.
But this does:
>>> L = [i.strip() for i in L]
>>> L
['foo', 'bar']
What other strange behaviour should I expect from for loops?
None - loops do not have "strange" behaviors.
Perhaps
x < 0: a.remove(x)
"""
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
neral, have been promoted as techniques to improve the maintainability
and overall quality of imperative programs. Object-oriented programming
extends this approach."
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@pyt
This seems pretty simple if a 'which' statement exists e.g. (which
values in list 1 == list3[k], and looping through k), but I can't find
one. To write one seems to require a loop.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tuto
| | | | / / | __| | _ /
| |_| | | |/ /| |___ | | \ \
\_/ |___/ |_| |_| \_\
"""
)
input("\n\nPress the enter key to exit.")
___
Tutor maillist - Tutor@python.org
To unsubsc
gnise that the problem is with "the"
rather than "range(10)"
To be more specific - Python is "happy" with "for i in the ". It is
"expecting"either : or some operator. "range" is neither - so that is
where the error pointer is.
Ex
be in the try block.
I also suggest unique error messages. If the user does not enter a
number tell him so.
Also you need a way to break out of the loop once user enters a valid key.
Consider using the isdigit function to test the input instead of an
exception.
--
Bob Gailer
919-636-4239
Also note that the database function creates a local variable "database"
but does nothing with it.
When the function terminates that variable is lost.
Did you intend to return it?
Also it is not good practice to use the same name for a function and a
variable.
--
Bob Gailer
91
n(all_data))
finally:
input_file.close()
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Please always reply-all so a copy goes to the list.
On 6/1/2010 6:49 PM, Colin Talbert wrote:
Bob thanks for your response,
The file is about 9.3 gig and no I don't want read the whole
thing at once. I want to read it in line by line. Still it will read
in to the same point (9
f size == "thumbnail" isThumbnail = False ]
and the scoping extending to one level above without resorting to
the global keyword?
I have no idea what you mean by that. Please provide context.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor ma
eached the Python Tutor list. This is not the appropriate
place for a JavsScript question.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailma
tion;
please PM me.
There are no laws. By "inappropriate" I meant that
1 - you would be less likely to get an answer here.
2 - my preference is that only Python questions be asked, as it takes my
time to decipher a question. I examined your code to see if it were
Python related.
On 6/6/2010 8:44 PM, Alex Hall wrote:
--
Have a great day,
Alex (msg sent from GMail website)
mehg...@gmail.com;http://www.facebook.com/mehgcap
What is your question?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor
On 6/6/2010 9:37 PM, Alex Hall wrote:
On 6/6/10, Lie Ryan wrote:
On 06/07/10 11:08, Alex Hall wrote:
On 6/6/10, bob gailer wrote:
On 6/6/2010 8:44 PM, Alex Hall wrote:
--
Have a great day,
Alex (msg sent from GMail website)
mehg...@gmail.com;http
you will get a syntax error!
Feed: Yes
Originally it was not legal. Then in some version it became legal.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http
startswith("yes") will cover all your
cases.
You can collect functions in a sequence, then iterate over it. This
allows for easy expansion (when you decide to add another function).
funcs = (dosomething(), dosomethingelse())
for func in funcs:
getid()
func()
--
Bob Gailer
919-6
On 6/12/2010 3:59 PM, Alan Gauld wrote:
"bob gailer" wrote
You can collect functions in a sequence, then iterate over it. This
allows for easy expansion (when you decide to add another function).
funcs = (dosomething(), dosomethingelse())
I suspect Bob meant to leave off the
if not line: break
print line + " RG:Z:2302"
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ional database.
Python happens to come with the sqlite3 module which makes database work
quite easy.
So, I just figured that I would have a couple of nested dictionaries.
bob = Student('123456','Bob Hurley')
bob.period = 4
bob.grad_class = 2010
bob[&
is processed. That in
turn closes the client socket.
Either keep the channel open or put the client connect in the loop.
# Execution starts here:
try:
main()
except KeyboardInterrupt:
sys.exit("Aborting.")
_______
Tutor maillist - Tu
tell
us a lot more about what you are doing.
Please also reply-all so a copy of your reply goes to the tutor list.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mai
ess - that you are typing $ pydoc -g at the Python
Interpreter prompt (>>>)
The manual recommends typing it a the shell prompt. In which case the $
represents the prompt and you should just type pydoc -g.
--
Bob Gailer
919-636-4239
Chapel Hill NC
__
rewrote
the entire course, starting them with a program that read 2 numbers,
added them and printed the result. In those days students sat at
terminals, edited program files, submitted them to the resident HP 3000
computer and shortly received printouts.
--
Bob Gailer
919-636-4239
Chapel Hill NC
hon interpreter written in Java. It allows you
to use Java classes in your Python code. You might want to learn Java to
take advantage of that.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or chan
inue
statement is executed in the try <#try> suite of a try <#try>...finally
<#finally> statement, the finally <#finally> clause is also executed 'on
the way out.' A continue statement is
illegal in the finally <#finally> clause. (The reason is a prob
:
http://mail.python.org/mailman/listinfo/tutor
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ure
I could output the analysis using that but am not sure it will be
readable under Mac and Windows. Any ideas are welcome!
Write the data to an html file and view it in a browser.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist -
.
But the differences are much more dramatic than the commonalities. I
have developed in both. I find it painful to work in one while desiring
a feature that exists only in the other.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist
On 7/2/2010 9:44 PM, Jeff Johnson wrote:
On 07/02/2010 08:19 PM, bob gailer wrote:
On 7/2/2010 5:56 PM, Jeff Johnson wrote:
[snip]
Visual FoxPro ... is very similar to Access
I differ. Access and FoxPro are very different. Yes they both use
tables, relationships, indexes and SQL. Yes they
We received 2 copies of the tutor digest from you.
If you intentionally sent it - why?
Please do not do that again. If you have a specific question or comment
- change the subject to something more meaningful
- delete everything from the digest that is not related to your question.
--
Bob
You have gotten good advice from others.
My request is that you provide a meaningful subject when you post a
question. We track by subject. "Help" is not the best subject.
Better would be "How to find prime numbers"
--
Bob Gailer
919-636
(0,7,3):
isPrime(i-1)
isPrime(i+1)
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
aisleNo < MAX_AISLE - 1:
print "Located on aisle %s" % aisleNo + 1
else:
print "Not in store"
print "\n".join(items)
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
f = open("c:\test.txt", "w")
f.write("1234")
f.write("5678")
print open("c:\test.txt").read()
When you say "line" I assume you mean text followed by whatever the OS defines
as end-of-line or end-of-record.
To write such a line in Python
a
platform-specific representation on writing and back on reading. Thus,
when opening a binary file, you should append 'b' to the /mode/ value to
open the file in binary mode, which will improve portability. (Appending
'b' is useful even on systems that don't treat
nts with wings'),
('Eye size:' , EYESIZE, 0.1,10, 'Size of the eyes'),
('Tail taper:' , TAILTAPER, 0.1,10,
'Taper fraction of each tail segment'),]):
return
Anybody know why I keep getting this error?
The return statement is not in a function. Wha
1.25 seconds
Therefore 1 billion in ~21 minutes. 3 ghz processor 2 g ram.
Changing length up or down seems to increase time.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
user for a password without echoing. The user is prompted
using the string /prompt/, which defaults to 'Password: '.
HTH
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscr
On 7/19/2010 10:48 AM, Richard D. Moores wrote:
I've been unable to find any mention of that use of the asterisk in
the 3.1 docs
http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting
--
Bob Gailer
919-636-4239
Chapel Hi
[snip]
I did not read the documentation with enough understanding. I withdraw the use
of sample.
Sigh!
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http
t possible
Indeed. There are several ways to do this. Easiest:
dict(zip(a,b))
i mean i tried it using loops
d = {}
for i in range(len(a)):
d[a[i] = b[i]
and all but i cant append a directory
Of course you can't append, since a dictionary is not a sequence. But
you can add a
will
guess that you want:
def writer(line):
myfile.write(line + '\n')
session.retrlines("RETR 'mainframe.filename'", writer)
The documentation is in error in that it does not explicitly state that
a line is passed to the callback function as an argument. I am
quot; are too vague.
Post your script if not too large else use a pastebin and provide the link.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
, passing 1 or 2
as the divisor for my_dmg and returning the updated values for my_ho and
my_hp.
def update(factor):
print "The Lich King is at", mo_hp, "Hit Points"
print "you did ", my_dmg / factor, "damage!"
print
print "I was attacked b
se p1number == p2number:
playerOne, playerTwo = winnerName
def displayInfo():
#how do I display winner?
main()
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/
nd returns
the traceback to the web browser.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 7/31/2010 6:40 PM, Eric Hamiter wrote:
On Sat, Jul 31, 2010 at 4:48 PM, bob gailer <mailto:bgai...@gmail.com>> wrote:
Please post that code, and the URL you use to invoke it.
test.py: this works on my laptop but not on the server
http://pastebin.com/ChjUzLRU
test-working
On 7/31/2010 8:24 PM, Steven D'Aprano wrote:
On Sun, 1 Aug 2010 04:35:03 am bob gailer wrote:
Continue to avoid writing functions. They are not necessary for such
a simple program.
That is *terrible* advice. Absolutely awful.
Well I disagree. I was trying to steer the OP t
On 7/31/2010 11:03 PM, Eric Hamiter wrote:
On Sat, Jul 31, 2010 at 9:53 PM, bob gailer <mailto:bgai...@gmail.com>> wrote:
Main difference I see is lack of any html tags in test.py! Try adding
1.
print ""
2.
print "Publix Aide&q
following script - let's call it "test.py".
Upload it then invoke it. Try http://url-to-your-site/test.py
#!/usr/bin/python
print "Content-type: text/html"
print
print ""
print "Hello World from Python"
print ""
print "Standard Hel
bals()['__name__'], in various forms, to no avail.
Replace those stars with main as derived above.
globals()['output_text'] will also give you a reference to the function.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor ma
On 8/4/2010 3:44 PM, Huy Ton That wrote:
Oh, that's right, I should have tried to example in the interpreter
instead of in my head:P
Say Bob,
Is that the preferred method over something like:
I would prefer to create a class and make these functions class methods.
class A:
On 8/4/2010 4:04 PM, bob gailer wrote:
On 8/4/2010 3:44 PM, Huy Ton That wrote:
Oh, that's right, I should have tried to example in the interpreter
instead of in my head:P
Say Bob,
Is that the preferred method over something like:
I would prefer to create a class and make these func
7;, data)
print a.call_by_name('output_hex', data)
print a.call_by_name('foo', data)
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 8/4/2010 4:32 PM, Huy Ton That wrote:
I have a side question,
I am using python 2.7.
Why do you use class A: instead of class A(object): ?
My example does not depend on old / new style classes.
--
Bob Gailer
919-636-4239
Chapel Hill NC
On 8/7/2010 6:29 PM, Evert Rol wrote:
[a for a in map(chr, os.urandom(6))]
Overkill!
map(chr, os.urandom(6))
is sufficient.
Or
[chr(x) for x in os.urandom(6))]
The latter is easier to read.
--
Bob Gailer
919-636-4239
Chapel Hill NC
een written so that it printed only hex,
b'l\xbb\xae\xb7\x0ft' would have been
b'\x6c\xbb\xae\xb7\x0f\x74' , right?
Thanks very much for that, Alan.
How were we supposed to know that all the hexes have 2 digits?
In version 2.6.5 Language Reference 2.4.1 -
the other files go?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Exactly what do you want your mentor to do?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
e()
print("from MAIN")
print(room_final)
print()
print("a PRINT_MAP call from MAIN")
print_map()
print()
print()
===
partial sample output showing the current incorrect results:
a PRINT_MAP call from MAIN
+-+
|
On 8/9/2010 11:13 PM, Bill Allen wrote:
Bob,
Thanks for the feedback. I have been stepping through it in the IDLE
debugger. However, it may be that I am letting the debugger get in my
way as I am new to it also. You are right. I'll get out the old
yellow legal pad and step through
On 8/10/2010 10:42 AM, Bill Allen wrote:
Bob,
I was really off on that algorithm and had way over complicated it.
I have it working correctly now, but for the sake of those who saw my
earlier really botched code, here is the resultant code that works.
The entire inner loop and intermediate
On 8/17/2010 12:30 AM, Bill Allen wrote:
I am looking for some guidance about how to best utilize box drawing
characters(using unicode?) in as portable a way as possible in
Python. Any good guides out there for this?
Please tell us a bit more about your goals.
--
Bob Gailer
919-636-4239
arly of for-loops,
but not list comprehensions. The whole point is with a list comp,
you're forced to iterate over the entire sequence, even if you know
that you're done and would like to exit.
Take a look at itertools.takewhile!
result = [i%2 for i in itertools.takewhile(lamda x:i< 10, seq)]
self[0]
if len(self) == 2:
self.y = self[1]
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
f[0], self[1], and self[2]:
http://users.rcn.com/python/download/Descriptor.htm
Thanks all for good suggestions. I'm intrigued by the idea of subclassing list
(suggested by both Bob and Wayne) and using x, y and z as descriptors to the
elements in the list. Obviously, it's important th
elf[1], and self[2]:
http://users.rcn.com/python/download/Descriptor.htm
Thanks all for good suggestions. I'm intrigued by the idea of subclassing list
(suggested by both Bob and Wayne) and using x, y and z as descriptors to the
elements in the list. Obviously, it's important that th
On 8/20/2010 8:35 PM, bob gailer wrote:
After yet more thought it gets even more better: I even added a unit test.
class PointND(list):
def __init__(self, *a_list):
super(PointND, self).__init__(a_list)
def getSet(ix):
def chklen(self):
if len(self) < ix + 1:
ra
very digit is placed on another line.
How can I prevent this ?
print int(digit2), # add a comma
Your algorithm is unnecessarily complicated.
You don't need to count first.
You don't need float.
getal=13789
while getal > 0:
getal, digit = divmod(getal, 10)
print digit,
But it is
e. I would think this would
be done with a while loop, but can't seem to get the details right.
Even though a while will work, you will have tied up the CPU until the
loop terminates. This is never a good idea.
What is your higher level goal?
--
Bob Gailer
919-636-4239
Chap
On 8/23/2010 1:09 PM, Gregory, Matthew wrote:
Bob Gailer wrote:
class PointND(list):
def __init__(self, *a_list):
super(PointND, self).__init__(a_list)
def getSet(ix):
def chklen(self):
if len(self)< ix + 1:
raise AttributeError
def get(s
tSet(1, 'y')
z = getSet(2, 'z')
p = PointND(1,2,3)
assert (p.x, p.y, p.z) == (1, 2, 3)
p.x = 6; p.y = 9; p.z = 5
assert (p.x, p.y, p.z) == (6, 9, 5)
try:
p = PointND(1,2)
p.z = 3
except AttributeError:
print 'Passed all tests'
--
Bob Gailer
919-636-4239
Ch
help.
How does this sound to you? Will you give it a try?
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
7;S', then enter = Door to the South."
print "'E', then enter = Door to the East."
print "'W', then enter = Door to the West."
print "'Look at', then 'objects name'
101 - 200 of 2074 matches
Mail list logo