Re: Re: PyQt QCalendarWidget events question

2012-07-16 Thread John Posner
On 7/16/2012 12:28 PM, tinn...@isbd.co.uk wrote: > tinn...@isbd.co.uk wrote: >> I am trying to use the PyQt4 calendar widget to perform some different >> actions on specific dates. There are three events available:- >> >> selectionChanged() >> activated(QDate) >> clicked(QDate) >> >> O

Re: calling a simple PyQt application more than once

2012-01-27 Thread John Posner
Jabba Laci wrote: > Hi, > > I have a simple PyQt application that creates a webkit instance to > scrape AJAX web pages. It works well but I can't call it twice. I > think the application is not closed correctly, that's why the 2nd call > fails. Here is the code below. I also put it on pastebin: > h

Re: calling a simple PyQt application more than once

2012-01-29 Thread John Posner
Jabba Laci wrote: > Hi, Thanks for your reply. I forgot to mention that my first solution > created a headless browser, i.e. it didn't create any GUI. I would > like to keep it that way, thus I could scrape (AJAX-powered) webpages > in batch mode without any user interaction. No head, no problem.

Re: Re: what is the difference between @property and method

2012-02-09 Thread John Posner
On 2:59 PM, Devin Jeanpierre wrote: > It is kind of funny that the docs don't ever explicitly say what a > property is. http://docs.python.org/library/functions.html#property -- > Devin Here's a writeup that does: http://wiki.python.org/moin/AlternativeDescriptionOfProperty -John -- http://m

Re: Formate a number with commas

2012-02-09 Thread John Posner
On 2:59 PM, noydb wrote: > How do you format a number to print with commas? I would readily admit that both the "locale" module and "format" method are preferable to this regular expression, which certainly violates the "readability counts" dictum: r"(?<=\d)(?=(\d\d\d)+$)" # python 2.6.6 imp

Re: Re: Python Gotcha's?

2012-04-05 Thread John Posner
On 4/4/2012 7:32 PM, Chris Angelico wrote: > Don't know if it's what's meant on that page by the += operator, Yes, it is. >> a=([1],) >> a[0].append(2) # This is fine [In the following, I use the term "name" rather loosely.] The append() method attempts to modify the object whose name is "a[0]"

Re: Lambda question

2011-06-05 Thread John Posner
On 2:59 PM, Ian Kelly wrote: > On Sat, Jun 4, 2011 at 12:09 PM, Chris Angelico wrote: >> Python doesn't seem to have an inbuilt function to divide strings in >> this way. At least, I can't find it (except the special case where n >> is 1, which is simply 'list(string)'). Pike allows you to use the

Re: Dynamic Zero Padding.

2011-06-07 Thread John Posner
Friedrich: >> I would be much obliged if someone can give me some tips on how to >> achieve a variably pad a number. > :) > > ('%%0%dd' % (pads,)) % (n,) > > Probably be good to wrap it in a function. It looks kind of obscure as it > is. You might want to try "new style" string formatting [1]

Re: Using decorators with argument in Python

2011-06-29 Thread John Posner
On 2:59 PM, Lie Ryan wrote: >> Can any of you guys explain me advantages and disadvantages of >> using each of them > Simplicity is one, using @decor() means you have at least three-level > nested functions, which means the code is likely to be very huge and > perhaps unnecessarily. Bruce Eckel po

Re: Using decorators with argument in Python

2011-07-01 Thread John Posner
On 2:59 PM, Ethan Furman wrote: > def __call__(self, func=None): > if func is None: > return self._call() > self.func = func > return self > def _call(self): > print("\n" + self.char * 50) > self.func() > print(self.char * 50 +

Re: Property setter and lambda question

2011-07-11 Thread John Posner
On 2:59 PM, Anthony Kong wrote: > So the question: is it possible to use lambda expression at all for > the setter? (As in the last, commented-out line) > > Python interpreter will throw an exception right there if I use the > last line ('SyntaxError: lambda cannot contain assignment'). I'd use >

Re: Tkinter/py2exe with installer

2011-07-25 Thread John Posner
On 2:59 PM, Kevin Walzer wrote: > Can anyone point me in the direction of a Tkinter/Python app that has > been wrapped with py2exe and is deployed on Windows as a standalone > using one of the standard installer tools? (MSI, NSIS, Inno Setup, > etc.) I'm working on a Tkinter app for Windows and hav

Re: Tkinter/py2exe with installer

2011-07-25 Thread John Posner
On 2:59 PM, Kevin Walzer wrote: > Can anyone point me in the direction of a Tkinter/Python app that has > been wrapped with py2exe and is deployed on Windows as a standalone > using one of the standard installer tools? (MSI, NSIS, Inno Setup, > etc.) I'm working on a Tkinter app for Windows and hav

Re: how to separate a list into two lists?

2011-08-06 Thread John Posner
On 2:59 PM, smith jack wrote: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i do not want to use loop

Re: how to separate a list into two lists?

2011-08-06 Thread John Posner
On 2:59 PM, smith jack wrote: > if a list L is composed with tuple consists of two elements, that is > L = [(a1, b1), (a2, b2) ... (an, bn)] > > is there any simple way to divide this list into two separate lists , such > that > L1 = [a1, a2... an] > L2=[b1,b2 ... bn] > > i do not want to use loop

Re: testing if a list contains a sublist

2011-08-16 Thread John Posner
On 2:59 PM, Nobody wrote: > On Tue, 16 Aug 2011 01:26:54 +0200, Johannes wrote: > >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? > "Best" is subjective. AFAIK, the theoretically-optimal algorithm is > Boyer-Moore. But that would req

Re: testing if a list contains a sublist

2011-08-16 Thread John Posner
On 2:59 PM, Nobody wrote: > On Tue, 16 Aug 2011 01:26:54 +0200, Johannes wrote: > >> what is the best way to check if a given list (lets call it l1) is >> totally contained in a second list (l2)? > "Best" is subjective. AFAIK, the theoretically-optimal algorithm is > Boyer-Moore. But that would req

Re: Py2exe problem with pyqt+matplotlib

2011-03-15 Thread John Posner
On 2:59 PM, Massi wrote: > I everyone, > > I'm trying to write a setup file for py2exe (0.6.9) to convert my > script into a windows (on win 7) executable. In my script (python2.6) > I use PyQt and matplotlib. Here is the setup.py file: > ImportError: No module named Tkinter > > Obviously Tkinter

Re: How best to convert a string "list" to a python list

2011-05-13 Thread John Posner
On 5/13/2011 3:38 PM, noydb wrote: > I want some code to take the items in a semi-colon-delimted string > "list" and places each in a python list. I came up with below. In > the name of learning how to do things properly, No big deal that you weren't aware of the split() method for strings. Sin

Re: all() is slow?

2011-11-08 Thread John Posner
On 2:59 PM, Chris Angelico wrote: >>> So really, it's not "all() is slow" but "function calls are slow". >>> Maybe it'd be worthwhile making an all-factory: >> PLEASE say you're joking. If I saw code like that on any of our project, >> this would definitely qualify for a DailyWTF. > For the benefi

Re: Insert comma in number?

2013-03-07 Thread John Posner
Peter Otten wrote: > Last not least there's the option to employ locale-aware formatting: Not quite last ... there's the mind-bending regular expression route: import re re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "12345678") # 12,345,678 re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "-54321")

Re: Tkinter w.pack()?

2009-01-28 Thread John Posner
The difference between the fill=, expand=, and anchor= options to the pack() function takes a while to get used to. In brief: * fill= controls the size of a control itself * expand= controls the size of the space into which the pack() function places a control * anchor= comes into play if the si

RE: Changing the Image on a button

2009-02-16 Thread John Posner
>> from Tkinter import * >> >> def do(): >> btn.configure(image = None) >> >> root = Tk() >> img1 = PhotoImage(file="bacon.gif") >> >> btn = Button(image = img1, command = do, text = "hello" ) >> btn.img = img1 >> btn.pack() >> root.mainloop() >> Try this change: from: btn.

RE: Changing the Image on a button

2009-02-17 Thread John Posner
>> > Try this change: >> > >> >   from: btn.configure(image = None) >> >     to: img1.blank() >> > >> >> This does in fact clear the image out, however it isn't causing the >> text to display... Do i have have to create a new button and swap it >> out? I knew you were gonna ask that! :-)

Re: Peculiar swap behavior

2009-02-23 Thread John Posner
>> m,n = [1,2,3],[4,5,6] >> m[:],n[:] = n,m I believe this is an RTFM situation. In the Python 2.6.1 help topic "Simple Statements" > "Assignment Statements", see this para: If the target is a slicing: The primary expression in the reference is evaluated. It should yield a mutable seq

RE: Delete all items in the list

2009-02-26 Thread John Posner
>> >> > L = filter('a'.__ne__,L) >> >> And this is probably the fastest. But not all types define >> __ne__ so a >> more generic answer would be: >> >> from functools import partial >> from operator import ne >> L = filter(partial(ne, 'a'), L) >> And don't forget this "traditio

functools.partial (was: Delete all items in the list)

2009-02-26 Thread John Posner
>> >> from functools import partial >> from operator import ne >> L = filter(partial(ne, 'a'), L) >> I learned about functools.partial only recently (on this list). functools is implemented in C, not Python, so I couldn't answer this question for myself: Is functools.partial completely

RE: A Simple Menu , Stretching the Window Width--Tkinter

2009-03-03 Thread John Posner
>> >> I'd like to create a simple Menu bar with one item in it, >> say, called "My >> Menu", and have a few submenu items on it like "Change >> Data" and "Exit". I >> can do that but I'd like the title I put on the enclosing >> window to be >> completely visible. The title is, for ex

Re: wxPython fast and slow

2009-03-08 Thread John Posner
> def move_panel(self, evt): > def gen(): > for x in range(200): > yield x > for x in range(200, 0, -1): > yield x > for x in gen(): > self.square.SetPosition((x, 30)) > time.sleep(0.005) > I can'

Re:

2009-03-13 Thread John Posner
> I have 2 lists > a = [(4, 1), (7, 3), (3, 2), (2, 4)] > b = [2, 4, 1, 3] > > Now, I want to order _a_ (a[1]) based on _b_. > i.e. the second element in tuple should be the same as > b. > i.e. Output would be [(3, 2), (2, 4), (4, 1), (7, 3)] > > I did the same as follows: >

Re: An ordering question

2009-03-13 Thread John Posner
> If you don't want to build the intermediary dict, a > less efficient > version that runs in O(n^2): > > a.sort(key=lambda k: b.index(k[1])) > > Which is mostly similar to John's solution, but still > more efficient > because it only does a b.index call once per 'a' > item instead of twice > pe

Re: Style question - defining immutable class data members

2009-03-15 Thread John Posner
(My apologies if the thread has already covered this.) I believe I understand the WHAT in this situation, but I don't understand the WHY ... Given this class definition: class Cls(object): x = 345 ... I observe the following, using IDLE 2.6.1: >>> inst = Cls() >>> Cls.x is inst.x True

Re: Style question - defining immutable class data members

2009-03-15 Thread John Posner
Matthew Woodcraft said: > I doubt it's because anyone particularly wanted this > behaviour; it just > falls out of the way '+=' is defined. > > At the point where 'inst.x += 1' is compiled, > Python doesn't know > whether 'inst.x' is going to turn out to be a class > attribute or an > instance a

Re: Style question - defining immutable class data members

2009-03-15 Thread John Posner
Earlier, I said: > I'll look into what the standard Python doc set says on this > matter. > RTFM, in section "Augmented assignment statements" of python301.chm: --- For targets which are attribute references, the initial value is retrieved with a getattr() and the result is assigned with a se

Re: converting pipe delimited file to fixed width

2009-03-19 Thread John Posner
[snip] > field_widths = [14, 6, 18, 21, 21, 4, 6] > > out = open("/home/chatdi/ouptut.csv", 'w') > for line in open("/home/chatdi/input.csv", "r"): > fields = line.rstrip().split('|') > padded_fields = [field.ljust(width) for field, width in zip(fields, > field_widths)] > out.write

Re: Generator

2009-03-22 Thread John Posner
[snip] > > If you want next(g) to yield 3, you'd have to do something like: > > > > g = (x for x in s[:]) > > > > where s[:] makes a copy of s that is then iterated over. BTW, this simpler statement works, too: g = iter(s[:]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-25 Thread John Posner
On Mon Mar 16 03:42:42, I said: > RTFM, in section "Augmented assignment statements" of python301.chm: > > --- > For targets which are attribute references, the initial value is retrieved > with a getattr() and the result is assigned with a setattr(). Notice that the > two methods do not necess

RE: Style question - defining immutable class data members

