473,769 Members | 8,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dinamically altering a function


I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:

def dec(func):
def wrapper(obj = None):
if not obj : obj = Obj()
<bind obj to func>
return func()

return wrapper()

@dec()
def fun(b):
obj.desc = 'marked'
obj.b = b
return obj

so the call to fun : fun(obj = myobj,'b argument')
or fun('b argument')

So the function "fun" assumes it has an obj instance and other instance
objects computed by the decorator, this decorator will be like a generic
factory for this kind of functions,which depends on the decorator to work.


Jul 18 '05 #1
7 1462
vegetax wrote:
I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:

def dec(func):
def wrapper(obj = None):
if not obj : obj = Obj()
<bind obj to func>
return func()

return wrapper()

@dec()
def fun(b):
obj.desc = 'marked'
obj.b = b
return obj

so the call to fun : fun(obj = myobj,'b argument')
or fun('b argument')

So the function "fun" assumes it has an obj instance and other instance
objects computed by the decorator, this decorator will be like a generic
factory for this kind of functions,which depends on the decorator to work.


For a byte-code hack that does something similar, see the recent thread:

http://mail.python.org/pipermail/pyt...ch/270324.html

It can do something like:

py> class Object(object):
.... pass
....
py> @presets.preset s(obj=Object())
.... def fun(b):
.... obj.desc = "marked"
.... obj.b = b
.... return obj
....
py> fun(1)
<__main__.Objec t object at 0x01162BD0>
py> fun(1).b
1

But note that you then only have a single instance for all calls to the
function:

py> fun(1) is fun(2)
True

Have you considered using OO here? You might find that this is more
easily written as:

py> class Object(object):
.... pass
....
py> class fun(object):
.... def __new__(self, *args):
.... if len(args) == 2:
.... obj, b = args
.... elif len(args) == 1:
.... obj, [b] = Object(), args
.... else:
.... raise TypeError
.... obj.desc = "marked"
.... obj.b = b
.... return obj
....
py> myobj = Object()
py> fun(myobj, 2)
<__main__.Objec t object at 0x01162E30>
py> myobj.b
2
py> obj = fun(1)
py> obj.b
1

This doesn't use any bytecode hacks, but I'm still not certain it's
really the way to go. What is it you're trying to write this way?

STeVe
Jul 18 '05 #2
Steven Bethard wrote:
vegetax wrote:
I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:

def dec(func):
def wrapper(obj = None):
if not obj : obj = Obj()
<bind obj to func>
return func()

return wrapper()

@dec()
def fun(b):
obj.desc = 'marked'
obj.b = b
return obj

so the call to fun : fun(obj = myobj,'b argument')
or fun('b argument')

So the function "fun" assumes it has an obj instance and other instance
objects computed by the decorator, this decorator will be like a generic
factory for this kind of functions,which depends on the decorator to
work.
For a byte-code hack that does something similar, see the recent thread:

http://mail.python.org/pipermail/pyt...ch/270324.html

It can do something like:

py> class Object(object):
... pass
...
py> @presets.preset s(obj=Object())
... def fun(b):
... obj.desc = "marked"
... obj.b = b
... return obj
...
py> fun(1)
<__main__.Objec t object at 0x01162BD0>
py> fun(1).b
1

But note that you then only have a single instance for all calls to the
function:

py> fun(1) is fun(2)
True


Interesting hack, but the functions must not share the same object.Maybe i
could make my version of that decorator,i will check it.
Have you considered using OO here? You might find that this is more
easily written as:

py> class Object(object):
... pass
...
py> class fun(object):
... def __new__(self, *args):
... if len(args) == 2:
... obj, b = args
... elif len(args) == 1:
... obj, [b] = Object(), args
... else:
... raise TypeError
... obj.desc = "marked"
... obj.b = b
... return obj
...
py> myobj = Object()
py> fun(myobj, 2)
<__main__.Objec t object at 0x01162E30>
py> myobj.b
2
py> obj = fun(1)
py> obj.b
1

This doesn't use any bytecode hacks, but I'm still not certain it's
really the way to go. What is it you're trying to write this way?


OO doesnt work here,i have factored to classes with inheritance but it looks
clumsy and it is clumsy to use, this things are in nature,function s.

What i want is to declare in the decorator some code that is common to all
these functions, so the functions assume that the decorator will be there
and wont need to duplicate the code provided by it, and the functions are
not known ahead of time, it has to be dynamic.


