Peter Faulks, 27.04.2012 22:31:
> On 27/04/2012 6:55 PM, Stefan Behnel wrote:
>> Peter Faulks, 27.04.2012 10:36:
>>> On 27/04/2012 5:15 PM, Stefan Behnel wrote:
Peter Faulks, 26.04.2012 19:57:
> I want to extend an embedded interpreter so that calls to print() are
> automagically sent
On 27/04/2012 6:55 PM, Stefan Behnel wrote:
Peter Faulks, 27.04.2012 10:36:
On 27/04/2012 5:15 PM, Stefan Behnel wrote:
Peter Faulks, 26.04.2012 19:57:
I want to extend an embedded interpreter so that calls to print() are
automagically sent to a C++ gui (windows exe) via a callback function in
On 4/27/2012 4:55 AM, Stefan Behnel wrote:
I want the script
itself to update a window in the host application (via the extension) every
time the script calls print().
Then replace sys.stdout (and maybe also sys.stderr) by another object that
does what you want whenever its write() method is c
Peter Faulks, 27.04.2012 10:36:
> On 27/04/2012 5:15 PM, Stefan Behnel wrote:
>> Peter Faulks, 26.04.2012 19:57:
>>> I want to extend an embedded interpreter so that calls to print() are
>>> automagically sent to a C++ gui (windows exe) via a callback function in
>>> the DLL.
>>>
>>> Then I'll be a
On 27/04/2012 5:15 PM, Stefan Behnel wrote:
Peter Faulks, 26.04.2012 19:57:
I want to extend an embedded interpreter so that calls to print() are
automagically sent to a C++ gui (windows exe) via a callback function in
the DLL.
Then I'll be able to do this:
test.py
import printoverload
Peter Faulks, 26.04.2012 19:57:
> I want to extend an embedded interpreter so that calls to print() are
> automagically sent to a C++ gui (windows exe) via a callback function in
> the DLL.
>
> Then I'll be able to do this:
>
> test.py
> import printoverload
>
> printoverload.set_stdout(
Peter Faulks, 26.04.2012 21:28:
> "All you have to do is assign to print". Sounds great! Can some kind soul
> hit me with a clue stick? Were do I look in the API?
Here's the (Py3) Cython code for it:
print = my_print_function
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Apr 27, 2012 at 5:28 AM, Peter Faulks wrote:
> Cheers,
>
> Yes was aware this would (might) be possible in 3.x only.
>
> "All you have to do is assign to print". Sounds great! Can some kind soul
> hit me with a clue stick? Were do I look in the API?
(We prefer to avoid top-posting on this
Cheers,
Yes was aware this would (might) be possible in 3.x only.
"All you have to do is assign to print". Sounds great! Can some kind
soul hit me with a clue stick? Were do I look in the API?
On 27/04/2012 4:26 AM, Chris Angelico wrote:
On Fri, Apr 27, 2012 at 3:57 AM, Peter Faulks wrote
On Fri, Apr 27, 2012 at 3:57 AM, Peter Faulks wrote:
> I want to extend an embedded interpreter so that calls to print() are
> automagically sent to a C++ gui (windows exe) via a callback function in the
> DLL.
>
> Then I'll be able to do this:
>
> test.py
> import printoverload
>
> printo
G'day,
I want to extend an embedded interpreter so that calls to print() are
automagically sent to a C++ gui (windows exe) via a callback function in
the DLL.
Then I'll be able to do this:
test.py
import printoverload
printoverload.set_stdout()
printoverload.set_stderr()
print("th
On Aug 25, 5:18 pm, Ross Williamson
wrote:
> Hi All
>
> Is there anyway in a class to overload the print function?
>
> >> class foo_class():
> >> pass
> >> cc = foo_class()
> >> print cc
>
> Gives:
>
> <__main__.foo_class instance at >
>
> Can I do something like:
>
> >> class foo_class()
ves:
>
> > hello
>
> Hmm, on what Python version are you? To my knowledge there is no
> __print__ special method. Did you mean __str__ or __repr__ ?
>
> > I'm looking at finding nice way to print variables in a class just by
> > asking to print it
>
> In Pyt
On Wed, Aug 25, 2010 at 2:23 PM, Glenn Hutchings wrote:
> On 25 Aug, 22:18, Ross Williamson
> wrote:
> > Is there anyway in a class to overload the print function?
> >
> > >> class foo_class():
> > >> pass
> > >> cc = foo_class()
> > >> print cc
> >
> > Gives:
> >
> > <__main__.foo_class in
les in a class just by
asking to print it
In Python3 you *can* overload print(), but still, you better define
__str__() on your class to return a string, representing what ever
you want:
In [11]: class Foo(object):
: def __str__(self):
: return "foo"
On Wed, 25 Aug 2010 16:18:15 -0500
Ross Williamson wrote:
> Hi All
>
> Is there anyway in a class to overload the print function?
Your terminology threw me off for a moment. You don't want to override
print. You want to override the default representation of an object.
>
> >> class foo_class
On Wed, Aug 25, 2010 at 2:18 PM, Ross Williamson
wrote:
> Hi All
>
> Is there anyway in a class to overload the print function?
>
>>> class foo_class():
>>> pass
>
>>> cc = foo_class()
>>> print cc
>
> Gives:
>
> <__main__.foo_class instance at >
>
> Can I do something like:
>
>>> class f
On 25 Aug, 22:18, Ross Williamson
wrote:
> Is there anyway in a class to overload the print function?
>
> >> class foo_class():
> >> pass
> >> cc = foo_class()
> >> print cc
>
> Gives:
>
> <__main__.foo_class instance at >
>
> Can I do something like:
>
> >> class foo_class():
> >> de
Hi All
Is there anyway in a class to overload the print function?
>> class foo_class():
>> pass
>> cc = foo_class()
>> print cc
Gives:
<__main__.foo_class instance at >
Can I do something like:
>> class foo_class():
>> def __print__(self):
>> print "hello"
>> cc = foo
19 matches
Mail list logo