Re: tabs with tkinter

2014-11-28 Thread Peter Otten
Terry Reedy wrote: > On 11/28/2014 10:52 AM, Peter Otten wrote: >> ast wrote: >> >>> I have been using tkinter for few weeks now and I didn't found >>> how to make some tabs on a window. >>> >>> see this picture for a window with tabs >>> http://www.computerhope.com/jargon/t/tabs.gif >>> >>> Isn't

Re: Can you use self in __str__

2014-11-28 Thread Shiyao Ma
2014-11-29 11:36 GMT+08:00 Chris Angelico : > You can use id() on any object. You are guaranteed to get back an > integer which is both stable and unique among all ids of objects that > exist at the same time as the one you called it on. For as long as the > object continues to exist, that number *

Re: Can you use self in __str__

2014-11-28 Thread Chris Angelico
On Sat, Nov 29, 2014 at 2:16 PM, Shiyao Ma wrote: > 2014-11-28 13:00 GMT+08:00 Chris Angelico : >> On Fri, Nov 28, 2014 at 2:04 PM, Shiyao Ma wrote: >>> What if it's in the local namespace of a function or method? IDK, try >>> to get that thing first. >> > Sure enough. I will even avoid using "id

Re: Can you use self in __str__

2014-11-28 Thread Shiyao Ma
2014-11-28 13:00 GMT+08:00 Chris Angelico : > On Fri, Nov 28, 2014 at 2:04 PM, Shiyao Ma wrote: >> What if it's in the local namespace of a function or method? IDK, try >> to get that thing first. > Sure enough. I will even avoid using "id" as it's dependent on CPython implementation. :) > What i

Re: I love assert

2014-11-28 Thread Chris Angelico
On Sat, Nov 29, 2014 at 1:56 PM, MRAB wrote: > On 2014-11-29 01:30, Steven D'Aprano wrote: > [snip] >> >> I stress that assertions aren't a replacement for unit testing, but they >> compliment unit testing: assertions can help cover code missed by your >> unit >> tests, and check that your unit te

Re: I love assert

2014-11-28 Thread MRAB
On 2014-11-29 01:30, Steven D'Aprano wrote: [snip] I stress that assertions aren't a replacement for unit testing, but they compliment unit testing: assertions can help cover code missed by your unit tests, and check that your unit tests are correct. [snip] I think you meant "complement". :-)

Re: I love assert

2014-11-28 Thread Steven D'Aprano
alister wrote: > And as may wiser people than me have already highlighted Assertions can > be switched off in python which means they cannot be relied upon in > production code invalidating the authors suggestion that they can > automate bug reports & "Extend testing into the lifetime of the produ

Re: tabs with tkinter

2014-11-28 Thread Terry Reedy
On 11/28/2014 10:52 AM, Peter Otten wrote: ast wrote: I have been using tkinter for few weeks now and I didn't found how to make some tabs on a window. see this picture for a window with tabs http://www.computerhope.com/jargon/t/tabs.gif Isn't it feasible with tkinter ? See

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Akira Li
Ned Batchelder writes: > On 11/28/14 10:22 AM, Dave Angel wrote: >> On 11/28/2014 10:04 AM, fetchinson . wrote: >>> Hi all, >>> >>> I have a feeling that I should solve this by a context manager but >>> since I've never used them I'm not sure what the optimal (in the >>> python sense) solution is

Re: Asyncio problem, looking for advice.

2014-11-28 Thread Akira Li
Benjamin Risher writes: > On Friday, November 28, 2014 6:12:20 AM UTC-6, Akira Li wrote: >> Benjamin Risher writes: >> >> > Hello all, >> > >> > I'm working on a project to learn asyncio and network programming. >> > What I'm trying to do is forward a connection from myself to >> > another machi

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Michael Torrie
On 11/28/2014 08:04 AM, fetchinson . wrote: > Hi all, > > I have a feeling that I should solve this by a context manager but > since I've never used them I'm not sure what the optimal (in the > python sense) solution is. So basically what I do all the time is > this: I'd personally do it with a g

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Marko Rauhamaa
Chris Angelico : > Since we're so good at it on this list, I will nit-pick: that's not a > context manager class, that's an iterator class. A context manager has > __enter__ and __exit__, an iterator has __iter__ (returning self) and > __next__ (returning or raising StopIteration). Excellent. Lea

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Chris Angelico
On Sat, Nov 29, 2014 at 4:55 AM, Marko Rauhamaa wrote: > I think the OP can learn from the comparison. One question, many > lessons: > > * Here's how you write a generator. > > * Here's how you write a context manager class. You run into those >quite often as well. > > * See how much more s

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Marko Rauhamaa
Dave Angel : > Why would you prefer that over a generator function, as given earlier > in the thread? See for example Ned's message. By using 'yield', you > get Python to generate all the class boilerplate for you. I think the OP can learn from the comparison. One question, many lessons: * Here

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Dave Angel
Please don't start a new thread when responding to an existing topic. Just reply-List to the message you're responding to, and include some context from that message. On 11/28/2014 12:06 PM, ast wrote: Hi Here is a solution with a custom iterator which operate on files. I tested it with a sma

Re: tabs with tkinter

2014-11-28 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.16409.1417189956.18130.python-l...@python.org... See thx -- https://mail.python.org/mailman/listinfo/python-list

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread ast
Hi Here is a solution with a custom iterator which operate on files. I tested it with a small file. Just a remark, there are no empty line on a file, there is at least '\n' at the end of each lines but maybe the last one. If readline() got an emptyline, then the end of file has been reached.

Re: Can you use self in __str__

2014-11-28 Thread Rustom Mody
On Friday, November 28, 2014 7:51:40 PM UTC+5:30, Rustom Mody wrote: > On Friday, November 28, 2014 6:57:23 AM UTC+5:30, Seymore4Head wrote: > > def __str__(self): > > s = "Hand contains " > > for x in self.hand: > > s = s + str(x) + " " > > return s > > > > Thi

Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-28 Thread Michael Torrie
On 11/28/2014 06:06 AM, Juan Christian wrote: > Which one would be better in performance, having a single 'Worker' to call > all URLs, having inside this worker functions for each stuff, or having 3~5 > different workers doing different stuff. In the end I'll only print the > data when I have them

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Dave Angel
On 11/28/2014 11:01 AM, Ned Batchelder wrote: On 11/28/14 10:22 AM, Dave Angel wrote: On 11/28/2014 10:04 AM, fetchinson . wrote: Hi all, I have a feeling that I should solve this by a context manager but since I've never used them I'm not sure what the optimal (in the python sense) solution i

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Ned Batchelder
On 11/28/14 10:22 AM, Dave Angel wrote: On 11/28/2014 10:04 AM, fetchinson . wrote: Hi all, I have a feeling that I should solve this by a context manager but since I've never used them I'm not sure what the optimal (in the python sense) solution is. So basically what I do all the time is this:

Re: Asyncio problem, looking for advice.

2014-11-28 Thread Benjamin Risher
On Friday, November 28, 2014 6:12:20 AM UTC-6, Akira Li wrote: > Benjamin Risher writes: > > > Hello all, > > > > I'm working on a project to learn asyncio and network programming. What > > I'm trying to do is forward a connection from myself to another machine. > > Kind of like an asynchronou

Re: tabs with tkinter

2014-11-28 Thread Peter Otten
ast wrote: > I have been using tkinter for few weeks now and I didn't found > how to make some tabs on a window. > > see this picture for a window with tabs > http://www.computerhope.com/jargon/t/tabs.gif > > Isn't it feasible with tkinter ? See

Re: Db transactions and locking

2014-11-28 Thread Ian Kelly
On Nov 27, 2014 4:39 PM, "Chris Angelico" wrote: > > On Fri, Nov 28, 2014 at 5:02 AM, Ian Kelly wrote: > > On Nov 27, 2014 4:26 AM, "Frank Millman" wrote: > >> All Python database adaptors that I have used start a transaction when you > >> open a cursor. I have just re-read DB-API 2.0, and I can

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread fetchinson .
On 11/28/14, Dave Angel wrote: > On 11/28/2014 10:04 AM, fetchinson . wrote: >> Hi all, >> >> I have a feeling that I should solve this by a context manager but >> since I've never used them I'm not sure what the optimal (in the >> python sense) solution is. So basically what I do all the time is

Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread Dave Angel
On 11/28/2014 10:04 AM, fetchinson . wrote: Hi all, I have a feeling that I should solve this by a context manager but since I've never used them I'm not sure what the optimal (in the python sense) solution is. So basically what I do all the time is this: for line in open( 'myfile' ): if n

