Alphametric fun with Python

2009-01-15 Thread Raymond Hettinger
Thought you guys might enjoy this: http://code.activestate.com/recipes/576615/ SEND + MORE == MONEY 9567 + 1085 == 10652 Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-15 Thread Lie
On Jan 5, 9:03 am, Derek Martin wrote: > On Sat, Jan 03, 2009 at 10:15:51AM +, Marc 'BlackJack' Rintsch wrote: > > On Fri, 02 Jan 2009 04:39:15 -0600, Derek Martin wrote: > > > > On Tue, Dec 30, 2008 at 02:21:29PM +, John O'Hagan wrote: > > > What the Python community often overlooks, when

Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
I had this test program originally that sent message over TCP/IP. Messages where buffered two a Queue.Queue instances, one for incoming and one for outgoing. #1. endpoint.send_message(msg) -> endpoint.outgoing.put(msg) #2. endpoint._process_outgoing() is a thread, that does: endpoint.write_in

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

2009-01-15 Thread James Mills
On Thu, Jan 15, 2009 at 5:05 PM, Russ P. wrote: (...) > 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? Did anyo

Re: General direction

2009-01-15 Thread Diez B. Roggisch
MLT schrieb: Hello all: I'm a beginner to Python (and programming altogether), and am now looking to create a program of my own. What I've got in mind is a very basic pest control program that would keep track of 1) trap findings and 2) pesticides. My thought is to make each of these classes.

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
then the speed goes up to 64 messages/sec on windows and 500 messages/sec on Linux. Finally I could reach 1500 messages/sec without using the queue. If I comment out one line (use the queue instead of direct write into socket) then speed decreases to 40-60 messages/sec. I don't understand wh

Re: process/thread instances and attributes

2009-01-15 Thread Laszlo Nagy
Hey all, I have this concept I'm working on and here is the code... Problem is if you run this it doesn't terminate. I believe you can terminate it in the main process by calling a.stop() But I can't find a way for it to self terminate, ie: self.stop() As indicated by the code... I'm not sur

Re: Python 3 isinstance

2009-01-15 Thread Duncan Booth
Terry Reedy wrote: > Lambert, David W (S&T) wrote: >> Overly terse. I do mean that this is illegal: >> >> isinstance(s, {str, bytes}) >> >> tuples have order, immutability, and the possibility of repeat items. >> >> A set is most reasonable in a mathematical sense. > > I agree. However, isi

Re: why o/p is different ???

2009-01-15 Thread asit
On Jan 15, 11:47 am, "James Mills" wrote: > On Thu, Jan 15, 2009 at 4:34 PM, asit wrote: > > I recently faced a peculiar o/p. > > > My objective is to remove the command name(my script name) from > > sys.argv[0]. > > I coded like this > > If you _really_ want to remove your script_name from > sys

Possible bug in Tkinter - Python 2.6

2009-01-15 Thread Eric Brunel
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 file_name def ask_con

Re: process/thread instances and attributes

2009-01-15 Thread James Mills
On Thu, Jan 15, 2009 at 7:36 PM, Laszlo Nagy wrote: (...) Value won't do obviously :) As there could be an arbitary no. of processes. > What do you want to try with this example? I guess I just am confused as to what belongs to which process (the main or the child) ... I need a clear cut examp

Re: Possible bug in Tkinter - Python 2.6

2009-01-15 Thread bieffe62
On 15 Gen, 11:30, "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():

Re: General direction

2009-01-15 Thread James Stroud
MLT wrote: Hello all: I'm a beginner to Python (and programming altogether), and am now looking to create a program of my own. What I've got in mind is a very basic pest control program that would keep track of 1) trap findings and 2) pesticides. My thought is to make each of these classes. Lo

List/Set/Dict..

2009-01-15 Thread bruce
Hi... i have the test dict/list a= {"a": 'a1',"b" : "b1"} b= [{"a": 'a1',"b" : "b1"}] i'm trying to figure out how to programtically tell them apart... ie, which is a dict, and which is a list... is there a way to accomplish this.. thanks -- http://mail.python.org/mailman/listinfo/python-li

LGPL license for Qt 4.5