Jul 18 '05 #3
vegetax wrote:
Steven Bethard wrote:
Have you considered using OO here? You might find that this is more
easily written as:

py> class Object(object):
... pass
...
py> class fun(object):
... def __new__(self, *args):
... if len(args) == 2:
... obj, b = args
... elif len(args) == 1:
... obj, [b] = Object(), args
... else:
... raise TypeError
... obj.desc = "marked"
... obj.b = b
... return obj
...
py> myobj = Object()
py> fun(myobj, 2)
<__main__.Obj ect object at 0x01162E30>
py> myobj.b
2
py> obj = fun(1)
py> obj.b
1

This doesn't use any bytecode hacks, but I'm still not certain it's
really the way to go. What is it you're trying to write this way?


OO doesnt work here,i have factored to classes with inheritance but it looks
clumsy and it is clumsy to use, this things are in nature,function s.

What i want is to declare in the decorator some code that is common to all
these functions, so the functions assume that the decorator will be there
and wont need to duplicate the code provided by it, and the functions are
not known ahead of time, it has to be dynamic.


If you need to use it as a decorator, you could try something like:

py> class Object(object):
.... pass
....
py> class ObjectSupplier( object):
.... def __init__(self, func):
.... self.func = func
.... def __call__(self, *args):
.... if len(args) == 2:
.... obj, b = args
.... elif len(args) == 1:
.... obj, [b] = Object(), args
.... else:
.... raise TypeError
.... return self.func(obj, b)
....
py> @ObjectSupplier
.... def fun(obj, b):
.... obj.desc = "marked"
.... obj.b = b
.... return obj
....
py> fun(1)
<__main__.Objec t object at 0x01162910>
py> fun(1).b
1
py> myobject = Object()
py> fun(myobject, 2)
<__main__.Objec t object at 0x01162770>
py> myobject.b
2

Basically, ObjectSupplier just guarantees that the function will be
called with an initialized Object argument if one isn't supplied. Note
that your functions must be declared with the initial argument now though.

STeVe

P.S. Making ObjectSupplier general enough to work with any number of
arguments is left as an exercise to the reader. ;)
Jul 18 '05 #4
> What i want is to declare in the decorator some code that is common to all
these functions, so the functions assume that the decorator will be there
and wont need to duplicate the code provided by it, and the functions are
not known ahead of time, it has to be dynamic.


This sounds like a call for a Pythonic varient on the Template pattern:

class Root(object):
def __init__(self):
self.dataChunk = 22 # or whatever

class Child(Root):
def __call__(self):
print self.dataChunk
c = Child()
c() 22
Don't be put off by the "OO"-ness here, it acts just like a function
thanks to __call__, and behind the scenes you get full OO support for your
functions.

I strongly suspect this is the best solution to your problem, not a
decorator. Note whatever you are doing to create the functions can be done
in other ways, especially note that "class" statements are executed, not
declarations, for instance:
import operator
class Root(object): .... def __init__(self):
.... self.op1 = 22
.... self.op2 = 44
.... funcs = []
for op in operator.add, operator.sub, operator.pow: .... def newfunc(self, basefunc = op):
.... print basefunc(self.o p1, self.op2)
.... class New(Root):
.... __call__ = newfunc
.... funcs.append(Ne w)
.... funcs # show the classes [<class '__main__.New'> , <class '__main__.New'> , <class '__main__.New'>] [x() for x in funcs] # show the new "functions" [<__main__.New object at 0xb7e78bcc>, <__main__.New object at 0xb7e78e4c>, <__ma
in__.New object at 0xb7e78ecc>] [x()() for x in funcs] # call each of the functions, note no return

66
-22
116572995441436 549620289361494 791139391860487 905922101805056
[None, None, None]

Upshot is, with a bit of creativity this can do whatever you want, in
conjection with dynamically-created classes, no bytecode hacks, no really
weird decorators, just standard OO and __call__.
Jul 18 '05 #5
On Sat, 12 Mar 2005 18:19:36 -0400, vegetax <ve******@gmail .com> wrote:
Steven Bethard wrote:
vegetax wrote:
I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:

def dec(func):
def wrapper(obj = None):
if not obj : obj = Obj()
<bind obj to func>
return func()

return wrapper()

@dec()
def fun(b):
obj.desc = 'marked'
obj.b = b
return obj

so the call to fun : fun(obj = myobj,'b argument')
or fun('b argument')

So the function "fun" assumes it has an obj instance and other instance
objects computed by the decorator, this decorator will be like a generic
factory for this kind of functions,which depends on the decorator to
work.
For a byte-code hack that does something similar, see the recent thread:

http://mail.python.org/pipermail/pyt...ch/270324.html

It can do something like:

py> class Object(object):
... pass
...
py> @presets.preset s(obj=Object())
... def fun(b):
... obj.desc = "marked"
... obj.b = b
... return obj
...
py> fun(1)
<__main__.Objec t object at 0x01162BD0>
py> fun(1).b
1

But note that you then only have a single instance for all calls to the
function:

py> fun(1) is fun(2)
True


Interesting hack, but the functions must not share the same object.Maybe i
could make my version of that decorator,i will check it.

What do you mean "function_s _" [plural] ? I see only one function named "fun".
An ordinary decorator will only modify that single function, so if you want
more than one function instance, IWT you would want a factory function that
can produce multiple function instances, tailored as you like. You could
use a decorator to modify a template function within the factory, and return
the result. But you might no need a decorator if you just make your template
function refer to stuff passed into the factory, i.e., as cell variables.

Will your template function know the names of dynamic things it will use?
If not, what kind of protocol will you use to discover what's available?
If it does know the names (like "obj") then you could just write something like

def mkfun(obj=None) : ... if obj is None: obj = Obj()
... def fun(b):
... obj.desc = 'marked'
... obj.b = b
... return obj
... return fun
... fun = mkfun() Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 2, in mkfun
NameError: global name 'Obj' is not defined

oops
class Obj(object): pass ... fun = mkfun()
fun2 = mkfun()
fun(1) <__main__.Obj object at 0x02EF15CC> fun(1).b 1 fun(2).b 2 fun2(3) <__main__.Obj object at 0x02EF162C> fun2(3).b 3 fun(1) is fun2(2) False fun(1) is fun(2) True

The code of the function the factory produces is:
dis.dis(mkfun() ) 4 0 LOAD_CONST 1 ('marked')
3 LOAD_DEREF 0 (obj)
6 STORE_ATTR 1 (desc)

5 9 LOAD_FAST 0 (b)
12 LOAD_DEREF 0 (obj)
15 STORE_ATTR 2 (b)

6 18 LOAD_DEREF 0 (obj)
21 RETURN_VALUE

We could use the byte code hack to change the code not to use
LOAD_DEREF cell vars, but preset and use a local variable instead:
from ut.presets import presets
def mkfun(obj=None) : ... if obj is None: obj = Obj()
... @presets(obj=ob j)
... def fun(b):
... obj.desc = 'marked'
... obj.b = b
... return obj
... return fun
... dis.dis(mkfun() )

3 0 LOAD_CONST 2 (<__main__.Obj object at 0x02EF728C>)
3 STORE_FAST 1 (obj)

5 6 LOAD_CONST 1 ('marked')
9 LOAD_FAST 1 (obj)
12 STORE_ATTR 1 (desc)

6 15 LOAD_FAST 0 (b)
18 LOAD_FAST 1 (obj)
21 STORE_ATTR 2 (b)

7 24 LOAD_FAST 1 (obj)
27 RETURN_VALUE

Not sure that gains anything significant.
Have you considered using OO here? You might find that this is more
easily written as:

py> class Object(object):
... pass
...
py> class fun(object):
... def __new__(self, *args):
... if len(args) == 2:
... obj, b = args
... elif len(args) == 1:
... obj, [b] = Object(), args
... else:
... raise TypeError
... obj.desc = "marked"
... obj.b = b
... return obj
...
py> myobj = Object()
py> fun(myobj, 2)
<__main__.Objec t object at 0x01162E30>
py> myobj.b
2
py> obj = fun(1)
py> obj.b
1

This doesn't use any bytecode hacks, but I'm still not certain it's
really the way to go. What is it you're trying to write this way?
Yes, that is a good question ;-)

OO doesnt work here,i have factored to classes with inheritance but it looks
clumsy and it is clumsy to use, this things are in nature,function s.

What i want is to declare in the decorator some code that is common to all
these functions, so the functions assume that the decorator will be there
and wont need to duplicate the code provided by it, and the functions are
not known ahead of time, it has to be dynamic.

Still not sure what you mean by "the functions are not known ahead of time."

Please pretend things worked the way you want, and post an example. Maybe we can
make it work.

Regards,
Bengt Richter
Jul 18 '05 #6
Bengt Richter wrote:
On Sat, 12 Mar 2005 18:19:36 -0400, vegetax <ve******@gmail .com> wrote:
Steven Bethard wrote:
vegetax wrote:
I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:

def dec(func):
def wrapper(obj = None):
if not obj : obj = Obj()
<bind obj to func>
return func()

return wrapper()

@dec()
def fun(b):
obj.desc = 'marked'
obj.b = b
return obj

so the call to fun : fun(obj = myobj,'b argument')
or fun('b argument')

So the function "fun" assumes it has an obj instance and other instance
objects computed by the decorator, this decorator will be like a
generic factory for this kind of functions,which depends on the
decorator to work.

For a byte-code hack that does something similar, see the recent thread:

http://mail.python.org/pipermail/pyt...ch/270324.html

It can do something like:

py> class Object(object):
... pass
...
py> @presets.preset s(obj=Object())
... def fun(b):
... obj.desc = "marked"
... obj.b = b
... return obj
...
py> fun(1)
<__main__.Objec t object at 0x01162BD0>
py> fun(1).b
1

But note that you then only have a single instance for all calls to the
function:

py> fun(1) is fun(2)
True


Interesting hack, but the functions must not share the same object.Maybe i
could make my version of that decorator,i will check it.

What do you mean "function_s _" [plural] ? I see only one function named
"fun". An ordinary decorator will only modify that single function, so if
you want more than one function instance, IWT you would want a factory
function that can produce multiple function instances, tailored as you
like. You could use a decorator to modify a template function within the
factory, and return the result. But you might no need a decorator if you
just make your template function refer to stuff passed into the factory,
i.e., as cell variables.

Will your template function know the names of dynamic things it will use?
If not, what kind of protocol will you use to discover what's available?
If it does know the names (like "obj") then you could just write something
like

>>> def mkfun(obj=None) : ... if obj is None: obj = Obj()
... def fun(b):
... obj.desc = 'marked'
... obj.b = b
... return obj
... return fun
... >>> fun = mkfun() Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 2, in mkfun
NameError: global name 'Obj' is not defined

oops
>>> class Obj(object): pass ... >>> fun = mkfun()
>>> fun2 = mkfun()
>>> fun(1) <__main__.Obj object at 0x02EF15CC> >>> fun(1).b 1 >>> fun(2).b 2 >>> fun2(3) <__main__.Obj object at 0x02EF162C> >>> fun2(3).b 3 >>> fun(1) is fun2(2) False >>> fun(1) is fun(2) True

The code of the function the factory produces is:
>>> dis.dis(mkfun() ) 4 0 LOAD_CONST 1 ('marked')
3 LOAD_DEREF 0 (obj)
6 STORE_ATTR 1 (desc)

5 9 LOAD_FAST 0 (b)
12 LOAD_DEREF 0 (obj)
15 STORE_ATTR 2 (b)

6 18 LOAD_DEREF 0 (obj)
21 RETURN_VALUE

We could use the byte code hack to change the code not to use
LOAD_DEREF cell vars, but preset and use a local variable instead:
>>> from ut.presets import presets
>>> def mkfun(obj=None) : ... if obj is None: obj = Obj()
... @presets(obj=ob j)
... def fun(b):
... obj.desc = 'marked'
... obj.b = b
... return obj
... return fun
... >>> dis.dis(mkfun() )

3 0 LOAD_CONST 2 (<__main__.Obj object at
0x02EF728C>)
3 STORE_FAST 1 (obj)

5 6 LOAD_CONST 1 ('marked')
9 LOAD_FAST 1 (obj)
12 STORE_ATTR 1 (desc)

6 15 LOAD_FAST 0 (b)
18 LOAD_FAST 1 (obj)
21 STORE_ATTR 2 (b)

7 24 LOAD_FAST 1 (obj)
27 RETURN_VALUE

Not sure that gains anything significant.
Have you considered using OO here? You might find that this is more
easily written as:

py> class Object(object):
... pass
...
py> class fun(object):
... def __new__(self, *args):
... if len(args) == 2:
... obj, b = args
... elif len(args) == 1:
... obj, [b] = Object(), args
... else:
... raise TypeError
... obj.desc = "marked"
... obj.b = b
... return obj
...
py> myobj = Object()
py> fun(myobj, 2)
<__main__.Objec t object at 0x01162E30>
py> myobj.b
2
py> obj = fun(1)
py> obj.b
1

This doesn't use any bytecode hacks, but I'm still not certain it's
really the way to go. What is it you're trying to write this way?

Yes, that is a good question ;-)

OO doesnt work here,i have factored to classes with inheritance but it
looks clumsy and it is clumsy to use, this things are in nature,function s.