tabs with tkinter

2014-11-28 Thread ast
Hi I have been using tkinter for few weeks now and I didn't found how to make some tabs on a window. see this picture for a window with tabs http://www.computerhope.com/jargon/t/tabs.gif Isn't it feasible with tkinter ? thanks -- https://mail.python.org/mailman/listinfo/python-list

Iterate over text file, discarding some lines via context manager

2014-11-28 Thread fetchinson .
Hi all, I have a feeling that I should solve this by a context manager but since I've never used them I'm not sure what the optimal (in the python sense) solution is. So basically what I do all the time is this: for line in open( 'myfile' ): if not line: # discard empty lines

Re: Can you use self in __str__

2014-11-28 Thread Rustom Mody
On Friday, November 28, 2014 6:57:23 AM UTC+5:30, Seymore4Head wrote: > def __str__(self): > s = "Hand contains " > for x in self.hand: > s = s + str(x) + " " > return s > > This is part of a Hand class. I need a hand for the dealer and a hand > for the player.

Re: localization virt-manager

2014-11-28 Thread Akira Li
Беляев Игорь writes: > I can't install localization for Virt-manager (virt-manager launched on > python2.7 (Windows XP)). virt-manager is a GUI for KVM, Xen, LXC virtual machines. It is a Linux application. > How do I correctly install location? Do you mean *locale*? > How can I change the

manipulating an existing plot !

2014-11-28 Thread ram rokr
Hello, I already have a script that plots a polygon. But now I'm trying to script a python class that would enable me to import the previous plot , make instances and control it too(like specifying parameters like spacing , width, height or the like). My approach was, to create a new layout

Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-28 Thread Juan Christian
On Fri Nov 28 2014 at 2:07:32 AM Michael Torrie wrote: Okay, here's a reworking of the code that invokes a new QThread instance each time. Note the QThread instance has to be bound to the MainWindow so that it won't be destroyed when it goes out of scope. Also the Worker thread sends a signal with

Re: Asyncio problem, looking for advice.

2014-11-28 Thread Akira Li
Benjamin Risher writes: > Hello all, > > I'm working on a project to learn asyncio and network programming. What I'm > trying to do is forward a connection from myself to another machine. Kind of > like an asynchronous python implementation of fpipe. > > In a nutshell: > > 1 --> start a serve

Re: Can you use self in __str__

2014-11-28 Thread Dave Angel
On 11/27/2014 08:43 PM, Chris Angelico wrote: On Fri, Nov 28, 2014 at 12:26 PM, Seymore4Head wrote: dealer=Hand() player=Hand() This prints out 'Hand contains " foo bar for both the dealer's hand and the player's hand. Is there a way to include "self" in the __string__ so it reads Dealer hand

Re: Can you use self in __str__

2014-11-28 Thread Chris Angelico
On Fri, Nov 28, 2014 at 12:26 PM, Seymore4Head wrote: > dealer=Hand() > player=Hand() > This prints out 'Hand contains " foo bar > for both the dealer's hand and the player's hand. > > Is there a way to include "self" in the __string__ so it reads > Dealer hand contains foo bar > Player hand conta

localization virt-manager

2014-11-28 Thread Беляев Игорь
Hello! I can't install localization for Virt-manager (virt-manager launched on python2.7 (Windows XP)). How do I correctly install location? How can I change the value of the environment variable LANG? --  С уважением, Беляев Игорь +79168341810 -- https://mail.python.org/mailman/listinfo/pyth

Re: Can you use self in __str__

2014-11-28 Thread Dave Angel
On 11/27/2014 10:31 PM, Seymore4Head wrote: On Thu, 27 Nov 2014 21:49:29 -0500, Dave Angel wrote: class Hand: def __init__(self): self.hand = [] # create Hand object def __str__(self): s = 'Hand contains ' for x in self.hand: s = s + s

Re: Can you use self in __str__

2014-11-28 Thread Steven D'Aprano
Seymore4Head wrote: > def __str__(self): > s = "Hand contains " > for x in self.hand: > s = s + str(x) + " " > return s > > This is part of a Hand class. I need a hand for the dealer and a hand > for the player. > dealer=Hand() > player=Hand() > This print