Re: [Tutor] Readabilty vs 80 characters

2012-04-19 Thread Evert Rol
On 19 Apr, 2012, at 15:29 , Tino Dai wrote: Hi! I have a question about style. In PEP-8, it says don't exceed 79 characters, but can this rule ever be trumped by readability? Yes, it obviously can. I am a big fan of the 79 character rule, though. Even with screens and terminals

Re: [Tutor] Unwanted close failed in file object destructor after broken pipe

2012-04-17 Thread Evert Rol
First, generate a file named data.txt as follows: -- 8 -- for i in range(1,100): print '.' * 80 -- 8 -- After that, save the following snippet as test.py in the directory containing data.txt: -- 8

Re: [Tutor] summing lists

2012-04-10 Thread Evert Rol
I have 4 lists: a [40] b [2] c [23] d [12] Why are you using lists with a single element, instead of single integer variables? (thus, a=40, b=2, c=23, d=12.) how is it possible to do add elements in list. sum(list) I can do this using tupples, but I do not know how to

Re: [Tutor] a problem with a server and client

2012-04-06 Thread Evert Rol
i'm trying to implement a server that adds a time stamp to incoming text form a client. the server's code is (but doesn't seem to have the problem as demoed by the error below: from socket import * from time import ctime HOST = '' PORT = 21567 BUFSIZ = 1024 ADDR =(HOST, PORT)

Re: [Tutor] which gets called

2012-04-06 Thread Evert Rol
Hi, I want to create a class that inherits two other classes. class NewClass( A,B) But both A and B contain a method with the same name (onKeyDown). If my NewClass does not contain something to override the methods which one would be called if myinstance = NewClass()

Re: [Tutor] How to use g_timeout_add () function?

2012-04-06 Thread Evert Rol
Hello all, i have a question: when i check gtk_time_out in the gtk+2 reference, it said gtk_timeout_add has been deprecated since version 2.4 and should not be used in newly-written code. Use g_timeout_add() instead. but i don't know how tu use the g_timout_add() function: my_id =

Re: [Tutor] New to this list ....

2012-03-30 Thread Evert Rol
Hi and welcome Barry, One of the things I wanted to do is to use a four integer array to get four integers returned from a function. I ended up using what I think is a list. (I'm not really sure of the datatypes yet). This is what I did, and it works, but looks very inelegant to me:

Re: [Tutor] Problem Stripping

2012-03-30 Thread Evert Rol
Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters but it doesn't seem to work like I thought. res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE) uname = res.stdout.read().strip() uname 'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011

Re: [Tutor] Syntax error help

2012-03-30 Thread Evert Rol
Alright i have been trying to right a (relatively) simple to calculate area and volume below is my current working code def areamenu(): print 'Square (1)' print 'triangle (2)' print 'rectangle (3)' print 'trapazoid (4)' print 'circle (5)' def squareacalc():

Re: [Tutor] plotting several datasets and calling data from afar

2012-03-27 Thread Evert Rol
See below, but not all the way. Interspersed in the code. snipped some text; to keep it digestible I am trying to set up a code to do some plotting and before I get too far I wanted to ask some structure questions. Basically I want to tell python to read 2 datasets, plot them on the

Re: [Tutor] plotting several datasets and calling data from afar

2012-03-26 Thread Evert Rol
Hi Elaina, Hi everyone, I am trying to set up a code to do some plotting and before I get too far I wanted to ask some structure questions. Basically I want to tell python to read 2 datasets, plot them on the same scale on the same x-y axis , read a third dataset and match the name

Re: [Tutor] Permissions Error

2012-03-25 Thread Evert Rol
Hi everyone, If I've created a folder, why would I receive a permissions error when trying to copy the file. My source code is here: http://pastebin.com/1iX7pGDw What's the permission error you get? Can't you copy the file, or not create the destination directory? Or you may not be

Re: [Tutor] Simple GUI

2012-03-04 Thread Evert Rol
Im trying to code a simple GUI but I'm having a bit of a problem. Heres my code: from tkinter import * class Application(Frame): def __init__(self,master=None): Frame.__init__(self,master) self.grid(sticky=N+S+E+W)

Re: [Tutor] roman to arabic

2012-02-27 Thread Evert Rol
I wrote a little program that does the conversion (I won't post it because it would be a spoiler for the OP). The one thing I don't know, though, is how to formalise that it is not allowed to write something like X, but instead just II. Or not DM but simply D. The rule is to write

Re: [Tutor] problem editing modules and defs

2012-02-24 Thread Evert Rol
Hi David, Hi, I am new to python and have made a couple of definitions. I imported them and they worked ok. I they worked except for one which gave me the error NameError: global name 'np' is not defined. I then edited my script for the def to include import numpy as np saved it and

Re: [Tutor] Solve wave equation

2012-02-23 Thread Evert Rol
OK so I can solve the equation but now I am having trouble plotting the solution! I would like to produce a surface plot with colors defined by p and animate it. That is plot the value of p at all x and z, over time (t). My code to get p is below but I really have no idea how to plot this.

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Evert Rol
Hi, I have created a list of containing strings that represent distances between many different points and would like to display the results in a table. I have been trying to write them to a text file but it is difficult to organise them into rows and columns with appropriate spacing to

Re: [Tutor] ssh from Windows to a Solaris server

2012-02-20 Thread Evert Rol
I’m a newbie in python programming … I wrote the followings to ssh from Windows to a Solaris server: command1 = plink -ssh -pw myPassword myUserName@myServerIP p1 = subprocess.Popen(command1) p2 = subprocess.Popen('ls') I could verify that command1 was executed successfully, ie. the

Re: [Tutor] Some help Please

2012-02-15 Thread Evert Rol
Hi Joseph, take an example of updating Bank Accounts, gaving the following table: acc_idacc_namestanding_Balance mn0001computer 2 my problem is how can i credit the standing balance from user data,as in making a deposit onto

Re: [Tutor] (no subject)

2012-02-12 Thread Evert Rol
Hi, Tip: use a meaningful subject line; attracts more/better attention and makes it easier to trace your email in the archives. Continued at the bottom. import numpy as np import matplotlib.pyplot as plt E=[81.97400737666324, 322.0939978589591, 694.5766491226185] V0=1000 a=0.1 def

Re: [Tutor] how to stop a running program in python without closing python interface?

2012-02-12 Thread Evert Rol
actually a i ran a progam in python which is sufficiently large . so i want to stop the execution of the program now . how can i do this? This will depend on your operating system. On a Mac you press alt + command + esc and the choose the program you want to Force Quit. I have no idea

Re: [Tutor] confusion about scipy

2012-02-08 Thread Evert Rol
ImportError Traceback (most recent call last) C:\Python27\lib\site-packages\IPython\utils\py3compat.pyc in execfile(fname, glob, loc) 166 else: 167 filename = fname -- 168 exec compile(scripttext, filename, 'exec')

Re: [Tutor] Python with HTML

2012-01-29 Thread Evert Rol
hi everyone, I want to make a web page which has to include some python script and html tags as well, am not getting how to do that . I searched some articles but cant understand them . is there anything like linking an external html file into python script ? Can u please help for same

Re: [Tutor] compile time calculator

2012-01-28 Thread Evert Rol
Well, using python documentation, I did this.. (calculating execution time). def main(): ## This is my whole puzzle code... fobj_ip = open('D:/code/py/input.txt', 'r') fobj_op = open('D:/code/py/output.txt','w') line=1 for eachLine in fobj_ip: if line1:

Re: [Tutor] Question regarding setup.py

2012-01-27 Thread Evert Rol
I had a question regarding installing packages that I posted a couple of days ago. But I'm re-sending the question again.. this time with output so that it is clearer. I am unable to install libraries using 'python setup.py install' Say that I'm installing a package kando. I extract it

Re: [Tutor] Question about install.py

2012-01-19 Thread Evert Rol
Hi, I'm new to Python and was wondering if someone could answer a question I have. Say that I have a python library, arithmetic-0.5, located at /X/arithmetic-0.5 I'd like to run setup and install it. But I guess since /X/arithmetic-0.5 is not in install.py's default search path, it comes

Re: [Tutor] changing coordinate

2012-01-11 Thread Evert Rol
Hi Sue, I am trying to define a new coordinate for My plot. I have a plot x axis is Concentration, Y axis, depth or Z. Z= -1000 um. and I would like to see the the trend and plot of concentration up to -300 um and see how the plot changed according to the depth. So, my main question

Re: [Tutor] question regarding regular expression compile

2011-01-12 Thread Evert Rol
I am determining a regular expression that can recognize the any of the following strings: MAT file log\20101225 deleted MAT file billing\20101225 deleted MAT file util\20101225 deleted MAT file carrier\20101225 deleted I begin by creating a regular expression object so that I can

Re: [Tutor] variabel from raw input into re.search?

2011-01-07 Thread Evert Rol
Hi Tommy, I try to write a program, where the user can write a word or a name and I will tell how many times the subject was mentioned in a text, I’m hosting. I guess it’s possible but not this way it seems? The re is only searching for the word “name” and not the variable name I’m using

Re: [Tutor] matplotlib.pylab.plotfile formatting help

2011-01-04 Thread Evert Rol
Hi Sean, I've got a csv file that contains two data fields, the short name of a month and an integer. I'm experimenting with pylab and ipython to get a feel for how pylab works. I'm able to generate a bar graph from my data, but there are two problems with it: 1. I don't want 2011

Re: [Tutor] paramiko error with put()

2010-12-23 Thread Evert Rol
I don't really know the answer, but more a question/note (below): Hi I am using paramiko 1.7.6 fanny on microsoft windows xp v2002 service pack3 with python 2.4.2 I have the follwing script: import paramiko hostname='blah' port=22 username='blah' password='blah'

Re: [Tutor] why ifconfig is alway running?

2010-12-19 Thread Evert Rol
#!/usr/bin/env python import datetime import subprocess import sys import os import signal from time import sleep def host_run(cmd, secs=10): print(running %s % cmd) timeout = datetime.timedelta(seconds=secs) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,

Re: [Tutor] why ifconfig is alway running?

2010-12-19 Thread Evert Rol
#!/usr/bin/env python import datetime import subprocess import sys import os import signal from time import sleep def host_run(cmd, secs=10): print(running %s % cmd) timeout = datetime.timedelta(seconds=secs) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,

Re: [Tutor] why ifconfig is alway running?

2010-12-19 Thread Evert Rol
#!/usr/bin/env python import datetime import subprocess import sys import os import signal from time import sleep def host_run(cmd, secs=10): print(running %s % cmd) timeout = datetime.timedelta(seconds=secs) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,

Re: [Tutor] Question on tkinter event binding

2010-12-04 Thread Evert Rol
Hi Patty, As far as books are concerned, I actually prefer (programming) books in the English language. Although the Dutch don't do it as much as e.g. the French or the Germans, I hate it when technical terms are translated into Dutch in a somewhat artificial way (Computer is Ordinateur

Re: [Tutor] temporarily modifying sys.path

2010-11-28 Thread Evert Rol
I need a function that will import a module (using __import__) from only one specific location on my filesystem. Name collisions are possible. To avoid this I could *temporarily* modify sys.path for the operation so that it contains only the path that I want to work from. Just curious, but

Re: [Tutor] A regular expression problem

2010-11-28 Thread Evert Rol
snip intro Here's what I do. This was just a first attempt to get strings starting with a non alpha-numeric symbol. If this had worked, I would have continued to build the regular expression to get words with non alpha-numeric symbols in the middle and in the end. Alas, even this first

Re: [Tutor] Working with interactive Python shell

2010-11-24 Thread Evert Rol
snip intro --- One question for Steve (or for whoever wants to answer): you say you have a terminal with two tabs (neat, I wonder whether I can get tabs as well for my terminal in OS X) In Terminal.app, just type command-T and you get a new tab. Switch with the mouse or command-shift-[

Re: [Tutor] Working with interactive Python shell

2010-11-24 Thread Evert Rol
You're not really showing what exactly you type. That's often more clearer than describing what you do, although in this case we can get a pretty good picture anyway. OK, here's what I do: import test I know the shell is importing the file because I can see the following message:

Re: [Tutor] Math: integers to a fractional power

2010-11-15 Thread Evert Rol
OK, so I have a question for you math people: I am trying to solve a quartic equation (Ax^4 + Bx^3 + Cx^2 + Dx + E) using Ferrari's Method, which I found on Wikipedia at this location. I'm using Python 3.1.2 (on Mac OS X 10.6, in case that matters). First, since I

Re: [Tutor] Creating one file out of all the files in a directory

2010-11-14 Thread Evert Rol
Again, thanks a lot. Too bad you and Kushal don't live close. I would like to invite you to a beer or a coffe or something. Thanks for the offer. Some time ever in the far, far future perhaps ;-). snip So close ;-). What you're missing is the next write statement: f.write(data) (or

Re: [Tutor] Recommend a MVC framework

2010-11-14 Thread Evert Rol
Django can run be run through mod_wsgi (or mod_python if you really want). And other web servers than Apache will also work. Don't know what you mean with shared server, but if you mean multiple accounts running their web apps through one Apache server, that can work (provided Apache is

Re: [Tutor] Building input for a function call

2010-11-12 Thread Evert Rol
This is a more precise question, the above was after trying different methods, and it got a little confusing. Why in the below does using in line 12:self.objectsvars = 'menuitemhere','menuitemhere','menuitemhere','menuitemhere', not work, but placing

Re: [Tutor] Creating one file out of all the files in a directory

2010-11-11 Thread Evert Rol
I'm trying to create a script to do the following. I have a directory containing hundreds of text files. I need to create a single file with the contents of all the files in the directory. Within that file, though, I need to create marks that indicate the division between the contents of each

Re: [Tutor] How to copy file from a source, I do not know the source file name, Only path to the src directory I know

2010-11-09 Thread Evert Rol
Hi All I am trying our Python . My aim is to copy a file to a location and later removing the file.I had written a small script which works.It works only if I specify the source file name. I would like to make it work in a scenario in which I do not know the name of the source file(the

Re: [Tutor] How to copy file from a source, I do not know the source file name, Only path to the src directory I know

2010-11-09 Thread Evert Rol
)', why not use src again when assigning ffname? Cheers, Evert print ffname #shutil.copy(ffname,dst2) shutil.move(ffname,dst3) On Tue, Nov 9, 2010 at 4:38 PM, Evert Rol evert@gmail.com wrote: Hi All I am trying our Python . My aim is to copy a file

Re: [Tutor] scope, visibility?

2010-11-01 Thread Evert Rol
Here is my main class: class PenduGTK: Inside the class is a method with a bit of code: def masque(chaine,liInd=0): i = 0 lenght = len(chaine) The offending line is the one with len(chaine) Here are the error messages: penduGTK.py Traceback (most

Re: [Tutor] possible to run a python script from non-cgi?

2010-10-30 Thread Evert Rol
FYI: I am working in a linux environment with python 2.6.5 am an experienced web developer with 8 years in python, but :) I have never tried this trick before: I note that with the right .htaccess file, I can run a php file, from a non-cgi location. Example: On my machine, my wwwroot is at

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Evert Rol
What's the best way to model an unfair coin? This is one way to do it, I suppose: Create a list containing only 'H's and 'T's. If you want the coin to have the probability of a head to be 6/11, ['H', 'H', 'H', 'H', 'H', 'H', 'T', 'T', 'T', 'T', 'T'] is the list to use. Use

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Evert Rol
Btw, to be pedantic, 1/e is not an irrational number, just a real number. i/e would be. My bad: irrational != imaginary. And real = irrational. Things are definitely a bit rusty... ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Evert Rol
Actually, I used the unfair coin model as the simplest example of the kind of thing I want to do -- which is to model the USD-Yen exchange rate. I want the next quote to vary in a controlled random way, by assigning probabilities to various possible changes in the rate. See

Re: [Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Evert Rol
I have a numpy array ('data') that is the result of reading a netCDF file, and it typically looks like this: array([ 0., 0., 0., 0.], dtype=float32) I want to write this, after a date and time, to a CSV file, so the CSV file would have the entry:

Re: [Tutor] Writing elements of an array to a file using CSV module

2010-10-14 Thread Evert Rol
, I'm not sure why. I could write the list elements to variables before I write to the file, but it doesn't seem like a very elegant solution. Can anyone see why I have such a nested data structure? Or is the problem something completely different? Thanks Hanlie 2010/10/14, Evert Rol

Re: [Tutor] Networking

2010-10-14 Thread Evert Rol
Hi Chris, Bit hard to comment on the actual code, as it was in attachments, but the important bit is here: class Handler(SocketServer.BaseRequestHandler): #the handler '''A handler which calls %s in the handle method.'''%handle_func def handle(self): #the handle method

Re: [Tutor] Networking

2010-10-14 Thread Evert Rol
But what if I want it to serve one client, go to another and then go back. How does that work? You do some I/O multi-plexing or multi-processing/threading. You might want to do some reading on this. The very last example on http://docs.python.org/library/socketserver.html may help you.

Re: [Tutor] Multiple regex replacements, lists and for.

2010-10-12 Thread Evert Rol
I'm new to python and inexperienced in programming but I'm trying hard. I have a shell script that I'm converting over to python. Part of the script replaces some lines of text. I can do this in python, and get the output I want, but so far only using sed. Here's an example script: import

Re: [Tutor] urllib problem

2010-10-12 Thread Evert Rol
I have this program : import urllib import re f = urllib.urlopen(http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=6;) inhoud = f.read() f.close() nummer = re.search('[0-9]', inhoud) volgende = int(nummer.group()) teller = 1 while teller = 3 : url =

Re: [Tutor] OpenMP

2010-10-09 Thread Evert Rol
Hi, I have searched about how to use openMP using python and I couldn't fine any helpful info. anyone can help me on this. No openMP, but iPython could do what you want (parallel and some distributed computing): http://ipython.scipy.org/doc/stable/html/ Evert My idea is that to use

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-08 Thread Evert Rol
I realise that one cannot have a half integer :) I meant how would one round off to the first decimal nearest to either 0.5, or a whole number. Ugh...does anyone get what I'm trying to articulate? :) Multiply by 2, round(), divide by 2? On Fri, Oct 8, 2010 at 2:51 PM, Sithembewena

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-08 Thread Evert Rol
@Evert, I didn't figure out that your response was a solution, thought it was a question. Must be coffee time :P I tried it and, for instance, the rounded value (9) / 2 gave me 4.0 Couldn't get it until I noticed that @Joel divided the roudned figure by a decimal 2.0. That gave 4.5,

Re: [Tutor] pymssql and encoding

2010-10-07 Thread Evert Rol
print customerName ImmobiliŠre (whatever) customerName 'Immobili\x8are (whatever)' There should be a small E with a grave accent (è) instead of the capital S with a caron (Š) I'm getting. I've tried applying various encodings, but to no avail: snip / When executed from MS SQL

Re: [Tutor] wrap methods for logging purposes

2010-10-07 Thread Evert Rol
I used a the recipe (http://aspn.activestate.com/ASPN/Coo.../Recipe/198078) used to wrap methods for logging purposes. logging classes. But it does seem to work well with classes inherit form other classes - i get recursion errors! Here is an example of the classes .. class

Re: [Tutor] Non-ASCII

2010-10-07 Thread Evert Rol
I'm going through an online tutorial for Jython (www.jython.org). I can't find a place to ask a question on that site so I thought I'd try here. I believe the code is supposed to traverse a directory, identifying file types. The script is failing with the following message: File string,

Re: [Tutor] specifying precision with scientific notation

2010-10-05 Thread Evert Rol
I want to print scientific numbers with a specified number of decimal places. However, I want the number printed to be dynamically determined by the data. Example: a = 0.00762921383941 ea = 0.000830132912068 a / ea 9.190352205653852 By default, I will print the uncertainty (ea)

Re: [Tutor] Networking

2010-10-02 Thread Evert Rol
Dear Tutors, I have attached my 2 programs for networking. It uses socket and SocketServer, but it just simplifies it even more. The problem is it won't work. The Client raises the error, (with trace back) Traceback (most recent call last): File G:\My Dropbox\My Dropbox\Chris\Not

Re: [Tutor] inheritance problem

2010-09-30 Thread Evert Rol
Hi Roelof, Im following this page : http://openbookproject.net/thinkcs/python/english2e/ch17.html I just checked this, and it appears you've copied this example fine. snip / class Deck: def __init__(self): self.cards = [] for suit in range(4): for rank in

Re: [Tutor] Problems install Python

2010-09-29 Thread Evert Rol
I had just download PeGreSQL, unzip and installed it, but I have a problem such as: phuong...@ubuntu:~/PyGreSQL-4.0$ python setup.py build sh: pg_config: not found Traceback (most recent call last): File setup.py, line 94, in module pg_include_dir = pg_config('includedir') File

Re: [Tutor] function error

2010-09-29 Thread Evert Rol
Perhaps if you provide the full traceback from the error (assuming you're still getting this error); tracebacks generally show the offending code as well. It may be something that's simply overlooked but shows in the traceback. here it is: TypeError

Re: [Tutor] pyMVPA and OSError

2010-09-28 Thread Evert Rol
Hi, I am very much new to python, and thus I am likely to feel stupid about asking. But I need to get past this to continue with my work. I need pyMVPA module to run some analysis on fMRI data, but as a start I want to at first play around with the sample data provided on pyMVPA website.

Re: [Tutor] function error

2010-09-28 Thread Evert Rol
It seems that ur turtle.position doesn't return a list because of this when indexing is done on that u get this kind of error. --nitin it seemed to me that kind of error but then i found that it was a list, as expected: $ type(turtle.position()) $ type 'list' $

Re: [Tutor] dynamic arrays?

2010-09-27 Thread Evert Rol
One thing I have never much liked about Python is its need for specifically sized arrays and lack of a dynamic, array-like data structure. For example, the following fails with a list assignment index out of range error: a=[] i=0 for l in open(file.txt, r): a[i]=l i+=1 Hmm, what's

Re: [Tutor] function with multiple checks

2010-09-27 Thread Evert Rol
I've got a small function that I'm using to check whether a password is of a certain length and contains mixed case, numbers and punctuation. Originally I was using multiple if re.search for the patterns but it looked terrible so I've read up on list comprehensions and it's slightly

Re: [Tutor] unittest testing order...

2010-09-27 Thread Evert Rol
List, When using the unittest module, tests are run in alphanumeric order. What's the suggested way of specifying a test order? There isn't one. It shouldn't matter what order the tests run, no test should *rely* on another test. (Although of course, if one test fails, any tests

Re: [Tutor] input and raw input

2010-09-25 Thread Evert Rol
any one have an idea about how we can input many number in the one time and change it to list. for example: a=input(Enter the number of your class in the school:) # the number can be enter as: 12,13,14 or 12 13 14 with a space in between. now how I can put these numbers into list

Re: [Tutor] Tutor Digest, Vol 79, Issue 134

2010-09-25 Thread Evert Rol
I started seting up django. the only issue I am having is that all instructions seem to assume that I am on linux.Don't suppose there are any good instructions for those on a windows based system. Firstly: please don't reply to an unrelated message, but start a new one (with a proper

Re: [Tutor] input and raw input

2010-09-25 Thread Evert Rol
any one have an idea about how we can input many number in the one time and change it to list. for example: a=input(Enter the number of your class in the school:) # the number can be enter as: 12,13,14 or 12 13 14 with a space in between. now how I can put these numbers into

Re: [Tutor] trouble with a small Tkinter example

2010-09-21 Thread Evert Rol
I'm having trouble with this small example program: http://en.literateprograms.org/Bresenham%27s_line_algorithm_%28Python%29 When I run it, I only get a blank grey window. I'm running Python 2.6 under Windows XP. If there's a problem with the code, I can't see it... it seems like it

Re: [Tutor] Bus Error with matplotlib

2010-09-17 Thread Evert Rol
Hi, I have been trying to install matplotlib for python on my mac which is running snow leopard. The installation appeared to go well until I tried the following python import matplotlib import matplotlib.pyplot Bus error It is very annoying, I have posted the error message below

Re: [Tutor] quick speed question

2010-09-16 Thread Evert Rol
Hello Tutors, I was just wondering if you have a dictionary key is it faster to do: if dict['key'] == 'foo': ... or is this faster: if 'foo' in dict['key']: ... Or is there any difference and I'm chasing ghosts? The latter: they are not the same: d = {'key': 'food'}

Re: [Tutor] Function behavior

2010-09-16 Thread Evert Rol
I am unclear on the behavior of using a function. Below is a short code I wrote to print an amount out after inputting the number of match. # TEST Function.py def change(amount): if match == 1: amount = 0 if match == 2: amount = 0 if match == 3: amount

Re: [Tutor] robots question

2010-09-16 Thread Evert Rol
As a exercise from this book ( Thinking like a computer scientist ) I have to make this programm on this page(http://openbookproject.net/thinkcs/python/english2e/ch12.html) Exercise 11 # # robots.py # from gasp import * Argh! Is that really in the book? Bad book, bad. You can just

Re: [Tutor] what happened to the cards module

2010-09-15 Thread Evert Rol
I downloaded Python 2.6.6 for windows but I can't access the Cards module for playing card games. Did it get renamed? If so, how can I find it? I don't think there's a Cards module in the standard library. At least, I've never seen it, nor can I find any mention about it on the python

Re: [Tutor] selecting elements from dictionary

2010-09-15 Thread Evert Rol
using: for key, value in xdic.items(): if 1 in value and 2 in value or 3 in value: print key also print keys that have values such as [1,2,3]. In cases where there is [1,2,3] and [1,2] also reported. How can I extract those keys that have values only [1,2] and [1,3]

Re: [Tutor] what happened to the cards module

2010-09-15 Thread Evert Rol
what you mean by a card playing framework: do you mean (library) code, which language, what card game? Evert Thanks. John Soares jsoa...@safe-mail.net Original Message From: Evert Rol evert@gmail.com To: jsoa...@safe-mail.net Cc: tutor@python.org Subject: Re

Re: [Tutor] re.findall parentheses problem

2010-09-14 Thread Evert Rol
I have a regex that matches dates in various formats. I've tested the regex in a reliable testbed, and it seems to match what I want (dates in formats like 1 Jan 2010 and January 1, 2010 and also January 2008). It's just that using re.findall with it is giving me weird output. I'm using

Re: [Tutor] What's the best way to ask forgiveness here?

2010-09-13 Thread Evert Rol
I've been coding Python long enough that 'asking forgiveness instead of permission' is my first instinct, but the resulting code is sometimes clumsy, and I wonder if someone can suggest something I'm missing, or at least validate what's going on here in some way. What I'm trying to do

Re: [Tutor] tree problem

2010-09-12 Thread Evert Rol
Write a program named litter.py that creates an empty file named trash.txt in each subdirectory of a directory tree given the root of the tree as an argument (or the current directory as a default). So I change the example to this : def traverse(path, s='.\n', f=0, d=0): path2file =

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-11 Thread Evert Rol
My script to call a web service authenticates. Sorry, but where is the (full) script? I missed an attachment or (preferably) a link. Hello, Sorry, the verb of the sentence is authenticates, as in, My script ... authenticates. Sorry, misread that. Although code does help :-). I

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-11 Thread Evert Rol
snip / I'm not sure what you're exactly doing here, or what you're getting, but I did get curious and dug around urllib2.py. Apparently, there is a hardcoded 5 retries before the authentication really fails. So any stack trace would be the normal stack trace times 5. Not the 30 you

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Evert Rol
I can't work out how to suppress stacktrace printing when exceptions are thrown. I want the thrown exception to pass a message on the console, just like Java does when I catch an exception and print e.getMessage(). I tried some of the examples of controlling traceback through the

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-10 Thread Evert Rol
My script to call a web service authenticates. Sorry, but where is the (full) script? I missed an attachment or (preferably) a link. I would like to be able to trap an exception if the authentication fails. The script loops over a list of dates and I don't want it to retry for every

Re: [Tutor] smtp connection problem --- socket error 10061

2010-09-10 Thread Evert Rol
I could not connect with gmail smtp server in Vista 32( worked ok in XP 32). Both vista and xp have same anti-virus software. smtplib.SMTP(smtp.gmail.com,587) Traceback (most recent call last): File pyshell#1, line 1, in module smtplib.SMTP(smtp.gmail.com,587) File C:\Program

Re: [Tutor] slicing a string

2010-09-09 Thread Evert Rol
But remember that you can make it simpler if you simply don't specify the start and end points: 'hello'[::-1] 'olleh' While I know that idiom works, I haven't really found an explanation as to *why* it works that way. For a string S: * Using range, you need range(len(S),-1,-1) to

Re: [Tutor] Python command calls the wrong version!

2010-09-08 Thread Evert Rol
Dear Python Tutors, I am new to Python, having perviously used IDL for all my scripts. I was hoping to use Python and so I have just downloaded and installed version 2.6 using the mac installer. That all went fine. I then opened up X11, all fine. Then I typed in python and got

Re: [Tutor] sort problem

2010-09-08 Thread Evert Rol
I have this : def sort_sequence(seq): sort_sequence([3, 4, 6, 7, 8, 2]) [2, 3, 4, 6, 7, 8] sort_sequence((3, 4, 6, 7, 8, 2)) (2, 3, 4, 6, 7, 8) sort_sequence(nothappy) 'ahnoppty' if type(seq) == type([]): seq.sort()

Re: [Tutor] for loop results into list

2010-09-05 Thread Evert Rol
Hello all, I'm having a little problem figuring out how to accomplish this simple task. I'd like to take a list of 6 numbers and add every permutation of those numbers in groups of four. For example for 1, 2, 3, 4, 5, 6 add 1 + 1 + 1 +1 then 1 + 1 + 1 +2 etc. until reaching 6 + 6 + 6 +

Re: [Tutor] for loop results into list

2010-09-05 Thread Evert Rol
I'm having a little problem figuring out how to accomplish this simple task. I'd like to take a list of 6 numbers and add every permutation of those numbers in groups of four. For example for 1, 2, 3, 4, 5, 6 add 1 + 1 + 1 +1 then 1 + 1 + 1 +2 etc. until reaching 6 + 6 + 6 + 6. Using a for

Re: [Tutor] for loop results into list

2010-09-05 Thread Evert Rol
I'm having a little problem figuring out how to accomplish this simple task. I'd like to take a list of 6 numbers and add every permutation of those numbers in groups of four. For example for 1, 2, 3, 4, 5, 6 add 1 + 1 + 1 +1 then 1 + 1 + 1 +2 etc. until reaching 6 + 6 + 6 + 6. Using a

Re: [Tutor] for loop results into list

2010-09-05 Thread Evert Rol
On 5 Sep 2010, at 22:31 , Micheal Beatty wrote: On 09/05/2010 03:16 PM, Evert Rol wrote: I'm having a little problem figuring out how to accomplish this simple task. I'd like to take a list of 6 numbers and add every permutation of those numbers in groups of four. For example for 1, 2, 3

Re: [Tutor] nested functions

2010-09-04 Thread Evert Rol
hello, i have to plug two functions b() and c() inside another one a(); i wonder if the code defining b and c must be in the same text file of a or it is possible to import b and c somehow, hence giving the code a neater appearance Definitely! Read through

  1   2   >