Okay, it appears the method in a class has its own ID, but all
instantiations of that method have identical IDs. But what happens if we
have a huge number of instantiations trying to access the identical method
at the same time?
class MyClass:
def setdata(self, data):
self.data = data
When an instance uses a class method, does it actually use the method that
is in the class object's memory space, or is the method copied to the
instance?
--
Jim
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
'''I was using with open...:, but I'm printing a header in one function,
calling a looping
function to print detail lines, then returning to the calling function to
print
the footer. But that didn't work since the with statement only seems to work
with the lexical suite and the file wasn't open in
On 20 May 2015 at 01:02, Peter Otten __pete...@web.de wrote:
If you start with an object dir() gives you a list of attribute names. To
get the actual attributes use
attribute = getattr(object, attribute_name)
Then print the attributes' docstring with
print(attribute_name,
I use python help() a good deal but get tired of paging through the
__object__ stuff to get to what I use at my level, so I wrote the following
to omit it. The problem is, I want to import it then use it as shorthelp.py
for different modules so I could just type shorthelp(modulename). Only the
On 19 May 2015 at 17:18, Ben Finney ben+pyt...@benfinney.id.au wrote:
You will be pleased to know of the standard library ‘importlib’
library::
import importlib
Yes, I already got importlib to accept a string. But I can't figure how to
get dir to accept it:
x = 'shutil'
import
On 19 May 2015 at 17:25, Jim Mooney Py3.4.3winXP cybervigila...@gmail.com
wrote:
If I can get dir to accept x I can parse the output to get rid of the
__xxx stuff and print it out.
By that I mean dir will give me a list of strings I can then use __doc__ on
to get all useful help items
On 15 May 2015 at 22:45, Steven D'Aprano st...@pearwood.info wrote:
What does didn't work mean? Did your computer crash? Catch fire? A
completely different error got printed? Something else?
I can see I was marvelously unclear ;') Here is what I meant.
def make_error():
raise
On 14 May 2015 at 16:47, Alan Gauld alan.ga...@btinternet.com wrote:
Rather than printing the messages you could re-raise
the error but with the error message attached as a string.
I'm a little unclear how you catch the string you create in a raise, in the
caller. I tried an example from the
I noticed that if I call a function that throws an error, I can catch it
from the caller, instead of catching it in the function. Is this is what is
known as errors bubbling up? Also, is this how you're supposed to do it?
*** Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600
On 7 May 2015 at 18:42, Dave Angel da...@davea.name wrote:
Python doesn't have pointers
So what is the difference between a python name and a pointer? I'm a bit
fuzzy on that.
--
Jim
What a rotten, failed experiment. I'll start over. Maybe dogs instead of
monkeys this time. --God
I find this a bit confusing. Since the ID of K remains the same, so it's
the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I
understand that it's immutable but doesn't that mean K is created each time
in local scope so it should have a different ID each time?
def testid(K=10):
On 7 May 2015 at 13:03, Emile van Sebille em...@fenx.com wrote:
Compare to:
def testid(K=100):
K += 10
return 'the ID is', id(K), K
Ah, thanks. I forgot small integers are saved in a table. I was looking at
a demo that pointers to defaults in function parameters are
On 6 May 2015 at 14:08, Dave Angel da...@davea.name wrote:
I don't know why you would be expecting to get a utf-8 character for the
second byte of a function key code. It's an entirely arbitrary byte
sequence, and not equivalent to anything in Unicode, encoded or not
I just didn't think of
On 5 May 2015 at 21:51, Mark Lawrence breamore...@yahoo.co.uk wrote:
On 06/05/2015 05:30, Jim Mooney Py3.4.3winXP wrote:
On 5 May 2015 at 18:32, Steven D'Aprano st...@pearwood.info wrote:
https://code.activestate.com/recipes/577977-get-single-keypress/
That only has a stub for Linux
On 6 May 2015 at 10:41, Jim Mooney Py3.4.3winXP cybervigila...@gmail.com
wrote:
I went a further step from the recipes linked to above and got here
https://pypi.python.org/pypi/readchar
I think that's the one that failed for me
Addendum. That only failed in python 3.4. It worked fine
On 5 May 2015 at 15:36, Alan Gauld alan.ga...@btinternet.com wrote:
Can python detect a keypress?
That sounds simple but is actually quite tricky
since it's terminal dependent.
An ancillary question. I found a readchar that purports to install in py2
and 3 but fails in 3. The errors
On 5 May 2015 at 18:35, Steven D'Aprano st...@pearwood.info wrote:
Is this under Linux or another Unix? If so, only redirects stdout, not
stderr, so you need:
python3 setup.py 2 errors.txt
to capture the errors.
I have no idea if Windows works the same way.
Damn, that actually worked
On 5 May 2015 at 16:47, Jim Mooney Py3.4.3winXP cybervigila...@gmail.com
wrote:
But that didn't work. How can I get a printout of setup errors so I can
post them?
I remembered how to copy the DOS console. Here is the error. Error wasn't
in setup.py so that wouldn't have worked anyway.
C
On 5 May 2015 at 18:32, Steven D'Aprano st...@pearwood.info wrote:
https://code.activestate.com/recipes/577977-get-single-keypress/
That only has a stub for Linux, but I found one that does both. Although,
alas, no IOS version:
Can python detect a keypress? I've looked all over and can't find it. I
don't mean input('blah') and have to press Enter - just detect it directly
like Javascript does. All I find are references using msvcrt, which is
Msoft specific, or using tkinter - but I don't want a whacking big GUI,
just
Oops, my mistake. Ignore dumb remark below. I was thinking of the try -
except in the main loop, but since I only tested the parse function, I
never used that. I need to look a bit harder and find this stuff Before I
post ;')
Jim
On 29 April 2015 at 23:04, Jim Mooney Py3.4.3winXP cybervigila
On 29 April 2015 at 21:14, Dave Angel da...@davea.name wrote:
But why are you surprised? There's no try/except protecting the latter
line, so the exception will be uncaught, and you'll see it reported in
parse_string().
I think I meant something like this. An exception in a function is
Sure, but let me include the full working program after fixup
On 29 April 2015 at 19:09, Cameron Simpson c...@zip.com.au wrote:
These could all do with docstrings. add() is pretty obvious, but the
distinction between minus() and subtract() could do with elaboration.
etc, etc.
Thanks.
On 28 April 2015 at 22:40, Cameron Simpson c...@zip.com.au wrote:
As with all things, sometimes that cannot be reasonably achieved, but it
is usually so.
We can pick over your code as well if you like. Should we?
Cheers,
Cameron Simpson c...@zip.com.au
Sure, but let me include the full
I raised an exception in the parse_string function in my math parser
program, function_tosser.py, and caught it in the calling routine, and that
worked fine. But when I imported function_tosser.py into a test program,
tester.py, it threw the exception in the parse_string function instead of
26 matches
Mail list logo