[issue29657] os.symlink: FileExistsError shows wrong message

2017-02-26 Thread Wolfgang Rohdewald

New submission from Wolfgang Rohdewald:

execute the attached script. It should return

FileExistsError: [Errno 17] File exists: 'a_link' -> 'a'

but it returns

FileExistsError: [Errno 17] File exists: 'a' -> 'a_link'

--
components: Library (Lib)
files: x.py
messages: 288591
nosy: wrohdewald
priority: normal
severity: normal
status: open
title: os.symlink: FileExistsError shows wrong message
versions: Python 3.5
Added file: http://bugs.python.org/file46671/x.py

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29657>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29551] unittest: TestSuite.debug() does not like subTest()

2017-02-13 Thread Wolfgang Rohdewald

New submission from Wolfgang Rohdewald:

the main code is appended in main.py

if a test uses with self.subTest(), subTest() fails right in its first 
statement "if not self._outcome ..." because _outcome is None.

In main.py, the commented runner.run(suite) would work correctly.

If this is not meant to work, please mention it in the documentation and  
improve unittest's reaction.

what I would find more logical from the users's point of view is something like

runner.debug(suite)

--
components: Library (Lib)
files: main.py
messages: 287738
nosy: wrohdewald
priority: normal
severity: normal
status: open
title: unittest: TestSuite.debug() does not like subTest()
type: crash
versions: Python 3.5
Added file: http://bugs.python.org/file46637/main.py

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29551>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27742] Random.randint generates different values in Python2 and Python3

2016-08-12 Thread Wolfgang Rohdewald

Wolfgang Rohdewald added the comment:

@SilentGhost: Sorry, I did not see the latest messages, I was referring to 
msg272511

Having to re-implement everything but rnd.random is not very user friendly. I 
will do that now for my project.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27742>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27742] Random.seed(5, version=1) generates different values in PYthon2 and Python3

2016-08-12 Thread Wolfgang Rohdewald

Wolfgang Rohdewald added the comment:

There seems to be more to it, _randbelow already returns different values. 

And _randbelow is used by other user helpers like randrange, choice, select, 
shuffle, sample

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27742>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27742] Random.seed(5, version=1) generates different values in PYthon2 and Python3

2016-08-12 Thread Wolfgang Rohdewald

New submission from Wolfgang Rohdewald:

The documentation promises backwards compatible seeders. I understand this as 
such that they generate the same random sequences. But for Python 2.7.12 and 
3.5.2 this is not so, even if I pass an integer as seed value. The attached 
script returns different values.

Maybe I misunderstand the documentation - I believe it means that 
seed(version=1) uses the backwards compatible seeder, but it does not say so 
explicitly. If that is not so, the documentation does not say how to invoke the 
backwards compatible seeder.

--
components: Library (Lib)
files: r.py
messages: 272506
nosy: wrohdewald
priority: normal
severity: normal
status: open
title: Random.seed(5, version=1) generates different values in PYthon2 and 
Python3
versions: Python 2.7, Python 3.5
Added file: http://bugs.python.org/file44082/r.py

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27742>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22746] cgitb html: wrong encoding for utf-8

2014-10-28 Thread Wolfgang Rohdewald

Wolfgang Rohdewald added the comment:

 What about
  open(..., encoding='latin-1', errors='xmlcharrefreplace')

That works fine. I tested with a chinese character 与

But I do not think the application should work around something that cgitb is 
supposed to handle. More so since the documentation is dead silent about this. 
You need to use codecs.open instead of open and add those kw arguments. As long 
as this is not explained in the documentation, I guess it is a bug for everyone 
not using latin-1.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22746
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22746] cgitb html: wrong encoding for utf-8

2014-10-28 Thread Wolfgang Rohdewald

Wolfgang Rohdewald added the comment:

correction: A bug for everyone using non-ascii characters.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22746
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22746] cgitb html: wrong encoding for utf-8

2014-10-28 Thread Wolfgang Rohdewald

Wolfgang Rohdewald added the comment:

  You need to use codecs.open instead of open
 No, why? in python3 open() supports the errors handler.

right, but not in python2 which has the same problem. I need my code to run 
with both.

 Do you have a use case for xmlcharrefreplace in the HTML context?

No, my only use case is the local file.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22746
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22745] cgitb with Py3: TypeError: 'str' does not support the buffer interface

2014-10-27 Thread Wolfgang Rohdewald

New submission from Wolfgang Rohdewald:

The attached script works with Python2.7. With Python3.4, it produces

Traceback (most recent call last):
  File /usr/lib/python3.4/cgitb.py, line 268, in __call__
self.handle((etype, evalue, etb))
  File cgibug.py, line 12, in handle
cgitb.Hook.handle(self, info)
  File /usr/lib/python3.4/cgitb.py, line 273, in handle
self.file.write(reset())
TypeError: 'str' does not support the buffer interface

When replacing the file mode 'wb' with 'w', it produces this failure:
  File /usr/lib/python3.4/cgitb.py, line 288, in handle
self.file.write(doc + '\n')
TypeError: can't concat bytes to str

The script works as expected with Python2.7 with both file modes.

--
components: Library (Lib)
files: cgibug.py
messages: 230083
nosy: wrohdewald
priority: normal
severity: normal
status: open
title: cgitb with Py3: TypeError: 'str' does not support the buffer interface
type: crash
versions: Python 3.4
Added file: http://bugs.python.org/file37043/cgibug.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22745
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22746] cgitb html: wrong encoding for utf-8

2014-10-27 Thread Wolfgang Rohdewald

New submission from Wolfgang Rohdewald:

The attached script shows the non-ascii characters wrong wherever they occur, 
including the exception message and the comment in the source code.

Looking at the produced .html, I can say that cgitb simply passes the single 
byte utf-8 codes without encoding them as needed.

Same happens with Python3.4 (after applying some quick and dirty changes to 
cgitb.py, see bug #22745).

--
components: Library (Lib)
files: cgibug.py
messages: 230085
nosy: wrohdewald
priority: normal
severity: normal
status: open
title: cgitb html: wrong encoding for utf-8
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file37044/cgibug.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22746
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22746] cgitb html: wrong encoding for utf-8

2014-10-27 Thread Wolfgang Rohdewald

Wolfgang Rohdewald added the comment:

If you cannot offer a solution for arbitrary unicode, you have no solution at 
all. Afer all, that is what unicode is about: support ALL languages, not only 
your own.

I do not quite understand why you think this is not a bug.

If cgitb encodes unicode like  x e 4 ; (remove spaces), the browser does not 
have to guess the encoding, it will always show the correct character. This 
works for all of unicode. See 
https://en.wikipedia.org/wiki/Unicode_and_HTML#Numeric_character_references

So this bug is fixable, I am reopening it.

For Python3, the fix is actually very simple: Do not write doc but 
str(doc.encode('ascii', 'xmlcharrefreplace')), like in the attached patch. This 
patch works for me but there might be yet uncovered code paths. And my source 
file is encoded in utf-8, other source file encodings should be tested too. I 
do not know if cgitb correctly honors the source file header like # -*- coding: 
utf-8 -*-

Fixing this for Python2 is certainly doable too but perhaps more difficult 
because a Python2 str() may have an unknown encoding.

--
keywords: +patch
resolution: not a bug - 
status: closed - open
Added file: http://bugs.python.org/file37047/22746.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22746
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22746] cgitb html: wrong encoding for utf-8

2014-10-27 Thread Wolfgang Rohdewald

Changes by Wolfgang Rohdewald wolfg...@rohdewald.de:


--
resolution:  - remind

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22746
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22745] cgitb with Py3: TypeError: 'str' does not support the buffer interface

2014-10-27 Thread Wolfgang Rohdewald

Wolfgang Rohdewald added the comment:

This now works with mode 'w' and after reinstalling the packages. My Python is 
3.4.0 (ubuntu).

--
resolution:  - not a bug
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22745
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



QVariant.toPyObject()

2012-07-20 Thread Wolfgang Rohdewald
toPyObject() is mentioned but undocumented at
http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qvariant.html#toPyObject

without it being documented, I find it a bit surprising that toPyObject()
can return a QString.

Of course QString is a python object but then QVariant is too.


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with a large file

2011-09-12 Thread Wolfgang Rohdewald
On Montag 12 September 2011, Rita wrote:
 I have a large file, 18gb uncompressed, and I would like to
 know what is the preferred method to read this file for
 random access. I have several processes reading the file
 which different calculate arguments. My server has 64gb of
 memory. Not sure what is the preferred way to do this?

if the data is structured, you could store it in 
something like sqlite

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strang thing:

2011-09-06 Thread Wolfgang Rohdewald
On Dienstag 06 September 2011, 守株待兔 wrote:
 (date,open,high,low,close,vol,adjclose) = (row[0],
 row[1], row[2], row[3],row[4], row[5], row[6]) print  
 row[0], row[1], row[2], row[3],row[4], row[5], row[6]
 
 
 the wrong  output is :
 file = open(filename,'r')
 TypeError: 'str' object is not callable

you reassigned open to be a string

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: removing nested iffs

2011-07-29 Thread Wolfgang Rohdewald
On Freitag 29 Juli 2011, Josh Benner wrote:
 if args.build not None:

which python version understands this?

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun and games with lambda

2011-06-17 Thread Wolfgang Rohdewald
On Freitag 17 Juni 2011, Steven D'Aprano wrote:
 run this one-
 liner and wonder no more...

looks like something dangerous to me. What does
it do? rm -rf ?

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters (take two)

2011-05-31 Thread Wolfgang Rohdewald
On Dienstag 31 Mai 2011, Henry Olders wrote:
 You're partially right - what I want is a function that is
 free of side effects back through the parameters passed in
 the function call.

I don't know any object oriented language where it is not
possible to change objects passed in as parameters. It
is up to the passed object (a list in your case) to allow
or disallow manipulations no matter how they are invocated,
and the object is the same in the calling code and in the
called function.

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters (take two)

2011-05-30 Thread Wolfgang Rohdewald
On Dienstag 31 Mai 2011, Henry Olders wrote:
 What I would like is that the variables which are included in
 the function definition's parameter list, would be always
 treated as local to that function (and of course, accessible
 to nested functions) but NOT global unless explicitly defined
 as global. This would prevent the sort of problems that I
 encountered as described in my original post.

the parameter is local but it points to an object from an outer
scope - that could be the scope of the calling function or maybe
the global scope. So if you change the value of this parameter, 
you change that object from outer scope. But the parameter 
itself is still local. If you do 

def fnc2(c):
   c = 5

the passed object will not be changed, c now points to another
object. This is different from other languages where the global
c would change (when passing c by reference)

what you really seem to want is that a function by default
cannot have any side effects (you have a side effect if a
function changes things outside of its local scope). But
that would be a very different language than python

did you read the link Steven gave you?
http://mail.python.org/pipermail/tutor/2010-December/080505.html

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: float(nan) in set or as key

2011-05-29 Thread Wolfgang Rohdewald
On Sonntag 29 Mai 2011, Tim Delaney wrote:
 There's a second part the mystery - sets and dictionaries (and
 I think lists) assume that identify implies equality (hence
 the second result). This was recently discussed on
 python-dev, and the decision was to leave things as-is.

On Sonntag 29 Mai 2011, Grant Edwards wrote:
 Even if they are the same nan, it's still not equal to itself.

if I understand this thread correctly, they are not equal to
itself as specified by IEEE but Python treats them equal in
sets and dictionaries for performance reasons

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters

2011-05-29 Thread Wolfgang Rohdewald
On Sonntag 29 Mai 2011, Henry Olders wrote:
 It seems that in Python, a variable inside a function is
 global unless it's assigned.

no, they are local

 I would have thought that a function parameter would
 automatically be considered local to the function. It doesn't
 make sense to me to pass a global to a function as a
 parameter.

it is local. But consider what you actually passed:
You did not pass a copy of the list but the list itself.
You could also say you passed a reference to the list.
All python variables only hold a pointer (the id) to
an object. This object has a reference count and is
automatically deleted when there are no more references
to it.

If you want a local copy of the list you can either
do what you called being ugly or do just that within
the function itself - which I think is cleaner and
only required once.

def fnc2(c):
c = c[:]
c[1] = 'having'
return c


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GIL in alternative implementations

2011-05-28 Thread Wolfgang Rohdewald
On Samstag 28 Mai 2011, Marc Christiansen wrote:
 And I wouldn't rely on 3.2
 not to break.

it breaks too like it should, but only rarely
like one out of 10 times

i5:/pub/src/gitgames/kajongg/src$ python3.2 test.py 
100
i5:/pub/src/gitgames/kajongg/src$ python3.2 test.py 
100
i5:/pub/src/gitgames/kajongg/src$ python3.2 test.py 
98
i5:/pub/src/gitgames/kajongg/src$ python3.2 test.py 
100


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Closing generators

2011-04-22 Thread Wolfgang Rohdewald
On Freitag 22 April 2011, Terry Reedy wrote:
  for i in g:
  if i is not None:
  g.close()
  return i
 
 When returning from the function, g, if local, should
 disappear.

yes - it disappears in the sense that it no longer 
accessible, but

AFAIK python makes no guarantees as for when an object
is destroyed - CPython counts references and destroys
when no reference is left, but that is implementation
specific

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: suggestions, comments on an is_subdict test

2011-04-22 Thread Wolfgang Rohdewald
On Freitag 22 April 2011, Vlastimil Brom wrote:
 check whether all items of a given dictionary are
 present in a reference dictionary

I would not call this is_subdict. That name does not
clearly express that all keys need to have the same
value.

set(subdict.items()) = set(reference.items())

should be equivalent to your code

if you only want to check for presence of all
keys in the reference dict:

set(subdict.keys()) = set(reference.keys())

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Argument count mismatch

2011-04-21 Thread Wolfgang Rohdewald
On Donnerstag 21 April 2011, RVince wrote:
 When I make the following call:
 
 http://localhost/eligibility/cmseditorlinemethod/474724434

broken link - I have no /eligilibity on my localhost

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing setuptools on Windows custom python install

2011-04-18 Thread Wolfgang Rohdewald
On Montag 18 April 2011, Eric Frederich wrote:
   File F:\My_Python27\lib\socket.py, line 47, in module
 import _socket
 ImportError: No module named _socket
 
 F:\pyside\setuptools-0.6c11

I have C:\Python27

and within that, DLLS\_socket.pyd

this is what import _socket should find

do you have that?

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue11717] conflicting definition of ssize_t in pyconfig.h

2011-03-30 Thread Wolfgang Rohdewald

Wolfgang Rohdewald wolfg...@rohdewald.de added the comment:

types.h is from kdewin/include/msvc/sys

git clone git://anongit.kde.org/kdewin

types.h uses SSIZE_T but that is nowhere defined in KDE, so it must be the 
original one from msvc

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11717
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11717] conflicting definition of ssize_t in pyconfig.h

2011-03-30 Thread Wolfgang Rohdewald

Changes by Wolfgang Rohdewald wolfg...@rohdewald.de:


--
nosy: +mhammond

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11717
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11717] conflicting definition of ssize_t in pyconfig.h

2011-03-29 Thread Wolfgang Rohdewald

New submission from Wolfgang Rohdewald wolfg...@rohdewald.de:

compiling pykde on windows with msvc2010 on a 32bit Windows 7:

sipdnssdpart0.cpp
R:\include\msvc\sys/types.h(52) : error C2371: 'ssize_t' : redefinition; 
different basic types
c:\python27\include\pyconfig.h(201) : see declaration of 'ssize_t'

I can fix this by defining ssize_t as long in pyconfig.h or 
as int in kdewin/include/msvc/sys/types.h

the original files from windows define SSIZE_T as long so to
me this seems like a bug in pyconfig.h, it should say
typedef _W64 long ssize_t


Python27\include\pyconfig.h says (same in Python32):

#ifdef MS_WIN64
typedef __int64 ssize_t;
#else
typedef _W64 int ssize_t;
#endif

while kdewin/include/msvc/sys/types.h says:

typedef SSIZE_T ssize_t;

SSIZE_T is defined in Microsoft SDKs/Windows/v7.0A/Include/BaseTsd.h:

typedef LONG_PTR SSIZE_T, *PSSIZE_T;

and LONG_PTR from same directory, intsafe.h:
#if (__midl  501)
typedef [public]  __int3264 LONG_PTR;
#else
#ifdef _WIN64
typedef __int64 LONG_PTR;
#else
typedef _W64 long   LONG_PTR;
#endif // WIN64
#endif // (__midl  501)

for __midl see
http://msdn.microsoft.com/en-us/library/aa367301(v=vs.85).aspx

--
components: Windows
messages: 132558
nosy: wrohdewald
priority: normal
severity: normal
status: open
title: conflicting definition of ssize_t in pyconfig.h
type: compile error
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11717
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: value of pi and 22/7

2011-03-17 Thread Wolfgang Rohdewald
On Donnerstag 17 März 2011, kracekumar ramaraju wrote:

  22/7.0
 
 3.1428571428571428
 
  import math
  math.pi
 
 3.1415926535897931
 
 Why is the difference is so much ?is pi =22/7 or something ?

https://secure.wikimedia.org/wikipedia/en/wiki/Pi

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getpass and IDEs

2011-02-25 Thread Wolfgang Rohdewald
On Freitag 25 Februar 2011, Andrew wrote:
 I find that calling getpass produces a warning noting that it
 can't suppress output, if I'm using idle, wingide, or a few
 others. If I'm running from the console it works fine, but
 then I can't make use of ide-integrated debugging.
 
 I know I could just set up a test account for development
 purposes if I'm concerned about shoulder surfers, and that's
 probably a good idea anyway. But I'm curious what's different
 about IDE environments that makes it impossible to suppress
 output on them, and if there's anything that might be done
 about this.

I'd say your IDE redirects stdout/stderr so it can show
output within the IDE

http://docs.python.org/library/getpass.html
reading python docs lets me believe you are using
python pre 2.6

if so, you could try to open a stream to /dev/tty and pass
that to getpass.getpass()

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Wolfgang Rohdewald
On Dienstag 01 Februar 2011, Gerald Britton wrote:
 I'd like to know how (perhaps with the inspect module) I can
 tell if I am running in a context manager.

class f(object):
def __init__(self): 
self.inContext = False
def __enter__(self): 
self.inContext = True
return self
def __exit__(self,a,b,c):
self.inContext = False
return None

x = f()
print 'not within:', x.inContext
with f() as h:
print 'within:', h.inContext

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PJL

2011-01-10 Thread Wolfgang Rohdewald
On Montag 10 Januar 2011, loial wrote:
 First question...how do I send it to the printer?   Printer
 would be on the network.

echo PJL | lp -oraw -dnetworkprinter

if it works, translate it to python

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: decouple copy of a list

2010-12-10 Thread Wolfgang Rohdewald
On Freitag 10 Dezember 2010, Dirk Nachbar wrote:
 I want to take a copy of a list a
 
 b=a
 
 and then do things with b which don't affect a.
 
 How can I do this?
 
 Dirk

b=a[:]


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: decouple copy of a list

2010-12-10 Thread Wolfgang Rohdewald
On Freitag 10 Dezember 2010, Dirk Nachbar wrote:
  b=a[:]
  
  --
  Wolfgang
 
 I did that but then some things I do with b happen to a as
 well.

as others said, this is no deep copy. So if you do something
to an element in b, and if the same element is in a, both
are changed as they are still the same objects:

 x,y=5,6
 a=[x,y]
 b=a[:]
 id(a),id(b)
(140695481867368, 140695481867512)
 id(a[0]),id(b[0])
(33530584, 33530584)
 a=b
 id(a),id(b)
(140695481867512, 140695481867512)


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ensuring symmetry in difflib.SequenceMatcher

2010-11-24 Thread Wolfgang Rohdewald
On Mittwoch 24 November 2010, John Yeung wrote:
  Are there any
 simple adjustments that can be made without sacrificing (too
 much) performance?

 difflib.SequenceMatcher(None,*sorted(('BYRD','BRADY'))).ratio()
0.3

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLite3 and lastrowid

2010-11-19 Thread Wolfgang Rohdewald
On Freitag 19 November 2010, Alexander Gattin wrote:
 It's better to select count(1) instead of
 count(*). The latter may skip rows consisting
 entirely of NULLs IIRC.

in some data bases count(1) is said to be faster
than count(*), I believe

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I catch segmentation fault in python?

2010-11-17 Thread Wolfgang Rohdewald
On Mittwoch 17 November 2010, justin wrote:
 But the problem is that the code is not mine, and it takes
 over a day for me to get the point where the segmentation
 fault occurred. Plus, it seems that the point is not
 deterministic
 
 Still, I think I should at least try to figure out exactly at
 which point the segmentation fault occurs, and think where to
 go from there according to your kind advice.

try valgrind

-- 
mit freundlichen Grüssen

with my best greetings

Wolfgang Rohdewald

dipl. Informatik Ing. ETH Rohdewald Systemberatung
Karauschenstieg 4
D 21640 Horneburg
Tel.: 04163 826 819
Fax:  04163 826 828
Internet: http://www.rohdewald.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I catch segmentation fault in python?

