Do we have python equivalent of 'perl -e'??

2008-08-22 Thread srinivasan srinivas
HI, Like we run perl small code snippet using perl -e, do we have anything like that in python?? Thanks, Srini Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Do we have python equivalent of 'perl -e'??

2008-08-22 Thread Ben Finney
srinivasan srinivas [EMAIL PROTECTED] writes: Like we run perl small code snippet using perl -e, do we have anything like that in python?? It's customary to check the usage summary of the program itself. = $ python --help usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...

Re: Do we have python equivalent of 'perl -e'??

2008-08-22 Thread Peter Otten
srinivasan srinivas wrote: Like we run perl small code snippet using perl -e, do we have anything like that in python?? Thanks, $ python -c 'print yes' yes Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Graphics Contexts and DCs explanations?

2008-08-22 Thread Tim Roberts
RgeeK [EMAIL PROTECTED] wrote: ... I use the wxPython demo app heavily to figure this stuff out, and my experiments seem to work, but I'm flying blind somewhat. Can someone englighten me about the wx.GraphicsContext versus wx.PaintDC (BTW what does PaintDC stand for? Drawing Context

Re: Sorted Returns List and Reversed Returns Iterator

2008-08-22 Thread Peter Otten
++imanshu wrote: On Aug 22, 8:40 am, John Machin [EMAIL PROTECTED] wrote: On Aug 22, 1:35 pm, John Machin [EMAIL PROTECTED] wrote: On Aug 22, 12:12 pm, ++imanshu [EMAIL PROTECTED] wrote: Hi, Is there a reason why two similarly named functions Sorted and Reversed return different

Re: evaluating code lines above breakpoints ?

2008-08-22 Thread Tim Roberts
Stef Mientki [EMAIL PROTECTED] wrote: Diez B. Roggisch wrote: Why do you want this anyway? Why don't you simply show all the variables in the local frame? I'd say thats enough. because it's too much data, and too much data decreases information content. Most Python functions do not

Re: Sorted Returns List and Reversed Returns Iterator

2008-08-22 Thread Fredrik Lundh
John Machin wrote: reversed came later; returning an iterator rather than a list provides more flexibility. As in flexibility for the implementer, the day someone invents a sort algorithm that doesn't have to look at all source items before it starts producing output? Because I fail to

Re: File operations

2008-08-22 Thread Fredrik Lundh
John Machin wrote: and don't use the name of the built-in file function as one of your own names file is a type, not a function, and has been removed in 3.0. given that file is hardly ever used in properly written Python 2 code (if you need to check for file-like behaviour in Python 2,

Re: Could anyone point me to a good site for pearl compiler download

2008-08-22 Thread Fredrik Lundh
Gabriel Genellina wrote: Could anyone point me to a good site for pearl compiler download. Would be better to ask for it in a Perl group, don't you think? Or a Pearl group, even: http://www.irt.uni-hannover.de/pearl/pearl-gb.html /F --

Re: Sorted Returns List and Reversed Returns Iterator

2008-08-22 Thread Terry Reedy
Peter Otten wrote: ++imanshu wrote: I agree. Iterator is more flexible. I disagree. Neither is more flexible. You can iter the list returned by sorted and list the iter returned by reversed. Both do the minimum work necessary. See below. Together and both might have returned the

Re: semantics of the |= operator

2008-08-22 Thread akva
thanks all, Yes. That's the exact purpose of the in-place operators when they deal with mutable objects. What else did you expect? well, frankly I expected a |= b to mean exactly the same as a = a | b regardless of the object type. The manual explicitly specifies that mutable objects may

Re: Is my thinking Pythonic?

2008-08-22 Thread Fredrik Lundh
Bruno Desthuilliers wrote: Unless you have a really good reason to use an antiquated and deprecated object model, use new-style classes (for a value of new being now many years old): the distinction is gone in 3.0, so can we please stop flaming people for violating a crap rule that's quite

Re: semantics of the |= operator

