Re: Injecting a global into a defined function??

2009-01-15 Thread Terry Reedy
Cong Ma wrote: I'd appreciate your hints on this problem. I'm writing a module in which several functions can alter the value of a global variable (I know this sounds evil, Not to me. You are using the module as a singleton class. The alternative is to write a class, make the functions metho

Re: Executing global code

2009-01-15 Thread Terry Reedy
Jakub Debski wrote: Hi, Is it possible to execute global code (module-level code) more than once keeping the state of global variables? This means no reload() and no moving the code to a function. Wrap the code in a loop: for dummy in range(): # a plural count literal tjr -- http://ma

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

2009-01-15 Thread Bruno Desthuilliers
Russ P. a écrit : (snip) Wait a minute. Aren't the guy who just took me to task about the definition of functional programming? So the definition of functional programming is written in stone, but the definition of OO programming is written in smoke? Well, actually, the answer is mostly "yes".

Re: UnicodeError for join()

2009-01-15 Thread tmallen
On Jan 15, 4:09 pm, "Martin v. Löwis" wrote: > >> One of self.title and self.content is a Unicode string, the other is > >> a byte string. You need to change them to have the same type (depending > >> on whether you want to process them as Unicode or byte strings). > > > How can I do that? > > Fir

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread ajaksu
On Jan 15, 1:56 pm, mario ruggier wrote: > As > I mentioned in another thread, the real application behind all this is > one of the *few* secure templating systems around. Some info on its > security is at:http://evoque.gizmojo.org/usage/restricted/ > Tell you what, if you find a security hole the

optimizing large dictionaries

2009-01-15 Thread Per Freem
hello i have an optimization questions about python. i am iterating through a file and counting the number of repeated elements. the file has on the order of tens of millions elements... i create a dictionary that maps elements of the file that i want to count to their number of occurs. so i iter

Re: Python 3 isinstance

2009-01-15 Thread John Machin
On Jan 16, 4:28 am, "Lambert, David W (S&T)" wrote: > Although isinstance predates sets, the python history I recall is that > allowing tuples as second argument to isinstance happened at about the > same time as set type was builtin. isinstance 2nd arg as tuple of type info: 2.2 sets module: 2.3

Re: Python 3 isinstance

2009-01-15 Thread Carl Banks
On Jan 15, 1:08 pm, Duncan Booth wrote: > Carl Banks wrote: > > I don't see what the big deal is.  Right now isinstance accepts a type > > or a tuple of types.  The code could be changed to allow a type, or > > any iterable the returns types (wherein every items of the sequence is > > required to

report on building of python 2.5.2 under msys under wine on linux.

2009-01-15 Thread Luke Kenneth Casson Leighton
no, the above subject-line is not a joke: i really _have_ successfully built python2.5.2 by installing wine on linux, then msys under wine, and then mingw32 compiler - no, not the linux mingw32-cross-compiler, the _native_ mingw32 compiler that runs under msys, and then hacking things into submissi

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread mario ruggier
On Jan 15, 9:36 pm, Mark Wooding wrote: > mario ruggier writes: > > Some info on its security is at: > >http://evoque.gizmojo.org/usage/restricted/ > > Tell you what, if you find a security hole there (via exposed template > > source on a Domain(restricted=True) setup) I'll offer you a nice > > d

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

2009-01-15 Thread Paul Rubin
Terry Reedy writes: > I do not see any connection, really, between what you describe above > and your desire for static type-checking expressed elsewhere. When I > was regularly doing analysis of empirical data files, I learned > (sometimes the hard way, as you describe above) to **ALWAYS** run >

newbie OOP question (what's the analogue to java interfaces in Python?)

2009-01-15 Thread Larry Caruso
I'm an old time C programmer, but a newbie to OOP and Python. One OOP book I'm reading, "Holub on Patterns," discusses Java Interfaces in some detail (see http://en.wikipedia.org/wiki/Interface_(Java) for example) but with limited time, I'm hoping to avoid learning Java just to understand some key

Re: optimizing large dictionaries

2009-01-15 Thread Matimus
On Jan 15, 1:39 pm, Per Freem wrote: > hello > > i have an optimization questions about python. i am iterating through > a file and counting the number of repeated elements. the file has on > the order > of tens of millions elements... > > i create a dictionary that maps elements of the file that

Re: Py3 - converting bytes to ascii

2009-01-15 Thread John Machin
On Jan 16, 1:54 am, "Anjanesh Lekshminarayanan" wrote: > Using Python 3.0 > > res = urllib.request.urlopen(url) > f = open('file.txt', 'wb') # Since res.read() returns bytes > f.write(res.read()) > > But newline and return feeds are stored as b14, 58a as text in the text file. I can't imagine how

Re: optimizing large dictionaries

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 8:39 AM, Per Freem wrote: > hello > > i have an optimization questions about python. i am iterating through > a file and counting the number of repeated elements. the file has on > the order > of tens of millions elements... > > > for line in file: > try: >elt = MyCla

Python DateTime Manipulation

2009-01-15 Thread Kingston
I have a user input a date and time as a string that looks like: "200901010100" but I want to do a manipulation where I subtract 7 days from it. The first thing I tried was to turn the string into a time with the format "%Y%m%d%H%M" and then strip out the day value, turn it into an int and subtrac

Re: optimizing large dictionaries

2009-01-15 Thread Christian Heimes
> class MyClass > > def __str__(self): > return "%s-%s-%s" %(self.field1, self.field2, self.field3) > > def __repr__(self): > return str(self) > > def __hash__(self): > return hash(str(self)) > > > is there anything that can be done to speed up this simply code? right > now i

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread mario ruggier
On Jan 15, 10:35 pm, ajaksu wrote: > On Jan 15, 1:56 pm, mario ruggier wrote: > > > As > > I mentioned in another thread, the real application behind all this is > > one of the *few* secure templating systems around. Some info on its > > security is at:http://evoque.gizmojo.org/usage/restricted/

Re: Python DateTime Manipulation

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 2:19 PM, Kingston wrote: > I have a user input a date and time as a string that looks like: > "200901010100" but I want to do a manipulation where I subtract 7 days > from it. > > The first thing I tried was to turn the string into a time with the > format "%Y%m%d%H%M" and

Import functions in current namespace

2009-01-15 Thread Markus Schreyer
Hi, we embedded python into our application via Swig. Now we like to wrap the raw API functionality into a nicer more handleable module, but instead of repeating every function in this wrapper i thought about importing them into the namespace of the wrapper module. I like to give you an example of

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread Terry Reedy
Peter Otten wrote: List comprehensions delete the helper variable after completion: I do not believe they did in 2.4. Not sure of 2.5. There is certainly a very different implementation in 3.0 and, I think, 2.6. OP neglected to mention Python version he tested on. Code meant to run on 2

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread Terry Reedy
mario ruggier wrote: On Jan 15, 4:06 pm, Steven D'Aprano wrote: Hi Steve! class GetItemEvaluator(object): def __init__(self): self.globals = globals() # some dict (never changes) Ya, this is just a boiled down sample, and for simplicity I set to to the real globals(), so of cour

Re: Import functions in current namespace

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 2:35 PM, Markus Schreyer wrote: > Hi, > we embedded python into our application via Swig. Now we like to wrap the > raw API functionality into a nicer more handleable module, but instead of > repeating every function in this wrapper i thought about importing them into > the

Re: Convention vs. fascism (was: General direction)

2009-01-15 Thread Steven D'Aprano
On Fri, 16 Jan 2009 07:58:49 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> On Thu, 15 Jan 2009 10:08:37 +0100, Diez B. Roggisch wrote: >> >> > Familiarize yourself with PEP8 for naming and coding-conventions >> > first. >> >> Enough of the PEP8-fascism please. It is not compulsory to

Re: Executing global code

2009-01-15 Thread Steven D'Aprano
On Thu, 15 Jan 2009 17:50:54 +0100, Peter Otten wrote: > Jakub Debski wrote: > >> Is it possible to execute global code (module-level code) more than >> once keeping the state of global variables? This means no reload() and >> no moving the code to a function. > > You have a module containing e.

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread Steven D'Aprano
On Thu, 15 Jan 2009 07:56:02 -0800, mario ruggier wrote: > On Jan 15, 4:06 pm, Steven D'Aprano cybersource.com.au> wrote: > > Hi Steve! > >> > class GetItemEvaluator(object): >> >     def __init__(self): >> >         self.globals = globals() # some dict (never changes) > > Ya, this is just a b

Re: Possible bug in Tkinter - Python 2.6

2009-01-15 Thread Terry Reedy
Eric Brunel wrote: Hi all, I found a behaviour that might be a bug in Tkinter for Python 2.6. Here is the script: - from Tkinter import * from tkMessageBox import * from tkFileDialog import * root = Tk() def ask_file(): file_name = askopenfilename() print fil

Re: optimizing large dictionaries

2009-01-15 Thread bearophileHUGS
Matimus, your suggestions are all good. Try-except is slower than: if x in adict: ... else: ... A defaultdict is generally faster (there are some conditions when it's not faster, but they aren't much common. I think it's when the ratio of duplicates is really low), creating just a tuple instead of

Re: newbie OOP question (what's the analogue to java interfaces in Python?)

2009-01-15 Thread Benjamin Kaplan
On Thu, Jan 15, 2009 at 4:28 PM, Larry Caruso wrote: > I'm an old time C programmer, but a newbie to OOP and Python. One OOP > book I'm reading, "Holub on Patterns," discusses Java Interfaces in some > detail (see http://en.wikipedia.org/wiki/Interface_(Java) for example) but > with limited time

Re: Python DateTime Manipulation

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 9:19 AM, Kingston wrote: > I have a user input a date and time as a string that looks like: > "200901010100" but I want to do a manipulation where I subtract 7 days > from it. > > The first thing I tried was to turn the string into a time with the > format "%Y%m%d%H%M" and

Re: optimizing large dictionaries

2009-01-15 Thread Steven D'Aprano
On Thu, 15 Jan 2009 23:22:48 +0100, Christian Heimes wrote: >> is there anything that can be done to speed up this simply code? right >> now it is taking well over 15 minutes to process, on a 3 Ghz machine >> with lots of RAM (though this is all taking CPU power, not RAM at this >> point.) > > cl

logging multiple messages

2009-01-15 Thread Daniel
I was fighting with a problem all day that was producing multiple messages in my logging output. The problem was related to the fact that I was defining logging handlers multiple times. I found the following posting from a few years ago that related to my problem: http://groups.google.com/group/

How to verify whether a process got hanged or still alive.

2009-01-15 Thread neel
Hi There, I want to check the health of IE process using python. I am running an application on IE. I have to verify that the application is not crashing the IE. Is there any module which can help me in getting the process status? Thanks, Neel -- http://mail.python.org/mailman/listinfo/python-lis

How to verify whether a process got hanged or still alive.

2009-01-15 Thread neel
Hi There, I want to check the health of IE process using python. I am running an application on IE. I have to verify that the application is not crashing the IE. Is there any module which can help me in getting the process status? Thanks, Neel -- http://mail.python.org/mailman/listinfo/python-lis

Re: Import functions in current namespace

2009-01-15 Thread Markus Schreyer
Wow.. :) I think this is one kind of a stupid question.. ;) Anyway.. thanks a lot.. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread mario ruggier
On Jan 15, 11:35 pm, Terry Reedy wrote: > Peter Otten wrote: > > List comprehensions delete the helper variable after completion: > > I do not believe they did in 2.4.  Not sure of 2.5.  There is certainly >   a very different implementation in 3.0 and, I think, 2.6.  OP > neglected to mention Pyt

Re: report on building of python 2.5.2 under msys under wine on linux.

2009-01-15 Thread Luke Kenneth Casson Leighton
> practical decision, due to /bin/sh.exe messing around and stopping > python.exe from running! (under cmd.exe it's fine. i have to do a > bit more investigation: http://bugs.python.org/issue4956 found it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Executing global code

2009-01-15 Thread MRAB
Steven D'Aprano wrote: > On Thu, 15 Jan 2009 17:50:54 +0100, Peter Otten wrote: > >> Jakub Debski wrote: >> >>> Is it possible to execute global code (module-level code) more than >>> once keeping the state of global variables? This means no reload() and >>> no moving the code to a function. >> Yo

Re: Convention vs. fascism

2009-01-15 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 16 Jan 2009 07:58:49 +1100, Ben Finney wrote: > > > Steven D'Aprano writes: > > > >> On Thu, 15 Jan 2009 10:08:37 +0100, Diez B. Roggisch wrote: > >> > >> > Familiarize yourself with PEP8 for naming and > >> > coding-conventions first. > >> > >> Enough of th

Re: optimizing large dictionaries

2009-01-15 Thread Per Freem
thanks to everyone for the excellent suggestions. a few follow up q's: 1] is Try-Except really slower? my dict actually has two layers, so my_dict[aKey][bKeys]. the aKeys are very small (less than 100) where as the bKeys are the ones that are in the millions. so in that case, doing a Try-Except o

Re: optimizing large dictionaries

2009-01-15 Thread Paul Rubin
Per Freem writes: > 2] is there an easy way to have nested defaultdicts? ie i want to say > that my_dict = defaultdict(defaultdict(int)) -- to reflect the fact > that my_dict is a dictionary, whose values are dictionary that map to > ints. but that syntax is not valid. my_dict = defaultdict(lambd

Re: Python Crashes

2009-01-15 Thread David Bolen
koranthala writes: > Could anyone guide me on this? I have been facing this issue for a > day, and cannot seem to solve it. We had a scheduling system that had a similar "once in a long while hard Windows-process crash" which after a bunch of work to try to track down the source, the most ro

Re: optimizing large dictionaries

2009-01-15 Thread Steven D'Aprano
On Thu, 15 Jan 2009 14:49:29 -0800, bearophileHUGS wrote: > Matimus, your suggestions are all good. > > Try-except is slower than: > if x in adict: ... else: ... Not according to my tests. >>> def tryexcept(D, key): ... try: ... return D[key] ... except KeyError: ...

Re: optimizing large dictionaries

2009-01-15 Thread Christian Heimes
Per Freem schrieb: > 1] is Try-Except really slower? my dict actually has two layers, so > my_dict[aKey][bKeys]. the aKeys are very small (less than 100) where > as the bKeys are the ones that are in the millions. so in that case, > doing a Try-Except on aKey should be very efficient, since often

[python3.0] s = sha1(random()).hexdigest()

2009-01-15 Thread gert
from random import random from hashlib import sha1 s = sha1(random()).hexdigest() TypeError: object supporting the buffer API required, How does sha1 work in python3.0 please ? -- http://mail.python.org/mailman/listinfo/python-list

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

2009-01-15 Thread Terry Reedy
Paul Rubin wrote: Terry Reedy writes: I do not see any connection, really, between what you describe above and your desire for static type-checking expressed elsewhere. When I was regularly doing analysis of empirical data files, I learned (sometimes the hard way, as you describe above) to **A

Re: [python3.0] s = sha1(random()).hexdigest()

2009-01-15 Thread Paul Rubin
gert writes: > s = sha1(random()).hexdigest() > > TypeError: object supporting the buffer API required, > > How does sha1 work in python3.0 please ? sha1 hashes strings, not numbers. Try using str(random()). But if you want some random hex digits, try os.urandom(10).encode('hex') rather than

Re: s = sha1(random()).hexdigest()

2009-01-15 Thread gert
On Jan 16, 1:14 am, gert wrote: > from random import random > from hashlib import sha1 > s = sha1(random()).hexdigest() > > TypeError: object supporting the buffer API required, > > How does sha1 work in python3.0 please ? s = sha1(bytes(random(),'utf-8')).hexdigest() i found this, looks let say

Re: s = sha1(random()).hexdigest()

2009-01-15 Thread gert
On Jan 16, 1:20 am, Paul Rubin wrote: > gert writes: > > s = sha1(random()).hexdigest() > > > TypeError: object supporting the buffer API required, > > > How does sha1 work in python3.0 please ? > > sha1 hashes strings, not numbers.  Try using str(random()).  But if

Re: Convention vs. fascism

2009-01-15 Thread Steven D'Aprano
On Fri, 16 Jan 2009 10:24:19 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> On Fri, 16 Jan 2009 07:58:49 +1100, Ben Finney wrote: >> >> > Steven D'Aprano writes: >> > >> >> On Thu, 15 Jan 2009 10:08:37 +0100, Diez B. Roggisch wrote: >> >> >> >> > Familiarize yourself with PEP8 for n

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-15 Thread Ben Sizer
On Jan 14, 4:37 pm, Ivan Illarionov wrote: > On Jan 14, 1:49 pm, Ben Sizer wrote: > > > No, I don't want to do anything with sys.path apart from see it. I > > just wanted my original question answered, not a guess at my intent > > and a solution for something I'm not doing. ;) Thanks though! > >

except sqlite3.Error as e:

2009-01-15 Thread gert
except sqlite3.Error as e: ERROR = "Error " + ... how does except work in python3 ? -- http://mail.python.org/mailman/listinfo/python-list

Ordering of urlencoded tuples incorrect

2009-01-15 Thread benlucas99
I'm having problems with the ordering of the tuples produced by urllib.urlencode. Taking an example straight from the docs and so doing the following: import urllib ... params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) print params The documentation fo

Re: except sqlite3.Error as e:

2009-01-15 Thread gert
On Jan 16, 1:47 am, gert wrote: > except sqlite3.Error as e: >     ERROR = "Error " + ... > > how does except work in python3 ? except sqlite3.Error as e: ERROR = "Error " + e.args[0] oops i thought it did not work somehow in 3.0 but it does :) -- http://mail.python.org/mailman/listinfo/pytho

Soap Client

2009-01-15 Thread DougJrs
Good Evening Everyone, I am working to create a Soap client in Python using wsdl2py. So far I have been pretty successful in creating most of the client, but I am having trouble figuring out how to change the content of the message that is being sent. After running wsdl2py I have created this cl

Re: Convention vs. fascism

2009-01-15 Thread Ben Finney
Steven D'Aprano writes: > But by focusing on such a small aspect of my post (a quarter of my > text), It clearly was important to you, since you phrased it in highly emotive terms (and even, by your account, had to scale the emotion back a little). So, I don't think the proportion of number-of-c

Re: Ordering of urlencoded tuples incorrect

2009-01-15 Thread MRAB
benluca...@googlemail.com wrote: I'm having problems with the ordering of the tuples produced by urllib.urlencode. Taking an example straight from the docs and so doing the following: import urllib ... params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})

Re: Alphametric fun with Python

2009-01-15 Thread Terry Reedy
bearophileh...@lycos.com wrote: Raymond Hettinger: for simple programs that take minutes to write and get the job done. Thank you for posting this. It illustrates well the point you intended. For fun here's a specific example: from csp import Problem, timing print "SEND+MORE=MONEY problem:

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread ajaksu
On Jan 15, 8:21 pm, mario ruggier wrote: > OK! Here's a small script to make it easier... Thanks! I think I found a quick way around the restrictions (correct me if I borked it), but I think you can block this example by resetting your globals/builtins: exprs = [ '(x for x in range(1)).gi_fr

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

2009-01-15 Thread Rhodri James
On Thu, 15 Jan 2009 17:07:00 -, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: Luis Zarrabeitia writes: No, copy and paste from the original data structures would eliminate those mismatches. The whole point is that would be possible if Python had data structure definitions ("type

Re: Ordering of urlencoded tuples incorrect

2009-01-15 Thread John Machin
On Jan 16, 11:59 am, benluca...@googlemail.com wrote: > I'm having problems with the ordering of the tuples produced by > urllib.urlencode.  Taking an example straight from the docs and so > doing the following: What are "the docs" you are reading that include such an example? The docs distributed

Re: Convention vs. fascism

2009-01-15 Thread Aaron Brady
On Jan 15, 6:41 pm, Steven D'Aprano wrote: > On Fri, 16 Jan 2009 10:24:19 +1100, Ben Finney wrote: > > Steven D'Aprano writes: > > >> On Fri, 16 Jan 2009 07:58:49 +1100, Ben Finney wrote: > > >> > Steven D'Aprano writes: > > >> >> On Thu, 15 Jan 2009 10:08:37 +0100, Diez B. Roggisch wrote: > > >

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

2009-01-15 Thread Rhodri James
On Thu, 15 Jan 2009 17:13:41 -, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: Roy Smith writes: C is not evil. It's a tool. Would you call a hammer evil because it's not very good at driving screws? I would call a hammer evil if it were built in a way that made it unnecessaril

Re: Python 3 isinstance

2009-01-15 Thread Rhamphoryncus
On Jan 14, 3:14 pm, "Lambert, David W (S&T)" wrote: > Please, why isn't a set permitted as the second argument to isinstance? The real problem is it would be misleading. isinstance(a, myset) suggests implementation like type(a) in myset, but it's really any (isinstance(a, t) for t in myset). If

Lazy List Generator Problem

2009-01-15 Thread Mark Hahnenberg
I'm trying to make a lazy, (theoretically) infinite prime number sieve using generators. The code I have thus far is: #!/usr/bin/env python import itertools def sieve(): nats = naturals(2) while True: elem = nats.next() yield elem nats = itertools.ifilterfalse(lambda x:

Re: Suggested improvements for IDLE (non-official)

2009-01-15 Thread Tim H
r wrote: On Jan 14, 4:43 pm, Terry Reedy wrote: [snip] I think the 'main' IDLE maintainer is no longer active. I think someone who would do more than fix critical bugs might be welcome. Hello Terry, That's what i was beginning to think. I am not quite ready (as far as my skills are concerned

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread Mark Wooding
mario ruggier writes: > 2009-01-15 22:26:18,704 ERROR [evoque] AttributeError: 'function' > object has no attribute 'func_globals': File "", line 1, in > Damn. So that doesn't work. :-( > But even if inspect did have the func_globals attribute, the "open" > builtin will not be found on __bu

Re: optimizing large dictionaries

2009-01-15 Thread Paul McGuire
On Jan 15, 5:31 pm, Per Freem wrote: > ...the aKeys are very small (less than 100) where > as the bKeys are the ones that are in the millions.  so in that case, > doing a Try-Except on aKey should be very efficient, since often it > will not fail, ... Do you know the aKeys in advance? If so, the

spam on the list - how are things now?

2009-01-15 Thread skip
We've been running SpamBayes on the news-to-mail gateway on mail.python.org for a couple weeks now. To me it seems like the level of spam leaking onto the list has dropped way down but I'd like some feedback from people who read the python-list@python.org mailing list on the topic. Thanks, --

Re: process/thread instances and attributes

2009-01-15 Thread James Mills
After some work ... I've taken Laszlo's suggestion of using Value (shared memory) objects to share state between the -pseudo- Process (manager) object and it's underlying multiprocessing.Process instance (and subsequent process): Here is the code: #!/usr/b

Re: spam on the list - how are things now?

2009-01-15 Thread James Mills
On Fri, Jan 16, 2009 at 1:30 PM, wrote: > We've been running SpamBayes on the news-to-mail gateway on mail.python.org > for a couple weeks now. To me it seems like the level of spam leaking onto > the list has dropped way down but I'd like some feedback from people who > read the python-list@pyt

One Bug of Python 3.0

2009-01-15 Thread Wayne Huang
I met a bug of CGIXMLRPCRequestHandler in Python3.0. Because of the bug, I couldn't use RPC in Apache CGI. The version of my Python 3.0 is "Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] win32". The code of my client is follow. s = xmlrpc.client.ServerProxy('http://loc

Re: Injecting a global into a defined function??

2009-01-15 Thread Cong Ma
Terry Reedy wrote: > Not to me. You are using the module as a singleton class. The > alternative is to write a class, make the functions methods, and > instantiate the class. If that instance must be a singleton, more work > is required. If multiple instances make sense, you can go the class > r

Re: Injecting a global into a defined function??

2009-01-15 Thread James Mills
On Fri, Jan 16, 2009 at 4:28 AM, Cong Ma wrote: > I'd appreciate your hints on this problem. I'm writing a module in which > several > functions can alter the value of a global variable (I know this sounds evil, > please forgive me...). What I'm trying to do is to eliminate the "global foo" > lin

Re: Injecting a global into a defined function??

2009-01-15 Thread James Mills
On Fri, Jan 16, 2009 at 1:59 PM, Cong Ma wrote: > I've thought of this too, but it turns out those functions are related to each > other very loosely. They do a lot of completely different things independently > and have just one common global variable to share. IMHO it would reduce the > readabil

Re: Lazy List Generator Problem

2009-01-15 Thread alex23
On Jan 16, 12:42 pm, Mark Hahnenberg wrote: > When I execute this code, the numbers 2,3,4,...,11 are printed (i.e. > nothing gets filtered out).  Could anyone explain why this is > happening?  I generally understand generators, and my hypothesis is > that reassigning to nats the result of filterin

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

2009-01-15 Thread Paul Rubin
Terry Reedy writes: > > Right. And if the file is large enough that even parsing all the > > records to check the fields takes hours, well, that's where I'm at. > > So what is the problem? Let it run overnight. The idea of buying faster and faster computers is to not have to wait overnight.

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

2009-01-15 Thread Paul Rubin
"Rhodri James" writes: > It strikes me that what you actually want to write is the script that > scans your C data structure There is not a C data structure at the moment. It's all Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: s = sha1(random()).hexdigest()

2009-01-15 Thread Paul Rubin
gert writes: > s = urandom(10).encode('hex') > AttributeError: 'bytes' object has no attribute 'encode' Oh, Python 3. It's done some different way, someone else will have to specify. I'm still using 2.x. -- http://mail.python.org/mailman/listinfo/python-list

Re: s = sha1(random()).hexdigest()

2009-01-15 Thread Paul Rubin
gert writes: > s = sha1(bytes(random(),'utf-8')).hexdigest() > i found this, looks let say strange. But it works :) Be careful, if you're relying on the uniqueness and unpredictability of this number for program security, that random() isn't designed for such purposes. Use os.urandom instead. --

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

2009-01-15 Thread Michele Simionato
On Jan 15, 8:02 am, Paul Rubin wrote: > I'd say there was a time Lisp worked the right way, and a time C > worked the right way, and maybe a time Python worked the right way, > and for a while, Algol 60 was perfection embodied.  But times have > changed more than thos

Re: s = sha1(random()).hexdigest()

2009-01-15 Thread James Mills
On Fri, Jan 16, 2009 at 2:46 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > gert writes: >> s = urandom(10).encode('hex') >> AttributeError: 'bytes' object has no attribute 'encode' > > Oh, Python 3. It's done some different way, someone else will have to > specify. I'm still using 2

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

2009-01-15 Thread Paul Rubin
Michele Simionato writes: > Or perhaps it is you who changed? I can only speak for myself, but > when I first met Python (coming from Basic, Pascal, Fortran, > Mathematica, Maple) it was the best language I could imagine. I would say Algol 60 and Lisp were great languages the same way the Burroug

Beginner: Data type conversion question

2009-01-15 Thread flagg
I am still fairly new to python and programming in general. My question is regarding data conversion, I am working on a script that will edit dns zone files, one of the functions i wrote handles updating the serial number. Our zone files use the date as the first part of the serial and a two digit

Library for extracting new content from email reply messages?

2009-01-15 Thread Bernard Rankin
Hello, I'm looking to build a simple mostly email-based trouble ticket system. (I've yet to find a ready-made python solution that is both simple and well designed) Is there a Python email parsing library that can assist in extracting new content from messages that have been sent in reply

Re: s = sha1(random()).hexdigest()

2009-01-15 Thread Paul Rubin
"James Mills" writes: > >>> "".join([hex(c) for c in os.urandom(10)]) > '0x540x6c0xdf0xd90xe10x7c0x330x370x9a0x8' That doesn't look so good, because of all the 0x. -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner: Data type conversion question

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 9:09 PM, flagg wrote: > I am still fairly new to python and programming in general. My > question is regarding data conversion, I am working on a script that > will edit dns zone files, one of the functions i wrote handles > updating the serial number. > Our zone files use

Re: vb2py status?

2009-01-15 Thread alex23
On Jan 16, 3:17 pm, axtens wrote: > So is vb2py dead? If not, any idea when it'll support python 3? You're always better off asking at the project site than here, but given it hasn't been updated since Feb 2004 I think it's safe to say the project is dead. But it *is* open source, so feel free t

Re: Beginner: Data type conversion question

2009-01-15 Thread flagg
On Jan 15, 9:16 pm, Chris Rebert wrote: > On Thu, Jan 15, 2009 at 9:09 PM, flagg wrote: > > I am still fairly new to python and programming in general.  My > > question is regarding data conversion, I am working on a script that > > will edit dns zone files, one of the functions i wrote handles >

problem in implementing multiprocessing

2009-01-15 Thread gopal mishra
Hello, I am trying to implement the multiprocessing in my application to take advantage of multiple cores. I have created two Separate process something like this. que = Queue Process(target = getData, args=(que , section, MdbFile,)).start() Process(target = getData, args=(que , section, MdbFil

English-like Python

2009-01-15 Thread The Music Guy
Just out of curiousity, have there been any attempts to make a version of Python that looks like actual English text? I mean, so much of Python is already based on the English language that it seems like the next natural step would be to make a programming language which is actually a spoken one.

Re: English-like Python

2009-01-15 Thread James Mills
On Fri, Jan 16, 2009 at 11:02 AM, The Music Guy wrote: > Just out of curiousity, have there been any attempts to make a version > of Python that looks like actual English text? I mean, so much of Python > is already based on the English language that it seems like the next > natural step would be

Re: English-like Python

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 5:02 PM, The Music Guy wrote: > Just out of curiousity, have there been any attempts to make a version > of Python that looks like actual English text? I mean, so much of Python > is already based on the English language that it seems like the next > natural step would be t

Re: English-like Python

2009-01-15 Thread Paul Rubin
The Music Guy writes: > ...might be translated as... > >>> Import the operating system module. http://coboloncogs.org -- http://mail.python.org/mailman/listinfo/python-list

multiprocessing vs. distributed processing

2009-01-15 Thread James Mills
I've noticed over the past few weeks lots of questions asked about multi-processing (including myself). For those of you new to multi-processing, perhaps this thread may help you. Some things I want to start off with to point out are: "multiprocessing will not always help you get things done fast

Re: s = sha1(random()).hexdigest()

2009-01-15 Thread Martin v. Löwis
> s = urandom(10).encode('hex') > > AttributeError: 'bytes' object has no attribute 'encode' py> binascii.hexlify(os.urandom(10)) b'92b91d5734a9fe562f23' Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Python Style Guide Questions

2009-01-15 Thread koranthala
Hi, Which is more advisable? import x b = x.a or from x import a b = a I read in Learning Python that it is always better to use the former - especially since namespace wont be dirtied. But, doing that with PEP 8 together causes my code to look rather cluttered. Reason being tha

Re: Python Style Guide Questions

2009-01-15 Thread Steven D'Aprano
On Thu, 15 Jan 2009 22:13:06 -0800, koranthala wrote: > Hi, >Which is more advisable? > import x > b = x.a > or > from x import a > b = a > >I read in Learning Python that it is always better to use the > former Perhaps not "always", but often. > - especially since namespa

Re: English-like Python

2009-01-15 Thread Tobias Andersson
The Music Guy skrev: Just out of curiousity, have there been any attempts to make a version of Python that looks like actual English text? I mean, so much of Python is already based on the English language that it seems like the next natural step would be to make a programming language which is a

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

2009-01-15 Thread 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. If you "*shouldn't* mess with the implementation", then what is wrong with enforcin

<    1   2   3   >