Re: [Tutor] Extremely simple question

2012-01-10 Thread Noah Hall
On Wed, Jan 11, 2012 at 7:14 AM, Chris Johnson wrote: > Hi there, > > I am *new* (I cannot put enough emphasis on that!) to Python programming, > and to programming in general. I am trying to write out a statement that > will protect a file on my computer from being run unless I enter the right >

[Tutor] Extremely simple question

2012-01-10 Thread Chris Johnson
Hi there, I am *new* (I cannot put enough emphasis on that!) to Python programming, and to programming in general. I am trying to write out a statement that will protect a file on my computer from being run unless I enter the right specifications; your_weight = int(raw_input("Please enter your we

Re: [Tutor] Defining a File path

2012-01-10 Thread Dave Angel
On 01/10/2012 04:53 PM, Hugo Arts wrote: On Tue, Jan 10, 2012 at 8:31 PM, Adrian wrote: Hi guys, I know that if i dont include any path information, python looks in the current directory for the file. My question is how do i specify a file path to open a file saved on my desktop for example.

Re: [Tutor] x%2

2012-01-10 Thread Steven D'Aprano
bob gailer wrote: On 1/10/2012 1:47 PM, Noah Hall wrote: a % b is the remainder operator. It returns what's "left" after dividing a by b. Not to beat a dead horse- but % is the modulo operator. That depends on how you define "remainder" and "modulo". There is no definition agreed on by all

Re: [Tutor] Defining a File path

2012-01-10 Thread Hugo Arts
On Tue, Jan 10, 2012 at 8:31 PM, Adrian wrote: > Hi guys, > I know that if i dont include any path information, python looks in the > current directory for the file. My question is how do i specify a file path > to open a file saved on my desktop for example. > > Thanks all > > Adrian > Just wr

Re: [Tutor] Defining a File path

2012-01-10 Thread Emile van Sebille
On 1/10/2012 11:31 AM Adrian said... Hi guys, I know that if i dont include any path information, python looks in the current directory for the file. My question is how do i > specify a file path to open a file saved on my desktop for example. There's lots of ways that depend on your platform a

Re: [Tutor] generating unique set of dicts from a list of dicts

2012-01-10 Thread Peter Otten
[NN] >> uniques_map = {} >> for d in list_of_dicts: >> uniques[dict_hash(d)] = d >> unique_dicts = uniques_map.values() [Dave Angel] > unique_dicts = [] > for d in list_of_dicts: > if d not in unique_dicts: > unique_dicts.append(d) > > Do it, then decide if performance is

[Tutor] Defining a File path

2012-01-10 Thread Adrian
Hi guys, I know that if i dont include any path information, python looks in the current directory for the file. My question is how do i specify a file path to open a file saved on my desktop for example. Thanks all Adrian Sent from my iPad ___ Tuto

Re: [Tutor] x%2

2012-01-10 Thread bob gailer
On 1/10/2012 1:47 PM, Noah Hall wrote: a % b is the remainder operator. It returns what's "left" after dividing a by b. Not to beat a dead horse- but % is the modulo operator. It returns the residue class of the 2 operands. When a is positive this is the same as remainder, but not so for nega

Re: [Tutor] generating unique set of dicts from a list of dicts

2012-01-10 Thread Dave Angel
On 01/10/2012 03:24 PM, bruce wrote: Since dict_hash returns a string, which is immutable, you can now use a dictionary to find the unique elements: uniques_map = {} for d in list_of_dicts: uniques[dict_hash(d)] = d unique_dicts = uniques_map.values() *** not sure what the "uniqes" is, o

[Tutor] generating unique set of dicts from a list of dicts

2012-01-10 Thread bruce
trying to figure out how to generate a unique set of dicts from a json/list of dicts. initial list ::: [{"pStart1a": {"termVal":"1122","termMenu":"CLASS_SRCH_WRK2_STRM","instVal":"OSUSI", "instMenu":"CLASS_SRCH_WRK2_INSTITUTION","goBtn":"CLASS_SRCH_WRK2_SSR_PB_SRCH", "pagechk":"CLASS_SRCH_WRK2_SS

Re: [Tutor] x%2

2012-01-10 Thread Joel Goldstick
On Tue, Jan 10, 2012 at 1:47 PM, Noah Hall wrote: > On Tue, Jan 10, 2012 at 6:24 PM, emin wrote: >> answers = ["yes","no"] >> reaction = ["OK.I GOT IT.But why symbol of percent % not symbol of division >> / ?","PLEASE EXPLAIN MORE"] >> >> print "1st SORRY FOR BAD ENGLISH & DISTURBING:((i am begin

Re: [Tutor] x%2

2012-01-10 Thread Noah Hall
On Tue, Jan 10, 2012 at 6:24 PM, emin wrote: > answers = ["yes","no"] > reaction = ["OK.I GOT IT.But why symbol of percent % not symbol of division > / ?","PLEASE EXPLAIN MORE"] > > print "1st SORRY FOR BAD ENGLISH & DISTURBING:((i am beginner)" > print "So you want to say it doesnt mean 2 percent

Re: [Tutor] Removing certain sequences from a string list elements

2012-01-10 Thread Hugo Arts
On Sat, Jan 7, 2012 at 2:08 AM, Varsha Purohit wrote: > 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

Re: [Tutor] Help with lag

2012-01-10 Thread Hugo Arts
On Wed, Jan 4, 2012 at 9:45 PM, Nate Lastname wrote: > Hello! > > The attached file 'cameramovement.py' is very laggy. Could someone help me > out by telling me what part of this is slowing it down so much?  I've > checked the whole file through, and I can't see why it's so slow. You'll > have to

Re: [Tutor] a question about MySQLdb in python

2012-01-10 Thread Peter Otten
贾晓磊 wrote: > hi, all: > > python's version: 2.6. > MySQLdb version: 1.2.3. > > I once encounter with a question like this: > File > "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3-py2.6-linux- x86_64.egg/MySQLdb/connections.py", > > line 36, in defaulterrorhandler > raise erro

Re: [Tutor] Testing dymamically created methods

2012-01-10 Thread Thomas Maier
On Tue, Jan 10, 2012 at 3:31 PM, Walter Prins wrote: > Hi, > > On 10 January 2012 12:15, Thomas Maier wrote: >> This code works without py.test or nosetests. For example if I use print >> instead of 'assert'. >> Both py.test and nosetests failed to execute this correctly. >> Or maybe they do exec

Re: [Tutor] Python problem

2012-01-10 Thread Dave Angel
On 01/10/2012 05:04 AM, Bojan Antonijevic wrote: Hello, I send you a mail at 29.12.2011. about problem with my IDLE (Python GUI) and I didnt recive any ansfer; Instead, I am receiving correspondence between other members of forum; Honestly, I don't want to receive all this conversation's. Thank

Re: [Tutor] Primitive Chess Clock Program Question

2012-01-10 Thread wolfrage8...@gmail.com
>> I assume you want to display something like this: >> >> Enter your next move: 0:30 SNIP > Assuming Steven has guessed right then I think you need to use one of the > non blocking input mechanisms like kbhit() or getch() or somesuch. > > Those methods are notioriously unreliable and OS specific.

Re: [Tutor] Testing dymamically created methods

2012-01-10 Thread Walter Prins
Hi, On 10 January 2012 12:15, Thomas Maier wrote: > This code works without py.test or nosetests. For example if I use print > instead of 'assert'. > Both py.test and nosetests failed to execute this correctly. > Or maybe they do execute it correctly, I just don't understand it..:) > They both re

[Tutor] Testing dymamically created methods

2012-01-10 Thread Thomas Maier
Hi all, I would like to use some existing tool like py.test or nose to run my tests, but I failed to do so. The problem is as follow. I have tests: ### test_methods.py ### def test_one(): assert 1 == 1 def test_two(): assert 1 == 1 # I have abstraction layer that keeps info

[Tutor] a question about MySQLdb in python

2012-01-10 Thread 贾晓磊
hi, all: python's version: 2.6. MySQLdb version: 1.2.3. I once encounter with a question like this: File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue OperationalError

Re: [Tutor] Python problem

2012-01-10 Thread wolfrage8...@gmail.com
To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor On Tue, Jan 10, 2012 at 11:04 AM, Bojan Antonijevic wrote: > Hello, > > I send you a mail at 29.12.2011. about problem with my IDLE (Python GUI) and > I didnt recive any ansfer; Instead, I am receiving  c

[Tutor] Python problem

2012-01-10 Thread Bojan Antonijevic
Hello, I send you a mail at 29.12.2011. about problem with my IDLE (Python GUI) and I didnt recive any ansfer; Instead, I am receiving correspondence between other members of forum; Honestly, I don't want to receive all this conversation's. Thank you. _

[Tutor] Issue with Python 2.7.2 - beginner needing help

2012-01-10 Thread Mike G
Hi Tonyelle Your code doesn't work as expected due to your 2nd edition book uses Python 3x, see page xi, 'Changes in this edition'. This would work for your version of Python... room = 503 print 'I am staying in room number', room If you're new, Python 2.7.2 is (IMO) a better choice, many more

[Tutor] Issue with Python 2.7.2 - beginner needing help

2012-01-10 Thread tonyelle
Hello! I am just beginning to learn Python from the book Starting Out With Python - 2nd Edition.  I have read and completed exercises up to page 45. I am currently learning how to display multiple items with one call to the print function.        ex: 1 # This program demonstrates a variable.