• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(236855)  |  Call(235990)  |  Derive(865)  |  Import(0)
int(x[, base]) -> integer

Convert a string or number to an integer, if possible.  A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!)  When converting a string, use
the optional base.  It is an error to supply a base when converting a
non-string.  If base is zero, the proper base is guessed based on the
string content.  If the argument is outside the integer range a
long object will be returned instead.

src/p/y/python-application-1.2.5/examples/config.py   python-application(Download)
class Priority(int):
    """A numeric priority level. The keywords High, Normal and Low map to certain numeric values."""
    def __new__(typ, value):
        if isinstance(value, (int, long)):
            return int(value)
        elif isinstance(value, basestring):
            map = {'high': 10, 'normal': 50, 'low': 100}
            try:
                return map.get(value.lower()) or int(value)

src/p/y/pyjamas-0.7/examples/libtest/SetTest.py   Pyjamas(Download)
class HashCountingInt(int):
    'int-like object that counts the number of times __hash__ is called'
    def __init__(self, *args):
        self.hash_count = 0
    def __hash__(self):
        self.hash_count += 1
        return int.__hash__(self)

src/w/3/w3af-HEAD/extlib/pyPdf/pyPdf/generic.py   w3af(Download)
        #    print idnum, generation
        #    print repr(stream.read(40))
        assert r == "R"
        return IndirectObject(int(idnum), int(generation), pdf)
    readFromStream = staticmethod(readFromStream)
 
 
class FloatObject(float, PdfObject):
    def writeToStream(self, stream, encryption_key):
        stream.write(repr(self))
 
 
class NumberObject(int, PdfObject):
                break
            x += tok
            if len(x) == 2:
                txt += chr(int(x, base=16))
                x = ""
        if len(x) == 1:
            x += "0"
        if len(x) == 2:
            txt += chr(int(x, base=16))
                    tok = "\\"
                elif tok.isdigit():
                    tok += stream.read(2)
                    tok = chr(int(tok, base=8))
            txt += tok
        return StringObject(txt)
    readFromStream = staticmethod(readFromStream)

src/o/p/openerp-server-5.0.0-3/bin/report/pyPdf/generic.py   openerp-server(Download)
        r = stream.read(1)
        if r != "R":
            raise utils.PdfReadError("error reading indirect object reference")
        return IndirectObject(int(idnum), int(generation), pdf)
    readFromStream = staticmethod(readFromStream)
 
 
class NumberObject(int, PdfObject):
    def __init__(self, value):
        int.__init__(self, value)
 
    def writeToStream(self, stream, encryption_key):
        stream.write(repr(self))
 
            break
        x += tok
        if len(x) == 2:
            txt += chr(int(x, base=16))
            x = ""
    if len(x) == 1:
        x += "0"
    if len(x) == 2:
        txt += chr(int(x, base=16))
                tok = "\\"
            elif tok.isdigit():
                tok += stream.read(2)
                tok = chr(int(tok, base=8))
            elif tok in "\n\r":
                # This case is  hit when a backslash followed by a line
                # break occurs.  If it's a multi-char EOL, consume the

src/d/o/docsum-HEAD/trunk/bin/pyPdf/generic.py   docsum(Download)
        #    print idnum, generation
        #    print repr(stream.read(40))
        assert r == "R"
        return IndirectObject(int(idnum), int(generation), pdf)
    readFromStream = staticmethod(readFromStream)
 
 
class FloatObject(float, PdfObject):
    def writeToStream(self, stream, encryption_key):
        stream.write(repr(self))
 
 
class NumberObject(int, PdfObject):
                break
            x += tok
            if len(x) == 2:
                txt += chr(int(x, base=16))
                x = ""
        if len(x) == 1:
            x += "0"
        if len(x) == 2:
            txt += chr(int(x, base=16))
                    tok = "\\"
                elif tok.isdigit():
                    tok += stream.read(2)
                    tok = chr(int(tok, base=8))
            txt += tok
        return StringObject(txt)
    readFromStream = staticmethod(readFromStream)

