Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Paul Rubin
msrache...@gmail.com writes: > how do you guys like the functionality? Do you find it useable in > real-world use cases? It's interesting. I wouldn't have thought of that API--I'm used to populating defaultdict(int) in the obvious ways for this sort of thing--but it is attractive and I think it

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread bearophileHUGS
Raymond Hettinger: > The collections module in Python 2.7 and Python 3.1 has gotten a new > Counter class that works like bags and multisets in other languages. Very nice. Python std lib is growing more data structures, increasing the power of a default Python installation. I can remove more and m

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread bearophileHUGS
bearophile: > Are keys restricted to be long and int values only? Or are they > general (referenced) objects + a control of their integral nature? Here I meant values, sorry. Also: what's the rationale of allowing negative values too? Bye, bearophile -- http://mail.python.org/mailman/listinfo/pyt

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread Kay Schluehr
On 23 Jan., 08:13, Philip Semanchuk wrote: > On Jan 23, 2009, at 12:39 AM, Kay Schluehr wrote: > > > Whatever sufficiently sophisticated topic was initially discussed > > it ends all up in a request for removing reference counting and the > > GIL. > > Is this a variant of Godwin's Law for Python?

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread msrachel . e
On Jan 23, 12:27 am, bearophileh...@lycos.com wrote: > bearophile: > > > Are keys restricted to be long and int values only? Or are they > > general (referenced) objects + a control of their integral nature? > > Here I meant values, sorry. > Also: what's the rationale of allowing negative values to

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Terry Reedy
msrache...@gmail.com wrote: The term counter was what was originally approved. At first, I didn't like it but found that it had some advantages. The main advantage is that there are *bazillions* of programmers (including some very good ones) who have never heard the term multiset or bag but ha

Re: Adding a field to a 'foreign' object from the outside

2009-01-23 Thread Bruno Desthuilliers
atleta a écrit : Hi, I'm working with a callback API (a DBus one) and I'd need to store some state between the calls somewhere. I know that it's possible to extend an object with fields after creation, so I could just store my data in the session object that is passed in with every callback. H

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Terry Reedy
bearophileh...@lycos.com wrote: Also: what's the rationale of allowing negative values too? I can guess two: 1) Nuisance to check given that Python does not have a count (0,1,2...) type. 2. Useful. + = items on hand; - = items back-ordered. Bank account go negative also ;-). So does elevatio

Re: Idea to support public/private.

2009-01-23 Thread Bruno Desthuilliers
Brian Allen Vanderburg II a écrit : Okay so I don't really care about public/private but I was watching the lists (Does python follow its idea of readability or something like that) and I thought of a 'possible' way to add this support to the language. It has already been done at least a coup

problem with special characters in filename