What i want is to declare in the decorator some code that is common to all
these functions, so the functions assume that the decorator will be there
and wont need to duplicate the code provided by it, and the functions are
not known ahead of time, it has to be dynamic.

Still not sure what you mean by "the functions are not known ahead of
time."

Please pretend things worked the way you want, and post an example. Maybe
we can make it work.

Regards,
Bengt Richter


Ok , the complete use case is :

def fun1(a,b,obj = None):
isSuplied = 1
if not obj :
obj = generateObject( )
isSuplied = 0

<do something with obj>

if not isSuplied : obj.dispose()

def fun2(c,obj = None):
isSuplied = 1
if not obj :
obj = generateObject( )
isSuplied = 0

<do something else with obj>

if not isSuplied : obj.dispose()

So , maybe i will need to define fun3 later,i dont know , but fun3 also will
work with "obj".
So the thing is to try to factorize the code,so that it is in the decorator:

def dec(func):
def wrapper(*arg,** kw):
obj = kw.get('obj',No ne)
isSuplied = 1
if not obj :
obj = generateObject( )
kw['obj'] = obj
isSuplied = 0

res = func(*arg,**kw)
if not isSuplied : obj.dispose()
return res

return wrapper

so the previous function declarations, will look like:

@dec
def fun1(a,b,obj = None):
<do something with obj>

@dec
def fun2(c,obj = None):
<do something with obj>

but i have to define obj = None in each function,but the functions should
know they will have an obj instance available, so the byte code hack would
be :

def dec(func):
def wrapper(*arg,** kw):
obj = kw.get('obj',No ne)
isSuplied = 1
if not obj :
obj = generateObject( )
isSuplied = 0

<< BIND OBJ TO THE FUNCTION LOCAL NAMESPACE >>

res = func(*arg,**kw)
if not isSuplied : obj.dispose()
return res

return wrapper

so the functions knowing they will be altered(added an instance of obj),they
will just need to define their own arguments only.

@dec
fun1(a,b) : obj.result = a + b
@dec
fun2(c) : obj.result = c * 4

So the duplication would be removed.

But i realized the best aproach,is a callable class that provides that
infrastructure, or not? =P

Jul 18 '05 #7
On Sat, 12 Mar 2005 23:09:58 -0400, vegetax <ve******@gmail .com> wrote:
Bengt Richter wrote:

[...]
Please pretend things worked the way you want, and post an example. Maybe
we can make it work.

Regards,
Bengt Richter


Ok , the complete use case is :

def fun1(a,b,obj = None):
isSuplied = 1
if not obj :
obj = generateObject( )
isSuplied = 0

<do something with obj>

if not isSuplied : obj.dispose()

def fun2(c,obj = None):
isSuplied = 1
if not obj :
obj = generateObject( )
isSuplied = 0

<do something else with obj>

if not isSuplied : obj.dispose()

So , maybe i will need to define fun3 later,i dont know , but fun3 also will
work with "obj".
So the thing is to try to factorize the code,so that it is in the decorator:

def dec(func):
def wrapper(*arg,** kw):
obj = kw.get('obj',No ne)
isSuplied = 1
if not obj :
obj = generateObject( )
kw['obj'] = obj
isSuplied = 0

res = func(*arg,**kw)
if not isSuplied : obj.dispose()
return res

return wrapper

so the previous function declarations, will look like:

@dec
def fun1(a,b,obj = None):
<do something with obj>

@dec
def fun2(c,obj = None):
<do something with obj>

but i have to define obj = None in each function,but the functions should
know they will have an obj instance available, so the byte code hack would
be :

def dec(func):
def wrapper(*arg,** kw):
obj = kw.get('obj',No ne)
isSuplied = 1
if not obj :
obj = generateObject( )
isSuplied = 0

<< BIND OBJ TO THE FUNCTION LOCAL NAMESPACE >>

res = func(*arg,**kw)
if not isSuplied : obj.dispose()
return res

return wrapper

so the functions knowing they will be altered(added an instance of obj),they
will just need to define their own arguments only.

@dec
fun1(a,b) : obj.result = a + b
@dec
fun2(c) : obj.result = c * 4

So the duplication would be removed.

But i realized the best aproach,is a callable class that provides that
infrastructure , or not? =P

Maybe this implements what you are asking for?

----< vegetax.py >-------------------------
from ut.presets import presets

class generateObject( object):
def dispose(self): print 'disposing of %r: %r' %(self, vars(self))

