Re: Extending classes __init__behavior for newbies

2011-02-13 Thread Benjamin Kaplan
On Feb 13, 2011 5:37 PM, "James Mills" wrote: > > On Mon, Feb 14, 2011 at 8:21 AM, MRAB wrote: > > I would've done it this way: > > > > class FasterShip(Ship): > >def __init__(self, speed=0, **kwargs): > >Ship.__init__(self, **kwargs) > >self.speed = speed > > What's the diffe

Re: floating point woes

2011-02-15 Thread Benjamin Kaplan
On Tue, Feb 15, 2011 at 6:49 PM, Hans-Peter Jansen wrote: > Hi, > > while I usually cope with the woes of floating point issues, this is > one, that I didn't expect: > round(2.385, 2) > 2.3799 > > Doesn't the docs say, it's rounded up for this case? > > > Values are rounded to th

Re: Return Values & lambda

2011-02-21 Thread Benjamin Kaplan
On Mon, Feb 21, 2011 at 1:59 PM, pradeepbpin wrote: > I have a main program module that invokes an input dialog box via  a > menu item. Now, the code for drawing and processing the input of > dialog box is in another module, say 'dialogs.py'. I connect the menu > item to this dialog box by a state

Re: Python fails on math

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 8:20 AM, christian schulze wrote: > Hey guys, > > I just found out, how much Python fails on simple math. I checked a > simple equation for a friend. > > [code] from math import e as e from math import sqrt as sqrt 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) > Fal

Re: "ImportError: No module named gobject"

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 9:20 AM, J. Gerlach wrote: > Am 21.02.2011 16:04, schrieb Luther: >> I've tried installing pygtk, pygobject, and gobject-introspection from >> source, but none of them will compile, and nothing I install through >> synaptic has any effect. >> >> I've tried too many things t

Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 1:33 PM, Irmen de Jong wrote: > On 20-02-11 23:22, Georg Brandl wrote: >> >> On behalf of the Python development team, I'm delighted to announce >> Python 3.2 final release. > > Thanks to all the people who worked on this. > > However, I'm having trouble compiling a framewo

Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 2:54 PM, Irmen de Jong wrote: > On 22-02-11 19:57, Benjamin Kaplan wrote: > >> Have you tried compiling it with Macports? The port file is too much >> of a mess for me to figure out exactly what is getting called in what >> circumstances, bu

Re: reduce in loop

2010-04-04 Thread Benjamin Kaplan
On Sun, Apr 4, 2010 at 7:46 PM, monkeys paw wrote: > Why does the following fail with the Traceback? > > def add(x,y): return x+y > for rrr in range(1,20): >        reduce(add, range(1, r)) > > Traceback (most recent call last): >  File "", line 2, in > TypeError: reduce() of empty sequence with

Re: Recommend Commercial graphing library

2010-04-06 Thread Benjamin Kaplan
On Tue, Apr 6, 2010 at 9:05 AM, AlienBaby wrote: > On Apr 6, 4:24 pm, Jean-Michel Pichavant > wrote: >> Pablo Recio Quijano wrote: >> > Why must be commercial, when there is open and free alternatives? Like >> > GNU Plot. >> >> Gnuplot is ugly. I'm using it because I don't care if it's ugly but i

Re: Unit testing errors (testing the platform module)

2010-04-13 Thread Benjamin Kaplan
On Tue, Apr 13, 2010 at 10:01 AM, John Maclean wrote: > I normally use languages unit testing framework to get a better > understanding of how a language works. Right now I want to grok the > platform module; > > > 1 #!/usr/bin/env python > 2 '''a pythonic factor''' > 3 import unittest > 4 i

Re: Constructing an if statement from the client data in python

2010-04-13 Thread Benjamin Kaplan
All the operators are available as functions in the operator module. Just use a dict to select the correct function. import operator ops = {"and": operator.and_, "or": operator.or_} op1 = ops[lo1] op3 = ops[lo3] if op3( op1( condition1, condition2), condition4) : #do something On Tue, A

Re: when should I explicitly close a file?

2010-04-22 Thread Benjamin Kaplan
On Fri, Apr 23, 2010 at 12:29 AM, Lawrence D'Oliveiro wrote: > In message , Chris > Rebert wrote: > > > On Wed, Apr 21, 2010 at 5:53 PM, Lawrence D'Oliveiro wrote: > > > >> In message <4bc9aad...@dnews.tpgi.com.au>, Lie Ryan wrote: > >> > >>> Since in python nothing is guaranteed about implicit f

Re: dictionary

2010-04-26 Thread Benjamin Kaplan
On Mon, Apr 26, 2010 at 2:04 PM, gopi krishna wrote: > When I give a dictionary with key and value in order how can get back iy > in same order > > You can't using the standard dict type. If you're using Python 3.1, you can use collections.OrderedDict instead. Otherwise, you'll just have to defin

Re: assigning multi-line strings to variables

2010-04-27 Thread Benjamin Kaplan
On Tue, Apr 27, 2010 at 10:51 PM, goldtech wrote: > On Apr 27, 7:33 pm, MRAB wrote: > > goldtech wrote: > > > Hi, > > > > > This is undoubtedly a newbie question. How doI assign variables > > > multiline strings? If I try this i get what's cited below. Thanks. > > > > d="d > > > d"