2010-11-17 Thread Wolfgang Rohdewald
On Mittwoch 17 November 2010, Wolfgang Rohdewald wrote:
 On Mittwoch 17 November 2010, justin wrote:
  But the problem is that the code is not mine, and it takes
  over a day for me to get the point where the segmentation
  fault occurred. Plus, it seems that the point is not
  deterministic
  
  Still, I think I should at least try to figure out exactly
  at which point the segmentation fault occurs, and think
  where to go from there according to your kind advice.
 
 try valgrind

hit the send button too fast...

even if the segmentation fault only happens after a long time
valgrind might find problems much sooner, and fixing them
might remove the segmentation fault.

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-05 Thread Wolfgang Rohdewald
On Dienstag 05 Oktober 2010, MRAB wrote:
  About notation, even if loved right-hand-half-open
  intervals, I would wonder about [a,b] noting it. I guess
  99.9% of programmers and novices (even purely amateur) have
  learnt about intervals at school in math courses. Both
  notations I know of use [a,b] for closed intervals, while
  half-open ones are noted either [a,b[ or [a,b). Thus, for
  me, the present C/python/etc notation is at best
  misleading. So, what about a hypothetical language using
  directly math unambiguous notation, thus also letting
  programmers chose their preferred semantics (without
  fooling others)? End of war?
 
 Dijkstra came to his conclusion after seeing the results of
 students using the programming language Mesa, which does
 support all 4 forms of interval.

what was his conclusion?

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inspect.stack() or inspect.currentframe() gives list index out of range error

2010-09-25 Thread Wolfgang Rohdewald
On Samstag 25 September 2010, Steven D'Aprano wrote:
 My guess is that you've copied the .pyc file onto the server,
 BUT there  is also an older version of the .py file there as
 well. Because the modification date is older than that of the
 .pyc file, Python executes the compiled code from the .pyc
 file.

that would be horrible - this is what our own legacy software
does. A maintenance nightmare. Think adjusting system time
or cp -a spam.py

Actually the docs say something different:

The modification time of the version of spam.py used to create 
spam.pyc is recorded in spam.pyc, and the .pyc file is ignored if 
these don’t match.

found here:
http://docs.python.org/tutorial/modules.html

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: feature request: string.contains('...')

2010-09-24 Thread Wolfgang Rohdewald
On Freitag 24 September 2010, Wim Feijen wrote:
  would really like having a string.contains('...') function
 which returns either True or False. I know I can mimick this
 behaviour by saying string.find('...') != -1 , however, I
 find this harder to read.

 a = 'xy134'
 '13' in a
True
 '15' in a
False
 

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Line-by-line processing when stdin is not a tty

2010-08-11 Thread Wolfgang Rohdewald
On Mittwoch 11 August 2010, Cameron Simpson wrote:
 Usually you either
 need an option on the upstream program to tell it to line
 buffer explicitly

once cat had an option -u doing exactly that but nowadays
-u seems to be ignored

http://www.opengroup.org/onlinepubs/009695399/utilities/cat.html

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess escaping POpen?!

2010-08-05 Thread Wolfgang Rohdewald
On Donnerstag 05 August 2010, Chris Withers wrote:
 ...then the output is indeed captured. So, what is svn doing 
 differently? How is it escaping its jail?

maybe it does not read from stdin but directly from /dev/tty


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess escaping POpen?!

2010-08-05 Thread Wolfgang Rohdewald
On Donnerstag 05 August 2010, Chris Withers wrote:
 But why only the request for auth credentials?

for security reasons I suppose - make sure a human enters
the password

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where are the program that are written in python?

2010-05-21 Thread Wolfgang Rohdewald
On Freitag 21 Mai 2010, Jake b wrote:
  I don't know of any big game written in python. ( meaning
  python code, using c++ libs

would you call 8702 python statements big? If so,
Kajongg would be a candidate.

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-platform file paths

2010-05-08 Thread Wolfgang Rohdewald
On Sonntag 09 Mai 2010, Tim Roberts wrote:
 No.  On Linux, you need to mount the share in some empty
 directory (using mount or smbmount), then read the files from
 that directory.

actually the mount directory does not have to be empty - whatever
it contains is invisible while someting is mounted in it. But
of course using an empty directory gets you less surprises.

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Symbols as parameters?

2010-01-22 Thread Wolfgang Rohdewald
On Friday 22 January 2010, Alf P. Steinbach wrote:
 I get the impression that there's some message traffic that I don't
 see

 For example, the recent thread Covert number into string started
 with a  reply in my newreader, using EternalSeptember's NNTP host.
 
 It also starts with a reply in Google's archives, url: 
 http://groups.google.com/group/comp.lang.python/browse_thread/threa
 d/b8097d4de4a9c9b0/cb3a2e6ccd7736ef.

did you check your spam folder?

I got the original. If you want to, I can mail you the headers
privately

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: basic Class in Python

2010-01-17 Thread Wolfgang Rohdewald
On Monday 18 January 2010, BarryJOgorman wrote:
 TypeError: object._new_() takes no parameters

 def _init_(self, name, job=None, pay=0):

__init__ needs two underscores left and right


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python simply not scaleable enough for google?

2009-11-17 Thread Wolfgang Rohdewald
On Wednesday 18 November 2009, Terry Reedy wrote:
 Python today is at least 100x as fast as 1.4 (my first version) was
  in  its time. Which is to say, Python today is as fast as C was
  then

on the same hardware? That must have been a very buggy C compiler.
Or was it a C interpreter?


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regex (?!..) problem

2009-10-05 Thread Wolfgang Rohdewald
On Monday 05 October 2009, Carl Banks wrote:
 What you're not realizing is that if a regexp search comes to a
  dead end, it won't simply return no match.  Instead it'll throw
  away part of the match, and backtrack to a previously-matched
  variable-length subexpression, such as .*?, and try again with a
  different length.

well, that explains it. This is contrary to what the documentation
says, though. Should I fill a bug report?
http://docs.python.org/library/re.html

Now back to my original problem: Would you have any idea how
to solve it?

count() is no solution in my case, I need re.search to either
return None or a match.

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regex (?!..) problem

2009-10-05 Thread Wolfgang Rohdewald
On Monday 05 October 2009, Stefan Behnel wrote:
 Wolfgang Rohdewald wrote:
  I want to match a string only if a word (C1 in this example)
  appears at most once in it.
 
 def match(s):
 if s.count(C1)  1:
 return None
 return s
 
 If this doesn't fit your requirements, you may want to provide some
  more details.

Well - the details are simple and already given: I need re.search
to either return None or a match. But I will try to state it
differently:

I have a string representing the results for a player of a board
game (Mah Jongg - not the solitaire but the real one, played by
4 players), and I have a list of scoring rules. Those rules
can be modified by the user, he can also add new rules. Mah Jongg
is played with very different rulesets worldwide.

The rules are written as regular expressions. Since what they
do varies greatly I do not want do treat some of them in a special
way. That would theoretically be possible but it would really
complificate things.

For each rule I simply need to check whether it applies or not.
I do that by calling re.search(rule, gamestring) and by checking
the result against None.

Here you can look at all rules I currently have.
http://websvn.kde.org/trunk/playground/games/kmj/src/predefined.py?view=markup
The rule I want to rewrite is called Robbing the Kong. Of
course it is more complicated than my example with C1.

Here you can find the documentation for the gamestring:
http://websvn.kde.org/trunk/playground/games/doc/kmj/index.docbook?revision=1030476view=markup
(get HTML files with meinproc index.docbook) 

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regex (?!..) problem

2009-10-05 Thread Wolfgang Rohdewald
On Monday 05 October 2009, MRAB wrote:
 (?!.*?(C1).*?\1) will succeed only if .*?(C1).*?\1 has failed,
  in which case the group (group 1) will be undefined (no capture).

I see. 

I should have moved the (C1) out of this expression anyway:

 re.match(r'L(?Ptile..)(?!.*?(?P=tile).*?(?P=tile))(.*?
(?P=tile))','LC1 C1B1B1B1 b3b3b3b3 C2C2C3').groups()
('C1', ' C1')

this solves my problem, thank you!


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


regex (?!..) problem

2009-10-04 Thread Wolfgang Rohdewald
Hi,

I want to match a string only if a word (C1 in this example) appears
at most once in it. This is what I tried:

 re.match(r'(.*?C1)((?!.*C1))','C1b1b1b1 b3b3b3b3 C1C2C3').groups()
('C1b1b1b1 b3b3b3b3 C1', '')
 re.match(r'(.*?C1)','C1b1b1b1 b3b3b3b3 C1C2C3').groups()
('C1',)

but this should not have matched. Why is the .*? behaving greedy
if followed by (?!.*C1)? I would have expected that re first 
evaluates (.*?C1) before proceeding at all.

I also tried:

 re.search(r'(.*?C1(?!.*C1))','C1b1b1b1 b3b3b3b3 
C1C2C3C4').groups()
('C1b1b1b1 b3b3b3b3 C1',)

with the same problem.

How could this be done?

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a local variable scope.

2009-09-18 Thread Wolfgang Rohdewald
On Friday 18 September 2009, Ethan Furman wrote:
 loop != scope

true for python but in some languages the loop
counter has a scope limited to the loop


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to print without spaces?

2009-09-18 Thread Wolfgang Rohdewald
On Friday 18 September 2009, koranthala wrote:
 What if I want to print 1 to 100 in a loop without spaces in
  between? I think that is the OPs question.

arr = ['a', 'b', 'c', 'andsoon']
print ''.join(arr)

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: VT100 in Python

2009-09-14 Thread Wolfgang Rohdewald
On Sunday 13 September 2009, Nadav Chernin wrote:
 I'm writing program that read data from some instrument trough
  RS232. This instrument send data in VT100 format. I need only to
  extract the text without all other characters that describe how to
  represent data on the screen. Is there some library in python for
  converting VT100 strings?
 

that should be easy using regular expressions

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using expy to extend python

2009-08-05 Thread Wolfgang Rohdewald
On Thursday 06 August 2009, Yingjie Lan wrote:
 For more information about expy, please visit its homepage at:
 http://expy.sf.net/

looks very interesting, bookmarked.

In your example class mate, def rename looks wrong:
if malloc fails, the previous name should probably not
be replaced by an empty string?

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New implementation of re module

2009-07-30 Thread Wolfgang Rohdewald
On Tuesday 28 July 2009, Christopher Arndt wrote:
 setup(name='regex',
 version='1.0',
 py_modules = ['regex'],
 ext_modules=[Extension('_regex', ['_regex.c'])],
 )

 Also, you need to copy unicodedata_db.h from the Modules
 directory of the Python source tree to your working directory,
 since this file apparently is not installed into the include
 directory of a Python installation.

using issue2636-20090729.zip

I have Python 2.6.2 on ubuntu 9.04

with ggc-4.3:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -
Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c _regex.c -o 
build/temp.linux-i686-2.6/_regex.o
_regex.c: In Funktion »bmatch_context«:
_regex.c:1462: Fehler: Als Erhöhungsoperand wird L-Wert erfordert
_regex.c:1470: Fehler: Als Erhöhungsoperand wird L-Wert erfordert
_regex.c:1478: Fehler: Als Verringerungsoperand wird L-Wert erfordert

with gcc-4.4:
gcc-4.4 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-
prototypes -fPIC -I/usr/include/python2.6 -c _regex.c -o 
build/temp.linux-i686-2.6/_regex.o
_regex.c: In function ‘bmatch_context’:
_regex.c:1462: error: lvalue required as increment operand
_regex.c:1470: error: lvalue required as increment operand
_regex.c:1478: error: lvalue required as decrement operand


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New implementation of re module

2009-07-30 Thread Wolfgang Rohdewald
On Thursday 30 July 2009, MRAB wrote:
 There are other lines which are similar, eg line 1487. Do they all
 give the same/similar error with your compiler?

yes. The full output with gcc-4.3:


notebook:~/kmj/src$ LANG=C python setup.py  build
running build
running build_py
running build_ext
building '_regex' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -
Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c _regex.c -o 
build/temp.linux-i686-2.6/_regex.o
_regex.c: In function 'bmatch_context':
_regex.c:1462: error: lvalue required as increment operand
_regex.c:1470: error: lvalue required as increment operand
_regex.c:1478: error: lvalue required as decrement operand
_regex.c:1487: error: lvalue required as decrement operand
_regex.c:1593: error: lvalue required as increment operand
_regex.c:1606: error: lvalue required as decrement operand
_regex.c:1616: error: lvalue required as increment operand
_regex.c:1625: error: lvalue required as increment operand
_regex.c:1634: error: lvalue required as decrement operand
_regex.c:1643: error: lvalue required as decrement operand
_regex.c:2036: error: lvalue required as increment operand
_regex.c:2047: error: lvalue required as increment operand
_regex.c:2059: error: lvalue required as decrement operand
_regex.c:2070: error: lvalue required as decrement operand
_regex.c:2316: error: lvalue required as increment operand
In file included from _regex.c:2431:
_regex.c: In function 'umatch_context':
_regex.c:1462: error: lvalue required as increment operand
_regex.c:1470: error: lvalue required as increment operand
_regex.c:1478: error: lvalue required as decrement operand
_regex.c:1487: error: lvalue required as decrement operand
_regex.c:1593: error: lvalue required as increment operand
_regex.c:1606: error: lvalue required as decrement operand
_regex.c:1616: error: lvalue required as increment operand
_regex.c:1625: error: lvalue required as increment operand
_regex.c:1634: error: lvalue required as decrement operand
_regex.c:1643: error: lvalue required as decrement operand
_regex.c:2036: error: lvalue required as increment operand
_regex.c:2047: error: lvalue required as increment operand
_regex.c:2059: error: lvalue required as decrement operand
_regex.c:2070: error: lvalue required as decrement operand
_regex.c:2316: error: lvalue required as increment operand
error: command 'gcc' failed with exit status 1

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New implementation of re module

2009-07-30 Thread Wolfgang Rohdewald
On Thursday 30 July 2009, MRAB wrote:
 So it complains about:

  ++(RE_CHAR*)context-text_ptr

 but not about:

  ++info-repeat.count

 Does this mean that the gcc compiler thinks that the cast makes it
 an rvalue? I'm using Visual C++ 2008 Express Edition, which doesn't
 complain. What does the C standard say?

I am not really a C expert but I found some links. Most helpful:
http://developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/C-Dialect-Options.html

(search -fnon-lvalue-assign)

so I did the conversion mentioned there. This works: 

--- _regex.c2009-07-29 11:34:00.0 +0200
+++ n   2009-07-30 15:15:22.0 +0200
@@ -1459,7 +1459,7 @@
 if (text_ptr  (RE_CHAR*)context-slice_end  text_ptr[0] != '\n')
   {
 context-node = node-next_1;
-++(RE_CHAR*)context-text_ptr;
+++*(RE_CHAR**)context-text_ptr;
 } else
 context = reject_context(state, context);
 break;


-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New implementation of re module

2009-07-30 Thread Wolfgang Rohdewald
On Thursday 30 July 2009, Wolfgang Rohdewald wrote:
 so I did the conversion mentioned there. This works:

I actually do not know if it works - but it compiles.

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New implementation of re module

2009-07-27 Thread Wolfgang Rohdewald
On Monday 27 July 2009, MRAB wrote:
 I've been working on a new implementation of the re module. The
 details are at http://bugs.python.org/issue2636, specifically from
 http://bugs.python.org/issue2636#msg90954. I've included a .pyd
 file for Python 2.6 on Windows if you want to try it out.

how do I compile _regex.c on Linux?

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Detect target name in descriptor __set__ method

2009-07-21 Thread Wolfgang Rohdewald
On Wednesday 22 July 2009, Gabriel Genellina wrote:
 x = X()
 x.foo = value

del x.foo

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Detect target name in descriptor __set__ method

2009-07-21 Thread Wolfgang Rohdewald
On Wednesday 22 July 2009, Wolfgang Rohdewald wrote:
 On Wednesday 22 July 2009, Gabriel Genellina wrote:
  x = X()
  x.foo = value

 del x.foo

sorry, was not yet quite awaken - I read delete target name
instead of detect target name

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need to know if a file as only ASCII charaters

2009-06-17 Thread Wolfgang Rohdewald
On Wednesday 17 June 2009, Lie Ryan wrote:
 Wolfgang Rohdewald wrote:
  On Wednesday, 17. June 2009, Steven D'Aprano wrote:
  while text:
  for c in text:
  if c not in printable: return False
  
  that is one loop per character.
 
 unless printable is a set

that would still execute the line if c not in... 
once for every single character, against just one
regex call. With bigger block sizes, the advantage
of regex should increase.
 
  wouldn't it be faster to apply a regex to text?
  something like
  
  while text:
  if re.search(r'\W',text): return False
  
 
 regex? Don't even start...

Here comes a cProfile test. Note that the first variant of Steven
would always have stopped after the first char. After fixing that
making it look like variant 2 with block size=1, I now have 
3 variants:

Variant 1 Blocksize 1
Variant 2 Blocksize 65536
Variant 3 Regex on Blocksize 65536

testing for a file with 400k bytes shows regex as a clear winner.
Doing the same for an 8k file: variant 2 takes 3ms, Regex takes 5ms.

Variants 2 and 3 take about the same time for a file with 20k.


python ascii.py | grep CPU
 398202 function calls in 1.597 CPU seconds
 13 function calls in 0.104 CPU seconds
 1181 function calls in 0.012 CPU seconds

import re
import cProfile

from string import printable

def ascii_file1(name):
with open(name, 'rb') as f:
c = f.read(1)
while c:
if c not in printable: return False
c = f.read(1)
return True

def ascii_file2(name):
bs = 65536
with open(name, 'rb') as f:
text = f.read(bs)
while text:
for c in text:
if c not in printable: return False
text = f.read(bs)
return True

def ascii_file3(name):
bs = 65536
search = r'[^%s]' % re.escape(printable)
reco = re.compile(search)
with open(name, 'rb') as f:
   text = f.read(bs)
   while text:
   if reco.search(text): return False
   text = f.read(bs)
return True

def test(fun):
if fun('/tmp/x'):
   print 'is ascii'
else:
   print 'is not ascii'

cProfile.run(test(ascii_file1))
cProfile.run(test(ascii_file2))
cProfile.run(test(ascii_file3))




-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need to know if a file as only ASCII charaters

2009-06-16 Thread Wolfgang Rohdewald
On Wednesday, 17. June 2009, Steven D'Aprano wrote:
 while text:
 for c in text:
 if c not in printable: return False

that is one loop per character.

wouldn't it be faster to apply a regex to text?
something like

while text:
if re.search(r'\W',text): return False

-- 
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a maximum size to a Python program?

2009-04-27 Thread Wolfgang Rohdewald
On Montag, 27. April 2009, John Machin wrote:
 ἐδάκρυσεν ὁ Ἰησοῦς

και εγώ

+1

-- 
Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list


Re: Display directory pyqt4 and Python

2009-04-02 Thread Wolfgang Rohdewald
On Donnerstag, 2. April 2009, Dunwitch wrote:
 for x in (fileList):
 self.ui.displayVideo.setText(x) # This only shows the last


self.ui.displayVideo.setText('\n'.join(fileList))


but I would go for a solution with QDirModel / QListView

http://doc.trolltech.com/4.5/itemviews-dirview.html

-- 
Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Wolfgang Rohdewald
On Freitag, 13. März 2009, Raymond Hettinger wrote:
 [Paul Rubin]
  What if you want to change the separator?  Europeans usually
  use periods instead of commas: one thousand = 1.000.
 
 That is supported also.

do you support just a fixed set of separators or anything?

how about this: (Switzerland)

12'000.99

or spacing:

12 000.99

-- 
Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is python worth learning as a second language?

2009-03-10 Thread Wolfgang Rohdewald
On Montag, 9. März 2009, r wrote:
 Long answer:
  'Ye%s' %'s'*1000

simplified long answer:

'Yes' * 1000

or did you mean

'Ye%s' %('s'*1000)

-- 
Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python, HTTPS (SSL), tlslite and metoda POST (and lots of pain)

2009-02-23 Thread Wolfgang Rohdewald
On Montag, 23. Februar 2009, Steve Holden wrote:
 yat...@gmail.com wrote:
  Hi there.
 [...]
 
 Yatsek:
 
 You just hijacked a thread by writing your question as a reply to
 somebody else's post

did he? His mail headers show no reference to any other mail AFAICS

-- 
Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 vs 2.5 - Unicode error

2009-01-21 Thread Wolfgang Rohdewald
On Mittwoch, 21. Januar 2009, Gaurav Veda wrote:
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
 4357: ordinal not in range(128)
 
 Before sending the (insert) query to the mysql server, I do the
 following which I think should've taken care of this problem:
  sqlStr = sqlStr.replace('\\', '')

you might consider using what mysql offers about unicode: save
all strings encoded as unicode. Might be more work now but I think
it would be a good investment in the future.

have a look at the mysql documentation for

mysql_real_escape_string() takes care of quoted chars. 

mysql_set_character_set() for setting the character set used
by the database connection

you can ensure that the web page is unicode by doing something
like

charsetregex = re.compile(r'charset=(.*?)[\]')
charsetmatch = charsetregex.search(page)
if charsetmatch:
   charset=charsetmatch.group(1)
   utf8Text = unicode(page,charset)

-- 
Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list