string 5 « string « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » string » string 5 

1. rough estimate time it takes to do string comparisons Python    stackoverflow.com

I have a string, call it paragraph that contains about 50-100 words separated by spaces. I have an array of 5500 strings all about 3-5 characters long. ...

2. public string blaBla { get; set; } in python    stackoverflow.com

Consider the following example to understand better my question:

public class ClassName 
{
    public ClassName { }

    public string Val { get; set; }

   ...

3. what does calling a method do?    stackoverflow.com

ok, noob question I had this code

           list = ['random', 'set', 'of', 'strings']
          ...

4. Uninterpreted strings in YAML    stackoverflow.com

Is there a way to have uninterpreted strings within a YAML file? My goal is to have regular expressions that contain certain escape sequences like \w. Currently, Python's YAML ...

5. Issue with 'StringVar' in Python Program    stackoverflow.com

I am trying to write a VERY simple UI in Python using Tkinter. I have run into a small problem with the StringVar class. The thing is, when I ...

6. How can a non-assigned string in Python have an address in memory?    stackoverflow.com

Can someone explain this to me? So I've been playing with the id() command in python and came across this:

>>> id('cat')
5181152
>>> a = 'cat'
>>> b = 'cat'
>>> id(a)
5181152
>>> id(b)
5181152
This makes some ...

7. Python intern for non-strings    stackoverflow.com

Why is Python's intern built-in only for strings? It should be possible to extend intern to classes that are hashable and comparable, right?

8. How to add set elements to a string in python    stackoverflow.com

how would I add set elements to a string in python? I tried:

sett = set(['1', '0'])
elements = ''
for i in sett:
       elements.join(i)
but no dice. when ...

9. How in Python check if two files ( String and file ) have same content?    stackoverflow.com

I am very new to Python and have question. How in Python check if two files ( String and file ) have same content ? I need to download some stuffs ...

10. How create a tempory file from base64 encoded string?    stackoverflow.com

How can I create a file into the temporary files from a encoded string and then execute it?

11. python: how do you concatenate time to a string?    stackoverflow.com

I'm a py newbie and was wondering if there was a simpler way to concatenate time to a string in a write function? here is my code running windows xp ...

12. [python]: how to get the string from the pointer by using ctypes?    stackoverflow.com

Here is the thing, I wrote a program using windows api EnumWindows which requires a callback func as the first arg, my poor code is as follows:

User32 = WinDLL('User32.dll')
LPARAM = wintypes.LPARAM

HWND ...

13. Add a String as an Item to a tableWidget in QT/Python    stackoverflow.com

I have an array with strings and I want to add each string in a different row and the same column of a tableWidget. I'm using the function setItem to change the ...

14. Analog of bash "echo $(cat file)" in python (one more time string interpolation)    stackoverflow.com

I have a file values.txt with hierarchical formatting like this:

group1
      subgroup1
            value1
    ...

15. string comprehension in Python    stackoverflow.com

I am working with images that have multiple layer which are described in their meta data that looks like this..

print layers
Cube1[visible:true, mode:Normal]{r:Cube1.R, g:Cube1.G, b:Cube1.B, a:Cube1.A}, Ground[visible:true, mode:Lighten, opacity:186]{r:Ground.R, g:Ground.G, b:Ground.B, a:Ground.A}, ...

16. Trouble concatenating two strings    stackoverflow.com

I am having trouble concatenating two strings. This is my code:

info = infl.readline()
while True:
    line = infl.readline()
    outfl.write(info + line)
    print info ...

17. What is wrong with this implementation of String interpolation in python*    stackoverflow.com

import re

r = re.compile("#{([^}]*)}")

def I(string):
    def eval_str_match(m):
        return str(eval(m.group(1)))
    return r.sub(eval_str_match,string)
* besides python taste/style/standards
Is there a nicer succinct ...

18. Propery CPython String Concatenation    stackoverflow.com

Last night I was at a Boston Python Meetup that described various Python implementations. Part of the discussion included string concatenation. Apparently for CPython there is less heap fragmentation if ...

19. Plotting values versus strings in matplotlib?    stackoverflow.com

I am trying to create a plot in matplotlib where the x-values are integers and the y-values are strings. Is it possible to plot data of this type in matplotlib? I ...

20. Max size of file python can open?    stackoverflow.com

I opened an 8MB file in python because I wanted to batch change various types of file names. I went through and loaded the file into a string and used the ...

21. Python - how to delete hidden signs from string?    stackoverflow.com

Sometimes I have a strings with strange characters. They are not visible in browser, but are part of the string and are counted in len(). How can I get rid of it? ...

22. ABC for String?    stackoverflow.com

I recently discovered abstract base classes (ABCs) in collections and like their clear, systematic approach and Mixins. Now I also want to create customs strings (*), but I couldn't find an ...

23. How can I measure the width of a string rendering via tkFont without creating a window first?    stackoverflow.com

I can do the measure of text with tkFont, but I don't want a root window --> tk.Tk()

24. Identify folders with a specific string in Python    stackoverflow.com

Simple question here -- all I want to do is identify the folders in a directory which share a specific stub. For example, I would want to isolate all folders ...

25. Python: how to modify/edit the string printed to screen and read it back?    stackoverflow.com

I'd like to print a string to command line / terminal in Windows and then edit / change the string and read it back. Anyone knows how to do it? Thanks

print ...

26. Working with strings in python produces strange quotation marks    stackoverflow.com

currently I am working with scrapy, which is a web crawling framework based on python. The data is extracted from html using XPATH . (I am new to pyton) ...

27. String building: Hiding string length?    stackoverflow.com

I'm modifying python code and I came across this statement and have no idea what it means nor can I find anything on the interent about it. Sorry that its so ...

28. Using Python to break a continuous string into components?    stackoverflow.com

This is similar to what I want to do: breaking a 32-bit number into individual fields This is my typical "string" 00000000110000000000011000000000 I need to break it up into four equal parts: 00000000 11000000 00000110 00000000 I ...

29. How to define a python string (quasi-)constant that has dynamic inputs?    stackoverflow.com

For example:

MY_MESSAGE = 'Dear %s, hello.'
# ...
name = "jj"
print MY_MESSAGE % name
Does python have a feature for accomplishing something like my above code?

30. How to reformat a string in python?    stackoverflow.com

Right now I have a string in the form xxx@yyy.com@zzz.com and I want to strip off the @zzz.com so that it comes out as xxx@yyy.com.

31. Embedding executable python script in python string    stackoverflow.com

If you are a bash/posix sh wizard you will know the $(command substition) feature in bash, which could even be inserted in a string. For example,

$ echo "I can count: ...

32. Python: Deleting specific strings from file    stackoverflow.com

I am reposting after changing a few things with my earlier post. thanks to all who gave suggestions earlier. I still have problems with it. I have a data file (un-structed messy ...

33. python "string" module?    stackoverflow.com

So I'm reading this old module from I think around 2002 and it has this line "import string". Did Python require you to import a string module explicitly before to be ...

34. Selecting folders using strings in Python    stackoverflow.com

Simple question here: I'm trying to identify folders with a specific string in their name, but I want to specify some additional exclusion criteria. Right now, I'm looking for ...

35. Generating all terminal strings in Python with grammar/rules?    stackoverflow.com

I'm trying to generate all terminal strings from a given file up to a certain length. So for instance, if you have something like

A = A B
A = B
B = 0
B ...

36. Python checking file content with string    stackoverflow.com

Hello! I have the following script:

import os
import stat

curDir = os.getcwd()

autorun_signature = [ "[Autorun]",
                   ...

37. String Interpolation in Python    stackoverflow.com

I am trying to interpolate this string correctly:

/test/test?Monetization%20Source=%d&Channel%20Id=%d' % (mid, cid)
I want the the %20 to rendered as is and the %d to serve as place-holderes for the variables mid and ...

38. Create (sane/safe) filename from any (unsafe) string    stackoverflow.com

I want to create a sane/safe filename (i.e. somewhat readable, no "strange" characters, etc.) from some random Unicode string (mich might contain just anything). (It doesn't matter for me wether the function ...

39. Create (sane/safe) app bundle name from any (unsafe) string    stackoverflow.com

Possible Duplicate:
Create (sane/safe) app bundle identifier from any (unsafe) string
I want to create a sane/safe app bundle name (i.e. somewhat readable, no "strange" characters, ...

40. Create (sane/safe) app bundle identifier from any (unsafe) string    stackoverflow.com

I want to create a sane/safe app bundle name (i.e. somewhat readable, no "strange" characters, etc.) from some random Unicode string (mich might contain just anything). (It doesn't matter for me wether ...

41. Using python, how can I write a method to generate typos based on a string?    stackoverflow.com

I could just add in something that creates typos based on Levenshtein distance of 2, or something like that, or reverse-engineer Norvig's article on spellchecking. However I wonder ...

42. Python post build to change an msi name wiht Branding and Version?    stackoverflow.com

Hi I run a Build system for the company i work for... Currently I am using a dictionary function to take the name of the msi that is produced by the builds ...

43. simple string question - the Single quotation marks and Double quotation marks inside the string just make the string into several parts    stackoverflow.com

I need to use a long string for testing regular expression. However, the test string is always altered by the inside quotation marks, which leads to the whole string seperetaed into ...

44. Python readline() from a string?    stackoverflow.com

In python, is there a built-in way to do a readline() on string? I have a large chunk of data and want to strip off just the first couple lines ...

45. Having both single and double quotation in a python string    stackoverflow.com

Hi I'm trying to have a string that contains both single and double quotation in python -- ('"). The reason I need this expression is to use as an input to ...

46. Thrift : TypeError: getaddrinfo() argument 1 must be string or None    stackoverflow.com

Hi I am trying to write a simple thrift server in python (named PythonServer.py) with a single method that returns a string for learning purposes. The server code is below. I ...

47. Using strings as incomplete bits of code in Python    stackoverflow.com

(please help me clarify the title) This is what I'd like to do:

s = "'arg1', 'arg2', foo='bar', baz='qux'"
def m(*args, **kwargs):
  return args, kwargs

args, kwargs = m(magic(s))
# args = ['arg1', 'arg2']
# kwargs ...

48. enumerating all possible strings of length K from an alphabet in Python    stackoverflow.com

Possible Duplicate:
is there any best way to generate all possible three letters keywords
how can I enumerate all strings of length K from an alphabet ...

49. Why is environ['QUERY_STRING'] returning a zero length string?    stackoverflow.com

I found the solution to my (dumb) problem and listed it below. I'm using Python 2.7.1+ on Ubuntu 11.04. The client/server are on the same computer. From the Wing debugger, I know the ...

50. Python simplejson.dumps still returns string    stackoverflow.com

Input : {"id": null, "type": null, "order_for": null, "name": "Name"}
code :
input_map = simplejson.dumps(eval(line))  
print type(input_map)  
returns
<type 'str'>
what is wrong in here? Thank you

51. What does bare strings in the body of a class definition mean?    stackoverflow.com

Here is a snippet of code from django.core.exceptions:

class MiddlewareNotUsed(Exception):
    "This middleware is not used in this server configuration"
    pass
Is the bare string in the body ...

52. Mental block with os.walk - want to process a file not the filename string    stackoverflow.com

Trying to implement a little script to move the older log files out of apache (actually using a simple bash script to do this in 'real life' - this is just ...

53. gettext usage for 2 strings that are the same    stackoverflow.com

Is there a more compact way if I want 2 keys have the same value? This works:

msgid "Next"
msgstr "Pág. seguinte"

msgid "Next page"
msgstr "Pág. seguinte"
I could imagine writing it like this instead ...

54. My python interpreter does not recognize strings    stackoverflow.com

Newbie disclaimer: I am new to Python and just started using IDLE to play around with Python. My problem is the interpreter does not recognize strings, whether enclosed in ¨¨ or ´´. I ...

55. TypeError: 'in ' requires string as left operand, not generator in Python    stackoverflow.com

I'm trying to parse tweets data. My data shape is as follows:

59593936 3061025991 null null <d>2009-08-01 00:00:37</d> <s>&lt;a href="http://help.twitter.com/index.php?pg=kb.page&amp;id=75" rel="nofollow"&gt;txt&lt;/a&gt;</s> <t>honda just recalled 440k accords...traffic around here is gonna be light...win!!</t> ajc8587 ...

56. Error with string module, python os x    stackoverflow.com

I am self-teaching Python from Elkner's How To Think... and have gotten to Chapter 7, strings. I tried to load the string module by typing import string and it seemed to ...

57. Python String to BSTR    stackoverflow.com

I am Using the iTunes COM interface on windows 7. The method iTunes.CurrentTrack.AddArtworkFromFile(path) requires path to be of type BSTR. I understand from some research that BSTR is a C++/Visual Basic data type ...

58. python string to symbolic name    stackoverflow.com

I want to check imported names.
Code:

import fst # empty file fst.py
for s in dir(fst):
    print(s) # got string with symbolic names
Output:
__builtins__
__cached__
__doc__
__file__
__name__
__package__
Now I want to check values ...

59. PyQt returning empty string from a class?    stackoverflow.com

The code is along the lines of this:

class Solver(QDialog):
    def __init__(self, parent=None):
        blabla

    def solver(self):
    ...

60. Determining if a query is in a string    stackoverflow.com

I have a list of query terms, each with a boolean operator associated with them, like, say:

tom OR jerry OR desperate AND dan OR mickey AND mouse
Okay, now I have a ...

61. Importing using string in Python    stackoverflow.com

Short version: Say I have a string str and a file functions.py from which I would like to import a method whose name is stored in str. How do I go about ...

62. KML to string in Python?    stackoverflow.com

I'd like to download a KML file and print a particular element of it as a string in Python. Could anyone give me an example of how to do this? Thanks. ...

63. Populate a Google App Engine app's datastore with 20.000 strings    stackoverflow.com

I'm trying to create and store 20000 random codes in my local datastore, before trying this in appspot... This is the model

class PromotionCode (db.Model):
  code = db.StringProperty(required=True)
And this is the ...

64. Getting doc string of a python file    stackoverflow.com

Is there a way of getting the doc string of a python file if I have only the name of the file ? For instance I have a python file ...

65. python zipfile module with TextIOWrapper    stackoverflow.com

I wrote the following piece of code to read a text file inside of a zipped directory. Since I don't want the output in bytes I added the TextIOWrapper to ...

66. how to check if two strings have intersection in python?    stackoverflow.com

For example, a = "abcdefg", b = "krtol", they have no intersection, c = "hflsfjg", then a and c have intersaction.
What's the easiest way to check this? just need a True ...

67. python: best data structure to use to store strings?    stackoverflow.com

I am planning to break a long document in various strings, and save them as they are (so each string can have different length, i will not break them to strings ...

68. Impossible to set an attribute to a string?    stackoverflow.com

Usually, you can set an arbitrary attribute to a custom object, for instance

----------
>>> a=A()
>>> a.foo=42
>>> a.__dict__
{'foo': 42}
>>> 
----------
On the other hand, you can't do the same binding with a string ...

69. python string good practise: ' vs "    stackoverflow.com

Possible Duplicate:
Single quotes vs. double quotes in Python
I have seen that when i have to work with string in Python both of the following ...

70. python reading strings    stackoverflow.com

Can anyone help me with the following query what is the pythonic way to cleanse the following strings: Lets say I have the word

"abcd   
or
'blahblah
then the words actually are
abcd, blahblah
I ...

71. What is StringIO in python used for in reality?    stackoverflow.com

I am not a pro and I have been scratching my head over understanding what exactly StringIO is used for. I have been looking around the internet for some examples. However, ...

72. Request current route including query strings?    stackoverflow.com

I've been looking in the Pyramid API and haven't been able to find a method that allows me to extract the url in the user's address bar, specifically including the query ...

73. How can I get a value that's inside parentheses in a string in Python?    stackoverflow.com

I've got something like this:

a = '2(3.4)'
b = '12(3.5)'
I only want the value inside the brackets. I used regex, and it worked, but my teacher won't allow it. How can I ...

74. Compressing short English strings in Python?    stackoverflow.com

I would like to fit 80M strings of length < 20 characters in memory and use as little memory as possible. I would like a compression library that I can drive from ...

75. Python string append    stackoverflow.com

I have a python method that takes a list of tuples of the form (string, float) and returns a list of strings that, if combined, would not exceed a certain limit. I ...

76. :: in strings in Python    stackoverflow.com

I've been learning Python and I must say I loved it. But as a new learners I am having some other problems as well: Could you guys tell me whether it is ...

77. Python - Building a string from a loop    stackoverflow.com

I have a set of points that have latitude and longitude values and I am trying to create a string in the following format in order to work with the Gmaps ...

78. person name transformations [with diminutives]    stackoverflow.com

I'm looking for an api/dictionary or any resource that can help me return variants of names I give it. e.g. If i pass "william defoe", it should return "w.defoe", "bill.d", "william.d", ...

79. How do I get the values of a parsed query string in python?    stackoverflow.com

querystring = cgi.parse_qs(decrypted_qs)

self.response.out.write(querystring) #output: {'param2': ['v2'], 'param1': ['v1']}

self.response.out.write(querystring.param2) #AttributeError: 'dict' object has no attribute 'param2'
The original dict: {'param1': 'v1', 'param2': 'v2'} So why isn't the second one working, what's the right way ...

80. Mako, Babel and string interpolation    stackoverflow.com

I'm trying to do something like this: ${_('Hello ${name}, welcome to...', mapping=dict(name='${name}'))} Where _() is my Babel translation function, the first ${name} is string interpolation I'd like to be performed by Babel and ...

81. checking if there is a folder with a name that start with a specific string    stackoverflow.com

I'm writing a python script that is supposed to manage my running files. I want to make sure that the source and target folder exist before I run it and I ...

82. Python trying to write string to file then read string and eval, but something went wrong    stackoverflow.com

I am trying to write a very simple script that would simulate a pocket secretary for my homework, but I have a small issue. I want all my data to be ...

83. unmarshalling Error: For input string: ""    stackoverflow.com

Getting unmarshalling Error: For input string: "" . It probably means that wsdl is unable to unserialize data. But my xml is well formatted. Why is the wsdl service choking on ...

84. passing python strings, through cython, to C    stackoverflow.com

I am trying to write a module with some c and some python parts. I am using cython to bridge the gap. I want to store my (very long) string constants in ...

85. how to check if string is upper, lower or mixed case in python    stackoverflow.com

I want to clasify a list of string in python depending on whether they are upper case lower case or mixed case any short way to do that?

86. how to indent the content of a string in python    stackoverflow.com

i'm using the python cog module to generate c++ boilerplate code, and it is working great so far, but my only concern is that the resulting code, which is ...

87. Python - How to cut a string in Python?    stackoverflow.com

Suppose that I have the following string:

http://www.domain.com/?s=some&two=20
How can I take off what is after & including the & and have this string:
http://www.domain.com/?s=some

88. Python - How to concatenate to a string in a for loop?    stackoverflow.com

I need to "concatenate to a string in a for loop". To explain, I have this list:

list = ['first', 'second', 'other']
And inside a for loop I need to end with this:
endstring ...

89. Python UUID badly formed hexadecimal string    stackoverflow.com

Trying to generate a UUID based on an 6.6 XY coordinate pair and the date. However I am giving the function a 'badly formed hexadecimal UUID string'. Python noob plz help. ...

90. adding to a string without commas    stackoverflow.com

I want to add things to a string without any commas. I have a string URL: http://gdata.youtube.com/feeds/api/standardfeeds/feed_str?max-results=max_result&time=

feed_str = top_rated
max_result = 5
time_str = today
web_str = "http://gdata.youtube.com/feeds/api/standardfeeds/",feed_str, "?max-results=" ,max_result,"&time=" + time_str
it prints ...

91. Python string issue    stackoverflow.com

This is to take text from a file and combine with a string to print to a new file for a combined result

file = open('/home/user/facts', 'r')
result = open('/home/user/result.txt', 'a')
i = 1
for ...

92. QString :: is there some kind of "named place markers" (like in python string) ?    qtcentre.org

QString &QString::replace(const QString &before, const QString &after, Qt::CaseSensitivity cs) { return replace(before.constData(), before.size(), after.constData(), after.size(), cs); } QString &QString::replace(const QChar *before, int blen, const QChar *after, int alen, Qt::CaseSensitivity cs) { if (d->size == 0) { if (blen) return *this; } else { if (cs == Qt::CaseSensitive && before == after && blen == alen) return *this; } if (alen == ...

95. How to Ignore \n when reading in strings?    bytes.com

Hi, I am new to using python. I have a problem. I need to read in strings from a data file and only count those that are explicitly numbers. So I am using the isdigit() method. But the problem is that the data file has multiple strings so the problem is the \n messes my code up. My program only works ...

98. String    bytes.com

99. using a string to call a method    bytes.com

100. Get Strings from Entry Boxes    bytes.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.