Hey everyone,
Is there a standard way to associate version string with a python package in such way that I could do the following?
import foo
print foo.version
I would imagine there's some way to retrieve that data without any extra hardcoding, since minor/major strings are specified in setup.py already. Alternative solution that I f...
I'm coming to learn Perl from a Python background where the following hash-to-string conversion is built in to the language:
>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> str(d)
"{'a': 1, 'c': 3, 'b': 2}"
Is there a builtin and/or module that has a subroutine with output along the lines of:
"('a' => 1, 'b' => 2, 'c' => 3)"
Strangely, a web ...
Hello. I want to print a list to screen in a readable way. I use a loop to go through each element and make a new list which is formatted with commas and newlines. The problem is that in the first line of the output, I want a title. E.g., I want to print something like this:
List: red, green, blue, black, cars,
busses, ...
The p...
I've got a JSP page with a piece of Javascript validation code which limits to a certain amount of characters on submit. I'm using a <textarea> so I can't simply use a length attribute like in a <input type="text">.
I use document.getElementById("text").value.length to get the string length. I'm running Firefox 3.0 on Windows (but I've ...
I think you can guess the problem I'm having. I'm inserting filenames in to an sql database in C++ Builder. Some files have an apostrophe in their name. This breaks the sql insert query. the usual way to fix this is to double up and apostrophes you want to be part of the field value.
For example if I want to add 'george's' to field ...
I've read on articles and books that the use of String s = new String("..."); should be avoided pretty much all the time. I understand why that is, but is there any use for using the String(String) constructor whatsoever? I don't think there is, and don't see any evidence otherwise, but I'm wondering if anyone in the SO commmunity know...
I am getting a string hash like this:
string content = "a very long string";
int contentHash = content.GetHashCode();
I am then storing the hash into a dictionary as key mapping to another ID. This is useful so I don't have to compare big strings during default dictionary hash computation but I can just fish the ID from the dictionary...
Hi,
I tried everything possible, but still failed. I thought I got it at the point which I'll post
as my final attempt, but still isn't good [enough].
A script is being passed three arguments. Domain name, username and password.
But the probles is that I need domain separated in "domain" + ".com" format. Two variables.
I tried to split...
I'm using a string builder to build some SQL Scripts. I have a few Boolean Properties that I would like to test and then output different text based on true/false. I've you the C# syntax below when assigning a value to a variable, but it isn't working for this particular situation. Any ideas?
What I'm used to doing:
string someText ...
If I have a string such as
"17:31:51 up 134 days, 11:26, 1 user, load average: 0.22, 0.15, 0.10"
what is the best way to extract just the x3 load average values at the end? I have written a regexp that does this but is this the most efficient / fastest method?
>>> s = "17:31:51 up 134 days, 11:26, 1 user, load average: 0.22, 0.15,...
I am a little confused by the following C code snippets:
printf("Peter string is %d bytes\n", sizeof("Peter")); // Peter string is 6 bytes
This tells me that when C compiles a string in double quotes, it will automatically add an extra byte for the null terminator.
printf("Hello '%s'\n", "Peter");
The printf function knows when to ...
How do I convert a string to a byte array in .NET (C#)?
Update: Also please explain why encoding should be taken into consideration. Can't I simply get what bytes the string has been stored in? Why this dependency on encoding?!!!
...
I've been tinkering with small functions on my own time, trying to find ways to refactor them (I recently read Martin Fowler's book Refactoring: Improving the Design of Existing Code). I found the following function MakeNiceString() while updating another part of the codebase near it, and it looked like a good candidate to mess with. A...
This may be a bit of a nooby question, I have been trying to get better at ruby recently, and started reading the fantastic The Ruby Programming Language. Something that was mentioned is that string literals are considered mutable, so in a loop it is better to use a variable then a literal, as a new string will get instantiated at every ...
I am doing a CSV Import tool for the project I'm working on.
The client needs to be able to enter the data in excel, export them as CSV and upload them to the database.
For example I have this CSV record:
1, John Doe, ACME Comapny (the typo is on purpose)
Of course, the companies are kept in a separate table and linked with...
I'm looking to determine whether a string value from a user input (UITextField) is "blank" if it's not nil. Checking if [textField.text isEqualToString:""] isn't quite enough because I want to avoid any blank/whitespace input (like say a few space characters).
There does seem to be an indication of a good solution for my particular pro...
Has anyone ever seen an issue with an ASP.NET websuite blows up on initial login, complaining about a system.string type in the profile that is defined in the web.config.
More Info:
Server Error in '/abc' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An ...
System.Configuration.ConfigurationErrorsException: Attempting to load this property's type resulted in the following error: Could not load type 'System.String'. (D:\Inetpub\wwwroot\driverseat\web.config line 223)
---> System.Web.HttpException: Could not load type 'System.String'.
at System.Web.Compilation.BuildManager.GetType(String typ...
Hi.
How do you think is really necessary to provide IFormatProvider in method String.Format(string, object) ?
Is it better to write full variant String.Format(CultureInfo.CurrentCulture, "String is {0}", str) or just String.Format("String is {0}", str) ?
...
There are a lot of articles around the web concerning python performance, the first thing you read: concatenating strings should not be done using '+': avoid s1+s2+s3, instead use str.join
I tried the following: concatenating two strings as part of a directory path: three approaches:
'+' which i should not do
str.join
os.path.join
H...