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. -- Wolf

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

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: 's

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.

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 > a

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 pas

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

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/sr

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()) s

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

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 > 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

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.

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 cou

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 re

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: > > 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 ar

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: 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/pyt

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/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

Re: How can I catch segmentation fault in python?

2010-11-17 Thread Wolfgang Rohdewald
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

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 kno

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

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 >>

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

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: 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: 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 mount

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

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? -- Wol

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(?P..)(?!.*?(?P=tile).*?(?P=tile))(

Re: regex (?!..) problem

2009-10-05 Thread Wolfgang Rohdewald
On Monday 05 October 2009, MRAB wrote: > You're currently looking for one that's not followed by another; > the solution is to check first whether there are two: > > >>> re.match(r'(?!.*?C1.*?C1)(.*?C1)','C1b1b1b1 b3b3b3b3 > C1C2C3').groups() > > Traceback (most recent call last): >File ""

Re: regex (?!..) problem

2009-10-05 Thread Wolfgang Rohdewald
On Monday 05 October 2009, Carl Banks wrote: > Why do you have to use a regexp at all? not one but many with arbitrary content. please read my answer to Stefan. Take a look at the regexes I am using: http://websvn.kde.org/trunk/playground/games/kmj/src/predefined.py?view=markup moreover they are

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 >

Re: regex (?!..) problem

2009-10-04 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 t

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 sho

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: 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: 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

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 em

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-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 > compl

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 build

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 workin

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. h

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&quo

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: 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 > >

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)

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-01 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/itemview

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: (Swi

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://

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 =