u get something other than a command
not found kind of error then we can do something. Let us know.
Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
list's
append() and pop() methods).
For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as input and
prints -0.0481481 8 lines of Python. That indeed is less than 100. Took
about 7 minutes to code and test.
Bob Gailer
[EMAIL PROTEC
s a module named
operators
Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
f):
print 'Retrieves value of the X register from before the last'
print 'operation and pushes it in the X register, lifting the'
print 'stack.'
def help_multiply(self):
print 'Multiply X by Y register. Use "*&
ele1 in x:
for ele2 in seq:
if match:
print ele2
match = False
if ele1 in ele2:
print ele2
match = True
OR
for ele1 in x:
for index, ele2 in enumerate(seq):
if ele1 in ele2:
print ele2, seq[index+1]
[snip]
B
s:
DO function WITH parameters (FoxPro, similar in COBOL)
function parameter or parameter1 function parameter2 (APL)
Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/li
At 12:39 PM 12/8/2004, Bob Gailer wrote:
At 11:27 AM 12/8/2004, Dick Moores wrote:
My thanks to both Max and Kent. So Python tries, and fails, to see 2() as
a function!
I also got some help from <http://www.pcwebopedia.com/TERM/c/call.html>
Note that SOME languages use () for call. The
nts of a spot_int element to
match a spot_cor element.
Then (for the subset of data you've provided):
>>> for ele1 in spot_cor:
... for ele2 in spot_int:
... if ele1 == ele2[:2]:
... print "%8s %8s %8s" % ele2
...
10
At 06:05 AM 12/6/2004, you wrote:
Bob Gailer wrote:
> For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as input
> and prints -0.0481481 8 lines of Python. That indeed is less than
> 100. Took about 7 minutes to code and test.
I'm quite interested in seeing
you don't seem to benefit from some of our suggestions.
Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
don't they just read the book?" That's how I
learned almost everything I know about programming. So it can be hard for
me to understand your struggle.
Nuf said for now...
[snip]
Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell
_
hich it should
instead of 0x03039
and print "0x%05X" % 12345 displays 0x03039
The Python docs state
The conversion will be zero padded for numeric values, when a 0 is used as
a flag between the % and the conversion type.
If you continue in the documentation right after 3 Conversion flags comes
e, and then writing
if e == True:
instead of
if e:
For some reason, that's extremely common in code written by newcomers
to Pascal.
Not to mention coding examples provided by Microsoft in some help topics!
[snip]
Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell
_
t a new reference
to the original attribute. Example
>>> import sys
>>> from sys import modules
>>> sys.modules is modules
True
>>> m = dict(sys.modules) # create a copy
>>> m is modules
False
--
Bob Gailer
Chapel Hill NC
919-636-4239
terseness:
terms = [random.randint(1, 99) for i in 'ab']
--
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
swers. Good
idea?
Yes indeed. That is what I did before reading your comment! Great minds
think alike.
--
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 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
Colin Talbert
GIS Specialist
US Geological Survey - Fort Collins Science Center
2150 Centre Ave. Bldg. C
Fort Collins, CO 80526
(970) 226-9425
talbe...@usgs.gov
From: bob gailer
To: Colin Talbert
Cc: tutor@python.org
Date: 06/01/2010 04:43 PM
Subject:Re
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
the credit
attributes, just like you did for Student. Then assign instances of
Credit to entries in self.credit.
If I don't set it to anything, ie, like it is, I get an error
Stud instance has no attribute '__getitem__'
If I try to leave it available for adding to somewha
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
def output_text(self, data):return data
def output_hex(self, data):return '\\x' + data
def __getattr__(self, name):
return self.output_text
a = A()
data='bar'
print a.output_text(data)
print a.output_hex(data)
print a.foo(data)
--
Bob Gailer
91
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
1 - 100 of 1317 matches
Mail list logo