src/p/y/pyPdf-HEAD/pyPdf/generic.py   pyPdf(Download)
        r = stream.read(1)
        if r != "R":
            raise utils.PdfReadError("error reading indirect object reference")
        return IndirectObject(int(idnum), int(generation), pdf)
    readFromStream = staticmethod(readFromStream)
 
 
class NumberObject(int, PdfObject):
    def __init__(self, value):
        int.__init__(value)
 
    def writeToStream(self, stream, encryption_key):
        stream.write(repr(self))
 
            break
        x += tok
        if len(x) == 2:
            txt += chr(int(x, base=16))
            x = ""
    if len(x) == 1:
        x += "0"
    if len(x) == 2:
        txt += chr(int(x, base=16))
                        tok += ntok
                    else:
                        break
                tok = chr(int(tok, base=8))
            elif tok in "\n\r":
                # This case is  hit when a backslash followed by a line
                # break occurs.  If it's a multi-char EOL, consume the

src/d/o/docsum-HEAD/bin/pyPdf/generic.py   docsum(Download)
        #    print idnum, generation
        #    print repr(stream.read(40))
        assert r == "R"
        return IndirectObject(int(idnum), int(generation), pdf)
    readFromStream = staticmethod(readFromStream)
 
 
class FloatObject(float, PdfObject):
    def writeToStream(self, stream, encryption_key):
        stream.write(repr(self))
 
 
class NumberObject(int, PdfObject):
                break
            x += tok
            if len(x) == 2:
                txt += chr(int(x, base=16))
                x = ""
        if len(x) == 1:
            x += "0"
        if len(x) == 2:
            txt += chr(int(x, base=16))
                    tok = "\\"
                elif tok.isdigit():
                    tok += stream.read(2)
                    tok = chr(int(tok, base=8))
            txt += tok
        return StringObject(txt)
    readFromStream = staticmethod(readFromStream)

src/p/y/pycopia-HEAD/core/pycopia/OS/Linux/proc/net/route.py   pycopia(Download)
    def is_up(self):
        return self.Flags & RTF_UP
    is_active = is_up # alias
 
    def is_gateway(self):
        return self.Flags & RTF_GATEWAY
 
    def is_host(self):
        return self.Flags & RTF_HOST
 
    def is_reject(self):
        return self.Flags & RTF_REJECT
 
class RouteFlags(int):
    def __new__(cls, v):
        return int.__new__(cls, int(v, 16))
    def __str__(self):
        return "%04X" %(self,)
 
 
HEADER="Iface   Destination Gateway     Flags   RefCnt  Use Metric  Mask        MTU Window  IRTT"
            [iface, dest, gateway, flags, refcnt, use, metric, mask, 
                mtu, window, irtt] = line.split()
            rt = RouteEntry(iface, 
                    Destination=ntohl(int(dest, 16)), 
                    Gateway=ntohl(int(gateway, 16)),
                    Flags=RouteFlags(flags), 
                    RefCnt=int(refcnt, 16), 
                    Use=int(use, 16), 
                    Metric=int(metric, 16), 
                    Mask=ntohl(int(mask, 16)), 
                    MTU=int(mtu, 16), 
                    Window=int(window, 16), 
                    IRTT=int(irtt, 16))

src/p/y/pycopia-core-1.0/pycopia/OS/Linux/proc/net/route.py   pycopia-core(Download)
    def is_up(self):
        return self.Flags & RTF_UP
    is_active = is_up # alias
 
    def is_gateway(self):
        return self.Flags & RTF_GATEWAY
 
    def is_host(self):
        return self.Flags & RTF_HOST
 
    def is_reject(self):
        return self.Flags & RTF_REJECT
 
class RouteFlags(int):
    def __new__(cls, v):
        return int.__new__(cls, int(v, 16))
    def __str__(self):
        return "%04X" %(self,)
 
 
HEADER="Iface   Destination Gateway     Flags   RefCnt  Use Metric  Mask        MTU Window  IRTT"
            [iface, dest, gateway, flags, refcnt, use, metric, mask, 
                mtu, window, irtt] = line.split()
            rt = RouteEntry(iface, 
                    Destination=ntohl(int(dest, 16)), 
                    Gateway=ntohl(int(gateway, 16)),
                    Flags=RouteFlags(flags), 
                    RefCnt=int(refcnt, 16), 
                    Use=int(use, 16), 
                    Metric=int(metric, 16), 
                    Mask=ntohl(int(mask, 16)), 
                    MTU=int(mtu, 16), 
                    Window=int(window, 16), 
                    IRTT=int(irtt, 16))

