Re: xml marshal of general (but non Python standard) class

2005-03-29 Thread "Martin v. Löwis"
syd wrote: But for my identifiedPeaks class (for instance), it has trouble. This class contains a list of "peak" classes IdentifiedPeaks.Peak... What precisely is the name of the class. You say it is IdentifiedPeaks.Peak, but... from IdentifiedPeaks import IdentifiedPeaks Here you import Identifie

Re: Problem in designing a global directory in python

2005-03-29 Thread Tian
I have tried using "sysctx=None" instead of "global sysctx", but it doesn't work either. It seems my initialization work in the previous calling of init() has no persistent effect when "utils" is imported using "from myproj.utils import getContext". What's weird, when a module is in the same direc

Re: good design & method calls

2005-03-29 Thread Ron_Adam
On Tue, 29 Mar 2005 09:09:37 -0500, Charles Hartman <[EMAIL PROTECTED]> wrote: >I know the answer to this is going to be "It depends . . .", but I want >to get my mind right. In Fowler's *Refactoring* I read: "Older >languages carried an overhead in subroutine calls, which deterred >people from

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread cjl
Hey all: Thanks for the responses... I've found a third open source implementation in pascal (delphi), and was wondering how well that would translate to python? -cjl -- http://mail.python.org/mailman/listinfo/python-list

Re: truncating a file from the top down

2005-03-29 Thread rbt
Mike Rovner wrote: Right. Thanks for the correction. Fredrik Lundh wrote: Mike Rovner wrote: if os.stat says the_file is too big: fh = open(the_file, 'rb') fh.seek(2008, 2) should be fh.seek(-2008, 2) right? data = fh.read() fh.close() assert len(data)==2008 # you may want some error pr

cgi and multipart/form-data?

2005-03-29 Thread Chris Curvey
I have a form like this: When I submit this form to my Python script using the CGI module, I seem to get the "myFile" variable, but I don't seem to the "foo" variable. Interestingly, if I take out the "myFile" variable (or specify a much smaller file) I do get the value for "foo

Re: Problem in designing a global directory in python

2005-03-29 Thread Bruno Desthuilliers
Tian a écrit : I want to create a object directory called Context in my program, which is based on a dict to save and retrieve values/objects by string-type name. I have the definition like this: utils.py global sysctx class Context: def __init__(self): def set(self, na

Need Help: Server to pass py objects

2005-03-29 Thread Sells, Fred
I have a legacy system with data stored in binary files on a remote server. I need to access and modify the content of those files from a webserver running on a different host. (All Linux) I would like to install a server on the legacy host that would use my python code to translate between the l

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Ron_Adam
On Tue, 29 Mar 2005 11:23:45 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: >On Tue, 29 Mar 2005 14:34:39 GMT, Ron_Adam <[EMAIL PROTECTED]> wrote: >> On 28 Mar 2005 23:01:34 -0800, "Dan Bishop" <[EMAIL PROTECTED]> wrote: >> >> def print_vars(vars_dict=None): >> >...if vars_dict is None: >>

Re: Who Knows of a Good Computational Physics Textbook?

2005-03-29 Thread James Stroud
Look into "Game Physics" by Eberly (Elsevier). On Sunday 13 March 2005 07:27 pm, [EMAIL PROTECTED] wrote: > There is some info on teaching computational physics at Rubin Landau's > site http://www.physics.orst.edu/~rubin/ . > > Springer recently published the book "Python Scripting for > Computati

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Michael Spencer
Steven Bethard wrote: Ville Vainio wrote: "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: Raymond> If the experience works out, then all you're left with is Raymond> the trivial matter of convincing Guido that function Raymond> attributes are a sure cure for the burden of ty

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Bill Mill
On 29 Mar 2005 11:02:38 -0800, cjl <[EMAIL PROTECTED]> wrote: > Hey all: > > Thanks for the responses... > > I've found a third open source implementation in pascal (delphi), and > was wondering how well that would translate to python? cjl, I think that the responses on the list so far collectiv

Re: Connecting to a SQL Server

2005-03-29 Thread Jarek Zgoda
ttmi napisał(a): Ok. Understood we can interface ADO from python and connect to MS SQL. But still not so clear where SSH comes in? Can elaborate more? No SSH is involved in this case -- MSSQL OLEdb provider offers SSL encrypted connection out of the box, just set appropriate property to true and

Re: Problem in designing a global directory in python

2005-03-29 Thread Tian
I googled about how to write singleton in python, but even if I use Singleton, in which module's namespace should I keep the instance of this singleton? suppose I have a singleton class definiton in "utils.py", how should I import and where should I make instance and initialize? Thanks!! -- http:

RE: Optimisation Hints (dict processing and strings)

2005-03-29 Thread Peter Hansen
Thanks for the correction. I didn't pause to think as I wrote that... -Peter > -Original Message- > From: Aaron Bingham [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 29, 2005 11:24 > To: Peter Hansen > Cc: [email protected] > Subject: Re: Optimisation Hints (dict processing an

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Patrick Useldinger
cjl wrote: I've found a third open source implementation in pascal (delphi), and was wondering how well that would translate to python? Being old enough to have programmed in UCSD Pascal on an Apple ][ (with a language card, of course), I'd say: go for Pascal! ;-) -- http://mail.python.org/mailma