Re: os x compile, install?

2010-04-28 Thread Benjamin Kaplan
On Wed, Apr 28, 2010 at 4:35 AM, Rob wrote: > On Apr 28, 2:09 pm, Rob wrote: >> Hi, >> >> Python on my system is behaving badly, so I want to create a new >> install from source code.  I have OS X 10.6.2, I downloaded the source >> code (Python-2.6.5.tar.bz2) and did the usual, ./configure, make,

Re: Teaching Programming

2010-05-04 Thread Benjamin Kaplan
On Tue, May 4, 2010 at 7:23 AM, superpollo wrote: > Stefan Behnel ha scritto: >> >> superpollo, 04.05.2010 12:28: >>> >>> i think there is an issue if you -- say -- produce python code, from >>> within another programming environment, to be executed on the fly, at >>> least in some instances. ther

Re: Teaching Programming

2010-05-04 Thread Benjamin Kaplan
On Tue, May 4, 2010 at 2:16 PM, superpollo wrote: > superpollo ha scritto: >> >> James Mills ha scritto: >>> >>> On Tue, May 4, 2010 at 9:56 PM, superpollo wrote: of course! *but* if i must generate on-the-fly python code that defines a function i am back again to the problem:

Re: Create a new process to run python function

2010-05-05 Thread Benjamin Kaplan
On Wed, May 5, 2010 at 10:33 AM, James Mills wrote: > On Wed, May 5, 2010 at 10:56 PM, Massi wrote: >> in my script (python 2.5 on windows xp) I need to run a simple >> function in a separate process. In other words I need something >> similar to the fork function under UNIX. I tried with threads

Re: Need help with my 1st python program

2010-05-08 Thread Benjamin Kaplan
On Sat, May 8, 2010 at 3:13 PM, Dave Luzius wrote: > > Pressure is a term for barometric pressure, and is understood by Conky, > which this program is designed to work with, and is understood by > weather.com. But the value it passes to conky is metric, and I want it to > display in imperial. > >

Re: Drilling down in a dict with "complex" objects

2010-05-24 Thread Benjamin Kaplan
On Mon, May 24, 2010 at 9:34 PM, Six wrote: > I am trying to access an objects sub-object attributes. I can boil the > code I am working with down to this problem section: > (snip) > class Pt: >  x = None >  y = None >  def __init__(self, x, y): >    self.x, self.y = x, y >  pass > > class Pts: >

Re: Python vs. Fedora and CentOS

2010-05-29 Thread Benjamin Kaplan
And since they're "using legacy stuff that works" from 3 years ago (no one upgrades major versions of software in a minor release- hence Win XP SP3 still coming with IE 6), it's no wonder that they're still on 2.4. On Sat, May 29, 2010 at 9:05 PM, Someone Something wrote: > > Redhat as always bel

Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Benjamin Kaplan
On Sun, May 30, 2010 at 3:16 PM, John Nagle wrote: > Antoine Pitrou wrote: > >> On Sun, 30 May 2010 10:10:00 -0700 >> John Nagle wrote: >> >>> Actually, a "built" but "uninstalled" Python works fine. >>> If it >>> didn't, "make test" wouldn't work. >>> >> >> That's a completely unrelated th

Re: What's the largest python/django powered website in the world?

2010-05-30 Thread Benjamin Kaplan
On Sun, May 30, 2010 at 4:27 PM, est wrote: > > > I'm afraid you'll need to define what you mean by "python powered". > > Except database, presentation layer, major business logic is done by > python. > > Except Google/youtube, what's next? > -- > http://mail.python.org/mailman/listinfo/python-lis

Re: questions about how to parse a string and put it in a dictionary

2010-06-03 Thread Benjamin Kaplan
On Thu, Jun 3, 2010 at 7:21 PM, joblack wrote: > I've got a string which (without any CR or LF) consists of > > 'attribute1=attribute_value;attribute2=attribute_value2; ...' > > and I want them to read in a dictionary so that the attribute name is > the key and the attribute value is the data. > >

Re: How to read source code of python?

2010-06-09 Thread Benjamin Kaplan
On Wed, Jun 9, 2010 at 10:25 PM, Qijing Li wrote: > Thanks for your reply. > I'm trying to understand python language deeply and  use it efficiently. > For example: How the operator "in" works on list? the running time is > be O(n)?  if my list is sorted, what the running time would be? > > Still

Re: GUIs - A Modest Proposal

2010-06-10 Thread Benjamin Kaplan
On Thu, Jun 10, 2010 at 9:34 AM, rantingrick wrote: > On Jun 10, 3:52 am, Gregory Ewing wrote: > >> Pywin32 does seem to have grown rather haphazardly. Some >> functionality is wrapped in two different ways in different >> modules, for no apparently good reason, and some other >> things are wrapp

Re: GUIs - A Modest Proposal

