473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Decorator for validation - inefficient?

I want my business objects to be able to do this:
class Person(base):

def __init__(self):
self.name = None

@base.validator
def validate_name(self):
if not self.name: return ['Name cannot be empty']

p = Person()
print p.invalid # Prints ['Name cannot be empty']
p.name = 'foo'
print p.invalid # Prints []
print bool(p.invalid) # Prints False

The invalid attribute and validator decorator would be in the base
class:
class base(object):

@staticmethod # so child can say: @base.validator
def validator(func):
"""Mark the function as a validator."""
func._validator = True
return func

def _get_invalid(self):
"""Collect all validation results from registered validators"""
result = []
for attrName in dir(self):
# Prevent recursive calls
if attrName == 'get_invalid' or attrName == 'invalid':
continue

attr = eval('self.' + attrName) # Get attribute

if str(type(attr)) == "<type 'instancemethod'>": # Check
if is function
if hasattr(attr, '_validator'): # Check if function
is a validator
valerr = attr() # Get result of validation
# Validation result can be a single string, list
of strings, or None.
# If the validation fails, it will be a string or
list of strings
# which describe what the validation errors are.
# If the validation succeeds, None is returned.
if type(valerr) == type([]):
for err in valerr:
result.append(err)
else:
if valerr != None: result.append(valerr)
return result # List of validation error strings
invalid = property(_get_invalid, None, None, "List of validation
errors") # Read-only, so no fset or fdel

I don't really like the _get_invalid() logic that reflects over each
attribute and does ugly string comparisons. Is there a cleaner/more
pythonic way to do this reflection?

Also, I am using a decorator to simply mark a function as being a
validator. This works, but I must enumerate all of the object's
attributes to find all the validators. My original plan was to use a
decorator to "register" a function as being a validator. Then the
_get_invalid() call would only need to enumerate the registered
functions. I ran into problems when I couldn't figure out how to use
a decorator to store a function in an attribute of the function's
class:
# Decorator to register function as a validator
def validator(func):
"""Save func in a list of validator functions on the object that
contains func"""
self._validation_functions.append(func) # ERROR: Cannot access
self this way
return func

I appreciate your feedback. I am relatively new to python but have
become completely enamored by it after looking for alternatives to the
MS languages I use to develop business apps.
Oct 31 '08 #1
8 2710
On Oct 31, 6:26*pm, Bryan <bryanv...@gmail.comwrote:
I want my business objects to be able to do this:
class Person(base):

* * def __init__(self):
* * * * self.name = None

* * @base.validator
* * def validate_name(self):
* * * * if not self.name: return ['Name cannot be empty']

p = Person()
print p.invalid *# Prints ['Name cannot be empty']
p.name = 'foo'
print p.invalid *# Prints []
print bool(p.invalid) *# Prints False

The invalid attribute and validator decorator would be in the base
class:
class base(object):

* * @staticmethod *# so child can say: @base.validator
* * def validator(func):
* * * * """Mark the function as a validator."""
* * * * func._validator = True
* * * * return func

* * def _get_invalid(self):
* * """Collect all validation results from registered validators"""
* * * * result = []
* * * * for attrName in dir(self):
* * * * * * # Prevent recursive calls
* * * * * * if attrName == 'get_invalid' or attrName == 'invalid':
continue

* * * * * * attr = *eval('self.' + attrName) *# Get attribute

* * * * * * if str(type(attr)) == "<type 'instancemethod'>": *# Check
if is function
* * * * * * * * if hasattr(attr, '_validator'): *# Check if function
is a validator
* * * * * * * * * * valerr = attr() *# Get resultof validation
* * * * * * * * * * # Validation result can be a single string, list
of strings, or None.
* * * * * * * * * * # If the validation fails, it will be a string or
list of strings
* * * * * * * * * * # which describe what the validation errors are.
* * * * * * * * * * # If the validation succeeds, None is returned.
* * * * * * * * * * if type(valerr) == type([]):
* * * * * * * * * * * * for err in valerr:
* * * * * * * * * * * * * * result.append(err)
* * * * * * * * * * else:
* * * * * * * * * * * * if valerr != None: result.append(valerr)
* * * * return result *# List of validation error strings
* * invalid = property(_get_invalid, None, None, "List of validation
errors") *# Read-only, so no fset or fdel

I don't really like the _get_invalid() logic that reflects over each
attribute and does ugly string comparisons. *Is there a cleaner/more
pythonic way to do this reflection?

Also, I am using a decorator to simply mark a function as being a
validator. *This works, but I must enumerate all of the object's
attributes to find all the validators. *My original plan was to use a
decorator to "register" a function as being a validator. *Then the
_get_invalid() call would only need to enumerate the registered
functions. *I ran into problems when I couldn't figure out how to use
a decorator to store a function in an attribute of the function's
class:
# Decorator to register function as a validator
def validator(func):
* * """Save func in a list of validator functions on the object that
contains func"""
* * self._validation_functions.append(func) *# ERROR: Cannot access
self this way
* * return func

I appreciate your feedback. *I am relatively new to python but have
become completely enamored by it after looking for alternatives to the
MS languages I use to develop business apps.
Hi

I suggest a simpler approach

class Base(object):
@property
def invalid(self):
invalid = []
for field in self.fields:
validate_field = getattr(self, 'validate_' + field)
if validate_field:
errors = validate_field()
if errors:
invalid.extend(errors)
return invalid

class Person(Base):
fields = 'name', 'age'
def __init__(self):
self.name = None
self.age = None
def validate_name(self):
if not self.name: return ['Name cannot be empty']
def validate_age(self):
if self.age is None: return ['Age cannot be empty']
if not isinstance(self.age, int): return ['Age must be a
number']

Then:
>>p=Person()
p.invalid
['Name cannot be empty', 'Age cannot be empty']
>>p.name='Lorenzo'
p.invalid
['Age cannot be empty']
>>p.age='green'
p.invalid
['Age must be a number']
>>p.age=12
p.invalid
[]
>>>
HTH

--
Arnaud

Oct 31 '08 #2
On Fri, 31 Oct 2008 11:26:19 -0700, Bryan wrote:
I want my business objects to be able to do this:
[snip code]

The code you show is quite long and complex and frankly I don't have the
time to study it in detail at the moment, but I can make a couple of
quick comments. I see by your subject line that you're (probably)
complaining about it being inefficient.

I notice that in the validation code, you do this:

def _get_invalid(self):
"""Collect all validation results from registered validators"""
result = []
for attrName in dir(self):
# Prevent recursive calls
if attrName == 'get_invalid' or attrName == 'invalid':
continue
attr = eval('self.' + attrName) # Get attribute
That's slow and wasteful. The right way to get an attribute is with
getattr:

attr = getattr(self, attname)

I haven't tested this specifically, but in the past my timing tests
suggest that x.attr or getattr() will run about ten times faster than
eval('x.attr').

if str(type(attr)) == "<type 'instancemethod'>":
This is probably also slow and wasteful. Why convert the instance into a
string and then do a string comparison?

At the top level of your module, do this once:

import new

and then in the validation method do this:

if type(attr) is new.instancemethod:

or better still:

if isinstance(attr, new.instancemethod):
valerr = attr() # Get result of validation
# Validation result can be a single string, list
# of strings, or None.
# If the validation fails, it will be a string or
# list of strings
# which describe what the validation errors are.
# If the validation succeeds, None is returned.
if type(valerr) == type([]):
for err in valerr:
result.append(err)
else:
if valerr != None: result.append(valerr)

This whole approach is unpythonic. That doesn't mean it's wrong, but it
does suggest you should rethink it. I recommend that the validation test
should simply raise an exception if the validation fails, and let the
calling code deal with it.
Hope this helps, and I may have another look at your code later today.
--
Steven
Nov 1 '08 #3


Steven D'Aprano wrote:
On Fri, 31 Oct 2008 11:26:19 -0700, Bryan wrote:
I want my business objects to be able to do this:
[snip code]

The code you show is quite long and complex and frankly I don't have the
time to study it in detail at the moment, but I can make a couple of
quick comments. I see by your subject line that you're (probably)
complaining about it being inefficient.

I notice that in the validation code, you do this:

def _get_invalid(self):
"""Collect all validation results from registered validators"""
result = []
for attrName in dir(self):
# Prevent recursive calls
if attrName == 'get_invalid' or attrName == 'invalid':
continue
attr = eval('self.' + attrName) # Get attribute

That's slow and wasteful. The right way to get an attribute is with
getattr:

attr = getattr(self, attname)

I haven't tested this specifically, but in the past my timing tests
suggest that x.attr or getattr() will run about ten times faster than
eval('x.attr').

if str(type(attr)) == "<type 'instancemethod'>":

This is probably also slow and wasteful. Why convert the instance into a
string and then do a string comparison?

At the top level of your module, do this once:

import new

and then in the validation method do this:

if type(attr) is new.instancemethod:

or better still:

if isinstance(attr, new.instancemethod):
valerr = attr() # Get result of validation
# Validation result can be a single string, list
# of strings, or None.
# If the validation fails, it will be a string or
# list of strings
# which describe what the validation errors are.
# If the validation succeeds, None is returned.
if type(valerr) == type([]):
for err in valerr:
result.append(err)
else:
if valerr != None: result.append(valerr)


This whole approach is unpythonic. That doesn't mean it's wrong, but it
does suggest you should rethink it. I recommend that the validation test
should simply raise an exception if the validation fails, and let the
calling code deal with it.
Hope this helps, and I may have another look at your code later today.
--
Steven
Thanks steven, this is the type of info I was looking for. The
instancemethod string comparison and eval() were making me cringe.

Upon review of my code I decided that I was using decorators to solve
this problem mostly because I just learned about them and I wanted to
use this cool new tool.
Instead of marking functions as being validators and then having to
inefficiently loop over all of an object's attrs to fing them all, I
am going to simply have a get_validators() function on my model
classes that my base class can call to get all the validators. Any
validators for a class would be returned in this function.

The list of validation error descriptions is returned instead of
raising exceptions so clients can show the errors to the user for
fixing. Raising exceptions seems like an uneeded burden for the
client, as there is nothing exceptional about bad user input. Instead,
I want to raise an exception if a client actually tries to save an
invalid entity back to the database. I will have to think on your
suggestion a bit more before I am sure however.

Bryan
Nov 2 '08 #4
On Sat, 01 Nov 2008 17:12:33 -0700, Bryan wrote:
The list of validation error descriptions is returned instead of raising
exceptions so clients can show the errors to the user for fixing.
Raising exceptions seems like an uneeded burden for the client, as there
is nothing exceptional about bad user input.
But of course there is. Exceptional doesn't mean rare. In this case, it
just means it's not the "normal" input which is expected.

Instead, I want to raise an
exception if a client actually tries to save an invalid entity back to
the database. I will have to think on your suggestion a bit more before
I am sure however.
As a general rule, every function should return one "kind" of thing.
Notice I don't say "type", because it doesn't matter what the type/class
of the data is, so long as it is conceptually the same sort of result.

E.g. a function that opens a connection to a database should *only*
return a connection to a data, although the actual type of that
connection may differ depending on the database. It shouldn't return
either a connection or an error code.

I say that this is a general rule, because you can get away with breaking
it, sometimes. E.g. string.find() returns either an offset or an error
signal of -1. But note that this sometimes leads to bugs where people
forget to check for a result of -1, and end up with code doing something
unexpected.
You've suggested a usage:

"The list of validation error descriptions is returned instead of
raising exceptions so clients can show the errors to the user for
fixing."

But you can do that with an exception as well:

while True:
try:
validate(arguments) # returns None on success, or raise Failure
break
except Failure, e:
print e.msg
for error in e.errors:
print "You must fix this error: %s" % error
# when we exit the loop, the arguments are validated.
do_something_with(arguments)
If you're coming from a Java background, you may be concerned that
exceptions are expensive. They aren't. Setting up the try...except block
is very cheap. There's very little overhead to a try block that doesn't
fail.
--
Steven
Nov 2 '08 #5
On Nov 1, 6:57*pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.auwrote:
On Sat, 01 Nov 2008 17:12:33 -0700, Bryan wrote:
The list of validation error descriptions is returned instead of raising
exceptions so clients can show the errors to the user for fixing.
Raising exceptions seems like an uneeded burden for the client, as there
is nothing exceptional about bad user input.

But of course there is. Exceptional doesn't mean rare. In this case, it
just means it's not the "normal" input which is expected.
Instead, I want to raise an
exception if a client actually tries to save an invalid entity back to
the database. I will have to think on your suggestion a bit more before
I am sure however.

As a general rule, every function should return one "kind" of thing.
Notice I don't say "type", because it doesn't matter what the type/class
of the data is, so long as it is conceptually the same sort of result.

E.g. a function that opens a connection to a database should *only*
return a connection to a data, although the actual type of that
connection may differ depending on the database. It shouldn't return
either a connection or an error code.

I say that this is a general rule, because you can get away with breaking
it, sometimes. E.g. string.find() returns either an offset or an error
signal of -1. But note that this sometimes leads to bugs where people
forget to check for a result of -1, and end up with code doing something
unexpected.

You've suggested a usage:

"The list of validation error descriptions is returned instead of
raising exceptions so clients can show the errors to the user for
fixing."

But you can do that with an exception as well:

while True:
* * try:
* * * * validate(arguments) *# returns None on success, or raise Failure
* * * * break
* * except Failure, e:
* * * * print e.msg
* * * * for error in e.errors:
* * * * * * print "You must fix this error: %s" % error
# when we exit the loop, the arguments are validated.
do_something_with(arguments)

If you're coming from a Java background, you may be concerned that
exceptions are expensive. They aren't. Setting up the try...except block
is very cheap. There's very little overhead to a try block that doesn't
fail.

--
Steven
I'm coming from a .Net background, and yes, one of the reasons I did
not consider raising exceptions was to avoid the overhead of an
exception handler clause, which in .Net land is expensive.

some more thought on this:

If I were going to be checking for validity during a property setter,
I would probably raise an exception there, because the essence of what
a client was requesting is "set property", and an invalid value
precludes this action from happening.

However, hoping to make client code cleaner and to avoid setter
functions doing expensive db lookup validations, I do not validate
during the setter, but instead defer it until the client explicitly
asks for the validity of the business object. So the essence of the
client's request at that point is "what are the invalid values for the
object", and an exception should only be raised if there was something
stopping this request from being served. Invalid business object
field values do not stop the functionality of the invalid() method.

If I had a validation function that checked the db for a duplicate
primary key, then the invalid() function should raise an exception if
the db could not be contacted. A client should be on the lookout for
that type of exception, but to throw a bunch of exceptions back at a
client who simply requested a list of things that need to be fixed
seems heavy. We would essentially be using Exceptions as an expected
return value of a function. So a doc string would explain: "Returns
None for a valid object, and Exceptions for an invalid object."

Should exceptions be an expected "return value" from a function? Am I
still using my .Net brain?

Bryan

Nov 2 '08 #6
Bryan <br*******@gmail.comwrites:
However, hoping to make client code cleaner and to avoid setter
functions doing expensive db lookup validations, I do not validate
during the setter, but instead defer it until the client explicitly
asks for the validity of the business object. So the essence of the
client's request at that point is "what are the invalid values for the
object", and an exception should only be raised if there was something
stopping this request from being served. Invalid business object
field values do not stop the functionality of the invalid() method.
This is perfectly fine IMHO, in fact this is similar to how django does
form validation. Each form has a property 'is_valid' and validation is
only triggered when form.is_valid is checked. This doesn't raise
exceptions but makes the errors available to the form user.

--
Arnaud
Nov 2 '08 #7
On Sun, 02 Nov 2008 09:33:41 -0800, Bryan wrote:
I'm coming from a .Net background, and yes, one of the reasons I did not
consider raising exceptions was to avoid the overhead of an exception
handler clause, which in .Net land is expensive.
Actually catching an exception in Python is expensive, so I wouldn't
recommend you use exceptions for message-passing in time-critical code.

As I understand it, in your case you actually need to stop for user-input
if the user's data fails the validation. If that's the case, an extra few
milliseconds to catch an exception isn't going to matter much.
some more thought on this:

If I were going to be checking for validity during a property setter, I
would probably raise an exception there, because the essence of what a
client was requesting is "set property", and an invalid value precludes
this action from happening.

However, hoping to make client code cleaner and to avoid setter
functions doing expensive db lookup validations, I do not validate
during the setter, but instead defer it until the client explicitly asks
for the validity of the business object.
Presumably if they *don't* explicitly ask, you validate anyway at some
point?

So the essence of the client's
request at that point is "what are the invalid values for the object",
and an exception should only be raised if there was something stopping
this request from being served. Invalid business object field values do
not stop the functionality of the invalid() method.

If I had a validation function that checked the db for a duplicate
primary key, then the invalid() function should raise an exception if
the db could not be contacted.
Yes!

A client should be on the lookout for
that type of exception, but to throw a bunch of exceptions back at a
client who simply requested a list of things that need to be fixed seems
heavy.

We would essentially be using Exceptions as an expected return
value of a function. So a doc string would explain: "Returns None for a
valid object, and Exceptions for an invalid object."

Should exceptions be an expected "return value" from a function? Am I
still using my .Net brain?
Because exceptions are first-class objects just like lists, ints and
strings, there is a difference between *returning* an exception and
*raising* an exception.

E.g.:

def build_exception(n):
if n < 0:
raise ValueError('unexpected negative code')
else:
exc = TypeError('error code #%d' % n)
exc.foo = "More info here"
return exc
try:
obj = build_exception(57)
print obj.foo
another_obj = build_exception(-1)
print "We never get here"
except ValueError, e:
print "Failed with error message:", e.message

Making the exception part of your code's API is perfectly legitimate and
I would recommend it. The docstring could say this:

"Return None for a valid object, otherwise raises InvalidDataException
(subclass of ValueError). You can get a list of errors from the
exception's errorlist attribute."
Here's a minimal way to generate the exception:

class InvalidDataException(ValueError):
pass
and then in your validation code:

def validate(obj):
print "Testing many things here"
e = InvalidDataException("failed because of %d errors") % 4
e.errorlist = [
"too many questions",
"too few answers",
"not enough respect",
"and your query's hair is too long (damn hippy)"]
raise e
That's one way. There are others. Have a browse through the standard
library or the Python docs and see how other exceptions are used.
But now that I have a better picture of your use-case, I'm leaning
towards a completely different model. Rather than testing if the business
object is valid, and raising an error if it isn't, you test it for
errors, returning an empty list if there aren't any.
def check_for_errors(obj):
errorlist = []
print "Testing many things here"
if too_many_questions():
errorlist.append("too many questions")
# and any others
return errorlist
I've used strings as errors, but naturally they could be any object that
makes sense for your application.

--
Steven
Nov 3 '08 #8
Steven D'Aprano wrote:
On Sun, 02 Nov 2008 09:33:41 -0800, Bryan wrote:
I'm coming from a .Net background, and yes, one of the reasons I did not
consider raising exceptions was to avoid the overhead of an exception
handler clause, which in .Net land is expensive.

Actually catching an exception in Python is expensive, so I wouldn't
recommend you use exceptions for message-passing in time-critical code.

As I understand it, in your case you actually need to stop for user-input
if the user's data fails the validation. If that's the case, an extra few
milliseconds to catch an exception isn't going to matter much.
some more thought on this:

If I were going to be checking for validity during a property setter, I
would probably raise an exception there, because the essence of what a
client was requesting is "set property", and an invalid value precludes
this action from happening.

However, hoping to make client code cleaner and to avoid setter
functions doing expensive db lookup validations, I do not validate
during the setter, but instead defer it until the client explicitly asks
for the validity of the business object.

Presumably if they *don't* explicitly ask, you validate anyway at some
point?

So the essence of the client's
request at that point is "what are the invalid values for the object",
and an exception should only be raised if there was something stopping
this request from being served. Invalid business object field values do
not stop the functionality of the invalid() method.

If I had a validation function that checked the db for a duplicate
primary key, then the invalid() function should raise an exception if
the db could not be contacted.

Yes!

A client should be on the lookout for
that type of exception, but to throw a bunch of exceptions back at a
client who simply requested a list of things that need to be fixed seems
heavy.

We would essentially be using Exceptions as an expected return
value of a function. So a doc string would explain: "Returns None for a
valid object, and Exceptions for an invalid object."

Should exceptions be an expected "return value" from a function? Am I
still using my .Net brain?

Because exceptions are first-class objects just like lists, ints and
strings, there is a difference between *returning* an exception and
*raising* an exception.

E.g.:

def build_exception(n):
if n < 0:
raise ValueError('unexpected negative code')
else:
exc = TypeError('error code #%d' % n)
exc.foo = "More info here"
return exc
try:
obj = build_exception(57)
print obj.foo
another_obj = build_exception(-1)
print "We never get here"
except ValueError, e:
print "Failed with error message:", e.message

Making the exception part of your code's API is perfectly legitimate and
I would recommend it. The docstring could say this:

"Return None for a valid object, otherwise raises InvalidDataException
(subclass of ValueError). You can get a list of errors from the
exception's errorlist attribute."
Here's a minimal way to generate the exception:

class InvalidDataException(ValueError):
pass
and then in your validation code:

def validate(obj):
print "Testing many things here"
e = InvalidDataException("failed because of %d errors") % 4
e.errorlist = [
"too many questions",
"too few answers",
"not enough respect",
"and your query's hair is too long (damn hippy)"]
raise e
That's one way. There are others. Have a browse through the standard
library or the Python docs and see how other exceptions are used.
But now that I have a better picture of your use-case, I'm leaning
towards a completely different model. Rather than testing if the business
object is valid, and raising an error if it isn't, you test it for
errors, returning an empty list if there aren't any.
def check_for_errors(obj):
errorlist = []
print "Testing many things here"
if too_many_questions():
errorlist.append("too many questions")
# and any others
return errorlist
I've used strings as errors, but naturally they could be any object that
makes sense for your application.

--
Steven
I like the errorlist attribute on the exception, I think I have a
place for that in my project. Thanks for all the help, now the next
thing I want to investigate is how I can write my validation code once
and make it work both on my objects, and on webforms that edit those
objects. I will always have strict validation in the object model
that will be checked on the server side, but it would be convenient
for the user if they were warned before making a round trip to the
server that the values they entered are probably not correct.

This project is using Pylons, so I'm off to investigate the
possibilities.

Bryan
Nov 3 '08 #9

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

Similar topics

41
by: John Marshall | last post by:
How about the following, which I am almost positive has not been suggested: ----- class Klass: def __init__(self, name): self.name = name deco meth0: staticmethod def meth0(x):
30
by: Ron_Adam | last post by:
I was having some difficulty figuring out just what was going on with decorators. So after a considerable amount of experimenting I was able to take one apart in a way. It required me to take a...
22
by: Ron_Adam | last post by:
Hi, Thanks again for all the helping me understand the details of decorators. I put together a class to create decorators that could make them a lot easier to use. It still has a few glitches...
3
by: Ron_Adam | last post by:
Ok... it's works! :) So what do you think? Look at the last stacked example, it process the preprocess's first in forward order, then does the postprocess's in reverse order. Which might be...
6
by: Michele Simionato | last post by:
could ildg wrote: > I think decorator is a function which return a function, is this right? > e.g. The decorator below if from http://www.python.org/peps/pep-0318.html#id1. > > def...
3
by: arc | last post by:
I have a server object that performs zipcode validation based on zipcode entered in the web form. Ideally this should work as follows: Once the zip code is entered in the edit box it should...
5
by: Doug | last post by:
I am looking at using the decorator pattern to create a rudimentary stored proc generator but am unsure about something. For each class that identifies a part of the stored proc, what if I want to...
11
by: thattommyhallll | last post by:
im plugging away at the problems at http://www.mathschallenge.net/index.php?section=project im trying to use them as a motivator to get into advanced topics in python. one thing that Structure...
4
by: thomas.karolski | last post by:
Hi, I would like to create a Decorator metaclass, which automatically turns a class which inherits from the "Decorator" type into a decorator. A decorator in this case, is simply a class which...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...

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.