src/p/a/parlance-HEAD/v1.4.0/parlance/language.py   parlance(Download)
class _integer_Token(int):
    ''' Core for the Token class, based on an integer.
        Advantages over the tuple-based class:
            - Doesn't confuse string interpolation
            - Slightly faster
        Possible disadvantages:
            - Easier to use improperly in arithmetic
    def __new__(klass, number):
        pos = protocol.max_pos_int
        neg = protocol.max_neg_int
        number = int(number)
        if number < 0: key = number + neg
        else: key = number
        result = IntegerToken.cache.get(key)
    def tokenize(self):
        seconds = int(self)
        if seconds > protocol.max_pos_int:
            result = Message((self.seconds, self.hours))
        else: result = Message(seconds)
        return result
    def __int__(self): return int(self.seconds + 3600*self.hours)
    def __str__(self): return str(Message(self))
    def __repr__(self): return 'Time(%s, %s)' % (self.seconds, self.hours)
    def __cmp__(self, other): return cmp(int(self), other)
def maybe_int(word):
    ''' Converts a string to an int if possible.
        Returns either the int, or the original string.
        >>> [(type(x), x) for x in [maybe_int('-3'), maybe_int('three')]]
        [(<type 'int'>, -3), (<type 'str'>, 'three')]
    '''#'''
    try:    n = int(word)
            if isinstance(key, Token): result = key
            elif self.base: result = self.base.get(key)
            else:
                try: number = int(key)
                except ValueError: result = default
                else:
                    if number < protocol.max_neg_int:
            while piece and (piece[-1] == slash):
                piece = piece[:-1]
                slashes += 1
            piece += slash * int(slashes/2)
 
            if slashes % 2:
                # Odd number: escape the quotation mark
                # Given sepearately, because the error description
                # might be on the same line as the type number.
                pos2 = pos + line[pos:].find('<')
                err_type = int(line[pos+1:pos2], 16)
 
            if err_type:
                match = re.search(r'<a name="([A-Z]\w+)">', line)
                else: old_line = line[line.rfind('>'):].strip()
            elif msg_name:
                if line.find('Message Type =') > 0:
                    type_num = int(re.search(r'Type = (\d+)', line).group(1))
                    self.message_types[msg_name] = type_num
                    msg_name = ''
            elif line.find(' (0x') > 0:
                match = re.search(r'[> ](\w[\w ]+) \((0x\w\w)', line)
                descrip = match.group(1)
                start_cat = int(match.group(2), 16)
                match = re.search(r' (0x\w\w)\)', line)
                if match:
                    last_cat = int(match.group(1), 16)
                    # This must come before the ' 0x' search.
                    match = re.search(r'>([\w -]+) category = (0x\w\w)<', line)
                    if match:
                        last_cat = int(match.group(2), 16)
                        self.token_cats[last_cat] = descrip = match.group(1)
                        self.token_cats[descrip.replace(' ', '_')] = last_cat
                        rep_item = True
                    match = re.search(r'>(\w\w\w) (0x\w\w)', line)
                    if match:
                        name = match.group(1).upper()
                        number = last_cat + int(match.group(2), 16)
                        if rep_item: default_tokens[number] = name
                        else: token_names[number] = name
            elif line.find('M)') > 0:
                match = re.search(r'The (\w+) Message', line)
                if match: msg_name = match.group(1)
            elif line.find('Version ') >= 0:
                match = re.search(r'Version (\d+)', line)
                if match: self.version = int(match.group(1))
                if match: self.version = int(match.group(1))
            elif line.find('Magic Number =') > 0:
                match = re.search(r'Number = (0x\w+)', line)
                if match: self.magic = int(match.group(1), 16)
                else: self.log_debug(1, 'Invalid magic number: ' + line)
        self.base_rep = Representation(token_names, None)
        self.default_rep = Representation(default_tokens, self.base_rep)

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next