Re: cgi and multipart/form-data?

2005-03-29 Thread Chris Curvey
Chris Curvey wrote: I have a form like this: When I submit this form to my Python script using the CGI module, I seem to get the "myFile" variable, but I don't seem to the "foo" variable. Interestingly, if I take out the "myFile" variable (or specify a much smaller file) I do ge

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Bill Mill
> >> > >> Fred = 5 > >> John = 8 > >> Winner = John > >> > >> Both John and Winner are pointing to the literal '8'. > > > >ummm, yes, of course they are. What's your point? > > Hi Bill, > > My point is if you look up the name and print it, you may get. > > Instead of: > > Fred has 5 points

Re: PyParsing module or HTMLParser

2005-03-29 Thread Paul McGuire
La - In general, I have shied away from doing general-purpose HTML parsing with pyparsing. It's a crowded field, and it's likely that there are better candidates out there for your problem. I've heard good things about BeautifulSoup, but I've also heard from at least one person that they prefer

how do you use a closure in a class

2005-03-29 Thread erinhouston
I have several functions that are almost the same in one class I would like to use a closure to get rid of the extra code how would I do this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help: Server to pass py objects

2005-03-29 Thread M.E.Farmer
Fred, Let me see if i understand, you want to 'serve' binary data as PYTHON OBJECTS to a REMOTE client. I am gonna show you how to fish ;) Search strategy: PYthon Remote Objects Python remote python objects I tried them and found plenty of information and code. hint: PYthon Remote Objects hth,

pyopenGL: glutInit : TypeError: not a list

2005-03-29 Thread Rakesh
Hi, I am starting to write this sample program in Python to use the GLUT library. <--> from OpenGL.GL import * from OpenGL.GLUT import * def init(): glClearColor(0, 0, 0, 0) glMatrixMode(GL_PROJECTION) glLoadIdentity() glLightfv(GL_LIGHT0, GL_AMBIENT, [0.0, 0.0, 0.0, 1.0]) g

Re: pyopenGL: glutInit : TypeError: not a list

2005-03-29 Thread Rakesh
After some playing around, here is how my code looks like and it works: from OpenGL.GL import * from OpenGL.GLUT import * import sys def init(): glClearColor(0, 0, 0, 0) glMatrixMode(GL_PROJECTION) glLoadIdentity() glLightfv(GL_LIGHT0, GL_AMBIENT, [0.0, 0.0, 0.0, 1.0]) glLightf

Re: problem with tkinter

2005-03-29 Thread Pierre Quentel
Instead of indexing self.lab by strings, you can index them by the attributes themselves : self.lab[self.i], and change line 23 into for var in (self.s, self,i) For your example, I wouldn't have used the "text" option in the definition of the labels, then "textvariable" in the callback meth