2008-08-22 Thread Fredrik Lundh
akva wrote: could you please refer me a link where this is specified? I couldn't find it in python documentation http://docs.python.org/ref/augassign.html An augmented assignment expression like x += 1 can be rewritten as x = x + 1 to achieve a similar, but not exactly equal effect. In the

Re: programming toolbox

2008-08-22 Thread Peter Anderson
Bill Purcell said: ... I was wondering what more experienced programmers think about what languages are necessary to be able to handle most programming problems. ... Bill, I have a similar length of experience with python to you. I look at other languages from time to time but the only two I

Re: 'While' question

2008-08-22 Thread Bruno Desthuilliers
John Machin a écrit : (snip) A quick rule of thumb for Python: if your code looks ugly or strained or awkward, it's probably also wrong. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Overwriting property- can't set attribute

2008-08-22 Thread Gregor Horvath
Hi, why is this code failing? class B(object): pass B.testattr = property(lambda s:hallo) b = B() b.testattr = test Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) /tmp/python-14202ViU.py in module() 14 B.testattr = property(lambda s:hallo) 15 b = B() --- 16 b.testattr = test

Re: Overwriting property- can't set attribute

2008-08-22 Thread Gregor Horvath
Gregor Horvath schrieb: why is this code failing? OK I answer myself :-) Because there is not fset function definied in the property. I have to del the attr before rebinding the attributename to another object. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Overwriting property- can't set attribute

2008-08-22 Thread Raymond Hettinger
On Aug 22, 5:38 am, Gregor Horvath [EMAIL PROTECTED] wrote: why is this code failing? class B(object):      pass B.testattr = property(lambda s:hallo) b = B() b.testattr = test First, property() only works when attached to classes, not instances. So the assignment should be: B.testattr =

Re: Overwriting property- can't set attribute

2008-08-22 Thread Bruno Desthuilliers
Raymond Hettinger a écrit : On Aug 22, 5:38 am, Gregor Horvath [EMAIL PROTECTED] wrote: why is this code failing? class B(object): pass B.testattr = property(lambda s:hallo) b = B() b.testattr = test First, property() only works when attached to classes, not instances. So the

Re: running exe file

2008-08-22 Thread [EMAIL PROTECTED]
On Aug 22, 12:12 am, Saurabh Sharma [EMAIL PROTECTED] wrote: How can I run .exe file from my python script? import os os.startfile('file.exe') The downside is that it doesn't work on the mac.. but it does work on stuff like os.startfile('notepad.txt') I have been waiting for a good hacker

def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Bart van Deenen
Hi all. I've stumbled onto a python behavior that I don't understand at all. Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) # function def X(l=[]): l.append(1) print l # first call of X X() [1] #second call of X X() [1, 1] Where does the list parameter 'l' live between the two

Re: Is my thinking Pythonic?

