473,288 Members | 1,726 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,288 software developers and data experts.

would this be called bug?

The code is attached below. Basically I am taking a substring of
variable m, and using "buffer" instead of slicing.

However, the application of int on that buffer start correctly from
the offset, but it scans all the way to the end, instead of stopping
at the length of the buffer.

It works however, if I apply str function to output of buffer
function.

-A
(Pdb) m = "AA1234AA"
(Pdb) x = buffer(m, 2, 4)
(Pdb) x
<read-only buffer for 0x2a9d0c18a0, size 4, offset 2 at 0x2a9d0cb7f0>
(Pdb) int(x)
*** ValueError: invalid literal for int() with base 10: '1234AA'
(Pdb) m = "AA1234AA"
(Pdb) m = "AA1234"
(Pdb) x = buffer(m, 2, 4)
(Pdb) int(x)
1234
(Pdb)
Jun 27 '08 #1
2 837
On May 24, 1:33 am, Amit Gupta <emaila...@gmail.comwrote:
The code is attached below. Basically I am taking a substring of
variable m, and using "buffer" instead of slicing.

However, the application of int on that buffer start correctly from
the offset, but it scans all the way to the end, instead of stopping
at the length of the buffer.

It works however, if I apply str function to output of buffer
function.

-A

(Pdb) m = "AA1234AA"
(Pdb) x = buffer(m, 2, 4)
(Pdb) x
<read-only buffer for 0x2a9d0c18a0, size 4, offset 2 at 0x2a9d0cb7f0>
(Pdb) int(x)
*** ValueError: invalid literal for int() with base 10: '1234AA'
(Pdb) m = "AA1234AA"
(Pdb) m = "AA1234"
(Pdb) x = buffer(m, 2, 4)
(Pdb) int(x)
1234
(Pdb)
Interestingly, if I try:

int(x, 10)

I get:

Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
int(x, 10)
TypeError: int() can't convert non-string with explicit base

Perhaps int(x) should also be complaining that x isn't a string.
Jun 27 '08 #2

"Amit Gupta" <em*******@gmail.comwrote in message
news:ab**********************************@u36g2000 prf.googlegroups.com...
| The code is attached below. Basically I am taking a substring of
| variable m, and using "buffer" instead of slicing.
|
| However, the application of int on that buffer start correctly from
| the offset, but it scans all the way to the end, instead of stopping
| at the length of the buffer.
|
| It works however, if I apply str function to output of buffer
| function.
|
| -A
|
|
| (Pdb) m = "AA1234AA"
| (Pdb) x = buffer(m, 2, 4)
| (Pdb) x
| <read-only buffer for 0x2a9d0c18a0, size 4, offset 2 at 0x2a9d0cb7f0>
| (Pdb) int(x)
| *** ValueError: invalid literal for int() with base 10: '1234AA'
| (Pdb) m = "AA1234AA"
| (Pdb) m = "AA1234"
| (Pdb) x = buffer(m, 2, 4)
| (Pdb) int(x)
| 1234
| (Pdb)

Just so you know, buffer() has been deprecated in 2.x and has been replaced
in Py3 by memoryview() (I believe) because others have had problems with
buffer().
Don't know any more.

Jun 27 '08 #3

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

Similar topics

26
by: Oplec | last post by:
Hi, I am learning standard C++ as a hobby. The C++ Programming Language : Special Edition has been the principal source for my information. I read the entirety of the book and concluded that I...
4
by: MS | last post by:
I'm strictly an amteur. Self taught via the help files. Here is an example of a DB I've done. It is quite simple to some of the ones I do for my workplace, but it is an example of the way i work....
5
by: scorpion53061 | last post by:
I would like your thoughts and impressions of the events of today and ask how you would handle this or if I am wrong and this is "normal" behaviour for a web provider and IIS. I am normally a...
4
by: scorpion53061 | last post by:
I would like your thoughts and impressions of the events of today and ask how you would handle this or if I am wrong and this is "normal" behaviour for a web provider and IIS. I am normally a...
5
by: MLH | last post by:
Access 97 does not provide a means of reading the most recent setting for SetWarnings Method. For example, if you had CBF that called a procedure in a global module and the following statement was...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.