> If you're not already familiar with collections.namedtuple, have a
> look at it, as it sounds like just naming the fields may be all that
> you need. You can also subclass it further to add methods if desired.
Yeah, all the types in these collections are named tuples... The collection
itself isn
#x27;re not already familiar with collections.namedtuple, have a
look at it, as it sounds like just naming the fields may be all that
you need. You can also subclass it further to add methods if desired.
> However, if the method returns one element of the collection, how can
> one enable introspectio
nable introspection for users of IDE's that the resulting reference
is of type A, and therefor has A's fields?
For example:
col = (Class(..), Class(...))
item = col[0]
Introspection will now enumerate item as an instance of Class, providing
its fields. The subclass of tuple breaks this.
Is there
Juan Kinunt wrote:
> In the PyDev installation documentation you see this sentence:
>
> "The Forced builtin libs are the libraries that are built-in the
> interpreter, such as __builtin__, sha, etc or libraries that should
> forcefully analyzed through shell introspection
In the PyDev installation documentation you see this sentence:
"The Forced builtin libs are the libraries that are built-in the
interpreter, such as __builtin__, sha, etc or libraries that should
forcefully analyzed through shell introspection (the other option to
analyze modules with too
On 6/14/2010 9:33 PM, Steven D'Aprano wrote:
On Mon, 14 Jun 2010 20:46:28 -0700, John Nagle wrote:
So how can I detect a closure?
I *think* you do it through the co_flags attribute of the code object.
This is in Python 2.5:
although this doesn't seem to be documented, at least not here:
htt
On Mon, Jun 14, 2010 at 9:46 PM, John Nagle wrote:
> No indication there that "fbar" is a closure inside "foo". There
> are "__closure__" and "__func_closure__" entries in there, but
> they are both None. A non-closure function has the same entries.
>
> So how can I detect a closure?
Maybe beca
On Mon, 14 Jun 2010 20:46:28 -0700, John Nagle wrote:
> So how can I detect a closure?
I *think* you do it through the co_flags attribute of the code object.
This is in Python 2.5:
>>> def f(x):
... def g():
... return x
... return g
...
>>>
>>> closure = f(42)
>>> closure(
I'm doing something with CPython introspection, and I'm trying
to determine whether a function is a closure. Consider
def foo(x) :
global fbar
def bar(y) :
pass
fbar = bar # export closure
foo(0)
We now have "fbar" as a reference to a closure.
Thanks Miki and Jason. I knew it could be done :-)
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 6, 8:38 am, Steven D'Aprano wrote:
> On Wed, 06 Jan 2010 06:53:40 -0800, m...@infoserv.dk wrote:
> > I'm looking for a way to make a list of string literals in a class.
>
> > Example:
>
> > class A:
> > def method(self):
> > print 'A','BC'
>
> ExtractLiterals(A)
> > ['A','BC'
On Wed, 06 Jan 2010 06:53:40 -0800, m...@infoserv.dk wrote:
> I'm looking for a way to make a list of string literals in a class.
>
> Example:
>
> class A:
>def method(self):
>print 'A','BC'
>
ExtractLiterals(A)
> ['A','BC']
>
> Is this possible? Can anyone point me in the rig
Hello Martin,
> I'm looking for a way to make a list of string literals in a class.
from inspect import getsourcelines
from tokenize import generate_tokens, STRING, NUMBER
def is_literal(t):
return t[0] in (STRING, NUMBER)
def get_lieterals(obj):
lines, _ = getsourcelines(obj)
readli
I'm looking for a way to make a list of string literals in a class.
Example:
class A:
def method(self):
print 'A','BC'
>>> ExtractLiterals(A)
['A','BC']
Is this possible? Can anyone point me in the right direction?
Thanks.
/Martin
--
http://mail.python.org/mailman/listinfo/python-l
Yuv wrote:
On Nov 8, 1:33 am, Carl Banks wrote:
Is the docstring expected to be formatted according to some
convention?
We tried to comply to PEP 257 and we're open to suggestions on this.
I'd suggest at the very least supporting Sphinx docstrings that have the
parameters in them...
Chri
On Nov 7, 3:44 pm, Yuv wrote:
> On Nov 8, 1:33 am, Carl Banks wrote:
>
> > Is the docstring expected to be formatted according to some
> > convention?
[snippage]
> We tried to comply to PEP 257 and we're open to suggestions on this.
Ah, so we finally get to the answer: the convention is PEP 2
On Nov 8, 1:33 am, Carl Banks wrote:
> Is the docstring expected to be formatted according to some
> convention?
Yes it does, we parse the docstring as explained in argparse.py:
def _parse_docstring(function):
"""Parses a function's docstring for a description of the function
and for
help
On Nov 7, 2:45 pm, Yuv wrote:
> This was posted to the argparse mailing list by Steven Bethard and now
> we'd like some feedback from comp.lang.python.
>
> We now have a branch[5] of argparse that supports an ``argparse.run``
> function[6] which does
> some function i
On Sat, Nov 7, 2009 at 5:45 PM, Yuv wrote:
> This was posted to the argparse mailing list by Steven Bethard and now
> we'd like some feedback from comp.lang.python.
>
> We now have a branch[5] of argparse that supports an ``argparse.run``
> function[6] which does
> some fu
This was posted to the argparse mailing list by Steven Bethard and now
we'd like some feedback from comp.lang.python.
We now have a branch[5] of argparse that supports an ``argparse.run``
function[6] which does
some function introspection to build a command line parser from a
function defin
In article <4a0d2e07$0$9422$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
>Aahz a écrit :
>> In article <4a0c6e42$0$12031$426a7...@news.free.fr>,
>> Bruno Desthuilliers wrote:
>>> Marco Mariani a écrit :
Bruno Desthuilliers wrote:
> Oh, you meant the "return type" ? Nope, no way.
Aahz a écrit :
In article <4a0c6e42$0$12031$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Marco Mariani a écrit :
Bruno Desthuilliers wrote:
Oh, you meant the "return type" ? Nope, no way. It just doesn't make
sense given Python's dynamic typing.
Unless he's really trying to write in N
On May 14, 3:55 pm, a...@pythoncraft.com (Aahz) wrote:
> In article <4a0c6e42$0$12031$426a7...@news.free.fr>,
> Bruno Desthuilliers wrote:
>
> >Marco Mariani a écrit :
> >> Bruno Desthuilliers wrote:
>
> >>> Oh, you meant the "return type" ? Nope, no way. It just doesn't make
> >>> sense given Py
Aahz wrote:
In article <4a0c6e42$0$12031$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Marco Mariani a �crit :
Bruno Desthuilliers wrote:
Oh, you meant the "return type" ? Nope, no way. It just doesn't make
sense given Python's dynamic typing.
Unless he's really trying to write in Noht
In article <4a0c6e42$0$12031$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
>Marco Mariani a écrit :
>> Bruno Desthuilliers wrote:
>>>
>>> Oh, you meant the "return type" ? Nope, no way. It just doesn't make
>>> sense given Python's dynamic typing.
>>
>> Unless he's really trying to write i
Marco Mariani a écrit :
Bruno Desthuilliers wrote:
Oh, you meant the "return type" ? Nope, no way. It just doesn't make
sense given Python's dynamic typing.
I thought that the OP was writing a tool to document not-very-dynamic code.
Unless he's really trying to write in Nohtyp,
You mean
Bruno Desthuilliers wrote:
Oh, you meant the "return type" ? Nope, no way. It just doesn't make
sense given Python's dynamic typing.
I thought that the OP was writing a tool to document not-very-dynamic code.
Unless he's really trying to write in Nohtyp, the language where value
types are mo
On the other hand, generally good programming practice suggests you to
write functions that have a constant return type. And in most programs
most functions are like this. This is why ShedSkin can indeed infer
the return type of functions in "good behaved" programs. To do this
ShedSkin uses a quite
execution time !-)
using introspection?
something like this, suppose I want to know the type of the return
value for the method "getsomething". Is it possible to get it without
actually calling 'getsomething'?
Oh, you meant the "return type" ? Nope, no way. It
Diez B. Roggisch wrote:
> flam...@gmail.com wrote:
>
>> Hello,
>> I am wondering if it's possible to get the return value of a method
>> *without* calling it using introspection?
>
> Nope. All that's possible to see if there is a implicit or explicit r
flam...@gmail.com:
> I am wondering if it's possible to get the return value of a method
> *without* calling it using introspection?
Python is dynamically typed, so you can create a function like this:
>>> foo = lambda x: "x" if x else 1
>>> foo(1)
&
flam...@gmail.com wrote:
> Hello,
> I am wondering if it's possible to get the return value of a method
> *without* calling it using introspection?
Nope. All that's possible to see if there is a implicit or explicit return
through dis.disassemble - if you find "LOAD_CONST
Hello,
I am wondering if it's possible to get the return value of a method
*without* calling it using introspection?
something like this, suppose I want to know the type of the return
value for the method "getsomething". Is it possible to get it without
actually calling
On Mon, Dec 1, 2008 at 12:23 PM, Rayene Ben Rayana
<[EMAIL PROTECTED]> wrote:
> Thanks Chris,
>
> Yeah it is kinda meta thing. My app allows to create a scene (a set of GUI
> objects). A scene can be saved as a python script. And, it can be loaded
> again using execfile().
>
> each GUI object has a
Thanks Chris,
Yeah it is kinda meta thing. My app allows to create a scene (a set of GUI
objects). A scene can be saved as a python script. And, it can be loaded
again using execfile().
each GUI object has a label. So, in the script scene, declaring an object in
a scene file should look like this
On Mon, Dec 1, 2008 at 6:04 AM, Rayene Ben Rayana
<[EMAIL PROTECTED]> wrote:
> Hello everybody,
>
> Is there an easy way to do something like this in python ?
>
red_car = MyVehicleClass()
car = red_car
car.labels()
> ['red_car' , 'car' ]
>
> In other words, does an instance has acces
Hello everybody,
Is there an easy way to do something like this in python ?
>>> red_car = MyVehicleClass()
>>> car = red_car
>>> car.labels()
['red_car' , 'car' ]
In other words, does an instance has access to its name pointers ?
Thanks in advance,
Rayene
--
http://mail.python.org/mailman/list
On Apr 2, 2:26 pm, 7stud <[EMAIL PROTECTED]> wrote:
>
> You don't need that helper function, which is a little tricky to
> follow:
>
Well, I appreciate the code sharing you did, but the helper function
is nice and compact, and I didn't have much trouble following it. I
ended up doing the followi
On 2 avr, 22:04, Brian Munroe <[EMAIL PROTECTED]> wrote:
> On Apr 2, 12:33 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
>
> > Why not do the import here, so you store a real module instead of a
> > name ?
>
> Right now I'm still in the prototyping phase and haven't really
> thought everyt
On Apr 2, 1:27 pm, Brian Munroe <[EMAIL PROTECTED]> wrote:
> On Apr 2, 12:07 pm, Brian Munroe <[EMAIL PROTECTED]> wrote:
>
>
>
> > This gives me ['system1','system2'] - which I can then use __import__
> > on.
>
> Addendum, thanks Bruno!
>
> I also required the helper function (my_import) from the P
On Apr 2, 12:33 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
>
> Why not do the import here, so you store a real module instead of a
> name ?
>
Right now I'm still in the prototyping phase and haven't really
thought everything through. I needed the names because I am
populating a GUI sele
On 2 avr, 21:07, Brian Munroe <[EMAIL PROTECTED]> wrote:
> On Apr 2, 11:04 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
>
> > More seriously: the answer is in the
> > doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html
>
> > read about the __import__ function, experiment in your
On Apr 2, 12:07 pm, Brian Munroe <[EMAIL PROTECTED]> wrote:
>
> This gives me ['system1','system2'] - which I can then use __import__
> on.
>
Addendum, thanks Bruno!
I also required the helper function (my_import) from the Python docs
you pointed me to, that actually was the key to getting every
On Apr 2, 11:04 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
>
> More seriously: the answer is in the
> doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html
>
> read about the __import__ function, experiment in your interactive
> python shell, and you should be done in a couple minut
> be1 = system1.Backend()
> be1.getStatus()
>
> This would work great if I knew about system1 and system2 ahead of
> time, but that isn't the case. Having to rewrite main.py every time a
> new backend module comes along is obviously a stupid idea too. I've
> been think
y time a
new backend module comes along is obviously a stupid idea too. I've
been thinking I need some kind of introspection, but I've been reading
about it and a whole mess of design pattern stuff, so my head is
swimming and I am totally unsure of what the best approach is.
My guess
Alex K wrote:
Please don't top-post.
> On 07/01/2008, Peter Otten <[EMAIL PROTECTED]> wrote:
>> Alex K wrote:
>>
>> > What would be the simplest way of enumerating all methods and members
>> > (including inherited) of a given object? Thank you.
>>
>> inspect.getmembers()
> Nice thank you. But an
2008/1/7, Alex K <[EMAIL PROTECTED]>:
> Nice thank you. But anyway to make it look pretty?
>
pprint.pprint(inspect.getmembers(someobject))
> On 07/01/2008, Peter Otten <[EMAIL PROTECTED]> wrote:
> > Alex K wrote:
> >
> > > What would be the simplest way of enumerating all methods and members
> >
Nice thank you. But anyway to make it look pretty?
On 07/01/2008, Peter Otten <[EMAIL PROTECTED]> wrote:
> Alex K wrote:
>
> > What would be the simplest way of enumerating all methods and members
> > (including inherited) of a given object? Thank you.
>
> inspect.getmembers()
>
> Peter
> --
> htt
Alex K wrote:
> What would be the simplest way of enumerating all methods and members
> (including inherited) of a given object? Thank you.
inspect.getmembers()
Peter
--
http://mail.python.org/mailman/listinfo/python-list
2008/1/7, Alex K <[EMAIL PROTECTED]>:
> Hi Guys,
>
> What would be the simplest way of enumerating all methods and members
> (including inherited) of a given object? Thank you.
>
> Alex
> --
> http://mail.python.org/mailman/listinfo/python-list
>
import inspect
inspect.getmembers(yourobject)
--
Hi Guys,
What would be the simplest way of enumerating all methods and members
(including inherited) of a given object? Thank you.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Ricardo Aráoz wrote:
> Ayaz Ahmed Khan wrote:
>
>> "James Stroud" typed:
>>
>>> py> def doit(a, b, c, x=14):
>>> ... pass
>>> ...
>>> py> doit.func_code.co_argcount
>>> 4
>>> py> doit.func_code.co_varnames
>>> ('a', 'b', 'c', 'x')
>>> py> doit.func_defaults
>>> (14,)
>>>
>> Neat.
>
Ayaz Ahmed Khan wrote:
> "James Stroud" typed:
>> py> def doit(a, b, c, x=14):
>> ... pass
>> ...
>> py> doit.func_code.co_argcount
>> 4
>> py> doit.func_code.co_varnames
>> ('a', 'b', 'c', 'x')
>> py> doit.func_defaults
>> (14,)
>
> Neat.
>
How do you know the 14 corresponds to x ?
--
http
"James Stroud" typed:
> py> def doit(a, b, c, x=14):
> ... pass
> ...
> py> doit.func_code.co_argcount
> 4
> py> doit.func_code.co_varnames
> ('a', 'b', 'c', 'x')
> py> doit.func_defaults
> (14,)
Neat.
--
Ayaz Ahmed Khan
I have not yet begun to byte!
--
http://mail.python.org/mailman/listinf
yagyala wrote:
> Hi. I would like to be able to tell, at run time, how many parameters
> a function requires. Ideally I would like to be able to tell which are
> optional as well. I've tried looking at the functions attributes, but
> haven't found one that helps in this. How can I do this?
>
> Tha
yagyala a écrit :
> Hi. I would like to be able to tell, at run time, how many parameters
> a function requires. Ideally I would like to be able to tell which are
> optional as well. I've tried looking at the functions attributes, but
> haven't found one that helps in this. How can I do this?
>>>
yagyala wrote:
> Hi. I would like to be able to tell, at run time, how many parameters
> a function requires. Ideally I would like to be able to tell which are
> optional as well. I've tried looking at the functions attributes, but
> haven't found one that helps in this. How can I do this?
>
> Tha
yagyala wrote:
> Hi. I would like to be able to tell, at run time, how many parameters
> a function requires. Ideally I would like to be able to tell which are
> optional as well. I've tried looking at the functions attributes, but
> haven't found one that helps in this. How can I do this?
>
I'v
Hi. I would like to be able to tell, at run time, how many parameters
a function requires. Ideally I would like to be able to tell which are
optional as well. I've tried looking at the functions attributes, but
haven't found one that helps in this. How can I do this?
Thanks
--
http://mail.python
In article <[EMAIL PROTECTED]>,
Alex Martelli <[EMAIL PROTECTED]> wrote:
>Aahz <[EMAIL PROTECTED]> wrote:
>>Alex:
>>>
>>>But don't put such black magic in production. The completely different
>>>way is: just don't.
>>
>> Could you expand on that? After all, that's exactly what we do to
>> implem
Martin Drautzburg <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
>
> > Yes, there is: use an ORM to do the SQL generation for you. Check out
> > SQLAlchemy, it will buy you much more than what you asked for.
>
> Might look, though in general I don't like OR mappers much. Having SQL
> generate
Aahz <[EMAIL PROTECTED]> wrote:
> >But don't put such black magic in production. The completely different
> >way is: just don't.
>
> Could you expand on that? After all, that's exactly what we do to
> implement a super() that works with classic classes -- and it's certainly
> production code.
In article <[EMAIL PROTECTED]>,
Alex Martelli <[EMAIL PROTECTED]> wrote:
>Martin Drautzburg <[EMAIL PROTECTED]> wrote:
>>
>> The problem is the first part: how can I lookup the callers module and
>> the classobjs defined in there? Or finding any constant strings in the
>> caller's module would also
Peter Otten wrote:
def SQL(sql):
> ... print sql
> ...
a = SQL("module")
> module # that one was obvious
class A:
> ... b = SQL("class")
> ... def method(self, c=SQL("default arg")):
> ... d = SQL("method")
> ...
You are my hero. Indeed very cool!
--
http:/
George Sakkis wrote:
> Yes, there is: use an ORM to do the SQL generation for you. Check out
> SQLAlchemy, it will buy you much more than what you asked for.
Might look, though in general I don't like OR mappers much. Having SQL
generated feels as strange as having python code generated. Too much
Martin Drautzburg wrote:
> > def SQL(sql, checked=set()):
> > if sql in checked:
> > return True
> > if not valid_sql(sql): raise ValueError
> > checked.add(sql)
> > return sql
>
> No this does not do the trick. I will not be able to validate an sql
> statement bofore I ru
Martin Drautzburg <[EMAIL PROTECTED]> wrote:
...
> The problem is the first part: how can I lookup the callers module and
> the classobjs defined in there? Or finding any constant strings in the
> caller's module would also be just fine. Or is there a completely
> different way to do such a thin
On Apr 21, 4:16 pm, Martin Drautzburg <[EMAIL PROTECTED]>
wrote:
> I would like to validate sql strings, which are spread all over the
> code, i.e. I run ("prepare") them against a database to see if it happy
> with the statements. Spelling errors in sql have been a major pain for
> me.
>
> The sta
Martin Drautzburg wrote:
> I would like to validate sql strings, which are spread all over the
> code, The statements will not be assembled from smaller pieces,
> but they will not neccessarily be defined at module level. I could
> live with class level,
> parse the source file, but I am
Peter Otten wrote:
> Martin Drautzburg wrote:
>
>> I would like to validate sql strings, which are spread all over the
>> code, i.e. I run ("prepare") them against a database to see if it
>> happy with the statements. Spelling errors in sql have been a major
>> pain for me.
>
> def validateSQL(
Martin Drautzburg wrote:
> I would like to validate sql strings, which are spread all over the
> code, i.e. I run ("prepare") them against a database to see if it happy
> with the statements. Spelling errors in sql have been a major pain for
> me.
>
> The statements will not be assembled from sma
I would like to validate sql strings, which are spread all over the
code, i.e. I run ("prepare") them against a database to see if it happy
with the statements. Spelling errors in sql have been a major pain for
me.
The statements will not be assembled from smaller pieces, but they will
not neccess
George Sakkis wrote:
> On Feb 2, 6:56 pm, James Stroud <[EMAIL PROTECTED]> wrote:
>
>> Hello,
>>
>> I wanted to automagically generate an instance of a class from a
>> dictionary--which might be generated from yaml or json. I came up with this:
>>
>> (snip)
>>
>> ==
>>
>> #! /usr/bin/env python
>>
George Sakkis wrote:
> On Feb 2, 6:56 pm, James Stroud <[EMAIL PROTECTED]> wrote:
>
>> Hello,
>>
>> I wanted to automagically generate an instance of a class from a
>> dictionary--which might be generated from yaml or json. I came up with this:
>>
>> (snip)
>>
>> ==
>>
>> #! /usr/bin/env python
>>
On Feb 2, 6:56 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wanted to automagically generate an instance of a class from a
> dictionary--which might be generated from yaml or json. I came up with this:
>
> (snip)
>
> ==
>
> #! /usr/bin/env python
>
> # automagical constructor
> def c
.im_func.func_code.co_varnames
argnames = vnames[1:-len(dflts)]
argvals = [adict.pop(n) for n in argnames]
return cls(*argvals, **adict)
I'm wondering, I did a lot of introspection here. How much of this
introspection can I count on in other implementations. Is this a
byproduct of CPython? Will all cl
Great !!! That works like charm.
Thanks alot.
Thomas
Leo Kislov wrote:
> Thomas W wrote:
> > Maybe a stupid subject, but this is what I want to do :
> >
> > I got some python code stored in a string:
> >
> > somecode = """
> >
> > from somemodule import ISomeInterface
> >
> > class Foo(ISomeIn
Thomas W wrote:
> Maybe a stupid subject, but this is what I want to do :
>
> I got some python code stored in a string:
>
> somecode = """
>
> from somemodule import ISomeInterface
>
> class Foo(ISomeInterface):
> param1 = ...
> param2 =
>
> """
>
> and I want to compile that code so
Thomas W wrote:
> from somemodule import ISomeInteface
>
> d = compile(sourcecode)
>
> myfoo = d.Foo()
>
> print ISomeInterface in myfoo.__bases__
>
> Any hints?
Python is a dynamic language, so compiling something won't tell you much
about what the code actually does. the only reliable way
Maybe a stupid subject, but this is what I want to do :
I got some python code stored in a string:
somecode = """
from somemodule import ISomeInterface
class Foo(ISomeInterface):
param1 = ...
param2 =
"""
and I want to compile that code so that I can use the Foo-class and
check w
Fredrik Lundh wrote:
> brad tilley wrote:
>
>> How do I import a module and then ask it to show me its methods or
>> other aspects about itself during execution? I'd like to do something
>> such as this:
>>
>> import win32api
>
> dir(win32api)
> help(win32api)
>
> and also
>
> import inspect
brad tilley wrote:
> How do I import a module and then ask it to show me its methods or other
> aspects about itself during execution? I'd like to do something such as
> this:
>
> import win32api
dir(win32api)
help(win32api)
and also
import inspect
help(inspect)
--
http://mail.python.org
brad tilley <[EMAIL PROTECTED]> writes:
> How do I import a module and then ask it to show me its methods or other
> aspects about itself during execution? I'd like to do something such as
> this:
>
> import win32api
>
> print win32api.methods()
>
> I'd like to write some test scripts that load
brad tilley wrote:
> How do I import a module and then ask it to show me its methods or other
> aspects about itself during execution? I'd like to do something such as
> this:
>
> import win32api
>
> print win32api.methods()
>
> I'd like to write some test scripts that load modules and probe them
How do I import a module and then ask it to show me its methods or other
aspects about itself during execution? I'd like to do something such as
this:
import win32api
print win32api.methods()
I'd like to write some test scripts that load modules and probe them for
information about themselves
[EMAIL PROTECTED] a écrit :
> As you mention, wether the methods take arguments or not is something
> to have into account.
> And they do take arguments, and a variable number of them, so AFAIK
> hooking with __getattr__ or __getattribute__ will not work, as you can
> only get the method name with
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > And they do take arguments, and a variable number of them, so AFAIK
> > hooking with __getattr__ or __getattribute__ will not work, as you can
> > only get the method name with that.
>
> why not just return the bound method *object* (a callable
[EMAIL PROTECTED] wrote:
> And they do take arguments, and a variable number of them, so AFAIK
> hooking with __getattr__ or __getattribute__ will not work, as you can
> only get the method name with that.
why not just return the bound method *object* (a callable), and let the
caller call that a
As you mention, wether the methods take arguments or not is something
to have into account.
And they do take arguments, and a variable number of them, so AFAIK
hooking with __getattr__ or __getattribute__ will not work, as you can
only get the method name with that. I was thinking of some __call__
legation.)
> The handler object is the same in all methods.
>
> I was wondering if there is a way to simplify this proxy class, maybe
> using some pythonic technique like metaclasses, introspection... any
> suggestion is appreciated.
My immediate thought would be to start with
_forw
dName(self):
> self._handlerClass.thisIsTheMethodName()
>
> The handler object is the same in all methods.
>
> I was wondering if there is a way to simplify this proxy class, maybe
> using some pythonic technique like metaclasses, introspection... any
> suggestion is appreciated.
>
&g
ndler object is the same in all methods.
I was wondering if there is a way to simplify this proxy class, maybe
using some pythonic technique like metaclasses, introspection... any
suggestion is appreciated.
Thanks,
Javier Sanz
--
http://mail.python.org/mailman/listinfo/python-list
I have the below code to get info about SOAP services at a wsdl url. It
gets the in parameters OK but does not seem to get out/return
parameters. Any idea why?
Ben
from SOAPpy import WSDL
import sys
wsdlfile = "http://www.xmethods.net/sd/2001/TemperatureService.wsdl";
server = WSDL.Proxy(wsdl
*binarystar* wrote:
> Hello there,
>
> what method would you use to return the name of the class and/or
> instance introspectively eg.
>
> class Bollocks:
>
> def __init__( self ):
>
> print self.__method_that_returns_class_name__()
> print self.__method_that_ret
ce_of_bollocks
>>> print another_name.name_of_instance()
??? which name should appear here ???
>>> more = [another_name]*5
>>> print more[2]
??? and what name here ???
and did you want a global name, or a local variable from some function and
if so which function and at wh
What about:
py> class A:
py. def __init__(self):
py. print self.__class__.__name__
py. print str(self)
py. def __str__(self):
py. return 'instance of %s' % self.__class__.__name__
py.
py> a = A()
A
instance of A
py>
--
http://mail.python.org/mailman/l
*binarystar* wrote:
> Hello there,
>
> what method would you use to return the name of the class and/or
> instance introspectively eg.
>
> class Bollocks:
>
> def __init__( self ):
>
> print self.__method_that_returns_class_name__()
> print self.__method_that_ret
Hello there,
what method would you use to return the name of the class and/or
instance introspectively eg.
class Bollocks:
def __init__( self ):
print self.__method_that_returns_class_name__()
print self.__method_that_returns_inst
Oops.
http://www.activestate.com/_images/screenshots/ss_Komodo_rails_large.gif
is the debugger screenshot for Ruby (Komodo supports more than one
language). Python's debugger in Komodo looks exactly the same.
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 152 matches
Mail list logo