Re: Need Help: Server to pass py objects

2005-03-29 Thread Ken Godee
>I have a legacy system with data stored in binary files on a remote >server. >I need to access and modify the content of those files from a webserver >running on a different host. (All Linux) > >I would like to install a server on the legacy host that would use my >python >code to translate bet

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Ron_Adam
On Tue, 29 Mar 2005 14:58:45 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: >> >> Or something else depending on how many references you made to the >> value 8. > >Yes, this is true, assuming that he looks for keys with the value 8 in >locals(). It's not necessarily true if there's a way to ask py

Re: how do you use a closure in a class

2005-03-29 Thread Paul McGuire
Well, I'm not sure "closure" is the Pythonic way. But in Python, you can use functions to dynamically create other functions. Here's an example of this feature (although there are far simpler ways to do this), tallying vowels and consonants in an input string by calling a function looked up in a

Python & LEGO Mindstorm control...

2005-03-29 Thread Venkat B
Hi all, I have a question re the use of Python to control a robot built with the LEGO Mindstorm system. This is to help my 11yr old with his increased interest in 'programming' and 'robotics'... If not feasible, he wants to use the graphical-tool that comes with it... Would you suggest: 1. Using

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread George Sakkis
"Steven Bethard" <[EMAIL PROTECTED]> wrote: > > [snip] > > I guess the real questions are[1]: > * How much does iter feel like a type? > * How closely are the itertools functions associated with iter? > > STeVe > > [1] There's also the question of how much you believe in OO tenets like > "functions

Re: Optimisation Hints (dict processing and strings)

2005-03-29 Thread John Machin
OPQ wrote: > (2)- in a dict mapping a key to a list of int, remove every entrie > where the list of int have of length < 2 > > > So far, my attempts are > for (2): > for k in hash.keys()[:]: # Note : Their may be a lot of keys here >if len(hash[k])<2: > del hash[k] > > > Here again, I th

How to execute a cmd line program without invoking console window?

2005-03-29 Thread Tian
In Windows, I have been simply using os.system() to run command line program in python. but there will be a black console window. How can I run the program without invoking that window? i guess there are some function with which I can redirect the output? -- http://mail.python.org/mailman/listinf

Re: Python & LEGO Mindstorm control...

2005-03-29 Thread D H
Venkat B wrote: Hi all, I have a question re the use of Python to control a robot built with the LEGO Mindstorm system. This is to help my 11yr old with his increased interest in 'programming' and 'robotics'... If not feasible, he wants to use the graphical-tool that comes with it... Would you sugg

Re: How to execute a cmd line program without invoking console window?

2005-03-29 Thread rbt
Tian wrote: In Windows, I have been simply using os.system() to run command line program in python. but there will be a black console window. How can I run the program without invoking that window? i guess there are some function with which I can redirect the output? name your scripts with .pyw ext

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Diez B. Roggisch
> What I or you prefer carries very little weight. I know layout-things > stir up a lot of bad feeling, but I honostly think those people should > grow up. When I cooperate in a project, I adapt my style to the one > used in the project. I may use a tool to change between styles for > things I work

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Peter Herndon
If you have three different implementations, and can read all three of them well enough to understand the code, use all three. If you are going to port software from one language to another, and want to reimplement it properly in your target language, you won't be porting word-for-word anyway. So

automatically mapping builtins (WAS: itertools to iter transition)

2005-03-29 Thread Steven Bethard
Michael Spencer wrote: > While we're on the topic, what do you think of having unary, > non-summary builtins automatically map themselves when called with an > iterable that would otherwise be an illegal argument: > > e.g., > int(iterable) -> (int(i) for i in iterable) > ord(iterable) -> (ord(i) fo

Re: How to execute a cmd line program without invoking console window?