2010-06-10 Thread Benjamin Kaplan
On Thu, Jun 10, 2010 at 10:17 PM, ant wrote: > I don't know whether this thread is going backwards, forwards or > sideways. But a lot of useful information is creeping out of the > woodwork. > > I like the points about backwards compatibility. Presumably that > reason alone is enough to keep Tkint

Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Benjamin Kaplan
On Fri, Jun 11, 2010 at 11:03 AM, Chris Hulan wrote: > Haven't used it but Racket (http://racket-lang.org/) looks to be a new > and improved Scheme > The language isn't new, just the name. Racket is the language formerly known as PLT Scheme. They decided that they made enough changes from R5RS th

Re: Printing forms and labels in Python

2010-06-13 Thread Benjamin Kaplan
On Sun, Jun 13, 2010 at 12:25 PM, Monte Milanuk wrote: > On 6/13/10 11:30 AM, Joel Goldstick wrote: >> >> Use django or another web framework, and make your application a web >> app.  With this approach you can display output to a web page, and >> create a print stylesheet that can be finely tuned

Re: file handling

2010-06-13 Thread Benjamin Kaplan
On Sun, Jun 13, 2010 at 10:35 PM, madhuri vio wrote: > i have a doubt about ...this..can u look into this.. > > a = open("human.odt","r") > b = a.readlines() > print b > > and i get d output something else... > > python monday.py > ["PK\x03\x04\x14\x00\x00\x00\x00\x00\xd6+\xce<^\xc62\x0c'\x00\x00\

Re: getting up arrow in terminal to scroll thought history of python commands

2010-06-14 Thread Benjamin Kaplan
On Mon, Jun 14, 2010 at 6:09 AM, Vincent Davis wrote: > On Mon, Jun 14, 2010 at 6:49 AM, Thomas Jollans wrote: >> On 06/14/2010 02:37 PM, Vincent Davis wrote: >>> On Sun, Jun 13, 2010 at 6:24 PM, Irmen de Jong >>> wrote: On 14-6-2010 1:19, Vincent Davis wrote: > > I just installed

Re: how to build with 2.4 having 2.6 as main python

2010-06-14 Thread Benjamin Kaplan
On Mon, Jun 14, 2010 at 3:09 AM, Alexzive wrote: > thanks guys, > > the solution for me was > > python2.4 setup.py install --prefix=/usr/local > > cheers, AZ > Don't do that! Like Steven said, you'll kill your system that way. Lots of programs in Linux use Python and those programs expect /usr/bi

Re: biopython

2010-06-14 Thread Benjamin Kaplan
On Mon, Jun 14, 2010 at 8:45 AM, madhuri vio wrote: > > i am still waiting for some help. > -- > madhuri :) > You already have your help- the traceback tells you everything you need to know. If you don't understand what the traceback is saying, come back here and specifically ask about the p

Re: how to build with 2.4 having 2.6 as main python

2010-06-15 Thread Benjamin Kaplan
On Tue, Jun 15, 2010 at 3:55 PM, Dan Stromberg wrote: > > I don't think #!/usr/bin/env python is the right thing - unless a script > really doesn't care much what version of python it gets. > > I used to #!/usr/bin/env everything, but I've been updating my old scripts > not to.  It's just too much

Re: Installing Python 3.1.2 from source, how do you resolve the sqlite3-dev dependency?

2010-06-16 Thread Benjamin Kaplan
On Wed, Jun 16, 2010 at 10:29 AM, Trevor wrote: > Running ubuntu 9.04 "jaunty". > > When I run make I get the following error: > >    Python build finished, but the necessary bits to build these > modules were not found: >    _sqlite3 > > > So the easy solution is to just install the missing depen

Re: Removing anti-Jewish postings from Python list

2010-06-16 Thread Benjamin Kaplan
On Wed, Jun 16, 2010 at 12:21 PM, Mark Lawrence wrote: > On 16/06/2010 18:56, Alan Harris-Reid wrote: >> >> Any idea how we get rid of this 'noise'?  Will it eventually go away if >> we ignore it, or is there anything the moderators can do to clean-up >> this (normally) wonderful resource for Pyth

Re: super() woes (n00b)

2010-06-17 Thread Benjamin Kaplan
On Thu, Jun 17, 2010 at 10:51 AM, Matteo Landi wrote: > I found few error in your code: > 1 the constructor of P class seems to be wrong: > class P(object): > ...    def __init__(self): > ...        print("I am a member of class P") > ... > > 2 super() works with new style classes, i.e.  the

Re: Processing HTML form

2010-06-17 Thread Benjamin Kaplan
On Thu, Jun 17, 2010 at 1:15 PM, Bradley Hintze wrote: > I apologize in advance for my lack of knowledge, I really do not know. > I would guess server but I quite honestly I am not clear what an 'HTTP > client' or 'HTTP server' refers to. I am running a webpage and am > serving it locally for the

Re: List of lists surprising behaviour

2010-06-17 Thread Benjamin Kaplan
On Thu, Jun 17, 2010 at 4:20 PM, bart.c wrote: > > "J Kenneth King" wrote in message > news:87wrtxh0dq@agentultra.com... >> >> candide writes: >> >>> Let's the following code : >>> >> t=[[0]*2]*3 >> t >>> >>> [[0, 0], [0, 0], [0, 0]] >> >> t[0][0]=1 >> t >>> >>> [[1, 0],

