Re: [Tutor] different behaviour in Idle shell vs Mac terminal

2012-01-09 Thread Peter Otten
Alan Gauld wrote: > On 08/01/12 23:34, Adam Gold wrote: >> >> I have short piece of code I'm using to print a string to > > the terminal one letter at a time. It works fine when >> I invoke the script from within Idle; each letter appears >> afterthe preceding one according to the designated tim

[Tutor] re module help

2012-01-09 Thread Ganesh Kumar
Hi Gurus, I have created regular expression with os modules, I have created file sdptool to match the regular expression pattern, will print the result. I want without creating file how to get required output, I tried but i didn't get output correctly, over stream. #! /usr/bin/python import os,re

Re: [Tutor] Moving from snippits to large projects?

2012-01-09 Thread Steven D'Aprano
Leam Hall wrote: I'm taking the O'Reilly Python 2 course on-line, and enjoying it. Well, when Eclipse works, anyway. I'm still getting the hang of that. While my coding over the years has been small snippits in shell, PHP, and a little C, python, and perl, I've never made the transition from

Re: [Tutor] Moving from snippits to large projects?

2012-01-09 Thread Leam Hall
Leam Hall wrote: >> Steve and Hugo Responded > To which Leam Replies: Thanks! The O'Reilly class has twelve lessons, the first two are on unit testing. The rest of them will enforce tests be written for their projects. :) I'll look at Git and Sourceforge in the next couple days. In theory

Re: [Tutor] different behaviour in Idle shell vs Mac terminal

2012-01-09 Thread Adam Gold
> Date: Sun, 8 Jan 2012 23:34:15 + > From: Adam Gold > To: > Subject: [Tutor] different behaviour in Idle shell vs Mac terminal > Message-ID: > Content-Type: text/plain; charset="iso-8859-1" > > > I have short piece of code I'm using to print a string to the terminal one > letter at a time

[Tutor] exception about "ctrl+c"

2012-01-09 Thread daedae11
I want to catch the "ctrl+c" exception. My program is as following. But when I run my script and press "ctrl"+"c", the program output nothing. I don't know where did I go wrong. Please help me. Thank you! def safe_input(prompting): try: return raw_input(prompting); except Keyboa

[Tutor] Sorting Nested Lists

2012-01-09 Thread Sarma Tangirala
Hi list, I was banging my head about a pythonic way of doing the following, Given a nested list, how do I sort the uppermost list based on one key and when a special condition occurs a sort on another key should be performed? For example, [[1,2], [2, 2], [3, 2], [4, 0]] would be sorted, in my ex

Re: [Tutor] re module help

2012-01-09 Thread bodsda
You could use read directly on the popen call to negate having to write to a file output = os.popen(“sdptool -i hci0 search OPUSH“).read() Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Ganesh Kumar Sender: tutor-bounces+bodsda=googlemail@python.org Date:

Re: [Tutor] exception about "ctrl+c"

2012-01-09 Thread Joel Goldstick
On Mon, Jan 9, 2012 at 7:24 AM, daedae11 wrote: > I want to catch the "ctrl+c" exception. My program is as following. But when > I run my script and press "ctrl"+"c", the  program output nothing. I don't > know where did I go wrong. Please help me. Thank you! > > def safe_input(prompting): > t

Re: [Tutor] exception about "ctrl+c"

2012-01-09 Thread Christian Witts
On 2012/01/09 02:24 PM, daedae11 wrote: I want to catch the "ctrl+c" exception. My program is as following. But when I run my script and press "ctrl"+"c", the program output nothing. I don't know where did I go wrong. Please help me. Thank you! def safe_input(prompting): try: retur

Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Steven D'Aprano
Sarma Tangirala wrote: Hi list, I was banging my head about a pythonic way of doing the following, Given a nested list, how do I sort the uppermost list based on one key and when a special condition occurs a sort on another key should be performed? For example, [[1,2], [2, 2], [3, 2], [4, 0]] w

Re: [Tutor] different behaviour in Idle shell vs Mac terminal

2012-01-09 Thread Steven D'Aprano
Adam Gold wrote: Thanks Steven that worked. In terms of why I'm using this: I shouldn't overstate what I'm doing when I say financial maths. One of the elements is a mortgage calculator for my mother who's, shall we say, not a "power user". After taking the basic inputs, it prints out a few s

Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Peter Otten
Sarma Tangirala wrote: > I was banging my head about a pythonic way of doing the following, > > Given a nested list, how do I sort the uppermost list based on one key and > when a special condition occurs a sort on another key should be performed? > > For example, [[1,2], [2, 2], [3, 2], [4, 0]]

Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Sarma Tangirala
On 9 January 2012 18:26, Steven D'Aprano wrote: > Sarma Tangirala wrote: > >> Hi list, >> >> I was banging my head about a pythonic way of doing the following, >> >> Given a nested list, how do I sort the uppermost list based on one key and >> when a special condition occurs a sort on another key

