st 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
ndamentally 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
atting style newer then python 2.5?
Yes. The new string formatting 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'H
On 8 Sep, 05:39, Steven D'Aprano
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
On 6 Sep, 09:00, Maggie 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, open('
ed it in quotes first:
>>> unquoted_string = 'hello\\nworld\\x21\\tand\\tgood\\040\\x47ood bye!'
>>> print unquoted_string
hello\nworld\x21\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
kslash as
> its last character.
Tried 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/refere
test.find(item) == True: ...
>
> > would have been 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
gging:
# debug_whatever.py:
import sys
sys.argv[1:] = ['arg1', 'arg2', 'arg3']
import whatever
whatever.main()
/Niklas Norrthon
--
http://mail.python.org/mailman/listinfo/python-list
On 26 Mar, 08:18, Niklas Norrthon 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)
>
for item in coll:
do_more(arg, item)
But that can 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
ocessing.GpDispatch.1')
With this little code snippet in a utility module, I can use python
2.6 with ArcGIS, and I can test my scritps with python 2.4, to ensure
that they run in ArcGIS 9.2 environments.
/Niklas Norrthon
--
http://mail.python.org/mailman/listinfo/python-list
n_section ** n / sqrt5 + 0.5)
>>> fib(501)
225591516161940121919323945317755919750165306733355143970858461525064153963081278412888159063487104942080L
>>> timeit.Timer('fib(501)', 'from __main__ import fib').timeit(1)
1.958083084179e-05
>
> Less than a millisecond, versus millions of years for the OP's algorithm.
> I know which 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
help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.urlopen('http://www.google.com/')
>
>>>
/Niklas Norrthon
--
http://mail.python.org/mailman/listinfo/python-list
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 = findSumOfD
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)
On 9 Juli, 22:25, Michiel Overtoom <[EMAIL PROTECTED]> wrote:
> Paul & Robert wrote...
> > d = ["soep", "reeds", "ook"]
> >print ', '.join(d)
> > soep, reeds, ook
>
> I occasionally have a need for printing lists of items too, but in the form:
> "Butter, Cheese, Nuts and Bolts". The last separator
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 "priva
't bother. IDLE is pretty
good. Emacs even better (unless you hate emacs).
--
Niklas Norrthon
ESRI S-GROUP
--
http://mail.python.org/mailman/listinfo/python-list
rogramming. There is a reason
why this is called cross posting.
/Niklas Norrthon
--
http://mail.python.org/mailman/listinfo/python-list
20 matches
Mail list logo