Re: Python interface problem with Windows

2010-06-26 Thread Benjamin Kaplan
On Sat, Jun 26, 2010 at 2:45 PM, Kermit Rose wrote: > On 6/26/2010 5:27 PM, Robert Kern wrote: >> >> I do not provide Python support in private email. Please try the >> python-list: >> >>   http://mail.python.org/mailman/listinfo/python-list >> >> or its USENET gateway: >> >>   news:comp.lang.pyth

Re: Where is StackPanel in IronPython / .Net 4?

2010-06-27 Thread Benjamin Kaplan
On Sun, Jun 27, 2010 at 10:36 AM, Ian Hobson wrote: > Hi All, > > According to this page > > http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx > > StackPanel is in the System.Windows.Controls Namespace > > When I try and set up a reference to that Namespace I get a "C

Re: I strongly dislike Python 3

2010-06-27 Thread Benjamin Kaplan
On Sun, Jun 27, 2010 at 4:03 PM, eric_dex...@msn.com wrote: > On Jun 27, 2:09 pm, "Martin v. Loewis" wrote: >> > I agree that there may be not much reason to port custom proprietary >> > apps that are working fine and which would hardly benefit from, let >> > alone need, and new Py3 features. >>

Re: Why Python3

2010-06-27 Thread Benjamin Kaplan
On Sun, Jun 27, 2010 at 6:51 PM, eric dexter wrote: > On Jun 27, 7:46 pm, MRAB wrote: >> Stephen Hansen wrote: >> > On 6/27/10 6:09 PM, MRAB wrote: >> >> Terry Reedy wrote: >> >>> Another would have been to add but never remove anthing, with the >> >>> consequence that Python would become increas

Re: Python as a scripting language. Alternative to bash script?

2010-06-28 Thread Benjamin Kaplan
On Mon, Jun 28, 2010 at 4:48 AM, Dave Pawson wrote: > I've a fairly long bash script and I'm wondering > how easy it would be to port to Python. > > Main queries are: > Ease of calling out to bash to use something like imageMagick or Java? Easiest way is os.system, most flexible way is subprocess

Re: dynamically modify help text

2010-06-28 Thread Benjamin Kaplan
On Mon, Jun 28, 2010 at 11:25 AM, Chris Rebert wrote: > On Mon, Jun 28, 2010 at 11:13 AM, Brian Blais wrote: >> On Jun 27, 2010, at 22:37 , Red Forks wrote: >>> Read you doc file and set the __doc__ attr of the object you want to >>> change. >>> >>> On Monday, June 28, 2010, Brian Blais wrote: >

Re: Python 2.7 released

2010-07-05 Thread Benjamin Kaplan
On Sun, Jul 4, 2010 at 7:58 PM, John Machin wrote: > On Jul 5, 12:27 pm, Martineau wrote: >> On Jul 4, 8:34 am, Benjamin Peterson wrote: >> >> >> >> > On behalf of the Python development team, I'm jocund to announce the second >> > release candidate of Python 2.7. >> >> > Python 2.7 will be the

Re: Getting started with python on macintosh snow leopard with mysql - need help

2010-07-11 Thread Benjamin Kaplan
On Sun, Jul 11, 2010 at 1:18 PM, dk wrote: > I have been going round and round trying to configure python 2.6 > running on osx 10.6.x to work with mySQL 5.1.44. > Python seems to work ... i have an installation of mysql 5.1.44 > running and have used it in conjunction for other php/apache projects

Re: how to delete "\n"

2010-07-12 Thread Benjamin Kaplan
On Mon, Jul 12, 2010 at 2:33 PM, Jia Hu wrote: > Thank you. It works now. > >  if I use 'print' to print the whole list, 'print' will add newline > at the end of the list but not each item in the list.  right? > > For the code: > for line in fileName: >     line = line.rstrip('\n') > I think this

Re: About problems that I have with learning wxPython in Macintosh

2010-07-15 Thread Benjamin Kaplan
On Thu, Jul 15, 2010 at 3:04 PM, ata.jaf wrote: > Hi, > I'm newbie to wxPython and need it to develop my little app. > But from start I have problems with tutorials. Because all of them are > compatible with Windows but not so much with Mac. > For example in this code: > > > import wx > > class M

Re: Is '[' a function or an operator or an language feature?

2010-07-17 Thread Benjamin Kaplan
On Sat, Jul 17, 2010 at 10:27 AM, Emile van Sebille wrote: > On 7/17/2010 9:38 AM Gary Herron said... > > and unrelated to the thread but still about python: >> >> http://xkcd.com/353/ >> > > ActivePython 2.6.1.1 (ActiveState Software Inc.) based on > Python 2.6.1 (r261:67515, Dec 5 2008, 13:58

Re: linux console command line history

2010-07-20 Thread Benjamin Kaplan
On Tue, Jul 20, 2010 at 2:38 PM, kak...@gmail.com wrote: > Hi to all, > I 'm writing a linux console app with sockets. It's basically a client > app that fires commands in a server. > For example: > $log user 55 > $sessions list > $server list etc. > What i want is, after entering some commands, t