2009-01-23 Thread fizzotti
using: Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Hello I have two files (let's assume they are all in the same directory): 1) "a.dat" containing the single line "Sébastien.dat" 2) "Sébastien.dat" containing arbitraty data I want to: open "

Re: A java hobbyist programmer learning python

2009-01-23 Thread TheFlyingDutchman
> > * No getters and setters. Python takes a very permissive approach to > class attributes, taking the philosophy "we're all adults here". It's > easy to change a public attribute to a private attribute with a getter/ > setter if you need to, so there's nothing to be gained by writing getters > f

Re: problem with special characters in filename

2009-01-23 Thread Murali Murali
Try this: import shutil,os file1 = open('a.dat','r') #opens file for reading for line in file1: print line ##old_name = line[0:len(line)-1] #gets rid of "\n" suffix ##print old_name line.strip() #gets rid of "\n" suffix print line os.rename('b.dat',line) #renames file file1.cl

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Thu, 22 Jan 2009 19:10:05 +, Mark Wooding wrote: Steven D'Aprano writes: On Thu, 22 Jan 2009 15:12:31 +0100, Bruno Desthuilliers wrote: Steven D'Aprano a écrit : But if you have free access to attributes, then *everything* is interface. Nope. How could an

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Bruno Desthuilliers
Russ P. a écrit : On Jan 21, 4:04 am, Bruno Desthuilliers wrote: Russ P. a écrit : (snip) Your mistake for being a moron. But it seems to happen regularly, doesn't it. How much more of my time are you going to waste, loser? Calling people names is certainly not the best way to defend your op

Re: Securing a database

2009-01-23 Thread kt83313
On Jan 23, 12:38 pm, "Diez B. Roggisch" wrote: > kt83...@gmail.com schrieb: > > > > > My company provides some services online, which now they are planning > > to make it offline and sell to customers who can use it in their > > networks. > > > One of our major moneywinners is some data which is s

Re: problem with special characters in filename

2009-01-23 Thread Diez B. Roggisch
fizzo...@gmail.com schrieb: using: Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Hello I have two files (let's assume they are all in the same directory): 1) "a.dat" containing the single line "Sébastien.dat" 2) "Sébastien.dat" containing arbi

Re: problem with special characters in filename

2009-01-23 Thread Diez B. Roggisch
The above at least applies to Linux. I'm not sure about windows - I *know* they have wide-char/unicode support, but I'm not sure how exactly that is exposed via the python file apis Just found this: http://www.amk.ca/python/howto/unicode there is a seciton about filenames and OSes in there

Re: A different kind of interface

2009-01-23 Thread Eduardo O. Padoan
On Thu, Jan 22, 2009 at 5:01 PM, wrote: > Eduardo O. Padoan: >> You are almost *describing* reinteract: > > - Thank you for the link and the software, I have not tried it yet, > but from the screencast it looks quite nice. > - I am glad that there are people that don't think that Emacs is > (desp

Re: Securing a database

2009-01-23 Thread Diez B. Roggisch
Thank you very much Diez. This was my fear. Anyways, if we can make it real hard for them to analyze also, I think we are in the good - esp since the clients are not extremely rich enough to go for professional analyzers -- What is the skype method? The code is not huge - less than 20K LOC so, cod

Need script to download file from a server using python script

2009-01-23 Thread Murali Murali
Hi, I am fairly new to python and i am looking for a python script to download file(latest build) from the server. But, the build name changes daily. For Ex: today the build URL will be "http://mybuilds/myapp_1234.exe"; and tomorrow it will be "http://myserver/mybuilds/myapp_3456.exe";. So i ne

Re: Securing a database

2009-01-23 Thread kt83313
On Jan 23, 3:19 pm, "Diez B. Roggisch" wrote: > > Thank you very much Diez. > > This was my fear. > > Anyways, if we can make it real hard for them to analyze also, I think > > we are in the good - esp since the clients are not extremely rich > > enough to go for professional analyzers -- > > What

Re: Need script to download file from a server using python script

2009-01-23 Thread Tim Chase
The build number keeps changing. So how can i use wildchars(?) or something else to handle change in the build no.? Short answer: you can't...HTTP doesn't support wild-card requests. Longer answer: presumably there's some method to the madness of naming the file. Find the algorithm and use

seeking to improve Python skills

2009-01-23 Thread mk
Hello everyone, I wrote the following program mainly for educational purpose of improving my Python programming skills -- would Pythonistas here please look at it and point out areas that could use improvement? This thing analyzes the stored load average record file, calculates simple moving

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Russ P.
On Jan 23, 1:54 am, Bruno Desthuilliers wrote: > Steven D'Aprano a écrit : > > > > > On Thu, 22 Jan 2009 19:10:05 +, Mark Wooding wrote: > > >> Steven D'Aprano writes: > > >>> On Thu, 22 Jan 2009 15:12:31 +0100, Bruno Desthuilliers wrote: > Steven D'Aprano a écrit : > > But if you ha

Re: what gives with

2009-01-23 Thread Darren Dale
On Jan 22, 10:07 pm, Benjamin Peterson wrote: > Darren Dale gmail.com> writes: > > > Judging fromhttp://bugs.python.org/issue2400, this issue > > was fixed back in May 2008, but it is still present with python-2.5.4, > > which was released in December. Why wont python-2.5 allow this kind of > > i

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Russ P.
On Jan 22, 9:22 pm, "Russ P." wrote: > code. You can play around with the internals all you want in your own > little world, but as when you are working with a team, you need to > adhere to the interfaces they define (if any). The word "as" should not be there: ... but when you are working with

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Antoon Pardon
On 2009-01-16, Luis Zarrabeitia wrote: > > Quoting "Russ P." : > >> On Jan 15, 12:21 pm, Bruno Desthuilliers >> wrote: >> >> > Once again, the important point is that there's a *clear* distinction >> > between interface and implementation, and that you *shouldn't* mess with >> > implementation.

Executing WinXP commands using os module

2009-01-23 Thread pranav
Greetings, I am writing a code to perform operations like checkout, check-in and others for SS. (SS is the command line utility for Visual SafeSource, VSS). I am familiar with all the commands for this purpose. I know li'l python also. What i want to learn is how do i use the command line arguments

Re: Executing WinXP commands using os module

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 3:50 AM, pranav wrote: > Greetings, > I am writing a code to perform operations like checkout, check-in and > others for SS. (SS is the command line utility for Visual SafeSource, > VSS). I am familiar with all the commands for this purpose. I know > li'l python also. > Wha

Re: Executing WinXP commands using os module

2009-01-23 Thread pranav
On Jan 23, 5:05 pm, Chris Rebert wrote: > On Fri, Jan 23, 2009 at 3:50 AM, pranav wrote: > > Greetings, > > I am writing a code to perform operations like checkout, check-in and > > others for SS. (SS is the command line utility for Visual SafeSource, > > VSS). I am familiar with all the command

Re: Need script to download file from a server using python script

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 3:00 AM, Murali Murali wrote: > Hi, > > I am fairly new to python and i am looking for a python script to download > file(latest build) from the server. But, the build name changes daily. For > Ex: today the build URL will be "http://mybuilds/myapp_1234.exe"; and > tomorro

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Giovanni Bajo
On 1/23/2009 2:49 AM, Chris Rebert wrote: On Thu, Jan 22, 2009 at 5:41 PM, Giovanni Bajo wrote: On Thu, 22 Jan 2009 10:11:37 -0800, Raymond Hettinger wrote: The collections module in Python 2.7 and Python 3.1 has gotten a new Counter class that works like bags and multisets in other languages

Re: Executing WinXP commands using os module

2009-01-23 Thread M�ta-MCI (MVP)
Hi! Try: os.system("""start "" cmd /css checkout $\projectName\file -Yusername,password -c'Test comment' """) (not tested ; it's directly from my memory) @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: A different kind of interface

2009-01-23 Thread Eduardo Lenz
On Thursday 22 January 2009 08:13:49 Vic Kelson wrote: > How about IDLE? It's a nice tool for the Python programmer. I've tried > lots of IDEs, but when it comes down to it, on small-to-medium jobs I > am be very productive indeed using IDLE... > > --v > -- > http://mail.python.org/mailman/listinfo

Re: Securing a database

2009-01-23 Thread Bryan Olson
kt83...@gmail.com wrote: Anyways, if we can make it real hard for them to analyze also, I think we are in the good - esp since the clients are not extremely rich enough to go for professional analyzers -- Sounds like you have the "digital rights management" (DRM) problem. As Diez pointed out,

Securing a database

2009-01-23 Thread kt83313
My company provides some services online, which now they are planning to make it offline and sell to customers who can use it in their networks. One of our major moneywinners is some data which is stored in a database. Now, this data inside the database was obtained after paying through the nose -

Dynamic methods and lambda functions

2009-01-23 Thread unineuro
Hi, I want to add some properties dynamically to a class, and then add the corresponding getter methods. Something resulting in this: class Person: def Getname(self): return self.__name def Getage(self): return self.__age I've implemented the next code, creating the prope

Re: How to write a simple shell loop in python?

2009-01-23 Thread Dietrich Bollmann
[Sorry for top posting - I had a HD problem and lost the original mails] Hi Saul, Steve, Ben, James, Scott David and James! Thank you all very much for your help! I finally got rid of the extra space and also understood why the space was printed :) After using Steve's 'input = raw_input("$ ")' s

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Steven D'Aprano
On Fri, 23 Jan 2009 10:54:53 +0100, Bruno Desthuilliers wrote: >> In context, I had just mentioned that lists' internals were >> inaccessible from Python code. I neglected to give an example at the >> time, but a good example is the current length of the list. Consider >> the experience of Microso

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
Steven D'Aprano writes: > On Thu, 22 Jan 2009 19:10:05 +, Mark Wooding wrote: >> Well, your claim /was/ just wrong. But if you want to play dumb: the >> interface is what's documented as being the interface. > > But you miss my point. Evidently. > We're told Python doesn't have private att

Re: Relax Syntax for Augmented Arithmetic?

2009-01-23 Thread Mark Wooding
a...@pythoncraft.com (Aahz) writes: > Actually, that is not correct. You're right, evidently. [snip] a > (1, ['foo', 'bar'], 'xyzzy') a[1] += ['spam'] > Traceback (most recent call last): > File "", line 1, in ? > TypeError: object doesn't support item assignment a > (1, ['foo

Re: Relax Syntax for Augmented Arithmetic?

2009-01-23 Thread Steve Holden
Aahz wrote: > In article <87hc3un1vn.fsf@metalzone.distorted.org.uk>, > Mark Wooding wrote: >> * Python augmented-assignment (`+=', for example) is inconsistent. >>Depending on what type of object the left-hand side evaluates to, it >>may /either/ mutate that object, /or/ assign a ne

DrPython and py2exe

2009-01-23 Thread mk
Hello, I'm trying to get DrPython to edit .py file on double-click on Windows. Sure, I can use trivial .bat file to open DrPython with file as argument. But the irritating thing is that DOS window stays open until particular instance of DrPython isn't closed. py2exe to rescue. I have modifie

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Bruno Desthuilliers
Russ P. a écrit : (snip) I am curious about something. Have you ever needed to access a "private" attribute (i.e., one named with a leading underscore) in Python code that you did not have the source code for? For that matter, have you ever even used a library written in Python without having acc

Re: Why GIL? (was Re: what's the point of rpython?)

2009-01-23 Thread Steve Holden
Paul Rubin wrote: > Carl Banks writes: >> 3. If you are going to use the low-level API on a mutable object, or >> are going to access the object structure directly, you need to acquire >> the object's mutex. Macros such as Py_LOCK(), Py_LOCK2(), Py_UNLOCK() >> would be provided. > > You mean ever

Re: Dynamic methods and lambda functions

2009-01-23 Thread Steven D'Aprano
On Fri, 23 Jan 2009 04:28:33 -0800, unineuro wrote: > Hi, > I want to add some properties dynamically to a class, and then add the > corresponding getter methods. Something resulting in this: > > class Person: > def Getname(self): > return self.__name > > def Getage(self): >

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Russ P.
On Jan 23, 4:30 am, Mark Wooding wrote: > Suppose that you write a Python library module and release it.  I find > that it's /almost/ the right thing for some program of mine, but it > doesn't quite work properly unless I hack about like so... perfect!  I'm > a happy bunny; you've gained a user (

Re: what gives with

2009-01-23 Thread Steve Holden
Darren Dale wrote: > On Jan 22, 10:07 pm, Benjamin Peterson wrote: >> Darren Dale gmail.com> writes: >> >>> Judging fromhttp://bugs.python.org/issue2400, this issue >>> was fixed back in May 2008, but it is still present with python-2.5.4, >>> which was released in December. Why wont python-2.5 a

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Steven D'Aprano
On Fri, 23 Jan 2009 13:57:52 +0100, Bruno Desthuilliers wrote: >> As I said before, if you have the source code you can always change >> private attributes to public in a pinch if the language enforces >> encapsulation. > > And then have to maintain a fork. No, thanks. If you're messing with the

Re: Adding a field to a 'foreign' object from the outside

2009-01-23 Thread Steve Holden
atleta wrote: > Hi, > > I'm working with a callback API (a DBus one) and I'd need to store > some state between the calls somewhere. I know that it's possible to > extend an object with fields after creation, so I could just store my > data in the session object that is passed in with every call

Re: seeking to improve Python skills

2009-01-23 Thread Jean-Paul Calderone
On Fri, 23 Jan 2009 12:17:41 +0100, mk wrote: Hello everyone, I wrote the following program mainly for educational purpose of improving my Python programming skills -- would Pythonistas here please look at it and point out areas that could use improvement? This thing analyzes the stored loa

Re: DrPython and py2exe

2009-01-23 Thread imageguy
But the irritating thing is that DOS window stays open until > particular instance of DrPython isn't closed. This is a relatively simple fix I think. You can change the extension of the drPython.py to drpython.pyw and the python windows executable (pythonw.exe) will launch the program instead o

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Russ P.
On Jan 23, 4:57 am, Bruno Desthuilliers wrote: > Russ P. a écrit : > > As I said before, if you have the source code you can always change > > private attributes to public in a pinch if the language enforces > > encapsulation. > > And then have to maintain a fork. No, thanks. For crying out loud

Re: What is intvar?

2009-01-23 Thread W. eWatson
r wrote: here is a good explanation of control vars: http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html Here are 3 great Tkinter refernces in order: http://infohost.nmt.edu/tcc/help/pubs/tkinter/ http://effbot.org/tkinterbook/ http://www.pythonware.com/library/tkinter/introduct

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Steven D'Aprano
On Fri, 23 Jan 2009 05:42:38 -0800, Russ P. wrote: >> My my my. If you don't trust your programmers, then indeed, don't use >> Python. What can I say (and what do I care ?). But once again, relying >> on the language's access restriction to manage *security* is, well, >> kind of funny, you know ?

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Steve Holden
Bruno Desthuilliers wrote: > Russ P. a écrit : [...] >> Mr. D'Aprano gave an excellent example of a large banking program. >> Without enforced encapsulation, anyone on the development team has >> access to the entire program and could potentially sneak in fraudulent >> code much more easily than if

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Divya Prakash
Hello thats excellant !! On 1/23/09, Russ P. wrote: > > On Jan 23, 4:57 am, Bruno Desthuilliers 42.desthuilli...@websiteburo.invalid> wrote: > > Russ P. a écrit : > > > > As I said before, if you have the source code you can always change > > > private attributes to public in a pinch if the lan

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Tim Rowe
2009/1/22 Scott David Daniels : > Having once been a more type-A, I labored for a couple of years trying > to build a restricted language that provably terminated for work on an > object-oriented database research. I was careful to say that it was the /use/ of the language that is restricted; it'

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Russ P.
On Jan 23, 6:21 am, Steve Holden wrote: > I have to say that I thought the example was somewhat bogus. Any > development team that is even slightly concerned about the possibility > of logic bombs in the code will try to mitigate that possibility by the > use of code inspections. Of course they

writing pickle function

2009-01-23 Thread perfreem
hello, i am using nested defaultdict from collections and i would like to write it as a pickle object to a file. when i try: from collections import defaultdict x = defaultdict(lambda: defaultdict(list)) and then try to write to a pickle file, it says: TypeError: can't pickle function objects

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread Tim Rowe
2009/1/23 Kay Schluehr : > Whatever sufficiently sophisticated topic was the initially discussed > it ends all up in a request for removing reference counting and the > GIL. Well, maybe, but it seems to me that the real issue here is that we need to remove reference counting and the GIL. -- Tim

Re: Implementing file reading in C/Python

2009-01-23 Thread mk
John Machin wrote: The factor of 30 indeed does not seem right -- I have done somewhat similar stuff (calculating Levenshtein distance [edit distance] on words read from very large files), coded the same algorithm in pure Python and C++ (using linked lists in C++) and Python version was 2.5 times

Re: Find all available Tkinter cursor names?

2009-01-23 Thread Kevin Walzer
r wrote: Thanks Kevin, These are exactly the ones i already knew about. I was hoping there where more, shucks!. I wonder how i could go about making my own cursors and adding them to Tkinter? Have any ideas? http://wiki.tcl.tk/8674 might offer some help in this regard. -- Kevin Walzer Code by

Re: Why GIL? (was Re: what's the point of rpython?)

2009-01-23 Thread skip
>> You mean every time you access a list or dictionary or class >> instance, you have to acquire a mutex? That sounds like a horrible >> slowdown. Steve> Indeed it would, but hey, let's not let that stop us repeating Steve> the thinking that's gone into CPython over the last

Re: Stalled ticket in Python bug tracker

2009-01-23 Thread skip
Steven> I'm interested in this ticket in the bug tracker: Steven> http://bugs.python.org/issue2527 Steven> but it seems to have been stalled for nine months. Is there a Steven> procedure for starting it up again? Assign it to yourself? Add a comment with relevant updates?

Re: writing pickle function

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 6:48 AM, wrote: > hello, > > i am using nested defaultdict from collections and i would like to > write it as a pickle object to a file. when i try: > > from collections import defaultdict > x = defaultdict(lambda: defaultdict(list)) > > and then try to write to a pickle f

Re: DrPython and py2exe

2009-01-23 Thread mk
imageguy wrote: drPython is probably selecting a specific version of wxpython and py2exe doesn't like it or can't find it. Once you solve that, py2exe will work fine with wxpython. Thanks, drPython was indeed making use of wxversion.select. What's strange is that it was selecting apparently c

Re: seeking to improve Python skills

2009-01-23 Thread mk
Jean-Paul Calderone wrote: The most significant thing missing from this code is unit tests. Developing automated tests for your code will help you learn a lot. Thanks for all the remarks, I'll restructure my code. Probably the biggest mistake was not keeping "moving average" class and others

Re: seeking to improve Python skills

2009-01-23 Thread Jean-Paul Calderone
On Fri, 23 Jan 2009 16:57:16 +0100, mk wrote: Jean-Paul Calderone wrote: The most significant thing missing from this code is unit tests. Developing automated tests for your code will help you learn a lot. Thanks for all the remarks, I'll restructure my code. Probably the biggest mistake wa

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread Benjamin Kaplan
On Fri, Jan 23, 2009 at 9:50 AM, Tim Rowe wrote: > 2009/1/23 Kay Schluehr : > > Whatever sufficiently sophisticated topic was the initially discussed > > it ends all up in a request for removing reference counting and the > > GIL. > > Well, maybe, but it seems to me that the real issue here is th

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread J. Cliff Dyer
I dub it Schluehr's law. On Thu, 2009-01-22 at 21:39 -0800, Kay Schluehr wrote: > Whatever sufficiently sophisticated topic was the initially discussed > it ends all up in a request for removing reference counting and the > GIL. > > -- > http://mail.python.org/mailman/listinfo/python-list > --

Where to place imports

2009-01-23 Thread John [H2O]
Hello, Im writing some modules and I am a little confused about where to place my imports... I don't really do any class programming yet, just defining a bunch of functions, so presently I have something along the lines of: import sys import os import traceback def Foo1(a,b): import numpy

Re: ossaudiodev problem: sawtooth noise

2009-01-23 Thread Peter Pearson
On Thu, 22 Jan 2009 20:58:14 -0200, Gabriel Genellina wrote: > En Mon, 19 Jan 2009 21:57:04 -0200, Peter Pearson > escribió: > >> The following code uses ossaudiodev to read 1000 values from >> my sound card at a rate of 12,000 samples per second: >> >> When I select a sample rate that is not a p

Re: Where to place imports

2009-01-23 Thread Diez B. Roggisch
John [H2O] schrieb: Hello, Im writing some modules and I am a little confused about where to place my imports... I don't really do any class programming yet, just defining a bunch of functions, so presently I have something along the lines of: import sys import os import traceback def Foo1(a,

Re: ossaudiodev problem: sawtooth noise

2009-01-23 Thread Gabriel Genellina
En Fri, 23 Jan 2009 14:36:46 -0200, Peter Pearson escribió: On Thu, 22 Jan 2009 20:58:14 -0200, Gabriel Genellina wrote: En Mon, 19 Jan 2009 21:57:04 -0200, Peter Pearson escribió: The following code uses ossaudiodev to read 1000 values from my sound card at a rate of 12,000 samples per sec

Re: Where to place imports

2009-01-23 Thread John [H2O]
So it isn't inefficient to import a bunch of modules that may not be used, say if only one function is used that doesn't rely on a larger module like numpy or pylab? Thanks. Diez B. Roggisch-2 wrote: > > John [H2O] schrieb: >> Hello, Im writing some modules and I am a little confused about whe

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread MRAB
Terry Reedy wrote: bearophileh...@lycos.com wrote: Also: what's the rationale of allowing negative values too? I can guess two: 1) Nuisance to check given that Python does not have a count (0,1,2...) type. 2. Useful. + = items on hand; - = items back-ordered. Bank account go negative also ;-)

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread Tim Rowe
2009/1/23 Benjamin Kaplan : > BTW, he said sufficiently sophisticated topic. Since there hasn't been an > extremely long post here yet, I don't know if this counts. Had I waited until the thread became long enough, somebody else would have already raised the issue -- you must surely know about Sc

Re: Where to place imports

2009-01-23 Thread Diez B. Roggisch
John [H2O] schrieb: So it isn't inefficient to import a bunch of modules that may not be used, say if only one function is used that doesn't rely on a larger module like numpy or pylab? Well, importing can take bit of time - but that's a short latency at startup-time, if anything. And if you

Re: Why GIL? (was Re: what's the point of rpython?)

2009-01-23 Thread Paul Rubin
s...@pobox.com writes: > Also, every object is mutable at some level. Tuples, ints and floats are > definitely mutable at creation time. You need to hold a mutex then, so > Carl's notion of three types of objects breaks down then. Hopefully, at creation time, they will usually be in a scope wher

Re: Dynamic methods and lambda functions

2009-01-23 Thread Brian Allen Vanderburg II
unine...@gmail.com wrote: class Person: def __init__(self): for prop in props: setattr(self, "__" + prop[0], prop[1]) setattr(Person, "Get" + prop[0], lambda self: getattr (self, "__" + prop[0])) I've had a similar problem here and here is best how I can ex

Re: Where to place imports

2009-01-23 Thread Steve Holden
Diez B. Roggisch wrote: [...] > The only valid reason for doing imports inside functions is if you > otherwise get into circular dependency hell, or have modules that need > some manipulation of the sys.path before they actually can be imported. > This is never true for system modules, and certainl

Re: Where to place imports

2009-01-23 Thread Diez B. Roggisch
Steve Holden schrieb: Diez B. Roggisch wrote: [...] The only valid reason for doing imports inside functions is if you otherwise get into circular dependency hell, or have modules that need some manipulation of the sys.path before they actually can be imported. This is never true for system modu

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Luis Zarrabeitia
On Friday 23 January 2009 06:31:50 am Antoon Pardon wrote: > On 2009-01-16, Luis Zarrabeitia wrote: > > Quoting "Russ P." : > >> If you "*shouldn't* mess with the implementation", then what is wrong > >> with enforcing that "shouldn't" in the language itself? > > > > Because, as a library user, it

Re: Where to place imports

2009-01-23 Thread Duncan Booth
"John [H2O]" wrote: > So it isn't inefficient to import a bunch of modules that may not be > used, say if only one function is used that doesn't rely on a larger > module like numpy or pylab? > Not really. If you import it at all then you might as well import it on startup i.e. at the top of th

Re: Where to place imports

2009-01-23 Thread Jean-Paul Calderone
On 23 Jan 2009 18:50:00 GMT, Duncan Booth wrote: [snip] BTW, if you ever find you are starting to write multi-threaded applications then you'll really regret it if you reuse code which does imports from inside functions. If two or more threads try to import a module simultaneously then one of t

Re: Why GIL? (was Re: what's the point of rpython?)

2009-01-23 Thread Rhamphoryncus
On Jan 22, 11:09 pm, Carl Banks wrote: > On Jan 22, 9:38 pm, Rhamphoryncus wrote: > > > > > On Jan 22, 9:38 pm, Carl Banks wrote: > > > > On Jan 22, 6:00 am, a...@pythoncraft.com (Aahz) wrote: > > > > > In article <7xd4ele060@ruckus.brouhaha.com>, > > > > Paul Rubin  

Re: writing pickle function

2009-01-23 Thread Gerard Flanagan
On Jan 23, 2:48 pm, perfr...@gmail.com wrote: > hello, > > i am using nested defaultdict from collections and i would like to > write it as a pickle object to a file. when i try: > > from collections import defaultdict > x = defaultdict(lambda: defaultdict(list)) > > and then try to write to a pick

Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread aha
Hello All, I've been charged with developing an XML configuration file format, for one of the applications that my company develops. (Yes, I know it would have been easier to just use the configuration file format as described in RFC 822) While I am finally comfortable with the XML description

OCaml, Language syntax, and Proof Systems

2009-01-23 Thread Xah Lee
recently, as you might have noted by a previous post of mine, that American Mathematical Society published a series of articles on formal proofs in 2008 November. See: http://www.ams.org/notices/200811/ The articles are: • Formal Proof by Thomas Hales • Formal Proof — The Four-Color Theorem by G

Re: Why GIL?

2009-01-23 Thread Hrvoje Niksic
Carl Banks writes: > Unfortunately, references on the stack would need to be registered > as well, so "PyObject* p;" might have to be replaced with something > like "Py_DECLARE_REF(PyObject,p);" which magically registers it. > Ugly. Not only registered at the beginning of the function, but also

Re: Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 11:19 AM, aha wrote: > Hello All, > I've been charged with developing an XML configuration file format, > for one of the applications that my company develops. (Yes, I know it > would have been easier to just use the configuration file format as > described in RFC 822) W

Re: Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread Stefan Behnel
Chris Rebert wrote: > On Fri, Jan 23, 2009 at 11:19 AM, aha wrote: >> I've been charged with developing an XML configuration file format, >> for one of the applications that my company develops. >> [...] >> I am still trying to determine the >> best XML parser API to use. I would love to use XPAT

Re: what gives with

2009-01-23 Thread Scott David Daniels
Darren Dale wrote: What is the point of providing absolute_import in __future__ if the api is completely different than the implementation in future python versions? The point is to obtain user experience with a proposed feature _before_ you fix the interface and start having to be "backwa

Re: Adding a field to a 'foreign' object from the outside

2009-01-23 Thread Scott David Daniels
Steve Holden wrote: Write a class that implements a __call__() method, and use an instance > of that class as your callback. Then the data can be stored as the callback > object's private instance data. In fact, you needn't name the method __call__. You can pass in Holder().method if you

Re: Why GIL? (was Re: what's the point of rpython?)

2009-01-23 Thread Carl Banks
On Jan 23, 7:33 am, s...@pobox.com wrote: >     >> You mean every time you access a list or dictionary or class >     >> instance, you have to acquire a mutex?  That sounds like a horrible >     >> slowdown. > >     Steve> Indeed it would, but hey, let's not let that stop us repeating >     Steve>

Re: writing pickle function

2009-01-23 Thread Peter Otten
perfr...@gmail.com wrote: > i am using nested defaultdict from collections and i would like to > write it as a pickle object to a file. when i try: > > from collections import defaultdict > x = defaultdict(lambda: defaultdict(list)) > > and then try to write to a pickle file, it says: > > TypeE

is None vs. == None

2009-01-23 Thread Gerald Britton
Hi -- Some time ago I ran across a comment recommending using is None instead of == None (also is not None, etc.) My own testing indicates that the former beats the latter by about 30% on average. Not a log for a single instruction but it can add up in large projects. I'm looking for a (semi)

Re: writing pickle function

2009-01-23 Thread Steve Holden
Peter Otten wrote: > perfr...@gmail.com wrote: > >> i am using nested defaultdict from collections and i would like to >> write it as a pickle object to a file. when i try: >> >> from collections import defaultdict >> x = defaultdict(lambda: defaultdict(list)) >> >> and then try to write to a pick

Re: is None vs. == None

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 11:58 AM, Gerald Britton wrote: > Hi -- Some time ago I ran across a comment recommending using is > None instead of == None (also is not None, etc.) My own > testing indicates that the former beats the latter by about 30% on > average. Not a log for a single instructi

  1   2   >