2009-01-15 Thread sturlamolden
According to a Norwegian publication, Nokia will release Qt under LGPL as of version 4.5. If I had stocks in Riverbank Computing ltd., I would sell them now... For the rest of us, this is fantastic news. http://digi.no/php/art.php?id=800922 -- http://mail.python.org/mailman/listinfo/python-lis

Open Source Software in the Government

2009-01-15 Thread Alvin ONeal
I thought it might be useful to know that if an idea gets enough votes on Obama's site, he (supposedly) reviews it. Here are the ideas related to open source software. http://citizensbriefingbook.change.gov/search/SearchResults?str=open+source&search.x=0&search.y=0&search=Submit I hope that that

Re: Why this code is working?

2009-01-15 Thread Aaron Brady
On Jan 14, 7:21 am, "Diez B. Roggisch" wrote: > r wrote: > > Listen Hussien, > > Granted, with a name of "r", spelling it wrong is hard, and thus you might > not be trained in the art of spelling names proper. Or spelling proper names! Bah ha. -- http://mail.python.org/mailman/listinfo/python-li

i want to join developer group

2009-01-15 Thread gkcdri
Hello, I want to contribute to the open source projects. -- http://mail.python.org/mailman/listinfo/python-list

Previous PyCon Videos, anyone?

2009-01-15 Thread Phoe6
Hello All, Youtube channel of pycon09 has some videos ( http://www.youtube.com/user/pycon08), but most of them don't have a sufficiently good audio quality. Is there anyone who has better recording of an earlier PyCon talk? If yes, can you please point me to the location? Thanks, Senthil -- htt

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
I would try something like this inside _process_outgoing: while not self.stop_requested.isSet(): data_ok = False while not self.stop_requested.isSet(): if not self.outgoing.empty(): try:

Re: List/Set/Dict..

2009-01-15 Thread John Machin
On Jan 14, 1:53 pm, "bruce" wrote: > Hi... > > i have the test dict/list >  a= {"a": 'a1',"b" : "b1"} >  b= [{"a": 'a1',"b" : "b1"}] > > i'm trying to figure out how to programtically tell them apart... > > ie, which is a dict, and which is a list... >>> a = {"a": 'a1', "b": "b1"} >>> b = [{"a":

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

2009-01-15 Thread mario ruggier
Hello, I would like to evaluate list comprehension expressions, from within which I'd like to call a function. For a first level it works fine but for second level it seems to lose the "_[1]" variable it uses internally to accumulate the results. Some sample code is: class GetItemEvaluator(object

Re: Alphametric fun with Python

2009-01-15 Thread bearophileHUGS
Raymond Hettinger: > Thought you guys might enjoy this: >    http://code.activestate.com/recipes/576615/ Nice and short, but it's also very slow on my PC (Psyco may help). This solves them in moments: http://labix.org/python-constraint Bye, bearophile -- http://mail.python.org/mailman/listinfo/p

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

2009-01-15 Thread bearophileHUGS
mario ruggier, that's a hack that you can forget. Your code can't be read. Don't use list comps for that purpose. Write code that can be read. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread bieffe62
On 15 Gen, 10:22, Laszlo Nagy wrote: > > then the speed goes up to 64 messages/sec on windows and 500 > > messages/sec on Linux. > > Finally I could reach 1500 messages/sec without using the queue. If I > comment out one line (use the queue instead of direct write into socket) > then speed decreas

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

2009-01-15 Thread mario ruggier
On Jan 15, 12:29 pm, mario ruggier wrote: > Any ideas why? > > Note, i'd like that the first parameter to ts() is as independent as > possible from the context in expression context, a sort of independent > mini-template. Thus, the i,j enumerate counters would normally not be > subbed *within* the

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

2009-01-15 Thread mario ruggier
On Jan 15, 1:48 pm, bearophileh...@lycos.com wrote: > mario ruggier, that's a hack that you can forget. Your code can't be > read. Don't use list comps for that purpose. Write code that can be > read. Ya, agree with you whole-heartily, but then so are most optimizations ;-) It is just an idea I am

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

2009-01-15 Thread Peter Otten
mario ruggier wrote: > Hello, > > I would like to evaluate list comprehension expressions, from within > which I'd like to call a function. For a first level it works fine but > for second level it seems to lose the "_[1]" variable it uses > internally to accumulate the results. Some sample code

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

2009-01-15 Thread Peter Otten
Peter Otten wrote: > mario ruggier wrote: > >> Hello, >> >> I would like to evaluate list comprehension expressions, from within >> which I'd like to call a function. For a first level it works fine but >> for second level it seems to lose the "_[1]" variable it uses >> internally to accumulate

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

2009-01-15 Thread mario ruggier
On Jan 15, 2:02 pm, Peter Otten <__pete...@web.de> wrote: > mario ruggier wrote: > > Hello, > > > I would like to evaluate list comprehension expressions, from within > > which I'd like to call a function. For a first level it works fine but > > for second level it seems to lose the "_[1]" variable

Re: Python 3 isinstance

2009-01-15 Thread MRAB
Lambert, David W (S&T) wrote: Overly terse. I do mean that this is illegal: isinstance(s, {str, bytes}) tuples have order, immutability, and the possibility of repeat items. A set is most reasonable in a mathematical sense. You could say the same about s.startswith(("a", "b")). It might be

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

2009-01-15 Thread Luis Zarrabeitia
Quoting Paul Rubin <"http://phr.cx"@NOSPAM.invalid>: > Luis Zarrabeitia writes: > > Wait, do you _really_ believe that _static_ checks could prevent problems > > arising from _unexpected_ conditions in the _data_? > > The data does not arrive from outer space on a magtape stapled to a > meteor.

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

2009-01-15 Thread Steven D'Aprano
On Wed, 14 Jan 2009 23:10:07 -0800, Paul Rubin wrote: > I think this sub-thread has been mostly about dynamically creating new > class instance attributes, but yes, at one point I did suggest adding > type checking (ML-like inference) to pylint, presumably with feedback to > the compiler for optim

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

2009-01-15 Thread Steven D'Aprano
On Wed, 14 Jan 2009 23:05:32 -0800, Russ P. wrote: > On Jan 14, 10:40 pm, "James Mills" wrote: >> On Thu, Jan 15, 2009 at 4:34 PM, Michele >> Simionato wrote: >> >> (...) >> >> > There are lots of Python developers (and most of the core developers) >> > that think the OO community is wrong about

Re: multiprocessing BaseManager doesn't clean up net connections?

2009-01-15 Thread gaius.julius
Hi, Having exactly the same problem. It appears even if I explicitly call manager's shutdown() method. Not sure it is a bug, though. But also didn't find anything in documentation or source code or debug output. On Jan 1, 8:01 am, Chris Brooks wrote: > Hi, > > I'm trying to use remote managers

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

2009-01-15 Thread Roy Smith
In article <7xwscx6zfo@ruckus.brouhaha.com>, Paul Rubin wrote: > basically I think C is evil. C is not evil. It's a tool. Would you call a hammer evil because it's not very good at driving screws? C is a very good tool for doing the kind of thing it was de

Re: General direction

2009-01-15 Thread Steven D'Aprano
On Thu, 15 Jan 2009 10:08:37 +0100, Diez B. Roggisch wrote: > MLT schrieb: >> Hello all: I'm a beginner to Python (and programming altogether), and >> am now looking to create a program of my own. What I've got in mind is >> a very basic pest control program that would keep track of 1) trap >> fi

