Search Results

Search found 30575 results on 1223 pages for 'number systems'.

Page 73/1223 | < Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >

  • Restrict a number to upper/lower bounds?

    - by Amy
    Is there a built-in way or a more elegant way of restricting a number num to upper/lower bounds in Ruby or in Rails? e.g. something like: def number_bounded (num, lower_bound, upper_bound) return lower_bound if num < lower_bound return upper_bound if num > upper_bound num end

    Read the article

  • urllib open - how to control the number of retries

    - by user1641071
    how can i control the number of retries of the "opener.open"? for example, in the following code, it will send about 6 "GET" HTTP requests (i saw it in the Wireshark sniffer) before it goes to the " except urllib.error.URLError" success/no-success lines. password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm() password_mgr.add_password(None,url, username, password) handler = urllib.request.HTTPBasicAuthHandler(password_mgr) opener = urllib.request.build_opener(handler) try: resp = opener.open(url,None,1) except urllib.error.URLError as e: print ("no success") else: print ("success!")

    Read the article

  • Add a + sign to a +ve number in PHP

    - by user318466
    I need to design a function to return -ve numbers unchanged but should add a + sign at the start of the number if its alreay no present. Example: Input Output ---------------- +1 +1 1 +1 -1 -1 It will get only numeric input. function formatNum($num) { # something here..perhaps a regex? } This function is going to be called several times in echo/print so the quicker the better.

    Read the article

  • Dojo treemodel- adding large number of items

    - by Ashley
    I am trying to add a large number of items (100+) to my tree via ForestStoreModel by calling newItem in a loop. This seems to be quite slow and locks up the browser. Is there any way I can do something similar to grid's beginUpdate & endUpdate? I want to basically 'turn off' my tree, add 100 items in a batch, then 'turn on' my tree. Any ideas? Thanks!

    Read the article

  • How can I find the number of highlighted chunks of text in an MS Word Document

    - by Majid
    Hi all, I am writing a macro in MS Word which should find all highlighted text in a document and perform some action on each. I am planning a loop to do the search and manipulation part and have no problem with this part of the code. But I don't know how to find how many iterations I'm going to need. Is there a vay to determine the number of highlights in VBA? Many thanks in advance.

    Read the article

  • factory class, wrong number of arguments being passed to subclass constructor

    - by Hugh Bothwell
    I was looking at Python: Exception in the separated module works wrong which uses a multi-purpose GnuLibError class to 'stand in' for a variety of different errors. Each sub-error has its own ID number and error format string. I figured it would be better written as a hierarchy of Exception classes, and set out to do so: class GNULibError(Exception): sub_exceptions = 0 # patched with dict of subclasses once subclasses are created err_num = 0 err_format = None def __new__(cls, *args): print("new {}".format(cls)) # DEBUG if len(args) and args[0] in GNULibError.sub_exceptions: print(" factory -> {} {}".format(GNULibError.sub_exceptions[args[0]], args[1:])) # DEBUG return super(GNULibError, cls).__new__(GNULibError.sub_exceptions[args[0]], *(args[1:])) else: print(" plain {} {}".format(cls, args)) # DEBUG return super(GNULibError, cls).__new__(cls, *args) def __init__(self, *args): cls = type(self) print("init {} {}".format(cls, args)) # DEBUG self.args = args if cls.err_format is None: self.message = str(args) else: self.message = "[GNU Error {}] ".format(cls.err_num) + cls.err_format.format(*args) def __str__(self): return self.message def __repr__(self): return '{}{}'.format(type(self).__name__, self.args) class GNULibError_Directory(GNULibError): err_num = 1 err_format = "destination directory does not exist: {}" class GNULibError_Config(GNULibError): err_num = 2 err_format = "configure file does not exist: {}" class GNULibError_Module(GNULibError): err_num = 3 err_format = "selected module does not exist: {}" class GNULibError_Cache(GNULibError): err_num = 4 err_format = "{} is expected to contain gl_M4_BASE({})" class GNULibError_Sourcebase(GNULibError): err_num = 5 err_format = "missing sourcebase argument: {}" class GNULibError_Docbase(GNULibError): err_num = 6 err_format = "missing docbase argument: {}" class GNULibError_Testbase(GNULibError): err_num = 7 err_format = "missing testsbase argument: {}" class GNULibError_Libname(GNULibError): err_num = 8 err_format = "missing libname argument: {}" # patch master class with subclass reference # (TO DO: auto-detect all available subclasses instead of hardcoding them) GNULibError.sub_exceptions = { 1: GNULibError_Directory, 2: GNULibError_Config, 3: GNULibError_Module, 4: GNULibError_Cache, 5: GNULibError_Sourcebase, 6: GNULibError_Docbase, 7: GNULibError_Testbase, 8: GNULibError_Libname } This starts out with GNULibError as a factory class - if you call it with an error number belonging to a recognized subclass, it returns an object belonging to that subclass, otherwise it returns itself as a default error type. Based on this code, the following should be exactly equivalent (but aren't): e = GNULibError(3, 'missing.lib') f = GNULibError_Module('missing.lib') print e # -> '[GNU Error 3] selected module does not exist: 3' print f # -> '[GNU Error 3] selected module does not exist: missing.lib' I added some strategic print statements, and the error seems to be in GNULibError.__new__: >>> e = GNULibError(3, 'missing.lib') new <class '__main__.GNULibError'> factory -> <class '__main__.GNULibError_Module'> ('missing.lib',) # good... init <class '__main__.GNULibError_Module'> (3, 'missing.lib') # NO! ^ why? I call the subclass constructor as subclass.__new__(*args[1:]) - this should drop the 3, the subclass type ID - and yet its __init__ is still getting the 3 anyway! How can I trim the argument list that gets passed to subclass.__init__?

    Read the article

  • Consolidate information held in a number of SQL Server Express Instances

    - by user321271
    Hi, I'm trying to determine the best architecture for creating an oData web service for information held in a number of SQL Server Express instances. The web service should provide a consolidated view of the data. All the SQL Server Express instances have the same DB schema. I was initially planning to use SQL server replication however as I understand it, SQL Server 2008 Express cannot be used as a publisher. Any help or suggestions would be appreciated.

    Read the article

  • Find closest number in range?

    - by Chris
    What is the best way to find the closes value in a range... for example i have an array with 0, 90, 180, 270, 360.. And a number 46... What is the best way to find 90 in the array? (in actipnscript 3)

    Read the article

  • MySQL One to Many order by number found in joined table

    - by Finbarr
    Two tables: table_a ------- table_a_id: (primary, int) table_b ------- table_a_id: (index, int, from table_a) table_b_value: (varchar) A one to many relationship between table_a_id and table_b_value. Given a query like this: SELECT DISTINCT(table_a_id) FROM table_a JOIN table_b ON table_a.table_a_id=table_b.table_a_id I want to order by the number of occurrences of table_a_id in table_b. I'm not really sure how to write this in MySQL.

    Read the article

  • [Qt] Check octal number

    - by sterh
    Hello, I write simple application in C++/Qt. And i have a text and some octal number in it. My app splits this text by spaces. And i need to check octal numbers from text. How can i select octal numbers from this text with regular expressions? Thank you.

    Read the article

  • Start a list from a certain number

    - by Colin
    What's the best way to get a ul to start from 'x'? The start tag is depricated and everything I have found on Google has used the :before pseudo class which doesn't work in IE6 or 7. Didn't have much luck when searching stack either. Only thing I can think of is manually go through and number the lists myself and style accordingly? Any help appreciated.

    Read the article

  • python count number of times the date has appeared

    - by Rajeev
    From the following array,how to count the dates for the number of times it has occured in the array.The output should be in the following format [date,count] new_dates = [['2012-12-02', 14],['2012-12-03',2],....] Input: dates = [['2012-12-02', 17], ['2012-12-01', 5], ['2012-12-02', 15], ['2012-12-02', 8], ['2012-12-02', 17], ['2012-12-02', 15], ['2012-12-11', 6], ['2012-12-02', 1], ['2012-12-02', 9], ['2012-12-02', 11], ['2012-12-03', 13], ['2012-12-03', 10], ['2012-12-02', 18], ['2012-12-02', 11], ['2012-12-02', 12], ['2012-12-05', 14], ['2012-12-02', 3], ['2012-12-02', 6], ['2012-12-06', 10], ['2012-12-07', 0], ['2012-12-08', 3], ['2012-12-09', 12], ['2012-12-02', 6]]

    Read the article

  • Variable number of arguments in VB

    - by Kratz
    How to create a function with variable number of arguments in visual basic? ex. x = Sum(1,2,3) y = Sum(1,2) Function Sum('how to declare argument here') 'Is there any special argument manipulation inside function before it is usable? End Function

    Read the article

< Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >