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.
... |
Consider the following example to understand better my question:
public class ClassName
{
public ClassName { }
public string Val { get; set; }
...
|
ok, noob question
I had this code
list = ['random', 'set', 'of', 'strings']
...
|
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 ... |
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 ... |
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 ... |
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?
|
|
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 ... |
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 ... |
How can I create a file into the temporary files from a encoded string and then execute it?
|
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 ... |
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 ...
|
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 ... |
I have a file values.txt with hierarchical formatting like this:
group1
subgroup1
value1
...
|
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}, ...
|
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 ...
|
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 ... |
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 ... |
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 ... |
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 ... |
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? ... |
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 ... |
I can do the measure of text with tkFont, but I don't want a root window --> tk.Tk()
|
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 ... |
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 ...
|
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) ... |
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 ... |
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 ... |
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?
|
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.
|
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: ...
|
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 ... |
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 ... |
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 ... |
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 ...
|
Hello! I have the following script:
import os
import stat
curDir = os.getcwd()
autorun_signature = [ "[Autorun]",
...
|
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 ... |
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 ... |
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, ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
(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 ...
|
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 ... |
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 ... |
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
|
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 ... |
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 ... |
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 ... |
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 ... |
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><a href="http://help.twitter.com/index.php?pg=kb.page&id=75" rel="nofollow">txt</a></s> <t>honda just recalled 440k accords...traffic around here is gonna be light...win!!</t> ajc8587 ...
|
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 ... |
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 ... |
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 ... |
The code is along the lines of this:
class Solver(QDialog):
def __init__(self, parent=None):
blabla
def solver(self):
...
|
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 ... |
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 ... |
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. ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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, ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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", ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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?
|
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 ... |
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
|
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 ...
|
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. ... |
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 ... |
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 ...
|
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 == ... |
|
|
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 ... |
|
|
|
|
|