Py3 - converting bytes to ascii

2009-01-15 Thread Anjanesh Lekshminarayanan
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. So how do I to convert res.read() to ascii on opening the file in ascii mode f = open('

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

2009-01-15 Thread Steven D'Aprano
On Thu, 15 Jan 2009 03:29:59 -0800, mario ruggier wrote: > Hello, > > I would like to evaluate list comprehension expressions, from within > which I'd like to call a function. For a first level it works fine but > for second level it seems to lose the "_[1]" variable it uses internally > to accum

Readline and Python 2.6.1 on a Mac

2009-01-15 Thread James Brady
Hi, I just upgraded Python from 2.5.2 up to 2.6.1 on my 10.5 Mac (installed from the DMG here: http://www.python.org/download/releases/2.6.1/), and I'm having some problems with readline and rl_completer. I have PYTHONSTARTUP pointing to this file: #!/usr/bin/env python try: import readline e

Re: Possible bug in Tkinter - Python 2.6

2009-01-15 Thread r
First of all be very careful using from "module" import * or you will have name conflicts. Tkinter is made to be imported this way and i do it all the time. for the others do. import tkMessageBox as MB import tkFileDialog as FD or whatever floats your boat. Secondly i hear all the time about prob

Wx broken?

2009-01-15 Thread tmallen
I've tried a few of the examples from http://wiki.wxpython.org/Getting%20Started , but after "Hello World" (window) nothing works. I get the following error message with the other examples: Traceback (most recent call last): File "C:/Documents and Settings/MyUserName/Desktop/WxExample.py", line

Re: Wx broken?

2009-01-15 Thread tmallen
On Jan 15, 10:46 am, tmallen wrote: > I've tried a few of the examples > fromhttp://wiki.wxpython.org/Getting%20Started > , but after "Hello World" (window) nothing works. I get the following > error message with the other examples: > > Traceback (most recent call last): >   File "C:/Documents an

Re: Py3 - converting bytes to ascii

2009-01-15 Thread Casey
On Jan 15, 9:54 am, "Anjanesh Lekshminarayanan" wrote: > Using Python 3.0 > > So how do I to convert res.read() to ascii on opening the file in > ascii mode f = open('file.txt', 'w')? > I think this is what you are looking for: res = urllib.request.urlopen(url) f = open('file.txt', 'w') f.write(

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

2009-01-15 Thread mario ruggier
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 course it will ch

Re: Wx broken?

2009-01-15 Thread Mark Smith
>   File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", > line 6, in >     new_instancemethod = new.instancemethod > AttributeError: 'module' object has no attribute 'instancemethod' I'm guessing you either have a python file called 'new.py' in your working directory, or you have

Re: Wx broken?

2009-01-15 Thread tmallen
On Jan 15, 10:56 am, Mark Smith wrote: > >   File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", > > line 6, in > >     new_instancemethod = new.instancemethod > > AttributeError: 'module' object has no attribute 'instancemethod' > > I'm guessing you either have a python file cal

Embedding Python and program path

2009-01-15 Thread arve.knud...@gmail.com
In my application embedding Python I want to have the standard Python module path, so I try to achieve this by setting the program path to that of the the interpreter. Even though I call Py_SetProgramName before Py_InitializeEx, however, Python thinks the program path (as returned by Py_GetProgramF

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

2009-01-15 Thread mario ruggier
The listcomps exploration above was primarily an attempt (unsuccessful) to make this piece of code go a little faster: s = " text %(item)s text " acc = [] for value in iterator: some_dict["item"] = value acc.append(s % evaluator) "".join(acc) The item=value pair is essentially a loop vari

the name of a method

2009-01-15 Thread thomas . steffen75
Hello, I have a Class: class myClass: def __init__(self): # do something print "name of class = " + self.__class__.__name__ def myMethod(self): # do something print "name of method = " + "myMethod" return ... I print the name of the class wi

Re: the name of a method

2009-01-15 Thread Diez B. Roggisch
thomas.steffe...@googlemail.com wrote: > Hello, > > I have a Class: > > class myClass: > def __init__(self): > # do something > print "name of class = " + self.__class__.__name__ > > def myMethod(self): > # do something > print "name of method = " + "myM

Re: Python 3 isinstance

2009-01-15 Thread
I have use case, needn't be dynamic, and it's not hard to enclose set as tuple. But I also write (for example) __all__ = 'this that other'.split() string_list = 'evenOneWord'.split() instead of __all__ = 'this','that','imTiredOfMistypingCommasAndQuotes' if not isinstance(o,set_of_handled_type

Re: Executing global code

2009-01-15 Thread Peter Otten
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. g. these two statements x = 42 x += 1 and want to rerun it with

Re: the name of a method

2009-01-15 Thread Jason Scheirer
On Jan 15, 8:37 am, "Diez B. Roggisch" wrote: > thomas.steffe...@googlemail.com wrote: > > Hello, > > > I have a Class: > > > class myClass: > >     def __init__(self): > >         # do something > >         print "name of class = " +  self.__class__.__name__ > > >     def myMethod(self): > >    

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

2009-01-15 Thread Paul Rubin
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 ("types") that were possible to copy and paste from some single location, instead of building up s

IFL 2009: Call for Papers

2009-01-15 Thread IFL 2009
Call for Papers IFL 2009 Seton Hall University SOUTH ORANGE, NJ, USA http://tltc.shu.edu/blogs/projects/IFL2009/ The 21st IFL symposium, IFL 2009, will be held for the first time in the USA. The hosting institution is Seton Hall University in South Orange, NJ, USA and the symposium dates are S

Re: Standard IPC for Python?

2009-01-15 Thread Mel
Mel wrote: > Philip Semanchuk wrote: > >> I'm working on message queue support, but the Sys V IPC API is a >> headache and takes longer to code against than the POSIX API. > > I hadn't found it that bad. I have a C extension I should perhaps clean > up and make public. I have a simple wrapper

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

2009-01-15 Thread Paul Rubin
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 unnecessarily likely to hit your thumb. > C is a very good tool for doing the kind of thing it was d

mimetypes oddity

2009-01-15 Thread Sion Arrowsmith
>>> ge = mimetypes.guess_extension >>> ge('image/jpeg') '.jpe' >>> ge('image/jpeg') '.jpeg' >>> I actually discovered this through explicitly calling mimetypes.init to reload an edited mime.types file between calls to guess_extension, but I think the above scenario makes for more disturbing readi

No Module Named MySQLdb Error

2009-01-15 Thread Sam
Hi Friends, This is Sam, a learner of Python programming language. I would like to know a feasible and flexible process of importing MySQLdb module. If anyone know about this and have an expertise over this can help me over this issue. 1) I installed interface MySQLdb 1.2.2 in my

Re: point class help

2009-01-15 Thread Sion Arrowsmith
r wrote: >here is what i have, it would seem stupid to use a conditional in each >method like this... > >def method(self, other): >if isinstance(other, Point2d): >x, y = origin.x, origin.y >else: >x, y = origin[0], origin[1] >#modify self.x & self.y with x&y Here's an

Re: Python 3 isinstance

2009-01-15 Thread MRAB
Lambert, David W (S&T) wrote: > I have use case, needn't be dynamic, and it's not hard to enclose set as > tuple. But I also write (for example) > > __all__ = 'this that other'.split() > string_list = 'evenOneWord'.split() > > instead of > > __all__ = 'this','that','imTiredOfMistypingCommasAndQuo

Re: Python 3 isinstance

2009-01-15 Thread
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. -- http://mail.python.org/mailman/listinfo/python-list

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

2009-01-15 Thread r
On Jan 14, 1:16 pm, Paul Rubin wrote: > "Russ P." writes: [snip] > I have a situation which I face almost every day, where I have some > gigabytes of data that I want to slice and dice somehow and get some > numbers out of.  I spend 15 minutes writing a one-off Pytho

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

2009-01-15 Thread r
On Jan 15, 11:13 am, Paul Rubin 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 > unnecessarily likely

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

2009-01-15 Thread Paul Rubin
r writes: > You said you wrote this program in 15 min. How much testing did you > actually do on this data before running it? If you told me you spent > more than 15 minutes i would not believe you. I would say hours, in the sense that the program ran correctly for that long, processing several

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

2009-01-15 Thread r
Paul Rubin > I would say hours, in the sense that the program ran correctly for > that long, processing several GB's of data before hitting something > obscure that it couldn't handle.  This is not a single incident, it's So what was the fatal error, care to post a traceback? -- http://mail.pytho

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

2009-01-15 Thread Paul Rubin
r writes: > So what was the fatal error, care to post a traceback? Usually it's "expected to find some value but got None", or got a list, or expected some structure but got a different one, or some field was missing, etc. It's not a single traceback, it's a recurring theme in developing this st

Re: Possible bug in Tkinter - Python 2.6

2009-01-15 Thread José Matos
On Thursday 15 January 2009 15:28:36 r wrote: > First of all be very careful using from "module" import * or you will > have name conflicts. Tkinter is made to be imported this way and i do > it all the time. for the others do. > > import tkMessageBox as MB > import tkFileDialog as FD > or whatever

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

2009-01-15 Thread r
On Jan 15, 11:59 am, Paul Rubin wrote: > r writes: > > So what was the fatal error, care to post a traceback? > > Usually it's "expected to find some value but got None", or got a > list, or expected some structure but got a different one, or some > field was missing

Re: mimetypes oddity

2009-01-15 Thread skip
[mimetype weirdness reported] Sion> Is this a bug? Might be. Can you file a bug report in the Python issue tracker with a small script that demonstrates the behavior? -- Skip Montanaro - s...@pobox.com - http://smontanaro.dyndns.org/ -- http://mail.python.org/mailman/listinfo/python-li

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

2009-01-15 Thread r
Heres a little food for thought, Maybe you did tell Python to hit the nail head, but your calculations of the direction vector were slightly off. Instead of a direct hit, the hammer grazed the head and now the resultant vector aims strait for your thumb -- Who's to blame here? -- http://mail.python

Re: the name of a method

2009-01-15 Thread Matimus
On Jan 15, 8:23 am, thomas.steffe...@googlemail.com wrote: > Hello, > > I have a Class: > > class myClass: >     def __init__(self): >         # do something >         print "name of class = " +  self.__class__.__name__ > >     def myMethod(self): >         # do something >         print "name of m

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

2009-01-15 Thread Paul Rubin
r writes: > Sounds like the results of poor testing and lack of design good > program logic It would sure be nice if the language made it easier, not harder. -- http://mail.python.org/mailman/listinfo/python-list

Re: Executing global code

2009-01-15 Thread Zac Burns
The first line: doLoad = False, is to be ignored. -- Zachary Burns (407)590-4814 Aim - Zac256FL Production Engineer (Digital Overlord) Zindagi Games On Thu, Jan 15, 2009 at 10:30 AM, Zac Burns wrote: > I'm not sure I fully understand the question "no moving the code to a > function", but you ca

Re: Python Crashes

2009-01-15 Thread Martin P. Hellwig
koranthala wrote: This does sounds more to me like a windows/hardware problem, what you could do is check the windows log for errors, especially look for read errors from the hard disk. Windows sometimes can behave very strangely especially if the external libs don't behave well on a multi

Injecting a global into a defined function??

2009-01-15 Thread Cong Ma
Hi, 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" lines in those functions' bodies and to use a decorator fo

Re: Injecting a global into a defined function??

2009-01-15 Thread MRAB
Cong Ma wrote: Hi, 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" lines in those functions' bodies and to u

Executing global code

2009-01-15 Thread Jakub Debski
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. regards, Jakub -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3 isinstance

2009-01-15 Thread Carl Banks
On Jan 15, 3:35 am, Duncan Booth wrote: > Terry Reedy wrote: > > Lambert, David W (S&T) wrote: > >> Overly terse.  I do mean that this is illegal: > > >> isinstance(s, {str, bytes}) > > >> tuples have order, immutability, and the possibility of repeat items. > > >> A set is most reasonable in a m

Re: Alphametric fun with Python

2009-01-15 Thread Raymond Hettinger
> > Thought you guys might enjoy this: > >    http://code.activestate.com/recipes/576615/ > > Nice and short, but it's also very slow on my PC (Psyco may help). > > This solves them in moments:http://labix.org/python-constraint Intelligent search beats brute force permutation search. The constrain

Re: Executing global code

2009-01-15 Thread Zac Burns
I'm not sure I fully understand the question "no moving the code to a function", but you can prevent reload in a module by doing something like this: doLoad = False try: no_reload except NameError: no_reload = True else: raise RuntimeError, "This module is not meant to be reloaded." -- Zach

Re: Readline and Python 2.6.1 on a Mac

2009-01-15 Thread Ned Deily
In article <4632a161-ed13-477c-a40a-2b606fda1...@a29g2000pra.googlegroups.com>, James Brady wrote: > Hi, I just upgraded Python from 2.5.2 up to 2.6.1 on my 10.5 Mac > (installed from the DMG here: http://www.python.org/download/releases/2.6.1/), > and I'm having some problems with readline and

Re: Python 3 isinstance

2009-01-15 Thread Duncan Booth
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 be a type). What's messy about that? No, it isn

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

2009-01-15 Thread r
On Jan 15, 12:25 pm, Paul Rubin wrote: > r writes: > > Sounds like the results of poor testing and lack of design good > > program logic > > It would sure be nice if the language made it easier, not harder. I am for anything that makes debugging easier, as long as t

Re: 2to3 Help?

2009-01-15 Thread Terry Reedy
marco.m.peter...@gmail.com wrote: I have Python 3.0. I tried to use the 2to3 program included with the interpreter to convert some scripts for Python 2.5 to Python 3.0 ones. I believe 2to3 is will work 'best' with files modified to use some new 2.6 features (backported from 3.0) where 'best' m

Re: Python 3 isinstance

2009-01-15 Thread Terry Reedy
Duncan Booth wrote: Terry Reedy wrote: Lambert, David W (S&T) wrote: Overly terse. I do mean that this is illegal: isinstance(s, {str, bytes}) tuples have order, immutability, and the possibility of repeat items. A set is most reasonable in a mathematical sense. I agree. However, isinst

Re: Alphametric fun with Python

2009-01-15 Thread bearophileHUGS
Raymond Hettinger: > for simple programs that take minutes to write and get the job done. For fun here's a specific example: from csp import Problem, timing print "SEND+MORE=MONEY problem:" p = Problem("recursivebacktracking") p.addvars("sendmory", range(10)) p.addrule(lambda d,e,y: (d+e)%10 == y

Parallel package hierarchies/directories

2009-01-15 Thread atleta
Hi, I'd need a logical way to organize my unit tests into packages, but I don't know how to do it in python. I'd like to separate my test sources (modules) from the code. The problem is that it seems that python does not allow a package to spread through multiple directories. I'd like to have th

Re: Python Crashes

2009-01-15 Thread Terry Reedy
I am using 9 3rd party modules and there are some DLLs too - PIL etc. But the problem is that the issue comes only after 3 hrs usually. When I checked the memory using taskmanager, I found that it is not going too high. I know of 3 general ways to crash the interpreter. 1. Use 3rd party module

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

2009-01-15 Thread Terry Reedy
Paul Rubin wrote: r writes: So what was the fatal error, care to post a traceback? Usually it's "expected to find some value but got None", or got a list, or expected some structure but got a different one, or some field was missing, etc. It's not a single traceback, it's a recurring theme i

UnicodeError for join()

2009-01-15 Thread tmallen
This line of code is throwing a UnicodeError for a handful of the few hundred files I'm processing: rc_file.write("\n\n".join([self.title, "### BEGIN CONTENT ###", self.content])) . UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 442: ordinal not in range() Wh

Re: UnicodeError for join()

2009-01-15 Thread Martin v. Löwis
> rc_file.write("\n\n".join([self.title, "### BEGIN CONTENT ###", > self.content])) > . > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position > 442: ordinal not in range() > > What should I change to make this unicode-safe? One of self.title and self.content is a

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

2009-01-15 Thread Terry Reedy
Michele Simionato wrote: On Jan 14, 3:27 am, Paul Rubin wrote:> I don't understand why some folks spew such violent rhetoric against the idea of augmenting Python with features to alert you automatically when you depart from the convention, so that you can check th

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

2009-01-15 Thread Terry Reedy
Michele Simionato wrote: On Jan 15, 7:38 am, "James Mills" wrote: If one is a clumsy programmer, then perhaps one ought to be using a language that holds one's hand. Yes, and I use Python because it is a language that holds my hand, otherwise I would use C and enjoy segmentation faults all th

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

2009-01-15 Thread Mark Wooding
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 > dinner (including the beer!) somewhere, maybe at s

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

2009-01-15 Thread Bruno Desthuilliers
Paul Rubin a écrit : Bruno Desthuilliers writes: We're not talking about libraries here. Yes we are. If the default is "non-dynamic", then a class author is in charge of explicitely allowing it when *he* see fits. Oh, I see what you mean, the standard libraries would be affected if the langu

Convention vs. fascism (was: General direction)

2009-01-15 Thread Ben Finney
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 follow > PEP8 in order to be allowed to learn Python. If Guido w

Re: UnicodeError for join()

2009-01-15 Thread tmallen
On Jan 15, 3:34 pm, "Martin v. Löwis" wrote: > > rc_file.write("\n\n".join([self.title, "### BEGIN CONTENT ###", > > self.content])) > > . > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position > > 442: ordinal not in range() > > > What should I change to make thi

Re: UnicodeError for join()

2009-01-15 Thread Martin v. Löwis
>> 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? First, you need to find out what the respective types ar

  1   2   3   >