2008-08-22 Thread Bruno Desthuilliers
Fredrik Lundh a écrit : Bruno Desthuilliers wrote: Unless you have a really good reason to use an antiquated and deprecated object model, use new-style classes (for a value of new being now many years old): the distinction is gone in 3.0, Yeps, but not in 2.5.2, which is still the current

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread cokofreedom
On Aug 22, 11:13 am, Bart van Deenen [EMAIL PROTECTED] wrote: Hi all. I've stumbled onto a python behavior that I don't understand at all. Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) # function def X(l=[]):    l.append(1)    print l # first call of X X() [1] #second call of X

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Wojtek Walczak
On Fri, 22 Aug 2008 11:13:52 +0200, Bart van Deenen wrote: I've stumbled onto a python behavior that I don't understand at all. ... Does anyone have any pointers to the language documentation where this behavior is described? Yes, it's documented in FAQ:

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Bart van Deenen
Hi Thanks all for your answers. I figured your solution already, but now I understand where the behavior is from. One question remains: can I find my parameter 'l' somewhere? I looked in a lot of objects, but couldn't find it. Thanks Bart. [EMAIL PROTECTED] wrote: On Aug 22, 11:13 am,

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Diez B. Roggisch
Wojtek Walczak schrieb: On Fri, 22 Aug 2008 11:13:52 +0200, Bart van Deenen wrote: I've stumbled onto a python behavior that I don't understand at all. ... Does anyone have any pointers to the language documentation where this behavior is described? Yes, it's documented in FAQ:

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Bruno Desthuilliers
Bart van Deenen a écrit : (ot : please don't top post - corrected) [EMAIL PROTECTED] wrote: On Aug 22, 11:13 am, Bart van Deenen [EMAIL PROTECTED] wrote: # function def X(l=[]): l.append(1) print l # first call of X X() [1] #second call of X X() [1, 1] Where does the list parameter 'l'

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Wojtek Walczak
On Fri, 22 Aug 2008 11:41:18 +0200, Bart van Deenen wrote: Thanks all for your answers. I figured your solution already, but now I understand where the behavior is from. One question remains: can I find my parameter 'l' somewhere? I looked in a lot of objects, but couldn't find it.

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Wojtek Walczak
On Fri, 22 Aug 2008 11:42:03 +0200, Diez B. Roggisch wrote: It's amazing. I didn't analyse this properly, but IMHO this issue is the single most asked question (or rather the effects in produces) on this list. Maybe we should get *really* explicit in

Launch an application and continue the script's execution

2008-08-22 Thread Marian Popa
Hello, I am new in Python programming and I have the following problem: I have a script in which I need to open an application (called from a batch file - trace.bat). For this purpuse, I'm executing the following piece of code:   import os, win32process from win32api import Sleep from ctypes

Re: exception handling in complex Python programs

2008-08-22 Thread magloca
Bruno Desthuilliers @ Thursday 21 August 2008 22:54: magloca a écrit : Bruno Desthuilliers @ Thursday 21 August 2008 17:31: If you mean the exceptions *explicitely raised* by your code, then I agree. But with any generic enough code, documenting any possible exception that could be raised

need help using enumerate ??

2008-08-22 Thread [EMAIL PROTECTED]
I am trying to take some data in file that looks like this command colnum_1 columnum_2 and look for the command and then cange the value in the collum(word) number indicated. I am under the impression I need enumerate but I am not sure what to do with it any help would be nice. import sys

Re: urllib2 HTTPBasicAuthHandler and resumingbroken downloads

2008-08-22 Thread Brendan
On Aug 21, 3:57 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 21 Aug 2008 15:37:41 -0300, Brendan [EMAIL PROTECTED]   escribi : Is there any way to resume an https file download using urllib2 and an HTTPBasicAuthHandler? You should provide the Range header (and probably If-Range

I am trying to install the mechanize lib so I can use python to do webbrowseing

2008-08-22 Thread [EMAIL PROTECTED]
Hi, I am trying to install the mechanize lib so I can use python to do webbrowseing. First I set up easy_install When I ran the script, it download the files ok, then I got these error messages sun is not reganized as a internal command I did a sercah on sun.* and the sercah came up empty, am I

Re: exception handling in complex Python programs

2008-08-22 Thread Maric Michaud
Le Thursday 21 August 2008 09:34:47 Bruno Desthuilliers, vous avez écrit : The point is that EAFP conflicts with the interest of reporting errors as soon as possible (on which much has been written see, for instance Ch. 8 - Defensive Programming in Code Complete), Defensive programming

Re: programming toolbox

2008-08-22 Thread eliben
Biggest issue I have with Python is screen input and output. I am trying to master wxPython (and Tkinter) but find this aspect harder than it ought to be. This is hardly an issue with Python. You'll run into it with all languages. You think wxPython is hard to master ? You should try writing

Trouble importing modules in IDLE (Win32)

2008-08-22 Thread [EMAIL PROTECTED]
Hello, I wrote aprogram that imports odbc and dbi. Originally I used PyWin, but now I prefer IDLE for working in Windows. Anyway, when I start my program from IDLE, it can't import the odbc and dbi modules. However, when I restart the shell and type import odbc at the prompt by, I don't get an

Re: Trouble importing modules in IDLE (Win32)

2008-08-22 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Hello, I wrote aprogram that imports odbc and dbi. Originally I used PyWin, but now I prefer IDLE for working in Windows. Anyway, when I start my program from IDLE, it can't import the odbc and dbi modules. However, when I restart the shell and type import odbc at the

Re: need help using enumerate ??

2008-08-22 Thread Chris
On Aug 22, 1:14 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am trying to take some data in file that looks like this command colnum_1 columnum_2 and look for the command and then cange the value in the collum(word) number indicated. I am under the impression I need enumerate but I

Re: exception handling in complex Python programs

2008-08-22 Thread Lie
On Aug 21, 12:59 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Wed, 20 Aug 2008 09:23:22 -0700, [EMAIL PROTECTED] wrote: On Aug 19, 4:12 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Tue, 19 Aug 2008 11:07:39 -0700, [EMAIL PROTECTED] wrote:   def

Re: exception handling in complex Python programs

2008-08-22 Thread Bruno Desthuilliers
Maric Michaud a écrit : Le Thursday 21 August 2008 09:34:47 Bruno Desthuilliers, vous avez écrit : The point is that EAFP conflicts with the interest of reporting errors as soon as possible (on which much has been written see, for instance Ch. 8 - Defensive Programming in Code Complete),

Re: Question about wx BoxSizer background

2008-08-22 Thread Gandalf
thanks! -- http://mail.python.org/mailman/listinfo/python-list

gridSizer inside a panel element

2008-08-22 Thread Gandalf
why when I try to insert gridSizer to a panel which already inside another panel the gridSizer doesn't work? this is the code: panel3= wx.Panel(self, -1, (0, 60), size=(400, 240) , style=wx.SIMPLE_BORDER); panel3.SetBackgroundColour('#dadadb') panel = wx.Panel(panel3, wx.ID_ANY,

Re: programming toolbox

2008-08-22 Thread William Purcell
Thanks for the replies. I am still wondering if C++ would be worth learning and I think it could be answered by these three questions... 1. Are programs written in C++ better (in any form of the word) than programs written in python or vise versa or equal? 2. Is compiled better than interpreted?

Re: exception handling in complex Python programs

2008-08-22 Thread Lie
On Aug 21, 2:34 pm, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] a écrit : On Aug 19, 4:12 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Tue, 19 Aug 2008 11:07:39 -0700, [EMAIL PROTECTED] wrote:   def do_something(filename):     if not

Re: Usual practice: running/testing modules in a package

2008-08-22 Thread [EMAIL PROTECTED]
On 18 ago, 08:28, Gabriel Genellina [EMAIL PROTECTED] wrote: A package is a library, meant to be imported by some other code. Your main script (or the testing code) is a program, it uses (i.e. imports) the library. You are right that a module is a library and its main use is to be imported

Re: gridSizer inside a panel element

2008-08-22 Thread Iain King
On Aug 22, 2:09 pm, Gandalf [EMAIL PROTECTED] wrote: why when I try to insert gridSizer to a panel which already inside another panel the gridSizer doesn't work? this is the code: panel3= wx.Panel(self, -1, (0, 60), size=(400, 240) , style=wx.SIMPLE_BORDER);

codecs, csv issues

2008-08-22 Thread George Sakkis
I'm trying to use codecs.open() and I see two issues when I pass encoding='utf8': 1) Newlines are hardcoded to LINEFEED (ascii 10) instead of the platform-specific byte(s). import codecs f = codecs.open('tmp.txt', 'w', encoding='utf8') s = u'\u0391\u03b8\u03ae\u03bd\u03b1' print

Re: exception handling in complex Python programs

2008-08-22 Thread Wojtek Walczak
On Fri, 22 Aug 2008 06:43:58 -0700 (PDT), Lie wrote: I think we should change except: into expect:, it would confuse less, would it? It signifies that the program expects so and so kinds of exceptional situations. The try: should also be changed to... perhaps in:, block:, onthiscode:, etc

Using Tkinter

2008-08-22 Thread J-Burns
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By this I mean that the format would be something like this: You have Page1 : This has 2-3 buttons on it.

Re: Early halt for iterating a_list and iter(a_list)

2008-08-22 Thread Lie
On Aug 15, 9:55 pm, Fredrik Lundh [EMAIL PROTECTED] wrote: Lie wrote: When you've got a nested loop a StopIteration in the Inner Loop would break the loop for the outer loop too: a, b, c = [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5] def looper(a, b, c):     for a_ in a:         for b_

Re: need help using enumerate ??

2008-08-22 Thread [EMAIL PROTECTED]
On Aug 22, 7:56 am, Chris [EMAIL PROTECTED] wrote: On Aug 22, 1:14 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am trying to take some data in   file that looks like this command colnum_1 columnum_2 and look for the command and then cange the value in the collum(word) number

Re: exception handling in complex Python programs

2008-08-22 Thread Maric Michaud
Le Friday 22 August 2008 15:03:21 Bruno Desthuilliers, vous avez écrit : Maric Michaud a écrit : Le Thursday 21 August 2008 09:34:47 Bruno Desthuilliers, vous avez écrit : The point is that EAFP conflicts with the interest of reporting errors as soon as possible (on which much has been

Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Steven D'Aprano
Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread finally, and painfully, fade away than another one starts up. I suggest that Python should raise

Re: need help using enumerate ??

2008-08-22 Thread bearophileHUGS
Chris: Iterate over your input file, split the line into it's component parts and then lookup if the first element 'command' is contained in the replacement data and if so change the data. If you want all input to be saved into your output file, just dedent the 'outFile.write'

Re: Is tempfile.mkdtemp() thread-safe?

2008-08-22 Thread Gabriel Rossetti
Dennis Lee Bieber wrote: On Thu, 21 Aug 2008 13:22:33 +0200, Gabriel Rossetti [EMAIL PROTECTED] declaimed the following in comp.lang.python: have a solution? I have to create unique and temp. directories to use an external program that creates a temp. file with the same name every time,

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Diez B. Roggisch
Steven D'Aprano schrieb: Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread finally, and painfully, fade away than another one starts up. I suggest that

dict views implementation

2008-08-22 Thread bearophileHUGS
Where can I find an explanation of how the new light dict views of Python 3 are implemented (or what's the name of the C source file to look inside for their implementation)? Thank you, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Christian Heimes
Steven D'Aprano wrote: I suggest that Python should raise warnings.RuntimeWarning (or similar?) when a function is defined with a default argument consisting of a list, dict or set. (This is not meant as an exhaustive list of all possible mutable types, but as the most common ones that I

Re: The Importance of Terminology's Quality

2008-08-22 Thread George Neuner
On Thu, 21 Aug 2008 02:30:27 GMT, [EMAIL PROTECTED] wrote: On Wed, 20 Aug 2008 21:18:22 -0500, [EMAIL PROTECTED] (Rob Warnock) wrote: Martin Gregorie [EMAIL PROTECTED] wrote: +--- | I was fascinated, though by the designs of early assemblers: I first | learnt Elliott assembler,

Re: programming toolbox

2008-08-22 Thread Derek Martin
On Fri, Aug 22, 2008 at 08:17:27AM -0500, William Purcell wrote: I am still wondering if C++ would be worth learning and I think it could be answered by these three questions... 1. Are programs written in C++ better (in any form of the word) than programs written in python or vise versa or

Re: gridSizer inside a panel element

2008-08-22 Thread Mike Driscoll
On Aug 22, 8:09 am, Gandalf [EMAIL PROTECTED] wrote: why when I try to insert gridSizer to a panel which already inside another panel the gridSizer doesn't work? this is the code: snip I'm not sure how to do multiple panels like that. And I'm not really sure what you're trying to achieve

Re: gridSizer inside a panel element

2008-08-22 Thread Mike Driscoll
On Aug 22, 8:51 am, Iain King [EMAIL PROTECTED] wrote: On Aug 22, 2:09 pm, Gandalf [EMAIL PROTECTED] wrote: why when I try to insert gridSizer to a panel which already inside another panel the gridSizer doesn't work? this is the code: panel3= wx.Panel(self, -1, (0, 60), size=(400,

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Peter Otten
Christian Heimes wrote: Steven D'Aprano wrote: I suggest that Python should raise warnings.RuntimeWarning (or similar?) when a function is defined with a default argument consisting of a list, dict or set. (This is not meant as an exhaustive list of all possible mutable types, but as the

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread bearophileHUGS
DrScheme is an implementation of Scheme that is very newbie-friendly. It has several limited sub-languages, etc. So maybe a command line option can be added to Python3 ( - newbie ? :-) ) that just switches on similar warnings, to help newbies (in schools, where there's a teacher that encourages

Re: codecs, csv issues

2008-08-22 Thread Peter Otten
George Sakkis wrote: I'm trying to use codecs.open() and I see two issues when I pass encoding='utf8': 1) Newlines are hardcoded to LINEFEED (ascii 10) instead of the platform-specific byte(s). import codecs f = codecs.open('tmp.txt', 'w', encoding='utf8') s =

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Peter Otten
[EMAIL PROTECTED] wrote: DrScheme is an implementation of Scheme that is very newbie-friendly. It has several limited sub-languages, etc. So maybe a command line option can be added to Python3 ( - newbie ? :-) ) that just switches on similar warnings, to help newbies (in schools, where

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Bart van Deenen
Diez B. Roggisch wrote: It's amazing. I didn't analyse this properly, but IMHO this issue is the single most asked question (or rather the effects in produces) on this list. I feel a bit dumb to ask a FAQ on the newsgroup. The problem with this particular question is that I found it hard to

Re: programming toolbox

2008-08-22 Thread Krishnakant Mane
hi william, I am slightly more experienced in python than you (2 years to be presise). Before this I handled pritty heavy as in coding and as in usage projects in java. Untill I came into the wonderful and powerful world of free software, I programmed in c++ using borlands c++ compiler and IDE.

Tkinter, toplevel and images

2008-08-22 Thread Pedro
Hi I'm trying to build a small application that can display some images in a toplevel window. I have this code: def Results(master): from Tkinter import Toplevel, Button, Label from PIL import ImageTk figures = ['first.png', 'second.png'] ResultsWindow = Toplevel(master)

property() usage - is this as good as it gets?

2008-08-22 Thread David Moss
Hi, I want to manage and control access to several important attributes in a class and override the behaviour of some of them in various subclasses. Below is a stripped version of how I've implemented this in my current bit of work. It works well enough, but I can't help feeling there a cleaner

Re: property() usage - is this as good as it gets?

2008-08-22 Thread castironpi
On Aug 22, 11:18 am, David Moss [EMAIL PROTECTED] wrote: Hi, I want to manage and control access to several important attributes in a class and override the behaviour of some of them in various subclasses. Below is a stripped version of how I've implemented this in my current bit of work.

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread castironpi
On Aug 22, 9:42 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread finally, and painfully,

Re: urllib2 HTTPBasicAuthHandler and resumingbroken downloads

2008-08-22 Thread Gabriel Genellina
En Fri, 22 Aug 2008 08:55:57 -0300, Brendan [EMAIL PROTECTED] escribi�: On Aug 21, 3:57 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 21 Aug 2008 15:37:41 -0300, Brendan [EMAIL PROTECTED]   escribi : Is there any way to resume an https file download using urllib2 and an

rules of thumb for cross os code

2008-08-22 Thread DwBear75
I am considering using python as a replacement for a lot of bash scripting that I have been doing. I would like to be as cross platform as possible, writing scripts for both windows and linux. Are there any guides are general rules of thumb on 1) keeping code os independant 2) nifty lambda's or

Re: programming toolbox

2008-08-22 Thread William Purcell
Thanks again for the replies. I think that Python will solve about any problem that I will need to do in some way or another. To give myself a better understanding of the computer mechanism in general and to be more rounded, I think I need to dabble in a lower language a little like C (and maybe

pickle passing client/server design

2008-08-22 Thread DwBear75
I am contemplating the need for a way to handle high speed data passing between two processes. One process would act as a queue that would 'buffer' data coming from another processes. Seems that the easiest way to handle the data would be to just pass pickles. Further, I'm thinking that using a

Re: programming toolbox

2008-08-22 Thread Mensanator
On Aug 22, 11:17 am, Krishnakant Mane [EMAIL PROTECTED] wrote: hi william, I am slightly more experienced in python than you (2 years to be presise). Before this I handled pritty heavy as in coding and as in usage projects in java. Untill I came into the wonderful and powerful world of free

Re: pickle passing client/server design

2008-08-22 Thread John Krukoff
On Fri, 2008-08-22 at 10:09 -0700, DwBear75 wrote: I am contemplating the need for a way to handle high speed data passing between two processes. One process would act as a queue that would 'buffer' data coming from another processes. Seems that the easiest way to handle the data would be to

Re: Usual practice: running/testing modules in a package

2008-08-22 Thread Gabriel Genellina
En Fri, 22 Aug 2008 10:48:50 -0300, [EMAIL PROTECTED] [EMAIL PROTECTED] escribió: On 18 ago, 08:28, Gabriel Genellina [EMAIL PROTECTED] wrote: A package is a library, meant to be imported by some other code. Your main script (or the testing code) is a program, it uses (i.e. imports) the

Re: Overwriting property- can't set attribute

2008-08-22 Thread norseman
Gregor Horvath wrote: Hi, why is this code failing? class B(object): pass B.testattr = property(lambda s:hallo) b = B() b.testattr = test Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) /tmp/python-14202ViU.py in module() 14 B.testattr = property(lambda s:hallo) 15 b = B()

Re: pickle passing client/server design

2008-08-22 Thread castironpi
On Aug 22, 12:09 pm, DwBear75 [EMAIL PROTECTED] wrote: I am contemplating the need for a way to handle high speed data passing between two processes. One process would act as a queue that would 'buffer' data coming from another processes. Seems that the easiest way to handle the data would be

How to read and write the same socket in different threads?

2008-08-22 Thread Leo Jay
I'd like to read and write the same socket in different threads. one thread is only used to read from the socket, and the other is only used to write to the socket. But I always get a 10022 'Invalid argument' exception. Anyone knows why? I'm using windows xp. my source code is here:

Re: property() usage - is this as good as it gets?

2008-08-22 Thread Miles
On Fri, Aug 22, 2008 at 12:18 PM, David Moss [EMAIL PROTECTED] wrote: Hi, I want to manage and control access to several important attributes in a class and override the behaviour of some of them in various subclasses. Below is a stripped version of how I've implemented this in my current

Re: How to read and write the same socket in different threads?

2008-08-22 Thread Jean-Paul Calderone
On Sat, 23 Aug 2008 01:47:23 +0800, Leo Jay [EMAIL PROTECTED] wrote: I'd like to read and write the same socket in different threads. one thread is only used to read from the socket, and the other is only used to write to the socket. But I always get a 10022 'Invalid argument' exception. Anyone

Re: dict views implementation

2008-08-22 Thread Christian Heimes
[EMAIL PROTECTED] wrote: Where can I find an explanation of how the new light dict views of Python 3 are implemented (or what's the name of the C source file to look inside for their implementation)? The views are implemented next to the dict object. Grepping for PyTypeObject in

Re: property() usage - is this as good as it gets?

2008-08-22 Thread George Sakkis
On Aug 22, 12:18 pm, David Moss [EMAIL PROTECTED] wrote: Hi, I want to manage and control access to several important attributes in a class and override the behaviour of some of them in various subclasses. Below is a stripped version of how I've implemented this in my current bit of work.

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Emile van Sebille
Steven D'Aprano wrote: Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread finally, and painfully, fade away than another one starts up. I suggest that

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread MRAB
On Aug 22, 4:09 pm, Christian Heimes [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: I suggest that Python should raise warnings.RuntimeWarning (or similar?) when a function is defined with a default argument consisting of a list, dict or set. (This is not meant as an exhaustive list of all

Re: property() usage - is this as good as it gets?

2008-08-22 Thread Christian Heimes
David Moss wrote: Hi, I want to manage and control access to several important attributes in a class and override the behaviour of some of them in various subclasses. Below is a stripped version of how I've implemented this in my current bit of work. It works well enough, but I can't help

Re: How to read and write the same socket in different threads?

2008-08-22 Thread Leo Jay
On Sat, Aug 23, 2008 at 1:58 AM, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Sat, 23 Aug 2008 01:47:23 +0800, Leo Jay [EMAIL PROTECTED] wrote: I'd like to read and write the same socket in different threads. one thread is only used to read from the socket, and the other is only used to

Re: How to read and write the same socket in different threads?

2008-08-22 Thread Jean-Paul Calderone
On Sat, 23 Aug 2008 02:25:17 +0800, Leo Jay [EMAIL PROTECTED] wrote: On Sat, Aug 23, 2008 at 1:58 AM, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Sat, 23 Aug 2008 01:47:23 +0800, Leo Jay [EMAIL PROTECTED] wrote: I'd like to read and write the same socket in different threads. one thread

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Christian Heimes
MRAB wrote: Could there be a new special method __mutable__? Why should we add a new method? Seriously, why should Python be cluttered and slowed down to warn about mutable arguments. It's neither a design flaw nor a surprising feature *ONCE* you have understood how functions work. I agree

Re: Using Tkinter

2008-08-22 Thread adam2new
For references, you may use these PDF files (One URL changed since my last time there, but it should be correct for now): http://www.pythonware.com/media/data/an-introduction-to-tkinter.pdf http://infohost.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdf (The first one may be useful for starting out)

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Diez B. Roggisch
Emile van Sebille schrieb: Steven D'Aprano wrote: Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread finally, and painfully, fade away than another one

Re: exception handling in complex Python programs

2008-08-22 Thread Gabriel Genellina
En Thu, 21 Aug 2008 14:48:45 -0300, magloca [EMAIL PROTECTED] escribió: Bruno Desthuilliers @ Thursday 21 August 2008 17:31: Java's checked exception system has proven to be a total disaster. Could you elaborate on that? I'm not disagreeing with you (or agreeing, for that matter); I'd

Python one-liner??

2008-08-22 Thread srinivasan srinivas
Hi, Do we have python one-liner like perl one-liner 'perl -e'?? Thanks, Srini Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/ -- http://mail.python.org/mailman/listinfo/python-list

[no subject]

2008-08-22 Thread Janno Tikka
Is there a way to make a fake mouse or something like that? I'm planning to create a frame with web open and then macro on it with that fake mouse. And i want fake mouse so i can use my computer while that fake mouse is doing its job. -- http://mail.python.org/mailman/listinfo/python-list

Re: 'While' question

2008-08-22 Thread Ben Keshet
Thanks. I tried to use 'for' instead of 'while' as both of you suggested. It's running well as my previous version but breaks completely instead of just skipping the empty file. I suspect the reason is that this part is inside another 'for' so it stops everything. I just want to it to

Re: Is tempfile.mkdtemp() thread-safe?

2008-08-22 Thread Gabriel Rossetti
Dennis Lee Bieber wrote: On Thu, 21 Aug 2008 13:22:33 +0200, Gabriel Rossetti [EMAIL PROTECTED] declaimed the following in comp.lang.python: have a solution? I have to create unique and temp. directories to use an external program that creates a temp. file with the same name every time,

  1   2   3   >