2009-03-26 Thread John Posner
[snip] >> > If the object is a class instance and the attribute reference occurs >> > on both sides of the assignment operator; for example:: >> > >> > self.x = self.x + 1 >> > >> > ... in the RHS expression, ``self.x`` is evaluated with >> > ``getattr()``, which ca

Cannot register to submit a bug report

2009-03-29 Thread John Posner
I've tried twice to register myself at bugs.python.org. But the confirmation email message never arrives. (Yes, I checked my spam folder.) What do I do now? E-mail message checked by Spyware Doctor (6.0.0.386) Database version: 5.12060 http://www.pctools.com/en/spyware-doctor-antivirus/ -- ht

RE: tkinter questions: behavior of StringVar, etc

2009-03-29 Thread John Posner
Scott David Daniels said: >> You ask, "What exactly is the role of ...", rather than saying >> something like, "I don't understand the role of ...", and continue >> to ask why the code is not architected the way you first expected >> it to be architected, calling those things you do not unders

RE: Cannot register to submit a bug report

2009-03-29 Thread John Posner
>> >> We can try to debug this :) >> >> > E-mail message checked by Spyware Doctor (6.0.0.386) >> > Database version: >> 5.12060http://www.pctools.com/en/spyware-doctor-antivirus/ >> >> Any chance it's Spyware Doctor or some anti-virus flagging >> the message >> and hiding it? >>

RE: tkinter questions: behavior of StringVar, etc

2009-03-30 Thread John Posner
Eric Brunel said: >> The Tk instance is registered in a hidden variable in the >> Tkinter module. When >> you don't specify a master, it'll use the latest created Tk >> instance one by >> default. BTW, the latest should be the only one: it is >> quite unsafe to create >> several Tk insta

RE: Cannot register to submit a bug report

2009-03-31 Thread John Posner
>> >> We can try to debug this :) >> >> >> >> > E-mail message checked by Spyware Doctor (6.0.0.386) >> >> > Database version: >> >> 5.12060http://www.pctools.com/en/spyware-doctor-antivirus/ >> >> >> >> Any chance it's Spyware Doctor or some anti-virus flagging >> >> the messag

RE: Style question - defining immutable class data members

2009-03-31 Thread John Posner
I said: >> > My intent was to fix an obvious omission: a special case >> was discussed in >> > the "Augmented assignment statements" section, but an >> almost-identical >> > special case was omitted from the "Assignment statements" section. After finally getting registered at bugs.python.o

RE: Cannot register to submit a bug report

2009-03-31 Thread John Posner
Terry Ready said: >> > My ISP (AT&T/Yahoo) was blocking email from the Python bug-tracker: "The >> > sending system has been identified as a source of spam". >> >> I hope you were able to suggest to them that that >> identification must be >> an error. Frustrating given the spam sources

Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Posner
Dennis Lee Bieber presented a code snippet with two consecutive statements that made me think, "I'd code this differently". So just for fun ... is Dennis's original statement or my "_alt" statement more idiomatically Pythonic? Are there even more Pythonic alternative codings? mrkrs = [b for b i

RE: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Posner
>> >    mrkrs_alt2 = filter(lambda b: b > 127 or b in list("\r\n\t"), block) >> > >> >> Never tested my 'pythonicity', but I would do: >> >> def test(b) : b > 127 or b in r"\r\n\t" Oops! Clearly, b in "\r\n\t" is preferable to ... b in list("\r\n\t") You do *not* want to u

Generators/iterators, Pythonicity, and primes

2009-04-04 Thread John Posner
Inspired by recent threads (and recalling my first message to Python edu-sig), I did some Internet searching on producing prime numbers using Python generators. Most algorithms I found don't go for the infinite, contenting themselves with "list all the primes below a given number". Here's a very P

RE: Generators/iterators, Pythonicity, and primes

2009-04-04 Thread John Posner
Mark Tolonen said: >> p <= sqrt(n) works a little better :^) >> >> -Mark >> Right you are -- I found that bug in my last-minute check, and then I forgot to trannscribe the fix into the email message. Duh -- thanks! -John E-mail message checked by Spyware Doctor (6.0.0.386) Database

RE: possible pairings in a set

2009-04-04 Thread John Posner
>> Also, if my code is considered ugly or redundant by this community, >> can you make suggestions to clean it up? Python is pretty mature: if you have a simple, generic problem, the chances are that someone else has already solved it, packaging the solution in a library (or "module"). For your

