Steve,
%x in your string interpolation uses Hex values. If you want decimal you should use %i.
···
On Fri, Jul 25, 2008 at 1:40 PM, Steve Freedenburg stevefreedenburg@charter.net wrote:
On a frame I have two buttons:
‘Add Container’, and ‘Remove Container’.
The events for each button respectively add a button to the frame
or remove a button from the frame.
If there are no buttons to remove the user gets a message dialog
that says “No buttons to remove.”
Pretty straight forward so far. It works, buttons add, and remove
as they should… My problem is small, but ODD. To me atleast.
Here is the event for “Add Button”
def ContAddEvent(self, event):
ContButtonLen = len(self.ContButtons)
x = ContButtonLen + 1
ContButton = {'ButtonNumber':''}
ContButton['ButtonNumber'] = wx.Button(self.ContButtonPanel, -1, 'Container %x'%x)
ContButton['ButtonNumber'].SetToolTipString('Click here to configure this container.')
self.ContButtonPanelSBS.Add(ContButton['ButtonNumber'], 1, wx.EXPAND | wx.ALL, 5)
self.Fit()
self.ContButtons.append(ContButton)
What it’s doing is getting the length of the list for which a dictionary
holds the reference to the button being generated.
takes that length and adds 1 to it, since most people would think it’s
odd to see the first button be named “Container 0”.
So the button says “Container 1”, the next says “Container 2”
and the 9th says “Container 9”. Makes sense?
print len(self.ContButtons) the result is a DECIMAL value.
once I get past 9 in the buttons the label says “Container a”, “Container b”, “Container c”,
“Container d”, 'Container e", 'Container f", and THEN “Container 10”. Which is
HEXIDECIMAL.
So if I make 15th button the button label is “Container f” and the length printed to the
Shell is 15.
So how come this happens? Why is the list length given in Hex, but the print length is Dec?
It’s not really a HUGE deal, I’m sure I can convert from Hex to Dec and what not.
Just something I’m curious about.
Steve
–
Stand Fast,
tjg. [Timothy Grant]
Timothy Grant wrote:
On a frame I have two buttons:
'Add Container', and 'Remove Container'.
The events for each button respectively add a button to the frame
or remove a button from the frame.
If there are no buttons to remove the user gets a message dialog
that says "No buttons to remove."
Pretty straight forward so far. It works, buttons add, and remove
as they should... My problem is small, but ODD. To me atleast.
Here is the event for "Add Button"
def ContAddEvent(self, event):
ContButtonLen = len(self.ContButtons)
x = ContButtonLen + 1
ContButton = {'ButtonNumber':''}
ContButton['ButtonNumber'] =
wx.Button(self.ContButtonPanel, -1, 'Container %x'%x)
ContButton['ButtonNumber'].SetToolTipString('Click here to
configure this container.')
self.ContButtonPanelSBS.Add(ContButton['ButtonNumber'], 1,
wx.EXPAND | wx.ALL, 5)
self.Fit()
self.ContButtons.append(ContButton)
What it's doing is getting the length of the list for which a
dictionary
holds the reference to the button being generated.
takes that length and adds 1 to it, since most people would think it's
odd to see the first button be named "Container 0".
So the button says "Container 1", the next says "Container 2"
and the 9th says "Container 9". Makes sense?
print len(self.ContButtons) the result is a DECIMAL value.
once I get past 9 in the buttons the label says "Container a",
"Container b", "Container c",
"Container d", 'Container e", 'Container f", and THEN "Container
10". Which is
HEXIDECIMAL.
So if I make 15th button the button label is "Container f" and the
length printed to the
Shell is 15.
So how come this happens? Why is the list length given in Hex,
but the print length is Dec?
It's not really a HUGE deal, I'm sure I can convert from Hex to
Dec and what not.
Just something I'm curious about.
Steve
Steve,
%x in your string interpolation uses Hex values. If you want decimal you should use %i.
Actually, "%i" is an integer format, not a decimal.
--
Stand Fast,
tjg. [Timothy Grant]
Mike
···
On Fri, Jul 25, 2008 at 1:40 PM, Steve Freedenburg > <stevefreedenburg@charter.net <mailto:stevefreedenburg@charter.net>> > wrote:
Timothy Grant wrote:
Steve,
%x in your string interpolation uses Hex values. If you want decimal you should use %i.
I've seen that used several times recently, and wondered where it comes from. The % formatting in Python uses C printf, and the format string for integers in printf is and always has been %d, not %i. Some (many) implementations accept %i as a synonym, but the canonical string is %d.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Are not all base 10 integers decimal?
···
On Fri, Jul 25, 2008 at 1:59 PM, Mike Driscoll mike@pythonlibrary.org wrote:
Timothy Grant wrote:
On Fri, Jul 25, 2008 at 1:40 PM, Steve Freedenburg <stevefreedenburg@charter.net mailto:stevefreedenburg@charter.net> wrote:
On a frame I have two buttons:
'Add Container', and 'Remove Container'.
The events for each button respectively add a button to the frame
or remove a button from the frame.
If there are no buttons to remove the user gets a message dialog
that says "No buttons to remove."
Pretty straight forward so far. It works, buttons add, and remove
as they should... My problem is small, but ODD. To me atleast.
Here is the event for "Add Button"
def ContAddEvent(self, event):
ContButtonLen = len(self.ContButtons)
x = ContButtonLen + 1
ContButton = {'ButtonNumber':''}
ContButton['ButtonNumber'] =
wx.Button(self.ContButtonPanel, -1, 'Container %x'%x)
ContButton['ButtonNumber'].SetToolTipString('Click here to
configure this container.')
self.ContButtonPanelSBS.Add(ContButton['ButtonNumber'], 1,
wx.EXPAND | wx.ALL, 5)
self.Fit()
self.ContButtons.append(ContButton)
What it's doing is getting the length of the list for which a
dictionary
holds the reference to the button being generated.
takes that length and adds 1 to it, since most people would think it's
odd to see the first button be named "Container 0".
So the button says "Container 1", the next says "Container 2"
and the 9th says "Container 9". Makes sense? print len(self.ContButtons) the result is a DECIMAL value.
once I get past 9 in the buttons the label says "Container a",
"Container b", "Container c",
"Container d", 'Container e", 'Container f", and THEN "Container
10". Which is
HEXIDECIMAL.
So if I make 15th button the button label is "Container f" and the
length printed to the
Shell is 15.
So how come this happens? Why is the list length given in Hex,
but the print length is Dec?
It's not really a HUGE deal, I'm sure I can convert from Hex to
Dec and what not.
Just something I'm curious about.
Steve
Steve,
%x in your string interpolation uses Hex values. If you want decimal you should use %i.
Actually, “%i” is an integer format, not a decimal.
–
Stand Fast,
tjg. [Timothy Grant]
http://docs.python.org/lib/typesseq-strings.html
I use %i for integer values because my brain requires one less parsing step when reading. The Mnemonic of %i for integer %f for float parses much more quickly than the %d for integer does.
···
On Fri, Jul 25, 2008 at 2:10 PM, Tim Roberts timr@probo.com wrote:
Timothy Grant wrote:
Steve,
%x in your string interpolation uses Hex values. If you want decimal you should use %i.
I’ve seen that used several times recently, and wondered where it comes from. The % formatting in Python uses C printf, and the format string for integers in printf is and always has been %d, not %i. Some (many) implementations accept %i as a synonym, but the canonical string is %d.
–
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
–
Stand Fast,
tjg. [Timothy Grant]
Steve Freedenburg wrote:
Do I have some type of effect on the people here, It's happened
several times already. I ask a question and that spawns more
questions. Let me know when I start treading on someones
feelings or something like that. ...
Like I said, it's fun to watch you work through all of these "aha!" moments. Please rest assured that if YOU have these questions, then there are at least 3 other people who have the exact same questions but are afraid to ask them in public. You are helping the community.
People like me have a disease makes us unable to stop ourselves from answering technical questions, and that inevitably leads to other technical questions, ad infinitum.
In my case, it has proven to be a beneficial disease, because it has earned me the "prestigious" (in some circles) MVP designation from Microsoft, 13 years in a row.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.