Re: Function closure inconsistency

2010-07-23 Thread Benjamin Kaplan
On Fri, Jul 23, 2010 at 11:30 AM, SeanMon wrote: > > I was playing around with Python functions returning functions and the > scope rules for variables, and encountered this weird behavior that I > can't figure out. > > Why does f1() leave x unbound, but f2() does not? > > def f1(): >    x = 0 >  

Re: Unicode error

2010-07-23 Thread Benjamin Kaplan
On Fri, Jul 23, 2010 at 2:46 PM, Nobody wrote: > On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: > >> Don't write bare excepts, always catch the error you want and nothing >> else. > > That advice would make more sense if it was possible to know which > exceptions could be raised. In pr

Re: understanding the mro (long)

2010-07-23 Thread Benjamin Kaplan
On Fri, Jul 23, 2010 at 7:42 PM, Rolando Espinoza La Fuente wrote: > TL;DR: if you want to stay sane, don't inherit two classes that share > same inheritance graph > > I recently got puzzled by a bug from a legacy lib (ClientForm) > which have this code: > >    class ParseError(sgmllib.SGMLParseEr

Re: why is this group being spammed?

2010-07-25 Thread Benjamin Kaplan
Python-list is comp.lang.python turned into mailing list form. gmane is python-list turned back into a newsgroup. The reason it gets less spam is because it's behind the mailing list's spam filters. Both the mailing list and gmane should see the same amount of spam. which is way less than the origi

Re: Why is there no platform independent way of clearing a terminal?

2010-08-02 Thread Benjamin Kaplan
On Mon, Aug 2, 2010 at 8:21 AM, Mark Lawrence wrote: > On 01/08/2010 12:10, Lawrence D'Oliveiro wrote: > >> In message, Mark >> Lawrence wrote: >> >> On 01/08/2010 08:18, Lawrence D'Oliveiro wrote: >>> >>> In message, Mark Lawrence wrote: On 01/08/2010 07:50, Lawrence D'Oliveiro

Re: Why is there no platform independent way of clearing a terminal?

2010-08-02 Thread Benjamin Kaplan
On Mon, Aug 2, 2010 at 9:51 AM, David Robinow wrote: > On Mon, Aug 2, 2010 at 11:41 AM, Benjamin Kaplan > wrote: > >... > > So these are the packages needed just to run Python in Ubuntu. It doesn't > > include the packages required for the kernel, the desktop

Re: Behavior of re.split on empty strings is unexpected

2010-08-02 Thread Benjamin Kaplan
On Mon, Aug 2, 2010 at 2:22 PM, John Nagle wrote: > On 8/2/2010 12:52 PM, Thomas Jollans wrote: > >> On 08/02/2010 09:41 PM, John Nagle wrote: >> >>> On 8/2/2010 11:02 AM, MRAB wrote: >>> John Nagle wrote: > The regular expression "split" behaves slightly differently than > stri

Re: Why is python not written in C++ ?

2010-08-03 Thread Benjamin Kaplan
On Tue, Aug 3, 2010 at 10:44 AM, John Nagle wrote: > On 8/1/2010 5:36 PM, Roy Smith wrote: > >> In article<4c55fe82$0$9111$426a3...@news.free.fr>, >> candide wrote: >> >> Python is an object oriented langage (OOL). The Python main >>> implementation is written in pure and "old" C90. Is it for h

Re: None is negative?

2010-08-03 Thread Benjamin Kaplan
On Tue, Aug 3, 2010 at 1:17 PM, wheres pythonmonks wrote: > > I did the google search... I must be blind as I don't see any hits... > > None is negative in Python?  (v2.6) > > http://www.google.com/search?ie=UTF-8&q=%22none+is+negative%22+python > > >>> if None < -999.99: print "hi" > > hi > >

Re: None is negative?

2010-08-03 Thread Benjamin Kaplan
On Tue, Aug 3, 2010 at 1:29 PM, Grant Edwards wrote: > On 2010-08-03, wheres pythonmonks wrote: > >> I did the google search... I must be blind as I don't see any hits... >> >> None is negative in Python?  (v2.6) > > Not really. > >> http://www.google.com/search?ie=UTF-8&q=%22none+is+negative%22+

Re: Trying to set a cookie within a python script

2010-08-03 Thread Benjamin Kaplan
2010/8/3 Νίκος : >>On 3 Αύγ, 21:00, Dave Angel wrote: > >> A string is an object containing characters. A string literal is one of >> the ways you create such an object. When you create it that way, you >> need to make sure the compiler knows the correct encoding, by using the >> encoding: line at

Re: how to pretty-print Python dict with unicode?

2010-08-04 Thread Benjamin Kaplan
On Wed, Aug 4, 2010 at 3:15 PM, kj wrote: > > > > Is there a simple way to get Python to pretty-print a dict whose > values contain Unicode?  (Of course, the goal here is that these > printed values are human-readable.) > > If I run the following simple script: > > from pprint import pprint > x =

Re: assigning variables from list data