Re: Generators/iterators, Pythonicity, and primes

2009-04-05 Thread John Posner
Kay Schluehr said: > g = (lambda primes = []: > (n for n in count(2) \ > if > (lambda n, primes: (n in primes if primes and n<=primes[-1] \ > else > (primes.append(n) or True \ > if all(n%p for p in primes if p <= sqrt(n)) \ >

Re: Generators/iterators, Pythonicity, and primes

2009-04-05 Thread John Posner
Kay Schluehr wrote: > That's because it is *one* expression. The avoidance of named > functions makes it look obfuscated or prodigious. Once it is properly > dissected it doesn't look that amazing anymore. > > Start with: > > (n for n in count(2) if is_prime(n, primes)) > > The is_prime function

Re: Generators/iterators, Pythonicity, and primes

2009-04-05 Thread John Posner
>> > g = (lambda primes = []: >> > (n for n in count(2) if >> > (lambda x, primes: >> > (primes.append(x) or True >> > if all(x%p for p in primes if p <= sqrt(x)) >> > else False) >> > )(n, primes) >> >

Re: Weird Tk Canvas coordinate issue

2009-04-06 Thread John Posner
Tim Shannon wrote: I'm new to python, so keep that in mind. I have a tk Canvas that I'm trying to draw on, and I want to start my drawing at an offset (from 0) location. So I can tweak this as I code, I set this offset as a class level variable: def ClassName: OFFSET = 20 def __i

Re: Re: How can I change size of GUI?

2009-04-07 Thread John Posner
For what definition of 'did not work'? Seems perfectly fine to me. Just try to add the lines: root = Tk() Try adding a line like this: root.geometry("400x300+100+75") ... which means: "make the window 400 pixels wide and 300 pixels high, with the upperleft corner at point (100,75)"

Re: Re: Why does Python show the whole array?

2009-04-09 Thread John Posner
Lawrence D'Oliveiro wrote: > Fine if it only happened once. But it's a commonly-made mistake. At some > point you have to conclude that not all those people are stupid, there > really is something wrong with the design. I think "something wrong with the design" is overstating the case a bit, an

Re: Re: Why does Python show the whole array?

2009-04-09 Thread John Posner
Hrvoje Niksic wrote: > if test.contains(item) # would return a Boolean value > >> That's a string method, not a function in the string module. Oops, of course. import operator operator.contains('foo', 'o') That's pretty good, and IMHO a bit better than John Machin's suggestion

Re: Re: Re: Why does Python show the whole array?

2009-04-09 Thread John Posner
> Peter Otten wrote: >> Could you explain why you prefer 'contains(belly, beer)' >> or 'belly.contains(beer)' over 'beer in belly'? The last form may be a bit >> harder to find in the documentation, but once a newbie has learned about >> it he'll find it easy to remember. andrew cooke wrote:

Re: Re: Generators/iterators, Pythonicity, and primes

2009-04-11 Thread John Posner
Arnaud Delobelle wrote: You could do something like this with the help of itertools.ifilter: prime_gen = ifilter( lambda n, P=[]: all(n%p for p in P) and not P.append(n), count(2) ) Formidable! (both the English and French meanings) This is the most elegant, Sieve of Eratos

Re: Re: Re: Generators/iterators, Pythonicity, and primes

2009-04-12 Thread John Posner
Duncan Booth wrote: John Posner wrote: Do know what in the itertools implementation causes adding a 'if p <= sqrt(n)' clause to *decrease* performance, while adding a 'takewhile()' clause *increases* performance? I haven't timed it, but I would guess t

Re: any(), all() and empty iterable

2009-04-14 Thread John Posner
Tim Chase wrote: I still prefer "Return False if any element of the iterable is not true" or "Return False if any element in the iterable is false" because that describes exactly what the algorithm does. Granted, anybody with a mote of Python skills can tell that from the algorithm, but if you

Re: Re: How to check all elements of a list are same or different

2009-04-15 Thread John Posner
Chris Rebert wrote: Ah, okay. Then you want: def all_same(lst): return len(set(lst)) == 1 def all_different(lst): return len(set(lst)) == len(lst) Note that these require all the elements of the list to be hashable. This solution relies on the object ID -- no hashability required:

Re: Re: How to check all elements of a list are same or different

2009-04-15 Thread John Posner
Scott David Daniels wrote: Assuming you really are going for "is" comparison, how about: max(id(x) for x in mylist) == min(id(x) for x in mylist) It has the advantage that if [id(x) for x in mylist] = [2N, 1N, 3N], you get the answer you desire. Oops -- got me! -John -- http://mail.python

Re: any(), all() and empty iterable

2009-04-16 Thread John Posner
Tim Chase wrote: I will probably leave the lead-in sentence as-is but may add another sentence specifically covering the case for an empty iterable. as one of the instigators in this thread, I'm +1 on this solution. Thanks for weighing in, Raymond. As long as people are getting in their last

Re: color propagation in tkinter

2009-04-22 Thread John Posner
Alan G Isaac wrote: Yes, that's what I am currently doing. But it seems that that is exactly the kind of thing we are enabled to avoid with e.g., named fonts. So I was hoping for an equivalent functionality for colors. From your answer, I am guessing there is none. Not sure this would help, but

Re: and [True,True] --> [True, True]?????

2009-04-26 Thread John Posner
jazbees wrote: > I'm surprised to see that the use of min and max for element-wise > comparison with lists has not been mentioned. When fed lists of True/ > False values, max will return True if there is at least one True in > the list, while min will return False if there is at least one False.

Re: and [True,True] --> [True, True]?????

2009-04-26 Thread John Posner
Arnaud Delobelle wrote: return any( not val for val in value_list ) This is the same as: return not all(value_list) Yes, I should have remembered De Morgan's Theorem. Thanks! -John -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: sorted() erraticly fails to sort string numbers

2009-04-28 Thread John Posner
uuid wrote: I am at the same time impressed with the concise answer and disheartened by my inability to see this myself. My heartfelt thanks! Don't be disheartened! Many people -- myself included, absolutely! -- occasionally let a blind spot show in their messages to this list. BTW: contai

Re: Please explain this strange Python behaviour

2009-04-30 Thread John Posner
Duncan Booth wrote: Tim Chase wrote: There _are_ cases where it's a useful behavior, but they're rare, so I don't advocate getting rid of it. But it is enough of a beginner gotcha that it really should be in the Python FAQ at www.python.org/doc/faq/general/ That's an excellent idea! So

Re: Re: Please explain this strange Python behaviour

2009-04-30 Thread John Posner
Stephen Hansen wrote: I have a feeling this might start one of those uber-massive "pass by value / reference / name / object / AIEE" threads where everyone goes around in massive circles explaining how Python uses one or another parameter passing paradigm and why everyone else is wrong... but..

Re: Re: list comprehension question

2009-05-01 Thread John Posner
Shane Geiger wrote: if type(el) == list or type(el) is tuple: A tiny improvement: if type(el) in (list, tuple): -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter and widget placement after resizing

2009-05-08 Thread John Posner
jamieson wrote: i.e. start out with a window like this: [1][4][7] [2][5][8] [3][6][9] make the main window larger and end up with this: [1][6] [2][7] [3][8] [4][9] [5 Here's a solution, using Label widgets for clarity. The keys are: * start numbering from zero, not one * use divmod() on an

Re: Noobie python shell question

2009-11-30 Thread John Posner
On Sun, 29 Nov 2009 22:03:09 -0500, tuxsun wrote: I've been working in the shell on and off all day, and need to see if a function I defined earlier is defined in the current shell I'm working in. Is there a shell command to get of list of functions I've defined? How about this: #

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread John Posner
On Wed, 02 Dec 2009 10:55:23 -0500, Mark Summerfield wrote: On Dec 1, 2:03 pm, Mark Summerfield wrote: I've produced a 4 page document that provides a very concise summary of Python 2<->3 differences plus the most commonly used new Python 3 features. It is aimed at existing Python 2 program

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread John Posner
On Wed, 02 Dec 2009 13:34:11 -0500, Carsten Haese wrote: With string interpolation, you don't need to do that, either. '%*d' % (8,456) ' 456' Thanks, Carsten and Mark D. -- I'd forgotten about the use of "*" in minimum-field-width specs and precision specs (doh). How about this:

Re: How to create a self-destructing Tkinter dialog box?

2009-12-17 Thread John Posner
On Thu, 17 Dec 2009 02:09:03 -0500, Martin P. Hellwig wrote: mrstevegross wrote: Ok, I would like to put together a Python/Tkinter dialog box that displays a simple message and self-destructs after N seconds. Is there a simple way to do this? Thanks, --Steve Just, thinking aloud, I proba

Re: Programming intro book ch1 and ch2 (Windows/Python 3) - Request For Comments

2009-12-19 Thread John Posner
On Fri, 18 Dec 2009 13:00:48 -0500, Alf P. Steinbach wrote: Chapter 2 is about Basic Concepts (of programming). It's the usual: variables, ... 1. Overall suggestion You have a tendency to include non-pertinent asides [1]. But then, rambling a bit endows a manuscript with the author's

Re: Class variables static by default?

2009-12-19 Thread John Posner
On Sat, 19 Dec 2009 19:10:13 -0500, KarlRixon wrote: Given the following script, I'd expect p1.items to just contain ["foo"] and p2.items to contain ["bar"] but they both contain ["foo", "bar"]. Why is this? Are object variables not specific to their instance? --- #!/u

Re: PyQt Signals and multiple sources

2009-12-20 Thread John Posner
On Sun, 20 Dec 2009 16:59:11 -0500, Zabin wrote: I am beginner in programming in pyqt. I have been trying to call the same function from multiple events- but each event results in a different instance of the function. I am just unable to figure out how to retrieve the source which calls the fun

Re: How to iterate the input over a particular size?

2009-12-28 Thread John Posner
On Sun, 27 Dec 2009 09:44:17 -0500, joy99 wrote: Dear Group, I am encountering a small question. Suppose, I write the following code, input_string=raw_input("PRINT A STRING:") string_to_word=input_string.split() len_word_list=len(string_to_word) if len_word_list>9: rest_words=

Re: How to iterate the input over a particular size?

2009-12-29 Thread John Posner
On Tue, 29 Dec 2009 01:35:41 -0500, Steven D'Aprano wrote: On Tue, 29 Dec 2009 00:49:50 -0500, John Posner wrote: On Sun, 27 Dec 2009 09:44:17 -0500, joy99 wrote: Dear Group, I am encountering a small question. Suppose, I write the following code, input_string=raw_input(&qu

Re: How to iterate the input over a particular size?

2009-12-29 Thread John Posner
On Tue, 29 Dec 2009 01:35:41 -0500, Steven D'Aprano wrote: On Tue, 29 Dec 2009 00:49:50 -0500, John Posner wrote: On Sun, 27 Dec 2009 09:44:17 -0500, joy99 wrote: Dear Group, I am encountering a small question. Suppose, I write the following code, input_string=raw_input("PRIN

Re: How to iterate the input over a particular size?

2009-12-29 Thread John Posner
On Tue, 29 Dec 2009 01:35:41 -0500, Steven D'Aprano wrote: On Tue, 29 Dec 2009 00:49:50 -0500, John Posner wrote: On Sun, 27 Dec 2009 09:44:17 -0500, joy99 wrote: Dear Group, I am encountering a small question. Suppose, I write the following code, input_string=raw_input("PRIN

Re: Dynamic text color

2009-12-30 Thread John Posner
On Wed, 30 Dec 2009 12:58:06 -0500, Dave McCormick wrote: Hi All, I am new to Python and the list so I hope I am posting this correctly... I am working on a way to have text automatically formated in a Tkiniter Text widget and would like some input on my code. Currently I am using Python

Re: Dynamic text color

2009-12-31 Thread John Posner
On Thu, 31 Dec 2009 10:24:44 -0500, Dave McCormick wrote: John, Thank you for the tips. I was changing the line-column index to a FLOAT because the search would return the starting position (pos) of the string, then by making it a FLOAT and adding the string length I was able to get the en

Re: multivariable assignment

2009-12-31 Thread John Posner
On Thu, 31 Dec 2009 11:32:04 -0500, Andreas Waldenburger wrote: On Thu, 31 Dec 2009 08:13:35 -0800 (PST) davidj411 wrote: I am not sure why this behavior is this way. at beginning of script, i want to create a bunch of empty lists and use each one for its own purpose. however, updating one l

Re: Dynamic text color

2010-01-02 Thread John Posner
On Sat, Jan 2, 2010 at 1:47 PM, Dave McCormick wrote: WooHoo!!! I got it!!! Yup, I am sure it can be optimized but it works!!! Dave, please ignore a couple of my bogus complaints in the previous message: ... you call function new_Rword() before you define it ... this version also has

Re: Dynamic text color

2010-01-02 Thread John Posner
On Sat, Jan 2, 2010 at 1:47 PM, Dave McCormick wrote: WooHoo!!! I got it!!! Yup, I am sure it can be optimized but it works!!! Hmmm ... it doesn't work for me ... RED for word in redList: new_Rword(complete, word) def new_Rword(complete, word): Tbox.tag_remov

Re: Dynamic text color

2010-01-04 Thread John Posner
On Fri, 01 Jan 2010 21:01:04 -0500, Cousin Stanley wrote: I was not familiar with the re.finditer method for searching strings ... Stanley and Dave -- So far, we've just been using finditer() to perform standard-string searches (e.g. on the word "red"). Since Dave now wants to

Re: A null program - what is it doing?

2010-01-05 Thread John Posner
No doubt a dumb question from a noob: The following program (a cut down version of some test code) uses no CPU, and does not terminate: import sys from PyQt4.QtCore import * if __name__=="__main__": app = QCoreApplication(sys.argv) sys.exit(app.exec_()) What is the program doing?

Re: Dynamic text color

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 10:31:09 -0500, Dave McCormick wrote: ... But this is what I have so far. ## file = 'red.txt' file = open("red.txt","r") rList = file.readlines() file.close() redList = str(rList).split() Dave, you're doing exactly the right thing: gradually expanding your

Re: parsing an Excel formula with the re module

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 13:12:00 -0500, vsoler wrote: Hello, I am acessing an Excel file by means of Win 32 COM technology. For a given cell, I am able to read its formula. I want to make a map of how cells reference one another, how different sheets reference one another, how workbooks reference

Re: Dynamic text color

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 15:08:04 -0500, Dave McCormick wrote: It's certainly a mistake to use the expression "str(rList).split()". Using str() to convert the list "rList" into a string creates a mess that includes square-bracket characters. Did this actually work for you? It sort of worked

Re: Dynamic text color

2010-01-06 Thread John Posner
On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick wrote: But it is not what I am wanting. I first thought to make it look for a space but that would not work when a single character like "#" is to be colored if there is a "string" of them. Or if all of the characters between quotes are

Re: QDoubleValidator

2010-01-06 Thread John Posner
On Wed, 06 Jan 2010 17:47:37 -0500, Zabin wrote: On Jan 7, 10:23 am, Zabin wrote: Hey! I am new PyQt programmer and want to restrict users to allow only numeric values into a table and lineedit boxes. I found the QDoubleValidator class but am unsure as to how to implement it. (I am a little

Re: Dynamic text color

2010-01-08 Thread John Posner
On Fri, 08 Jan 2010 14:28:57 -0500, MRAB wrote: Dave McCormick wrote: On Wed, Jan 6, 2010 at 9:18 AM, John Posner <mailto:jjpos...@optimum.net>> wrote: On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick mailto:mackrac...@gmail.com>> wrote: But it is not wh

Re: [2.5.1.1/dictionary] Change sorting order?

2010-01-22 Thread John Posner
On 1/22/2010 7:17 AM, Gilles Ganault wrote: Hello I use a dictionary to keep a list of users connected to a web site. To avoid users from creating login names that start with digits in order to be listed at the top, I'd like to sort the list differently every minute so that it'll start with the

Re: pylint and the 'missing docstring' warning

2010-01-26 Thread John Posner
On 1/26/2010 8:43 AM, Jean-Michel Pichavant wrote: Hello, Does anyone using pylint knows a way to make pylint ignore these 'missing docstring' warnings when the base class version of the method actually defines the docstring ? 'Cause my doc builder (epydoc) handle it properly and propagate docst

Re: pylint and the 'missing docstring' warning

2010-01-26 Thread John Posner
On 1/26/2010 9:22 AM, Jean-Michel Pichavant wrote: John Posner wrote: On 1/26/2010 8:43 AM, Jean-Michel Pichavant wrote: Hello, Does anyone using pylint knows a way to make pylint ignore these 'missing docstring' warnings when the base class version of the method actually d

Re: Need help with a program

2010-01-28 Thread John Posner
On 1/28/2010 10:50 AM, evilweasel wrote: I will make my question a little more clearer. I have close to 60,000 lines of the data similar to the one I posted. There are various numbers next to the sequence (this is basically the number of times the sequence has been found in a particular sample).

  1   2   3   >