2005-03-29 Thread raver2046
Or launch it with pythonw.exe ( on windows ) Sorcier glouton http://sorcier-glouton.ath.cx "rbt" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Tian wrote: >> In Windows, I have been simply using os.system() to run command line >> program in python. but there will be a

Re: How do I get better at Python programming?

2005-03-29 Thread alex23
Steve Holden wrote: > Where programming's concerned it's never too soon to start reading other > people's code, and fortunately there's a huge amount of Python about and > available as open source. I found the Cookbook to be especially helpful for this initially: digestable code chunks with plent

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Jack Diederich
On Tue, Mar 29, 2005 at 12:38:42PM +0300, Ville Vainio wrote: > > "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: > > Raymond> If the experience works out, then all you're left with is > Raymond> the trivial matter of convincing Guido that function > Raymond> attributes

Re: Problem in designing a global directory in python

2005-03-29 Thread '@'.join([..join(['fred', 'dixon']), ..join(['gmail', 'com'])])
noob warning: what is so wonderful about the NEW class over the old ? -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Bengt Richter
On Tue, 29 Mar 2005 11:32:33 -0800, Michael Spencer <[EMAIL PROTECTED]> wrote: [...] >While we're on the topic, what do you think of having unary, non-summary >builtins automatically map themselves when called with an iterable that would >otherwise be an illegal argument: That last "otherwise" is

RE: Python & LEGO Mindstorm control...

2005-03-29 Thread Tony Meyer
> I have a question re the use of Python to control a robot > built with the LEGO Mindstorm system. > This is to help my 11yr old with his increased interest in > 'programming' and 'robotics'... If not feasible, he wants to > use the graphical-tool that comes with it... > > Would you suggest: >

instance vs class attributes

2005-03-29 Thread Sarir Khamsi
I come from a C++ background and am learning some of the details of Python's OO capability and now have some questions. Given: #!/bin/env python class A(object): _x = 10 def __init__(self): self.x = 20 def square(self): return self.x * self.x print 'A.x = %d' % A._x a = A() print 'a.x =

How to use "__new__"?

2005-03-29 Thread could ildg
As there is already __init__, why need a __new__? What can __new__ give us while __init__ can't? In what situations we should use __new__? And in what situations we must use __new__? Can __new__ take the place of __init__? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding attributes in a list

