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

how to make '.' a string

51
i want to add '.' to another string .However the interpreter does not seem to see '.' as a string but something to do with the instancemethod.Does anyone know how to use a dot as a string.I have tried usind str to convert it i keep getting the same error:
Expand|Select|Wrap|Line Numbers
  1. Traceback<most recent call last>
  2.      File "C:\Python25\CalculatorBlueprint.py",line 194 in handler
  3.                 b=a+d
  4.     TypeError:unsupported operand type(s) for +:'instancemethod' and 'str'
Can anyone help?
Apr 23 '07 #1
8 2058
bartonc
6,596 Expert 4TB
i want to add '.' to another string .However the interpreter does not seem to see '.' as a string but something to do with the instancemethod.Does anyone know how to use a dot as a string.I have tried usind str to convert it i keep getting the same error:
Expand|Select|Wrap|Line Numbers
  1. Traceback<most recent call last>
  2.      File "C:\Python25\CalculatorBlueprint.py",line 194 in handler
  3.                 b=a+d
  4.     TypeError:unsupported operand type(s) for +:'instancemethod' and 'str'
Can anyone help?
Same way as any other character on the keyboard: with quotes
>>> print "Hello world" + "."
Hello world.
>>>
Apr 23 '07 #2
dynamo
51
Same way as any other character on the keyboard: with quotes
>>> print "Hello world" + "."
Hello world.
>>>
Yeah thatt works in idle but doesn't work in my script.
Apr 24 '07 #3
ghostdog74
511 Expert 256MB
Yeah thatt works in idle but doesn't work in my script.
it can't be. pls show your script.
Apr 24 '07 #4
dynamo
51
it can't be. pls show your script.
This is the problematic part of the code:

Expand|Select|Wrap|Line Numbers
  1.  if i==31:
  2.             a=self.txt.GetValue
  3.             d='.'
  4.             b= a+ d
  5.             self.txt.SetValue(b)
I gave the error message earlier.
Apr 25 '07 #5
ghostdog74
511 Expert 256MB
This is the problematic part of the code:

Expand|Select|Wrap|Line Numbers
  1.  if i==31:
  2.             a=self.txt.GetValue
  3.             d='.'
  4.             b= a+ d
  5.             self.txt.SetValue(b)
I gave the error message earlier.
i can guess your problem. I believe when you have a SetValue() method in your class, you will also have GetValue(). BUT, you have assigned 'a' to an instance because you forgot about (). The correct way should be something like
...
a = self.txt.GetValue()
...
the depending on what GetValue() returns (hopefully its a str type), then you can concat with your dot.
Apr 25 '07 #6
dynamo
51
i can guess your problem. I believe when you have a SetValue() method in your class, you will also have GetValue(). BUT, you have assigned 'a' to an instance because you forgot about (). The correct way should be something like
...
a = self.txt.GetValue()
...
the depending on what GetValue() returns (hopefully its a str type), then you can concat with your dot.
Brilliant spot,i don't believe that little error has been holding me back.Thanks.
I have another question though,how you do you open a file with python using another program like microsoft word or internet explorer for html files?Thanks
Apr 26 '07 #7
ghostdog74
511 Expert 256MB
Brilliant spot,i don't believe that little error has been holding me back.Thanks.
I have another question though,how you do you open a file with python using another program like microsoft word or internet explorer for html files?Thanks
if you want to read Word files, you can use Win32 COM. For readling html files, you can use urllib2 or urllib. If you want to simulate a browser, you can use the webbrowser module.
Apr 26 '07 #8
dynamo
51
if you want to read Word files, you can use Win32 COM. For readling html files, you can use urllib2 or urllib. If you want to simulate a browser, you can use the webbrowser module.
Wow,thats powerful.Thanks
Apr 26 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Daniel | last post by:
how to make two references to one string that stay refered to the same string reguardless of the changing value in the string?
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
42
by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
1
by: Robert | last post by:
Vb.Net Make dll that contain one function. Help Please. I would like to call a function from different applications. I think i have to make a dll. I have Visual Basic.net 2003 Standard...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
10
by: Extremest | last post by:
I know there are ways to make this a lot faster. Any newsreader does this in seconds. I don't know how they do it and I am very new to c#. If anyone knows a faster way please let me know. All...
4
by: Kyote | last post by:
I'm trying to persist a list of filenames. I've made a custom collection and a FileName class: 'Class to hold file name information Public Class FileNames Public fullName As String Public...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
18
by: active | last post by:
Console.WriteLine(String.Equals(s, s.Clone.ToString)) s is type string. This returns True. If Clone really made a new copy I'd expect False.
16
by: InDepth | last post by:
Now that .NET is at it's fourth release (3.5 is coming soon), my very humble question to the gurus is: "What have we won with the decision to have string objects immutable? Or did we won?" ...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.