2010-08-05 Thread Benjamin Kaplan
On Thu, Aug 5, 2010 at 7:26 AM, Chris Hare wrote: > > I have a database query result (see code below).  In PHP, I would have said > > list(var1,var2,var) = $result > > and each element in the list would be assigned to each of the named > variables.  I have my data coming out of the database, and

Re: easy question on parsing python: "is not None"

2010-08-05 Thread Benjamin Kaplan
On Thu, Aug 5, 2010 at 9:07 AM, wheres pythonmonks wrote: > Well, I am not convinced of the equivalence of not None and true: > not None > True 3 is True; > False 3 is not None > True > > P.S. Sorry for the top-post -- is there a way to not do top posts from > gmail?  I haven't

Re: defining, raising and catching exceptions

2010-08-05 Thread Benjamin Kaplan
What makes you think it has to do with user-defined exceptions? >>> try : ...raise Exception("hello") ... except Exception as (errno, errText) : ... print "whatever" ... Traceback (most recent call last): ValueError: need more than 1 values to unpack An Exception is an object, not a tuple o

Re: [Tutor] Finding the version # of a module, and py module problem

2010-08-06 Thread Benjamin Kaplan
On Fri, Aug 6, 2010 at 12:14 PM, W. eWatson wrote: > I must be missing something. I tried this. (Windows, IDLE, Python 2.5) > # Try each module > import sys > import numpy > import scipy > import string > > dependencies = "numyp", "scipy" > for dependency in dependencies: >    try: >        __impo

Re: Class initialization

2010-08-08 Thread Benjamin Kaplan
On Sun, Aug 8, 2010 at 6:32 AM, Costin Gament wrote: > > Hi there. > I'm kind of a beginner with Python (and programming in general). My > problem is with initializing a class. Let's say I've defined it like > this: > > class foo: >   a = 0 >   b = 0 > > and later I'm trying to initialize two diff

Re: Python "why" questions

2010-08-08 Thread Benjamin Kaplan
On Sun, Aug 8, 2010 at 10:24 AM, Default User wrote: > Not to prolong a good "food fight", but IIRC, many years ago in QBasic, > one could choose > > OPTION BASE 0 > > or > > OPTION BASE 1 > > to make arrays start with element [0] or element [1], respectively.  Could > such a feature be added to P

Re: Win7. Why Don't Matplotlib, ... Show up in Control Panel Add-Remove?

2010-08-08 Thread Benjamin Kaplan
On Sun, Aug 8, 2010 at 10:21 AM, David Robinow wrote: > On Sun, Aug 8, 2010 at 12:51 PM, Mark Lawrence > wrote: >> On 08/08/2010 17:16, W. eWatson wrote: >>> >>> See Subject. I use matplotlib, scipy, numpy and possibly one other >>> module. If I go to the control panel, I only see numpy listed.

Re: Win7. Why Don't Matplotlib, ... Show up in Control Panel Add-Remove?

2010-08-08 Thread Benjamin Kaplan
On Sun, Aug 8, 2010 at 4:15 PM, W. eWatson wrote: > On 8/8/2010 10:56 AM, Benjamin Kaplan wrote: >> >> On Sun, Aug 8, 2010 at 10:21 AM, David Robinow  wrote: >>> >>> On Sun, Aug 8, 2010 at 12:51 PM, Mark Lawrence >>>  wrote: >>>> >>>&