2005-03-29 Thread Bengt Richter
On Tue, 29 Mar 2005 11:29:33 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: >infidel wrote: >> You can use the new 'sorted' built-in function and custom "compare" >> functions to return lists of players sorted according to any criteria: >> >> >players = [ >> >> ... {'name' : 'joe', 'defe

Re: Python & LEGO Mindstorm control...

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, D H <[EMAIL PROTECTED]> wrote: . . . >I would use the graphical language environment that comes with Lego >Mindstorms. It was designed for kids. > >I haven't seen anyone show how to program mi

Re: how do you use a closure in a class

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Paul McGuire <[EMAIL PROTECTED]> wrote: >Well, I'm not sure "closure" is the Pythonic way. But in Python, you >can use functions to dynamically create other functions. Here's an >example of this feature (although there are far simpler ways to do >this), tallying vo

Re: What's the best GUI toolkit in Python,Tkinter,wxPython,QT,GTK?

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Dave Cook <[EMAIL PROTECTED]> wrote: . . . >wxPython seems to have the best cross-platform support among CPython >toolkits, but it never seemed very Pythonic to me. There's a higher-level >pack

Dr. Dobb's Python-URL! - weekly Python news and links (Mar 30)

2005-03-29 Thread Cameron Laird
QOTW: "This is a Python newsgroup. Assume that we all have been brainwashed." -- Peter Otten "[M]y experience porting Java to Jython is that it mostly involves deleting stuff :-)" -- Kent Johnson "[K]eep in mind, however, that not all problems in life can be solved with software." -- Roy Smith

Re: How to use "__new__"?

2005-03-29 Thread Steven Bethard
could ildg wrote: As there is already __init__, why need a __new__? What can __new__ give us while __init__ can't? In what situations we should use __new__? And in what situations we must use __new__? Can __new__ take the place of __init__? I believe the current documentation will be updated when 2

Re: good design & method calls

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Ron_Adam <[EMAIL PROTECTED]> wrote: >On Tue, 29 Mar 2005 09:09:37 -0500, Charles Hartman ><[EMAIL PROTECTED]> wrote: > >>I know the answer to this is going to be "It depends . . .", but I want >>to get my mind right. In Fowler's *Refactoring* I read: "Older >>lang

Re: Python Cookbook, 2'nd. Edition is published

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Trent Mick <[EMAIL PROTECTED]> wrote: >> > I don't have my copy yet. Can you give any guidance on how the 2'nd >> > edition compares to the 1'st edition? > >Here is an excerpt from the preface (typing errors are mine): > >If you already own the first edition, yo

Re: How to use "__new__"?

2005-03-29 Thread could ildg
Thank you. I'm clear after I read the doc: If __new__() returns an instance of cls, then the new instance's __init__() method will be invoked like "__init__(self[, ...])", where self is the new instance and the remaining arguments are the same as were passed to __new__(). If __new__() does not ret

Re: How to execute a cmd line program without invoking console window?

2005-03-29 Thread Bengt Richter
On 29 Mar 2005 13:23:55 -0800, "Tian" <[EMAIL PROTECTED]> wrote: >In Windows, I have been simply using os.system() to run command line >program in python. but there will be a black console window. How can I >run the program without invoking that window? i guess there are some >function with which

Re: urllib.urlretireve problem

2005-03-29 Thread Larry Bates
I noticed you hadn't gotten a reply. When I execute this it put's the following in the retrieved file: 404 Not Found Not Found The requested URL /pool/updates/main/p/perl/libparl5.6_5.6.1-8.9_i386.deb was no t found on this server. You will probably need to use something else to first determ

Re: instance vs class attributes

2005-03-29 Thread James Stroud
Sarir said: > Here are my questions: > > 1) What are the benefits of using a member variable without the 'self' >qualifier? (I think this is because you can use _x without an >instance of A().) No such thing as a benefit here. self.a inside a method is the same as a outside (see code belo

why and when we should do it?

2005-03-29 Thread Su Wei
hi,everybody,Sorry to bother you. i hvae seen some code like this before: class BusinessBO : dev __init__(slef): #write you own code here dev businessMethod : #write you own code here pass why and when we should add the keyword "pass" ? and some time i have seen class S

Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int'

2005-03-29 Thread Rakesh
In my Python code fragment, I want to write a code fragment such that the minimum element of a tuple is subtracted from all the elements of a given tuple. When I execute the following python script I get the following interpreter error. C:\>python test.py 200 ddf DNEWS Version 5.7b1,, S0, posti

Re: Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int'

2005-03-29 Thread Rakesh
To quote a much smaller trimmed-down example, here is how it looks like: <--> import sys ## ## def GenerateList(): array = ' ' for i in xrange(10): array = (array, i) return array ## --

Re: instance vs class attributes

2005-03-29 Thread James Stroud
On Tuesday 29 March 2005 05:37 pm, James Stroud wrote: > > 1) What are the benefits of using a member variable without the 'self' > >    qualifier? (I think this is because you can use _x without an > >    instance of A().) > > No such thing as a benefit here. self.a inside a method is the same as

Re: Please help for Python programming

2005-03-29 Thread yy0127
Thanks for your help! I am already fix it!! Many thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 1) The stuff doesn't has to be spread over multiple pages. One > can have 2 functions, each about three quarter of a page. > The second function will then cross a page boundary. Once upon a time, one could put a li

checksum works in unix but not win32 os

2005-03-29 Thread GujuBoy
i have the following code...which works fine in UNIX but then i move it over to WINDOWS XP and check the sum on the same file that i tested on unix and i get different results. def checksum(fileobj): filedata = array.array('B', fileobj.read()) totbytes = len(filedata) result = 0 de

