Re: os.path.walk() to get full path of all files

2011-03-16 Thread Benjamin Kaplan
On Wed, Mar 16, 2011 at 5:00 PM, dude ernied...@gmail.com wrote: awesome, that worked.  I'm not sure how the magic is working with your underscores there, but it's doing what I need.  thanks. -- It's not magic at all. _ is just a variable name. When someone names a variable _, it's just to

Re: Grabbing user's agent and OS type

2011-03-11 Thread Benjamin Kaplan
2011/3/11 Νικόλαος Κούρας nikos.kou...@gmail.com: Thanks a lot Steven! The following code worked like a charm! ** agent = os.environ['HTTP_USER_AGENT'] # determination of user browser agent = agent.lower() if 'chrome' in agent:        agent = 'Chrome' if 'firefox' in

Re: Calling C++ Modules in Python

2011-03-11 Thread Benjamin Kaplan
On Mar 11, 2011 4:23 PM, Patrick zxpat...@gmail.com wrote: Hi, I saw in the Beginner document that •Is easily extended by adding new modules implemented in a compiled language such as C or C++. . While to my investigation, it seems not that easy or did I miss something? boost python (C++

Re: Don't Want Visitor To See Nuttin'

2011-03-10 Thread Benjamin Kaplan
On Thu, Mar 10, 2011 at 6:48 PM, Victor Subervi victorsube...@gmail.com wrote: On Wed, Mar 9, 2011 at 5:33 PM, Ian hobso...@gmail.com wrote: On 09/03/2011 21:01, Victor Subervi wrote: The problem is that it prints Content-Type: text/html to the screen If you can see what is intended to be a

Re: Defining class attributes + inheritance

2011-03-08 Thread Benjamin Kaplan
On Mar 8, 2011 6:02 PM, Martin De Kauwe mdeka...@gmail.com wrote: Hi, I think this might be obvious? I have a base class which contains X objects which other classes inherit e.g. class BaseClass(object): def __init__(self, something, something_else): self.something = something

Re: changing to function what works like a function

2011-03-07 Thread Benjamin Kaplan
On Mar 7, 2011 6:35 AM, Victor Paraschiv victoryw...@yahoo.com wrote: Hi everyone i understood that the goal of Python is to make programing easy (of course, powerful at the same time). I think one way to do it is to eliminate unnecessary syntax exceptions. One is the following: for a complex

Re: how to communicate in python with an external process

2011-03-07 Thread Benjamin Kaplan
On Mon, Mar 7, 2011 at 6:12 PM, Danny Shevitz shev...@lanl.gov wrote: http://pypi.python.org/pypi/pymatlab/ Cheers, Chris I am on a mac. Does pymatlab support mac's? I tried the linux 64 bit egg (downloaded to my local machine) and got: macshevitz:~ dannyshevitz$ sudo easy_install

Re: questions about multiprocessing

2011-03-07 Thread Benjamin Kaplan
On Mon, Mar 7, 2011 at 7:47 PM, Vincent Ren renws1...@gmail.com wrote: Got it, thanks. But what should I do if I want to improve the efficiency of my program? Is there any particular reason you're using processes and not threads? Functions that wait for stuff to happen in C land, such as I/O

Re: subprocess running ant

2011-03-03 Thread Benjamin Kaplan
On Mar 3, 2011 1:19 PM, Thom Hehl t...@pointsix.com wrote: I am attempting to write a python script that will check out and build our code, then deploy the executable. It will report any failures via e-mail. To this end, I’m trying to run my ant build from inside of python. I have tried the

Re: Python Language Question?

2011-02-27 Thread Benjamin Kaplan
On Sun, Feb 27, 2011 at 11:45 AM, Paul Symonds paul.j.symo...@gmail.com wrote: Can someone give and explanation of what is happening with the following: a,b = 0,1                       # this assigns a = 0 and b = 1 while b 10: ...     print b ...     a, b = b, a+b ... 1 1 2 3 5 8

Re: backwards-compatibility

2011-02-26 Thread Benjamin Kaplan
On Sat, Feb 26, 2011 at 8:11 AM, Jason Swails jason.swa...@gmail.com wrote: Hello, I have a question I was having a difficult time finding with a quick google search, so I figured someone on here might know.  For the sake of backwards compatibility (and supporting systems whose default python

Re: Running Scripts vs Interactive mode

2011-02-24 Thread Benjamin Kaplan
On Thu, Feb 24, 2011 at 10:34 AM, grobs456 gregory.alexander.robe...@gmail.com wrote: c:\dev\pythonpython HelloWorld.py 'python' is not recognized as an internal or external command, operable program or batch file. #I then tried this for a success!: c:\dev\pythonc:\python27\python.exe

Re: Python fails on math

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 8:20 AM, christian schulze xcr...@googlemail.com 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)

Re: ImportError: No module named gobject

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 9:20 AM, J. Gerlach gerlach_jo...@web.de 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

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 ir...@-nospam-xs4all.nl 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

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 ir...@-nospam-xs4all.nl 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, but whatever

Re: Return Values lambda

2011-02-21 Thread Benjamin Kaplan
On Mon, Feb 21, 2011 at 1:59 PM, pradeepbpin pradeepb...@gmail.com 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

Re: floating point woes

2011-02-15 Thread Benjamin Kaplan
On Tue, Feb 15, 2011 at 6:49 PM, Hans-Peter Jansen h...@urpla.net 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? quote Values are rounded

Re: Extending classes __init__behavior for newbies

2011-02-13 Thread Benjamin Kaplan
On Feb 13, 2011 5:37 PM, James Mills prolo...@shortcircuit.net.au wrote: On Mon, Feb 14, 2011 at 8:21 AM, MRAB pyt...@mrabarnett.plus.com wrote: I would've done it this way: class FasterShip(Ship): def __init__(self, speed=0, **kwargs): Ship.__init__(self, **kwargs)

Re: Easy function, please help.

2011-02-10 Thread Benjamin Kaplan
On Thu, Feb 10, 2011 at 12:03 AM, Jason Swails jason.swa...@gmail.com wrote: On Wed, Feb 9, 2011 at 5:34 PM, MRAB pyt...@mrabarnett.plus.com wrote: On 09/02/2011 21:42, Jason Swails wrote: You've gotten several good explanations, mainly saying that 0 - False and not 0 - True, which is why

Re: Where and when does Python say this to you?

2011-02-08 Thread Benjamin Kaplan
On Tue, Feb 8, 2011 at 8:27 AM, gracemia gracemia grace...@gmail.com wrote: This is the simple code: import socket sock = socket(AF_UNIX, SOCK_STREAM) -- Thank you I think you're having a bit of trouble with

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-03 Thread Benjamin Kaplan
On Thu, Feb 3, 2011 at 5:29 AM, flebber flebber.c...@gmail.com wrote: On Feb 1, 11:38 pm, rantingrick rantingr...@gmail.com wrote: On Feb 1, 4:20 am, flebber flebber.c...@gmail.com wrote: Sorry Rick too boringtrying to get bored people to bite at your ultra lame post yawn...

Re: Errors while using strip and remove on a variable.

2011-02-03 Thread Benjamin Kaplan
On Thu, Feb 3, 2011 at 10:21 AM, anand jeyahar anand.ibm...@gmail.com wrote: Hi,     I am trying to strip a string and then remove on the resulting list to remove a set of characters. It works fine with the python shell. But after remove the list becomes None, when i am running it from within

Re: returning all matching groups with re.search()

2011-02-03 Thread Benjamin Kaplan
On Thu, Feb 3, 2011 at 3:32 PM, mhearne808[insert-at-sign-here]gmail[insert-dot-here]com mhearne...@gmail.com wrote: Here's a scenario: import re m = re.search('e','fredbarneybettywilma') Now, here's a stupid question: why doesn't m.groups() return ('e','e','e'). I'm trying to figure out

Re: python question

2011-02-02 Thread Benjamin Kaplan
On Wed, Feb 2, 2011 at 4:08 PM, Robin r...@thevoid1.net wrote: how do you acccess a hash element in python 3? It completely changed from version 2 and earlier, I think. What do you mean by accessing a hash element? Do you mean the hash of an object? Because that's stayed the same: hash(obj).

Re: Running python scripts from the command line.

2011-01-31 Thread Benjamin Kaplan
On Mon, Jan 31, 2011 at 9:43 PM, Nanderson mandersonrandersonander...@gmail.com wrote: I've recently started to program. Python is my first language, so I'm a complete beginner. I've been trying to call python scripts from the command line by entering this command into it: python test.py But

Re: [pygame-bug] Pygame.cdrom bug

2011-01-29 Thread Benjamin Kaplan
On Sat, Jan 29, 2011 at 11:25 PM, rantingrick rantingr...@gmail.com wrote: Hello folks, Pygame  --the best little 2d game engine in Pythoina-- is great for little 2d one off games and such (or so i've heard). I really don't do much 2d graphics but pygame has some other helpful modules so i

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-28 Thread Benjamin Kaplan
On Fri, Jan 28, 2011 at 1:33 PM, bansi mail2ba...@gmail.com wrote: On Jan 28, 9:46 am, bansi mail2ba...@gmail.com wrote: On Jan 26, 8:31 pm, MRAB pyt...@mrabarnett.plus.com wrote: On 27/01/2011 00:57, bansi wrote: On Jan 26, 6:25 pm, Ethan Furmanet...@stoneleaf.us  wrote: bansi

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-28 Thread Benjamin Kaplan
On Fri, Jan 28, 2011 at 3:24 PM, rantingrick rantingr...@gmail.com wrote: On Jan 28, 8:52 am, Giampaolo Rodolà g.rod...@gmail.com wrote: Why don't you file a ticket on the bug tracker instead of wasting yours and other people's time here by making appear another rant against Tkinter as a bug

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-28 Thread Benjamin Kaplan
On Fri, Jan 28, 2011 at 3:42 PM, bansi mail2ba...@gmail.com wrote: On Jan 28, 1:52 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Fri, Jan 28, 2011 at 1:33 PM, bansi mail2ba...@gmail.com wrote: On Jan 28, 9:46 am, bansi mail2ba...@gmail.com wrote: On Jan 26, 8:31 pm, MRAB pyt

Re: Slice lists and extended slicing

2011-01-26 Thread Benjamin Kaplan
On Wed, Jan 26, 2011 at 12:20 PM, Gerald Britton gerald.brit...@gmail.com wrote: I'm looking at extended slicing and wondering when and how to use slice lists: slicing          ::=  simple_slicing | extended_slicing simple_slicing   ::=  primary [ short_slice ] extended_slicing ::=  primary [

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-26 Thread Benjamin Kaplan
On Wed, Jan 26, 2011 at 11:53 AM, rantingrick rantingr...@gmail.com wrote: On Jan 26, 10:43 am, Emile van Sebille em...@fenx.com wrote: On 1/26/2011 8:00 AM rantingrick said... I just installed Python 3,0 on my machine. Try it again on the current release candidate

Re: documentation / reference help

2011-01-25 Thread Benjamin Kaplan
On Jan 25, 2011 1:19 PM, Craig Leffel cra...@earthlink.net wrote: Where does it return the value to? What do I need to put in the calling function so that I can use that value? I need a variable name to refer to. Shouldn't I have to define that variable someplace? Python functions are like

Re: why are functions greater than numbers?

2011-01-24 Thread Benjamin Kaplan
On Jan 24, 2011 5:31 PM, Alan alan.is...@gmail.com wrote: Why do function objects compare in this way to numbers? Thanks, Alan Isaac def f(): return ... f5 True Python 2 returned an arbitrary but consistent ordering for almost all comparisons, just in case you were doing something

Re: Problems with FTP

2011-01-21 Thread Benjamin Kaplan
On Fri, Jan 21, 2011 at 3:01 PM, RizlaJ razajaffre...@gmail.com wrote: Hi Tom, Giampaolo, Thank you both for your swift replies. I have asked our IT dept to see if it is the firewall that is blocking the FTP. They are working on that side of things. However I would have thought that the

Re: printing a list with non-ascii strings

2011-01-20 Thread Benjamin Kaplan
On Thu, Jan 20, 2011 at 10:43 AM, Helmut Jarausch jarau...@skynet.bewrote: Hi, I don't understand Python's behaviour when printing a list. The following example uses 2 German non-ascii characters. #!/usr/bin/python # _*_ coding: latin1 _*_ L=[abc,süß,def] print L[1],L The output of

Re: dictionary as attribute of a class...

2011-01-05 Thread Benjamin Kaplan
On Wed, Jan 5, 2011 at 10:07 AM, tinauser tinau...@libero.it wrote: Hallo list, here again I have a problem whose solution might be very obvious, but I really cannot see it: I have a class having as attribute a dictionary whose keys are names and values are instance of another class. This

Re: RE: Qt with PyDev

2011-01-05 Thread Benjamin Kaplan
On Jan 5, 2011 12:15 PM, Rohit Coder passionate_program...@hotmail.com wrote: Seen both, but do I need to install the binaries or add a link in Pydev to PySide source-code? You need to install the binaries. Doing that will put the pyside libraries in a location where Python and Pydev can find

Re: Importing modules from miscellaneous folders

2011-01-05 Thread Benjamin Kaplan
On Wed, Jan 5, 2011 at 8:08 PM, Jshgwave jshgw...@yahoo.com wrote: On a Windows PC, I would like to be able to store modules in topic-specific foldersinstead of in Python26/Lib/site-packages, and then import into an IPython session those modules and the functions in them. To test this, I

Re: Trying to decide between PHP and Python

2011-01-04 Thread Benjamin Kaplan
On Tue, Jan 4, 2011 at 3:20 PM, Google Poster gopos...@jonjay.com wrote: About once a year, I have to learn yet another programming language. Given all the recommendations (an outstanding accolade from Bruce Eckel, author of Thinking in Java) I have set my aim to Python. Sounds kinda cool.

Re: list 2 dict?

2011-01-02 Thread Benjamin Kaplan
On Jan 2, 2011 4:15 PM, Octavian Rasnita orasn...@gmail.com wrote: Octavian - Original Message - From: Alex Willmer a...@moreati.org.uk Newsgroups: comp.lang.python To: comp.lang.pyt...@googlegroups.com Cc: python-list@python.org Sent: Sunday, January 02, 2011 8:07 PM Subject:

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-24 Thread Benjamin Kaplan
On Dec 24, 2010 4:40 PM, Flávio Lisbôa flisboa.co...@gmail.com wrote: copy, here, is a dict method. It will create a dict. If you really need it, you could try this: import copy class neodict(dict): def copy(self): return copy.copy(self) d = neodict() print type(d) dd =

Re: Python programming

2010-12-22 Thread Benjamin Kaplan
If you're just starting out, look at the Python tutorial http://docs.python.org/tutorial/index.html This question is answered in the tutorial- specifically in http://docs.python.org/tutorial/datastructures.html#more-on-conditions Also, there's a separate list, the tu...@python.org , for people

Re: subprocess.Popen() and a .msi installer

2010-12-17 Thread Benjamin Kaplan
On Fri, Dec 17, 2010 at 5:57 PM, Sebastian Alonso alon.sebast...@gmail.com wrote: Hey everyone, I'm working on a script which uses subprocess to launch a bunch of installers, but I'm getting problems with .msi installers although .exe ones work fine. The output I get is this: import

Re: Concatenate a string as binary bytes

2010-12-14 Thread Benjamin Kaplan
2010/12/14 Jaime Fernández jjja...@gmail.com: Hi To build a binary packet (for SMPP protocol), we have to concatenate different types of data: integers, floats, strings. We are using struct.pack to generate the binary representation of each integer and float of the packet, and then they are

Re: How to experience python on a handheld, tablet, etc on linux?

2010-12-14 Thread Benjamin Kaplan
On Tue, Dec 14, 2010 at 6:30 PM, stateslave stonesn...@kol.co.nz wrote: Without buying first? I'd like to run the front end of all these new devices, on my PC and program in python, to assess which is the best on for me. pre-test python scripts before cross loading onto the device I finally

Re: Python critique

2010-12-10 Thread Benjamin Kaplan
On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita orasn...@gmail.com wrote: From: John Nagle na...@animats.com On 12/10/2010 2:31 AM, kolo 32 wrote: Hi, all, Python critique from strchr.com: http://www.strchr.com/python_critique    I have criticisms of Python, but those aren't them.    

Re: 64 bit memory usage

2010-12-09 Thread Benjamin Kaplan
On Thursday, December 9, 2010, Rob Randall rob.randa...@gmail.com wrote: But the C++ program using up memory does not slow up. It has gone to 40GB without much trouble. Your C++ program probably doesn't have a garbage collector traversing the entire allocated memory looking for reference

Re: Python's equivalent to Main calling program and subprograms

2010-12-01 Thread Benjamin Kaplan
On Wed, Dec 1, 2010 at 12:08 PM, m b sn...@hotmail.se wrote: if __name__ == __main__: main() What does this mean? /Mikael Every module has an attribute called __name__. Normally, it's the name of the module itself. However, the module being run as a script (rather than imported) is

Re: Standard module implementation

2010-11-28 Thread Benjamin Kaplan
On Sun, Nov 28, 2010 at 9:08 AM, candide cand...@free.invalid wrote: I was wondering if all the standard module are implemented in C. For instance, I can't find a C implementation for the minidom xml parser under Python 2.6. -- No they aren't. A good chunk of the standard library is

Re: I got a ImportError,help~!

2010-11-24 Thread Benjamin Kaplan
2010/11/24 xlizzard xlizz...@163.com: HI, I am a newer to python(my version is 3.1.2),recently I got a IDE named Eric(http://eric-ide.python-projects.org/index.html) to study and on this main page I downloaded a tutorial named minibrowser.

Re: String multi-replace

2010-11-17 Thread Benjamin Kaplan
On Wed, Nov 17, 2010 at 11:21 PM, Sorin Schwimmer sx...@yahoo.com wrote: Hi All, I have to eliminate diacritics in a fairly large file. Inspired by http://code.activestate.com/recipes/81330/, I came up with the following code: #! /usr/bin/env python import re

Re: [Beginner question] Error when converting raster to ASCII

2010-11-15 Thread Benjamin Kaplan
On Monday, November 15, 2010, Becky Kern kern...@gmail.com wrote: Hi again users, This is in response to my post from 11/14/2010 (see below) Hi users, I'm using Python 2.5 (in concert with ArcGIS 9.3) to convert a raster to an ASCII file. I used the code (listed below) several weeks ago to

Re: [Python] scipy code runs in empty directory, not another

2010-11-13 Thread Benjamin Kaplan
On Saturday, November 13, 2010, Chris Gonnerman chris.gonner...@newcenturycomputers.net wrote: On 11/13/2010 07:52 AM, Beliavsky wrote: After installing numpy, scipy, and matplotlib for python 2.6 and running the code from http://www.scipy.org/Cookbook/OptimizationDemo1 (stored as

Re: Making ActivePython and Python co-exist on Windows

2010-11-07 Thread Benjamin Kaplan
On Sun, Nov 7, 2010 at 2:25 PM, CWC c...@cwc.name wrote: I'm new to Python.  Is it possible to make ActivePython 3.12 and Python 3.12 co-exist on Windows?  I've got an app which requires the former, but I want to stay with the latter, since I'm interested in getting into development.  The main

Re: execute shell script from python, needs sys.argv

2010-11-04 Thread Benjamin Kaplan
On Thu, Nov 4, 2010 at 11:37 AM, Matt macma...@gmail.com wrote: Hi All, I am trying to execute a shell script from within python..  This shell script takes the format, where $1 and $2 are variables from the command line: cat $1 | Fastx_trimmer -n COUNT -o $2 straight into the cmd line it

Re: [Beginer Question] I heard about python needing somesort of_VariableName_ boiler plate?

2010-11-01 Thread Benjamin Kaplan
On Mon, Nov 1, 2010 at 2:18 PM, brad...@hotmail.com wrote: Sorry that is what I mean. What is it for? Sent wirelessly from my BlackBerry. What is what for? There is no boiler plate on variable names. *BY CONVENTION*, variables and methods with a special meaning will start and end with two

Re: serial I/O install fail -- DLL not found

2010-11-01 Thread Benjamin Kaplan
On Mon, Nov 1, 2010 at 5:55 PM, Fossil mskcrpttn...@gmail.com wrote: Just starting with Python. Installed:  Python 2.7  pywin32-214.win32-py2.7.exe  pyserial-2.5.win32.exe on a Home WinXP SP3 Toshiba laptop with 2GB memory.  Open Python and try to do simple I/O test and can't even get past

Re: Is there a way to pring a list object in Python?

2010-10-31 Thread Benjamin Kaplan
On Sun, Oct 31, 2010 at 3:04 PM, Zeynel azeyn...@gmail.com wrote:        Rep().replist = L        Rep().put()        query = Rep.all()        for result in query:            self.response.out.write(result.replist) The output of this is: [u'a', u'b'][u'a', u'b'][u'a', u'b']. . . So,

Re: Why flat is better than nested?

2010-10-26 Thread Benjamin Kaplan
On Tue, Oct 26, 2010 at 9:05 AM, kj no.em...@please.post wrote: In mailman.241.1288036400.2218.python-l...@python.org Terry Reedy tjre...@udel.edu writes: On 10/25/2010 3:11 PM, kj wrote: Well, it's pretty *enshrined*, wouldn't you say? No.  After all, it is part of the standard

Re: linking on OSX Snow Leopard

2010-10-24 Thread Benjamin Kaplan
On Sun, Oct 24, 2010 at 4:15 PM, john skaller skal...@users.sourceforge.net wrote: I'm not able to find the shared library version of Python3 on my Mac. There are libpython.dylib things for Python2. There is a Python3 libpython.a static lib. aside The docs on linking indicate a serious

Re: OO and game design questions

2010-10-18 Thread Benjamin Kaplan
On Mon, Oct 18, 2010 at 9:50 AM, dex josipmisko...@gmail.com wrote: You're aware Python can collect reference cycles, correct?  You don't have to delete references; Python will get them eventually. I'm not sure I understand this part? If I don't delete all strong references, the object will

Re: what difference does redirection make?

2010-10-17 Thread Benjamin Kaplan
On Sun, Oct 17, 2010 at 3:04 PM, Nikola Skoric n...@fly.srk.fer.hr wrote: When I execute n...@rilmir:~/code/simplepyged/docs/examples$ python latex.py I get expected output (bunch of latex markup). But, when I add a redirection, I get: n...@rilmir:~/code/simplepyged/docs/examples$ python

Re: open file on mac

2010-10-10 Thread Benjamin Kaplan
On Sun, Oct 10, 2010 at 5:29 PM, tinauser tinau...@libero.it wrote: On Oct 10, 6:54 am, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message d38a6549-379b-4ece-b391-904e15412...@i21g2000yqg.googlegroups.com, tinauser wrote: now,the file will be opened only if i give the

Re: unicode problem?

2010-10-09 Thread Benjamin Kaplan
On Sat, Oct 9, 2010 at 7:59 PM, Brian Blais bbl...@bryant.edu wrote: This may be a stemming from my complete ignorance of unicode, but when I do this (Python 2.6): s='\xc2\xa9 2008 \r\n' and I want the ascii version of it, ignoring any non-ascii chars, I thought I could do:

Re: direct print to log file

2010-10-05 Thread Benjamin Kaplan
On Tue, Oct 5, 2010 at 10:41 AM, Dave Angel da...@ieee.org wrote: On 2:59 PM, Dirk Nachbar wrote: How can I direct all print to a log file, eg some functions have their own print and I cannot put a f.write() in front of it. Dirk When code does a print() without specifying a file, it

Re: Random math op

2010-10-02 Thread Benjamin Kaplan
use the add, sub, div, and mul functions in the operator module. Stick them in a list, and then randomly pull one out. On Sat, Oct 2, 2010 at 12:53 PM, Hugo Léveillé hu...@fastmail.net wrote: Hi let say I have a simple math apps that randomize number X and number Y. How would you randomize

Re: Pyflakes and IPython does not work for Emacs on Windows?

2010-09-24 Thread Benjamin Kaplan
On Friday, September 24, 2010, Dsrt Egle dsrte...@gmail.com wrote: Hi, With Python on Windows, I tried to use Emacs as the programming environment. For syntax checking I installed pyflakes, but flymake always reports fail to launch. No such file or directory: pyflakes when opening a Python

Re: Too much code - slicing

2010-09-16 Thread Benjamin Kaplan
On Thu, Sep 16, 2010 at 3:35 PM, DataSmash r...@new.rr.com wrote: I need to create a simple utility to remove characters from either the right or left side of directories. This works, but there has to be a better way.  I tried to use a variable inside the brackets but I can't get that to

Re: Install python-mcrypt on Ubuntu

2010-09-14 Thread Benjamin Kaplan
On Tue, Sep 14, 2010 at 10:26 AM, lsolesen lsole...@gmail.com wrote: mcrypt.c:23:20: error: mcrypt.h: No such file or directory Well, there's your problem. You don't have the mcrypt headers installed. sudo apt-get install libmcrypt-dev -- http://mail.python.org/mailman/listinfo/python-list

Re: String formatting with the format string syntax

2010-09-14 Thread Benjamin Kaplan
On Tue, Sep 14, 2010 at 3:20 PM, Thomas Jollans tho...@jollybox.de wrote: On Tuesday 14 September 2010, it occurred to Miki to exclaim: You can use ** syntax: english = {'hello':'hello'} s.format(**english) No, you can't. This only works with dicts, not with arbitrary mappings, or dict

Re: bug in python documentation?

2010-09-11 Thread Benjamin Kaplan
On Sat, Sep 11, 2010 at 11:34 AM, Vito 'ZeD' De Tullio zak.mc.kra...@libero.it wrote: from http://docs.python.org/library/unittest.html --888888888888-- Here is a short script to test three functions from the random module: import random import

Re: default value for __init__ doesn't work

2010-09-10 Thread Benjamin Kaplan
On Sat, Sep 11, 2010 at 12:38 AM, 人言落日是天涯,望极天涯不见家 kelvin@gmail.com wrote: Please look at below code snippet: class test():    def __init__(self, a, dic={}):        self.a = a        self.dic = dic        print('__init__ params:',a, dic) This is a pretty popular mistake to make.

Re: how to extract an implicit dict expression (with statement return)

2010-09-09 Thread Benjamin Kaplan
On Thu, Sep 9, 2010 at 11:20 AM, Fritz Loseries fr...@loseries.info wrote: Hi, I do not know how to subject my problem in a better way. I have the following statement:    return [ dict(x1 = elem.x1, x2 = elem.x2, x3 = elem.x3,)                for elem in method(in_values)              ]

Re: listening socket

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 12:59 PM, cerr ron.egg...@gmail.com wrote: Hi, I'm trying to create a listening socket connection on port 1514. I tried to follow the documentation at: http://docs.python.org/release/2.5.2/lib/socket-example.html and came up with following lines: import socket host

Re: Slice a list of lists?

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 2:55 PM, Jonno jonnojohn...@gmail.com wrote: I know that I can index into a list of lists like this: a=[[1,2,3],[4,5,6],[7,8,9]] a[0][2]=3 a[2][0]=7 but when I try to use fancy indexing to select the first item in each list I get: a[0][:]=[1,2,3] a[:][0]=[1,2,3]

Re: Slice a list of lists?

2010-09-08 Thread Benjamin Kaplan
On Wed, Sep 8, 2010 at 4:23 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:18 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 3:06 PM, Jonno jonnojohn...@gmail.com wrote: On Wed, Sep 8, 2010 at 2:11 PM, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Wed

Re: The Samurai Principle

2010-09-07 Thread Benjamin Kaplan
On Tue, Sep 7, 2010 at 6:20 PM, Phlip phlip2...@gmail.com wrote: On Sep 7, 1:06 pm, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: try:    return Model.objects.get(pk=42) except Model.DoesNotExist:    return sentinel Visual Basic Classic had a Collection Class, which

Re: Database problems

2010-09-06 Thread Benjamin Kaplan
On Mon, Sep 6, 2010 at 3:01 PM, Edward Grefenstette egre...@gmail.com wrote: Dear Pythonistas, For a project I'm working on, I need to store fairly large dictionaries (several million keys) in some form (obviously not in memory). The obvious course of action was to use a database of some

Re: accessing a text file

2010-09-05 Thread Benjamin Kaplan
On Sun, Sep 5, 2010 at 5:47 PM, Baba raoul...@gmail.com wrote: level: beginner how can i access the contents of a text file in Python? i would like to compare a string (word) with the content of a text file (word_list). i want to see if word is in word_list. let's assume the TXT file is

Re: Stackless Python and EVE Online

2010-08-31 Thread Benjamin Kaplan
On Tuesday, August 31, 2010, Roman Sokolyuk romsok.t...@gmail.com wrote: Hi, I am new to Python and I wanted to understand something... The EVE Online Client is build using Stackless Python So when I install the client on my machine, how doe sit get run if I do not have Python installed?

Re: Stackless Python and EVE Online

2010-08-31 Thread Benjamin Kaplan
On Tue, Aug 31, 2010 at 5:45 PM, Krister Svanlund krister.svanl...@gmail.com wrote: On Tue, Aug 31, 2010 at 5:10 PM, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Tuesday, August 31, 2010, Roman Sokolyuk romsok.t...@gmail.com wrote: Hi, I am new to Python and I wanted to understand

Re: python 2.6.6 installation problems on osx

2010-08-30 Thread Benjamin Kaplan
On Mon, Aug 30, 2010 at 10:29 AM, jal j...@bethere.co.uk wrote: Hi All, I'm attempting a framework install of python 2.6.6 from source, on an intel mac running osx 10.6.4. At the end of the install the following errors occur. install: mkdir /usr/local/bin: Permission denied make[1]: ***

Re: How to convert (unicode) text to image?

2010-08-27 Thread Benjamin Kaplan
On Fri, Aug 27, 2010 at 8:01 PM, kj no.em...@please.post wrote: Hi!  Does anyone know of an easy way to convert a Unicode string into an image file (either jpg or png)? Do you mean you have some text and you want an image containing that text? PIL's ImageDraw module can do that. --

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 dsdal...@gmail.com wrote: On Aug 23, 9:58 am, Darren Dale dsdal...@gmail.com 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

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 fman...@gmail.com 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

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 agi...@gmail.com 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

Re: bash: syntax error near unexpected token

2010-08-16 Thread Benjamin Kaplan
On Mon, Aug 16, 2010 at 11:33 PM, kreglet kreg...@gmail.com 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

Re: Floating numbers

2010-08-12 Thread Benjamin Kaplan
On Thu, Aug 12, 2010 at 6:14 PM, Ned Deily n...@acm.org wrote: In article i41p6e$1f...@dough.gmane.org,  Christian Heimes li...@cheimes.de 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

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 rnospa...@flownet.com 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

Re: Weird Python behaviour

2010-08-10 Thread Benjamin Kaplan
On Tue, Aug 10, 2010 at 4:58 AM, Jonas Nilsson j...@spray.se 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

Re: python interview quuestions

2010-08-10 Thread Benjamin Kaplan
On Tue, Aug 10, 2010 at 1:44 PM, J Kenneth King ja...@agentultra.com wrote: James Mills prolo...@shortcircuit.net.au writes: On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase python.l...@tim.thechases.com wrote: I would like to aquint myself with Python Interview questions This came up a while

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 rene7...@gmail.com 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

Re: Using the print command in Python3

2010-08-09 Thread Benjamin Kaplan
On Mon, Aug 9, 2010 at 10:17 PM, Grady Knotts gradykno...@gmail.com 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',)  

Re: Class initialization

2010-08-08 Thread Benjamin Kaplan
On Sun, Aug 8, 2010 at 6:32 AM, Costin Gament costin.gam...@gmail.com 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

Re: Python why questions

2010-08-08 Thread Benjamin Kaplan
On Sun, Aug 8, 2010 at 10:24 AM, Default User hunguponcont...@gmail.com 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

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 drobi...@gmail.com wrote: On Sun, Aug 8, 2010 at 12:51 PM, Mark Lawrence breamore...@yahoo.co.uk 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

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 wolftra...@invalid.com wrote: On 8/8/2010 10:56 AM, Benjamin Kaplan wrote: On Sun, Aug 8, 2010 at 10:21 AM, David Robinowdrobi...@gmail.com  wrote: On Sun, Aug 8, 2010 at 12:51 PM, Mark Lawrencebreamore...@yahoo.co.uk  wrote: On 08/08/2010 17:16

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 wolftra...@invalid.com 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:      

Re: assigning variables from list data

2010-08-05 Thread Benjamin Kaplan
On Thu, Aug 5, 2010 at 7:26 AM, Chris Hare ch...@labr.net 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

<    1   2   3   4   5   6   7   8   >