Re: need a json representation of all members of any type of object, list or hashtable (php's var_dump)

2010-08-09 Thread Benjamin Kaplan
On Mon, Aug 9, 2010 at 7:18 PM, Rene Veerman wrote: > hi. > > for 2 open source components of mine that are used in debugging, i > would like to capture the output generated by print for any variable. > i'm new to python, so please excuse my noobishness. > > i don't know if objects can be json-ed

Re: Using the print command in Python3

2010-08-09 Thread Benjamin Kaplan
On Mon, Aug 9, 2010 at 10:17 PM, Grady Knotts wrote: > In earlier versions of Python I can do: >        print 'A', >        print 'B' > to print everything on the same line: 'A B' > > But I don't know how to do this with Python3 > I've been trying things like: >        print('A',) >        print('

Re: Weird Python behaviour

2010-08-10 Thread Benjamin Kaplan
On Tue, Aug 10, 2010 at 4:58 AM, Jonas Nilsson wrote: > Hello, > > Lets say that I want to feed an optional list to class constructor: > > class Family(): >        def __init__(self, fName, members = []): >                self.fName = fName >                self.members = members > > Now, lets add

Re: python interview quuestions

2010-08-10 Thread Benjamin Kaplan
On Tue, Aug 10, 2010 at 1:44 PM, J Kenneth King wrote: > James Mills writes: > >> On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase >> wrote: I would like to aquint myself with Python Interview questions >>> >>> This came up a while ago: >>> >>> http://www.mail-archive.com/python-list@python.org/m

Re: How does Python get the value for sys.stdin.encoding?

2010-08-11 Thread Benjamin Kaplan
On Wed, Aug 11, 2010 at 6:21 PM, RG wrote: > I thought it was hard-coded into the Python executable at compile time, > but that is apparently not the case: > > [...@mickey:~]$ python > Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) > [GCC 4.2.1 (Apple Inc. build 5646)] on darwin > Type "help", "

Re: Floating numbers

2010-08-12 Thread Benjamin Kaplan
On Thu, Aug 12, 2010 at 6:14 PM, Ned Deily wrote: > In article , >  Christian Heimes wrote: >>> Is there a way I can keep my floating point number as I typed it? For >>> example, I want 34.52 to be 34.52 and NOT 34.520002. >> This isn't a Python issue. Python uses IEEE 754 [1] double precisio

Re: bash: syntax error near unexpected token

2010-08-16 Thread Benjamin Kaplan
On Mon, Aug 16, 2010 at 11:33 PM, kreglet wrote: > Hello, > > I started learning python last year. All of this time i have used the > terminal and gedit to create, modify, and test my applications and modules. > For some reason I can not do this any more. > I'll try to do my best to explain whats

Re: How do I make python test.py work without a syntax error msg?

2010-08-19 Thread Benjamin Kaplan
On Thu, Aug 19, 2010 at 8:22 AM, Agida Kerimova wrote: > I am new to programming/python and have been having some difficulties > getting started. I can't seem to run scripts without a syntax error msg. > When I drag the file to the IDLE launcher or run the module it works, but > when I actually ty

Re: IDLE will not startup after upgrading Python on Mac OS X

2010-08-23 Thread Benjamin Kaplan
On Mon, Aug 23, 2010 at 9:45 AM, Frederick Manley wrote: > I have snow leopard and a brand new mac book pro.  After running python from > x11, I saw that I had python 2.5.1 installed on this laptop, That should be 2.6.1 if you're on Snow Leopard. Also, why were you running Python from an xterm? J

Re: problem with simple multiprocessing script on OS X

2010-08-24 Thread Benjamin Kaplan
On Tue, Aug 24, 2010 at 3:31 PM, Darren Dale wrote: > On Aug 23, 9:58 am, Darren Dale wrote: >> The following script runs without problems on Ubuntu and Windows 7. >> h5py is a package wrapping the hdf5 library (http://code.google.com/p/ >> h5py/): >> >> from multiprocessing import Pool >> import

Re: python repository?

2009-06-06 Thread Benjamin Kaplan
On Saturday, June 6, 2009, wrote: > Hi, > > I've written a large body of my work in MATLAB over the years. But it > looks like I'll need to move to Python soon. Is there a common > resource where people can post files for others to use such as the > MATLAB central file exchange? > > Thanks, > Joh

Re: install Python-2.4.4 from source (parallel to existing Python-2.6)

2009-06-12 Thread Benjamin Kaplan
On Fri, Jun 12, 2009 at 9:31 AM, Simon wrote: > edexter wrote: > >> simon wrote: >> >>> Hi everybody, >>> >>> The situation: >>> I wrote a GUI, based on Python, TkInter and Pmw. >>> It runs perfectly fine with Python 2.4 (providing, TkInter and Pmw are >>> installed). But it crashes with Python 2

Re: Good books in computer science?

2009-06-14 Thread Benjamin Kaplan
On Sun, Jun 14, 2009 at 9:04 AM, Steven D'Aprano < st...@removethis.cybersource.com.au> wrote: > Nathan Stoddard wrote: > > > The best way to become a good programmer is to program. Write a lot of > > code; work on some large projects. This will improve your skill more than > > anything else. > >

Re: please help...writing set to a file

2009-06-18 Thread Benjamin Kaplan
On Thu, Jun 18, 2009 at 5:24 AM, yadin wrote: > Good day every one! > > I got this python program that returns me a set like this.. > Set ([‘A\n’, B\n’, ‘C\n’, ‘D\n’, ‘E\n’, ‘F\n’, ‘G\n’ ]) > And a list pp = [‘100\n’ ‘200\n’ ‘300\n’ ‘400\n’] > I was reading this from a file…. > How can I transfor

Re: help!

2009-06-23 Thread Benjamin Kaplan
On Tue, Jun 23, 2009 at 12:19 PM, tanner barnes wrote: > Python Version: 2.6 > GUI toolkit: WxPython > > Ok so i am writing a program for my school's football team. In one part > there is a notebook with 4 tabs for that stats. In each > tab there are 4 txtctrl's with a + and - for each. The problem

Re: Advantages of Python (for web/desktop apps)?

2009-06-28 Thread Benjamin Kaplan
On Sun, Jun 28, 2009 at 11:03 AM, Aahz wrote: > In article , > Tim Chase   wrote: >> >>> - how do i design GUI for windows app? >> >>http://lmgtfy.com/?q=python+gui > > This is the first time I've tried LMGTFY, and it seems to be a piece of > trash that requires JavaScript.  I suggest that lmgtfy.c

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-01 Thread Benjamin Kaplan
On Wed, Jul 1, 2009 at 7:48 AM, Barak, Ron wrote: > Hi, > > I think I'm up against a limitation in cStringIO.StringIO(), but could not > find any clues on the web, especially not in > http://docs.python.org/library/stringio.html. > > What I have is the following function: > >     def concatenate_fi

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-04 Thread Benjamin Kaplan
On Sat, Jul 4, 2009 at 1:33 PM, John Nagle wrote: >   As an example of code that really needs to run fast, but is > speed-limited by Python's limitations, see "tokenizer.py" in > >        http://code.google.com/p/html5lib/ > > This is a parser for HTML 5, a piece of code that will be needed > in ma

Re: Zipped Python?

2009-07-04 Thread Benjamin Kaplan
On Sat, Jul 4, 2009 at 8:03 PM, Jeremy Cowles wrote: >>> I'm looking for a full 2.5 or 2.6 version of Python that is zipped (i.e. >>> no >>> install). My intentions are to use it for a distributed computing project >>> (PyMW) where there is no guarantee that Python is installed on the worker >>> ma

Re: tough-to-explain Python

2009-07-09 Thread Benjamin Kaplan
On Thu, Jul 9, 2009 at 1:05 AM, Simon Forman wrote: > Everyone gets so caught up in programming via languages that > you get, well, people trying to teach "Computer Programming" as if it > were only necessary to grok a language, rather than grokking /symbol > manipulation/ itself. > > +1 QOTW. I'

Re: older pythons

2009-07-09 Thread Benjamin Kaplan
On Thu, Jul 9, 2009 at 8:10 AM, Lie Ryan wrote: > superpollo wrote: >> Lie Ryan wrote: >> >>> AFAIK, no major linux distributions have officially ported to python >>> 3.x. >> >> http://packages.debian.org/experimental/python3.1 >> >> thanks for help > > Note the word "experimental" Assuming that D

Re: main in Python

2009-07-10 Thread Benjamin Kaplan
On Fri, Jul 10, 2009 at 5:52 PM, Tim wrote: > > Hi, > I learned that a Python script is written in this way: > def main(): >    ... > if __name__ == "__main__": >    main() > > Today, when I read a script, I found it has a different way: > > def main(): >    ... > > main() > > It can run as well. C

Re: Python graphics / imaging library

2009-07-18 Thread Benjamin Kaplan
On Sat, Jul 18, 2009 at 7:50 AM, Peter Chant < rempete...@cappetezilla.italsco.uk> wrote: > Michiel Overtoom wrote: > > > Peter Chant wrote: > > > >> what's the most appropriate (maintained) graphics library to use? PIL > >> seems to have last been updated in 2006 > >> http://www.pythonware.com/p

Re: Help understanding the decisions *behind* python? - immutable objects

2009-07-27 Thread Benjamin Kaplan
On Sun, Jul 26, 2009 at 2:24 PM, John Nagle wrote: > Beni Cherniavsky wrote: >> >> On Jul 22, 9:36 am, Hendrik van Rooyen >> wrote: >>> >>> On Tuesday 21 July 2009 15:49:59 Inky 788 wrote: >>> My guess is that it was probably for optimization reasons long ago. I've never heard a *good* r

Re: initializing with empty list as default causes freaky problems

2009-07-27 Thread Benjamin Kaplan
On Mon, Jul 27, 2009 at 1:40 PM, Reckoner wrote: > Hi, > > Observe the following: > > In [202]: class Foo(): >   .:     def __init__(self,h=[]): >   .:         self.h=h >   .: >   .: > > In [203]: f=Foo() > > In [204]: g=Foo() > > In [205]: g.h > Out[205]: [] > > In [206]: f.h > Out

Re: Does underscore has any special built-in meaningin Python ?

2009-07-29 Thread Benjamin Kaplan
On Wed, Jul 29, 2009 at 1:59 PM, dandi kain wrote: > > Hello everybody, > I have just started learning Python.I heard its simple so I pick a > presentation [1] and tried to work on it.But when it comes to > underscores leading and trailing an object I dont understand any.I > look through the pytho

Re: calling obect method

2009-07-30 Thread Benjamin Kaplan
On Thu, Jul 30, 2009 at 3:04 PM, srinivasan srinivas < sri_anna...@yahoo.co.in> wrote: > Hi, > I would like to know if i have an object and one of its methods as a > string. How to call the method using this string? > For ex > If object is x and string y has one of its method names. > x.value(y)()

Re: Confessions of a Python fanboy

2009-07-31 Thread Benjamin Kaplan
On Fri, Jul 31, 2009 at 11:35 AM, Iain King wrote: > On Jul 31, 4:08 pm, Ethan Furman wrote: >> Steven D'Aprano wrote: >> > On Thu, 30 Jul 2009 18:47:04 +0100, Tim Rowe wrote: >> >> >>That and the fact that I couldn't stop laughing for long enough to learn >> >>any more when I read in the Pragmati

Re: Can python do something like the onclick events in javascript ?

2009-08-03 Thread Benjamin Kaplan
On Mon, Aug 3, 2009 at 2:39 PM, Leo Brugud wrote: > I'm trying to use python to build a simple web page that make use of > the onclick behavior, instead of requiring users > to click the 'submit' button. > > I realize in javascript there are onclick, onchange events. Is python > capable of doing t

<    2   3   4   5   6   7   8   >