Re: [Tutor] Sorting Nested Lists

2012-01-09 Thread Walter Prins
Hi, On 9 January 2012 12:31, Sarma Tangirala wrote: > Given a nested list, how do I sort the uppermost list based on one key and > when a special condition occurs a sort on another key should be performed? > > For example, [[1,2], [2, 2], [3, 2], [4, 0]] would be sorted, in my example > as, [[4,

Re: [Tutor] making a custom file parser?

2012-01-09 Thread Devin Jeanpierre
> IIRC, Python's only non-regular feature is backreferences though Probably. I'm not too familiar with a couple other features or how their semantics work, in particular the (?(id)yes|no) syntax. > I'm not calling bs or anything, I don't know anything about .net > regexes and I'll readily believe

[Tutor] Moving from snippits to large projects?

2012-01-09 Thread Mike G
How does one go from small to medium, to large, as a coder? You might look into contributing to an existing project. There is a new project, MediaLocker, a Python / wxPython app recently underway, started from a blog post. I believe they are looking for input, including contributing - have a lo

Re: [Tutor] Moving from snippits to large projects?

2012-01-09 Thread leam hall
On 1/9/12, Mike G wrote: > How does one go from small to medium, to large, as a coder? > > You might look into contributing to an existing project. > > There is a new project, MediaLocker, a Python / wxPython app recently > underway, started from a blog post. I > believe they are looking for inp

[Tutor] USB volume unique volume info

2012-01-09 Thread Jeff Peery
Hello, I am writing a python script to install a program onto a customer computer from a USB drive. To prevent piracy, I want to know if the user has copied my install program to another USB drive. Do USB drives have some unique volume info or another feature that I might query to detect if the

Re: [Tutor] Game lag

2012-01-09 Thread Japhy Bartlett
If you made an effort to strip out parts of your code, it would probably show you where the bottlenecks are. You say that the large map is not the problem, but do you really know? On Jan 5, 2012, at 10:08 AM, Nate Lastname wrote: Thanks for the profilers - never had hear of 'em. Also, no, I

[Tutor] Removing certain sequences from a string list elements

2012-01-09 Thread Varsha Purohit
Hello, I have a simple python program where I am comparing two log files and I am storing the differences in a list. I am programming in python after a long time so may be I might have not written something very efficient. Please let me know what alternate solution I can apply for my program. I a

[Tutor] x%2

2012-01-09 Thread emin
http://www.youtube.com/watch?src_vid=QaYAOR4Jq2E&feature=iv&annotation_id=annotation_149056&v=M3g1GEkmyrw in this tutorial what does mean x%2 ? i think: i * 2% = always even number but why not 4,6 or 8? but i * 4(6,8,10,12...)% = always even number too for example: 100 * 2(4,6,8,10,12...)% = 2(4,

Re: [Tutor] Subclassing Exceptions

2012-01-09 Thread Chris Fuller
On Friday 06 January 2012, Steven D'Aprano wrote: > Chris Fuller wrote: > class Foo(SyntaxError): > > ... def __init__(self, a,b,c): > > ... self.args = (a,b,c) > > ... > > > raise Foo(1,2,3) > > > > Traceback (most recent call last): > > File "", line 1, in > > > > __main__.Foo:

Re: [Tutor] x%2

2012-01-09 Thread Noah Hall
2012/1/8 emin : > http://www.youtube.com/watch?src_vid=QaYAOR4Jq2E&feature=iv&annotation_id=annotation_149056&v=M3g1GEkmyrw > in this tutorial what does mean x%2 ? > i think: i * 2% = always even number > but why not 4,6 or 8? but  i * 4(6,8,10,12...)% = always even number too > for example: 100 *

Re: [Tutor] x%2

2012-01-09 Thread Steven D'Aprano
emin wrote: http://www.youtube.com/watch?src_vid=QaYAOR4Jq2E&feature=iv&annotation_id=annotation_149056&v=M3g1GEkmyrw in this tutorial what does mean x%2 ? x % 2 gives the remainder when you divide x by 2. i think: i * 2% = always even number What does that mean? i*2% does not work in Pytho

Re: [Tutor] USB volume unique volume info

2012-01-09 Thread Steven D'Aprano
Jeff Peery wrote: Hello, I am writing a python script to install a program onto a customer computer from a USB drive. To prevent piracy, I want to know if the user has copied my install program to another USB drive. Do USB drives have some unique volume info or another feature that I might query