Re: how to write a unicode string to a file ?

2009-10-16 Thread Niklas Norrthon
post are valuable insights. I have made a gnote of it! \d Here is a link to a page that explains unicode and encodings in a way that made me think I understand some of it: http://www.joelonsoftware.com/articles/Unicode.html /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: Are min() and max() thread-safe?

2009-09-16 Thread Niklas Norrthon
fundamentally silly by having them walk over the same list simultaneously? For one time sequences like files and generators your code is broken for obvious reasons. /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I format unicode strings?

2009-09-09 Thread Niklas Norrthon
appeared in python 2.6. Perhaps there is some __future__ stuff you can import to get it to work, don't know. If not you are stuck with the old string formatting until you upgrade to 2.6 or newer: print u'Hello %s!' % u'world' Hello world! /Niklas Norrthon -- http://mail.python.org/mailman

Re: simple string question

2009-09-08 Thread Niklas Norrthon
On 8 Sep, 05:39, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Mon, 07 Sep 2009 01:54:09 -0700, Niklas Norrthon wrote: Others have answered how to replace '\\n' with '\n'. For a more general approach which will handle all string escape sequences allowed in python

Re: simple string question

2009-09-07 Thread Niklas Norrthon
\tAnd\tgood\040\x47ood bye! print eval('str(%s)' % unquoted_string) hello world! And good Good bye! /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner's python help

2009-09-07 Thread Niklas Norrthon
On 6 Sep, 09:00, Maggie la.f...@gmail.com wrote: code practice: test = open (test.txt, r) readData = test.readlines() #set up a sum sum = 0; for item in readData:         sum += int(item) print sum test file looks something like this: 34 23 124 432 12 sum(map(int,

Re: Can I get a technical explanation on the following error

2009-05-25 Thread Niklas Norrthon
it: r'test \' SyntaxError: EOL while scanning string literal r'test \\' 'test ' Second one is accepted. See the language reference section 2.4.1 as of why; http://www.python.org/doc/current/reference/lexical_analysis.html?highlight=raw%20strings#string-literals /Niklas Norrthon -- http

Re: Why does Python show the whole array?

2009-04-09 Thread Niklas Norrthon
better? Clearly, any comparison with a boolean literal should be illegal.  ;) So you think truth_value = True if test.find(item) == truth_value: ... would have been better? :-) (couldn't resist...) /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: Unix programmers and Idle

2009-03-31 Thread Niklas Norrthon
:] = ['arg1', 'arg2', 'arg3'] import whatever whatever.main() /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: What way is the best to check an empty list?

2009-03-26 Thread Niklas Norrthon
easily be achieved with the or operator as Michiel Overton notes elsewhere in this thread: def some_function(arg, coll=None): do_stuff(arg) for item in coll or []: # = Here or is used to make None behave as an empty collection do_more(arg, item) /Niklas Norrthon -- http

Re: What way is the best to check an empty list?

2009-03-26 Thread Niklas Norrthon
On 26 Mar, 08:18, Niklas Norrthon niklas.norrt...@hotmail.com wrote: But that can easily be achieved with the or operator as Michiel Overton notes elsewhere in this thread: Michiel Overtoom was what I meant to write. My apologies! def some_function(arg, coll=None):     do_stuff(arg

Re: PythonWin -vs- Idle

2009-02-26 Thread Niklas Norrthon
with python 2.4, to ensure that they run in ArcGIS 9.2 environments. /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: can multi-core improve single funciton?

2009-02-10 Thread Niklas Norrthon
I would choose. Faster hardware can only go so far in hiding the effect of poor algorithms. I agree 100% /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib.urlopen fails in Emacs

2008-09-26 Thread Niklas Norrthon
._fileobject object at 0x00BF4030 /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list

Re: concatenate the elements in each list of a list of lists

2008-07-23 Thread Niklas Norrthon
On 23 Juli, 17:33, antar2 [EMAIL PROTECTED] wrote: I already asked a similar question, but encounter problems with python... How can I concatenate the elements in each list of a list of lists list_of_listsA = [['klas*', '*', '*'], ['mooi*', '*', '*', '*'], ['arm*', '*', '*(haar)']]

Re: Request Help Debugging Program

2008-07-23 Thread Niklas Norrthon
On 24 Juli, 00:30, Samir [EMAIL PROTECTED] wrote: from math import sqrt def findSumOfDivisor(n): [...]     return sum(divisor)                # return the sum of the divisors for i in range(2,10):                  # loop through integers 2 through 9 [...]         sum = findSumOfDivisor(i)

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Niklas Norrthon
On 6 Juni, 03:09, Russ P. [EMAIL PROTECTED] wrote: On Jun 5, 2:57 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Russ P. [EMAIL PROTECTED] writes: By the way, my recollection is that in C++ access defaults to private if nothing is declared explicity. So normally the private declaration is

Re: Pythonwin

2008-05-09 Thread Niklas Norrthon
better (unless you hate emacs). -- Niklas Norrthon ESRI S-GROUP -- http://mail.python.org/mailman/listinfo/python-list

Re: a Haskell a Day

2005-10-27 Thread Niklas Norrthon
this is called cross posting. /Niklas Norrthon -- http://mail.python.org/mailman/listinfo/python-list