def dec(func):
def getfun(f): return func # fake decorator to pass func to presets
def wrapper(*arg,** kw):
obj = kw.get('obj',No ne)
isSuplied = 1
if not obj :
obj = generateObject( )
isSuplied = 0
else:
del kw['obj'] # don't pass unexpected kwarg to func
#<< BIND OBJ TO THE FUNCTION LOCAL NAMESPACE >>
@presets(obj=ob j) # per comment above
@getfun
def funcalias(): pass # just for a local name to bind
res = funcalias(*arg, **kw)
if not isSuplied : obj.dispose()
return res
return wrapper

#so the functions knowing they will be altered(added an instance of obj),they
#will just need to define their own arguments only.
if __name__ == '__main__':
@dec
def fun1(a,b) : obj.result = a + b; return obj, vars(obj)
@dec
def fun2(c) : obj.result = c * 4; return obj, vars(obj)
o, v = fun1(111, 222) # bind obj to show that new obj is generated on next call
print o, v
print fun2(1111)
print 'supplying obj to fun2:', fun2(2222, obj=generateObj ect()) # supplied
print 'both ways:', (fun2(1111), fun2(2222, obj=generateObj ect()))
-------------------------------------------

[22:21] C:\pywk\clp>py2 4 vegetax.py
disposing of <__main__.gener ateObject object at 0x02EF9F0C>: {'result': 333}
<__main__.gener ateObject object at 0x02EF9F0C> {'result': 333}
disposing of <__main__.gener ateObject object at 0x02EF33CC>: {'result': 4444}
(<__main__.gene rateObject object at 0x02EF33CC>, {'result': 4444})
supplying obj to fun2: (<__main__.gene rateObject object at 0x02EF33CC>, {'result': 8888})
both ways: disposing of <__main__.gener ateObject object at 0x02EF33CC>: {'result': 4444}
((<__main__.gen erateObject object at 0x02EF33CC>, {'result': 4444}), (<__main__.gene rateObject o
bject at 0x02EF316C>, {'result': 8888}))
Regards,
Bengt Richter
Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1468
by: Daniel | last post by:
Hello!!! I'm creating controls dinamically in ASP.NET using VB. The problem is that i don't know how to catch the event of each button that i've create (the buttons are created dinamically). Any ideas?? Thanks!!!
2
12941
by: Marco | last post by:
How I can create TextBox dinamically. I have to create 10 textbox dinamically which name will be txtBox_01, txtBox_02, etc... Thanks.
3
1386
by: Luis Esteban Valencia | last post by:
Is that possible. I want to insert dinamically a row between 2 rows. That row will have the detail from the clicked row. as on www.isohunt.com Make a search and click on any result Grea
2
1439
by: Fabio Cavassini | last post by:
I have this code that load HTML tags (no including <html> or <body>) into a DIV dinamically... after correctly retrieving the HTML, I assign it to my DIV Container document.getElementById(containerid).innerHTML=page_request.responseText now from main page....I need to get a reference to an Object (a textbox) contained in the dinamically loaded HTML
4
1338
by: Cesar Ronchese | last post by:
Hello. I have a WebForm that contains a Panel object. This panel, at design time is empty. When running, I need to create dinamically a Label and a WebControl (built from the same project). I can create the label and the webcontrol dinamically with no errors, but only the Label appear in the panel when the page is shown in the client browser.
32
2677
by: Mateo | last post by:
I have char *array and it is dinamically alocated.... When I pass it to other function, I need to determine size of this array.... Problem: sizeof operator does not work with dinamically alocated arrays!?!?! How can I determine size of dinamically alocated array.... ? Please advice... Thx!
4
2802
by: Jeff | last post by:
....still new at this. ...hopefully a simple question Is there some practical way of altering the function of a keypress in Visual Web.net 2005 using VB without causing a postback on each keypress? For example: A have a listbox with a number of selections. The up and down keyboard keys change the indicated listbox selection and by default the <tabkey takes the focus away from the listbox and onto a button that will submit the selection. I'm...
3
2681
by: valerio | last post by:
Hello all I would like to dinamically allocate an array of array of structures. To explain this: struct file{ char* fileName,int inode) myfiles; struct file{ char* fileName,int inode) mydirs; but I would like to do it dinamically with linked list. I am able to do it for myfiles, but not with mydirs. Pseudo-code is ok.
9
8392
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. However, after I alter the table and open microsoft excel to look at any changes; I get the following error: "This file is not in a recognizable format" If I do open the file in excel it looks like its not formatted.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.