Re: convert user input to Decimal objects using eval()?

2005-03-29 Thread Terry Reedy
"Raymond Hettinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [Julian Hernandez Gomez] >> This is maybe a silly question, but... >> >> is there a "easy way" to make eval() convert all floating >> numbers to Decimal objects and return a Decimal? > > from decimal import Decimal

Weekly Python Patch/Bug Summary

2005-03-29 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 297 open (+11) / 2812 closed (+11) / 3109 total (+22) Bugs: 871 open ( +1) / 4900 closed (+33) / 5771 total (+34) RFE : 175 open ( +0) / 150 closed ( +0) / 325 total ( +0) New / Reopened Patches __ Decimal i

distutils: package data

2005-03-29 Thread Qiangning Hong
I am writing a setup.py for my package. I have a pre-compiled myextmod.pyd file in my package and I want the distutils to automatically copy it to C:\Python23\Lib\site-packages\mypackage\myextmod.pyd. I try to add the following parameter to setup(): data_file = [('mypackage', ['mypackage/myex

Re: why and when we should do it?

2005-03-29 Thread Swaroop C H
On Wed, 30 Mar 2005 09:38:28 +0800, Su Wei <[EMAIL PROTECTED]> wrote: > hi,everybody,Sorry to bother you. > why and when we should add the keyword "pass" ? You can use the 'pass' keyword to indicate an empty block. For example, if True: pass pass is usually used as a placeholder so that you

Re: checksum works in unix but not win32 os

2005-03-29 Thread Trent Mick
[GujuBoy wrote] > i have the following code...which works fine in UNIX but then i move it > over to WINDOWS XP and check the sum on the same file that i tested on > unix and i get different results. > > def checksum(fileobj): > filedata = array.array('B', fileobj.read()) > totbytes = len(f

Weakrefs to classes that derive from str

2005-03-29 Thread Ron Garret
Why doesn't this work? >>> from weakref import ref >>> class C(str): pass ... >>> ref(C()) Traceback (most recent call last): File "", line 1, in ? TypeError: cannot create weak reference to 'C' object >>> Note that this does work: >>> class D(int): pass ... >>> ref(D()) >>> Likewise for

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Terry Reedy
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > True it's not a huge win. But I'd argue that for the same reasons that > dict.fromkeys is a dict classmethod, the itertools methods could be iter > classmethods (or staticmethods). As near as I could tell from the

Re: distance, angle restraint

2005-03-29 Thread Terry Reedy
"HYUN-CHUL KIM" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I put more than 10,000 points in a box > and then want to get one of many solutions that matches all > angle restraints among any 3 points and all distance restraints > between any 2 points. It is not clear to me what

Re: checksum works in unix but not win32 os

2005-03-29 Thread Peter Hansen
GujuBoy wrote: i have the following code...which works fine in UNIX but then i move it over to WINDOWS XP and check the sum on the same file that i tested on unix and i get different results. def checksum(fileobj): filedata = array.array('B', fileobj.read()) Did you make sure you opened this "f

Re: How to use "__new__"?

2005-03-29 Thread Heiko Wundram
Am Mittwoch, 30. März 2005 03:27 schrieb could ildg: > Thank you. > I'm clear after I read the doc: > If __new__() returns an instance of cls, then the new instance's > __init__() method will be invoked like "__init__(self[, ...])", where > self is the new instance and the remaining arguments are t

Re: Problem in designing a global directory in python

2005-03-29 Thread Terry Reedy
"Tian" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I want to create a object directory called Context in my program, which > is based on a dict to save and retrieve values/objects by string-type I suspect that you would accomplish your goal much more easily by calling your modu

Re: how do you use a closure in a class

2005-03-29 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I have several functions that are almost the same in one class I would > like to use a closure to get rid of the extra code how would I do this? A more specific example might get a more to the point solution ;-) TJR -- http://mail

Re: How to use "__new__"?

2005-03-29 Thread Heiko Wundram
Am Mittwoch, 30. März 2005 04:36 schrieb Heiko Wundram: > You could extend the above example quite easily to deal with deallocation > (a reference to each created singleton is retained using the above class, > always, as long as the program is running) and also to make it threadsafe > or to disable

Re: How to use "__new__"?

2005-03-29 Thread Terry Reedy
"could ildg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > __new__() is intended mainly to allow subclasses of immutable types > (like int, str, or tuple) to customize instance creation. Exactly. It is an anwer to the conundrum: How do you give an immutable object its unchangea

Re: why and when we should do it?

2005-03-29 Thread Terry Reedy
"Su Wei" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >i hvae seen some code like this before: I really hope not... >class BusinessBO : dev __init__(slef): #write you own code here dev businessMethod : #write you own code here That is 'def', not 'dev' >p

Re: numbering variables

2005-03-29 Thread Steve
Ron_Adam wrote: On Mon, 28 Mar 2005 13:39:17 +0200, remi <[EMAIL PROTECTED]> wrote: Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is fi

Re: automatically mapping builtins (WAS: itertools to iter transition)

2005-03-29 Thread Michael Spencer
Steven Bethard wrote: Michael Spencer wrote: > While we're on the topic, what do you think of having unary, > non-summary builtins automatically map themselves when called with an > iterable that would otherwise be an illegal argument: I personally don't much like the idea because I expect 'int'

Re: Python for a 10-14 years old?

2005-03-29 Thread Greg Ewing
Jot wrote: If she's really gifted i hope she dumps that obsolete monolithic kernel as soon as she realizes that such beautiful language as python shouldn't be used on top of ugly, badly designed software. Maybe she'll go on to write that oft-proposed pure Python operating system, and give us a co

Re: Python for a 10-14 years old?

2005-03-29 Thread Joal Heagney
Joal Heagney wrote: Duncan Booth wrote: Joal Heagney wrote: Nice. I still have to download a version of pygame to try this out, but the fact that you can't hide the turtle in python.turtle was bugging me out with my version. (A fair bit of copy/paste in gimp, I can tell you!) What was wrong wi

reading from a txt file

2005-03-29 Thread jrlen balane
how should i modify this data reader: (assumes that there is only one entry per line followed by '\n') data_file = open(os.path.normpath(self.TextFile.GetValue()), 'r') data = data_file.readlines() self.irradianceStrings = map(str, data) self.irradianceIntegers = map(int, data) self.Irrad

Re: Python for a 10-14 years old?

2005-03-29 Thread Joal Heagney
Joal Heagney wrote: Joal Heagney wrote: Duncan Booth wrote: Joal Heagney wrote: Nice. I still have to download a version of pygame to try this out, but the fact that you can't hide the turtle in python.turtle was bugging me out with my version. (A fair bit of copy/paste in gimp, I can tell you!

Things you shouldn't do

2005-03-29 Thread Steve
All names have been removed to protect the guilty :-) In an earlier post, I read a piece of code: l1 = [1, 2, 3] l2 = [1, 2, 3] l1 == l2 True I immediately gave a double-take: 11 equals 12? What gives? Can you re-bind literals in Python??? >>> 11 = [1, 2, 3] SyntaxError: can't assign to literal A

Re: itertools to iter transition (WAS: Pre-PEP: Dictionaryaccumulator methods)

2005-03-29 Thread George Sakkis
"Terry Reedy" <[EMAIL PROTECTED]> wrote: > > "Steven Bethard" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > True it's not a huge win. But I'd argue that for the same reasons that > > dict.fromkeys is a dict classmethod, the itertools methods could be iter > > classmethods (or s

Re: Python for a 10-14 years old?

2005-03-29 Thread Joal Heagney
Duncan Booth wrote: Joal Heagney wrote: Nice. I still have to download a version of pygame to try this out, but the fact that you can't hide the turtle in python.turtle was bugging me out with my version. (A fair bit of copy/paste in gimp, I can tell you!) What was wrong with hiding the turtle?

Re: Python for a 10-14 years old?

2005-03-29 Thread Greg Ewing
Leif B. Kristensen wrote: I've got a thirteen-year old daughter to whom I have recently taught the HTML basics, but she doesn't readily take to actual programming. If you've got any idea what I should push to her to get her fascinated about _real_ programming, I'd be obliged. If she's interested in

Re: Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int'

2005-03-29 Thread George Yoshida
Rakesh wrote: > To quote a much smaller trimmed-down example, here is how it looks > like: > ## --- > # Entry Point to the whole program > ## --- > def main(): > mylist = GenerateList() > minnumber = min

Re: instance vs class attributes

2005-03-29 Thread Brian van den Broek
James Stroud said unto the world upon 2005-03-29 20:37: Sarir said: Here are my questions: 3) Should private data be written as self._x instead of self.x? This is a long standing debate. The usual answer is "we are all grownups here", meaning that self.x is preferred. However, I personally like

Re: how do you use a closure in a class

2005-03-29 Thread Paul McGuire
Well, despite my parenthetical disclaimer, my attempted point was that the OP wanted to avoid replicating several functions that were mostly the same. I think Python's idiom of using a function to create and return callables is a comparable feature to using anonymous closures. Unfortunately, I gue

Re: Things you shouldn't do

2005-03-29 Thread Paul McGuire
This struck me also when I first saw this post. It reminded me of a body of code I inherited at a former job, that I had to help untangle. The code was filled with two key variables: t_1 and t_l. Printing out the source in a Courier font made these two vars completely indistinguishable, and it to

mod_python

2005-03-29 Thread onur2029
Hi everybody, I need mod_python resources,documentation or ebook.But not manual from modpython.org.I'm waiting for your links. ONUR YILMAZ -- http://mail.python.org/mailman/listinfo/python-list

RE: mod_python

2005-03-29 Thread Delaney, Timothy C (Timothy)
onur2029 wrote: >I need mod_python resources,documentation or ebook.But not manual > from modpython.org.I'm waiting for your links. http://www.catb.org/~esr/faqs/smart-questions.html Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Steven Bethard
Terry Reedy wrote: "Steven Bethard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] True it's not a huge win. But I'd argue that for the same reasons that dict.fromkeys is a dict classmethod, the itertools methods could be iter classmethods (or staticmethods). As near as I could te

math - need divisors algorithm

2005-03-29 Thread Philp Smith
Hi Does anyone have suggested code for a compact, efficient, elegant, most of all pythonic routine to produce a list of all the proper divisors of an integer (given a list of prime factors/powers) -- http://mail.python.org/mailman/listinfo/python-list

Re: Weakrefs to classes that derive from str

2005-03-29 Thread Steven Bethard
Ron Garret wrote: Why doesn't this work? from weakref import ref class C(str): pass ... ref(C()) Traceback (most recent call last): File "", line 1, in ? TypeError: cannot create weak reference to 'C' object Note that you don't need the class redirection: py> ref('') Traceback (most recent call

Re: instance vs class attributes

2005-03-29 Thread runsun pan
>>> shy._Shy__mangled_method() Ive been mangled! Hi Brian, can you explain how this could possibly work? First of all it's not standard python usage, and secondly it's not working on my computer... pan -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib.urlretireve problem

2005-03-29 Thread gene . tani
Mertz' "Text Processing in Python" book had a good discussion about trapping 403 and 404's. http://gnosis.cx/TPiP/ Larry Bates wrote: > I noticed you hadn't gotten a reply. When I execute this it put's the following > in the retrieved file: > > > > 404 Not Found > > Not Found > The requested

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Myles Strous
Javier Bezos wrote: > "Jacob Lee" <[EMAIL PROTECTED]> escribió en el mensaje > > satisfy some handy properties, the first of which being: > > l[:n] + l[n:] = l > > I don't think l[:5] + l[5:] = l is a handy property > and to me is clearly counterintuitive. Further, It can be quite useful for ins

<    1   2   3   >