> button = tkinter.Button(frame, text='Up', command=click_up)
> button = tkinter.Button(frame, text='Down', command=click_down)
> when I first looked at it I thought it would not work, thinking that the
> second reference to button = would over write the first one.
It DOES overwrite it, in this
while loop to compute
the sum of the cubes of the first n counting numbers
do you have any suggestions as to how I need to look at a problem
and to “identify” what exactly it is asking for,
Can you do it on paper? If I gave you 5 as a starting point, could
you write down on your paper 1
How do you sort distances to prepare for nearest neighbor when the
results returned look like this
Have you read up on the key parameter for Python's sort() function?
You can use that, along with split() to do this.
Alan
___
Tutor maillist -
what is a hash value?
Some clever person back in the 1950s realized that computers were
better at numbers than names. So they came up with some gimmicks to
convert names to numbers. It was probably something fancier than a=1,
b=2, etc. Now let's add up all the letters of the person's name to
I need an explanation so simple as using the expression 'print ()', in this
case 'yield'.
Python 2.6 here!
Ever write any C programs with static variables? Generators can be
explained in those terms if you have experience with them.
Alan
___
Tutor
can you
guys help explain. super thanks
A class is like a blueprint.
An instance of that class is like a house built from that blueprint.
Think about it. An infinite number of houses could be constructed
using those blueprints. But the architect only had to draw them once.
__init__() is like
take value 15 from list
Hint: use square brackets to choose a particular item from a list.
test = ['first', 'second', 'third']
test[0] would refer to 'first' for example.
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
I don't understand how precisely the web page would communicate with
the python program.
In the simplest case, the webserver software executes your script.
Whatever you print() _is_ the webpage. The webserver sends whatever
you print() to the user's browser.
1. Write a program module with at least two functions.
Hint: def is the Python keyword used to define a function. You can
read all about def in the docs on python.org.
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription
I am stuck there my loop is not working
...
I know I have to use if and
else statement but I'm not able to do so :(
Hint:
Set the assignment aside and write a couple smaller practice programs.
Like a very simple one that just asks for a word and prints that word.
Or a simple one that checks
Also explain the logic in plain words. Else, we can only guess.
Were the comments not enough? You keep taking turns until you get home
or die. Each turn has 4 phases.
while playing:
#phase 1 - fly every turn, you might die
#phase 2 - stuff shoots at you every turn, you might die
You keep taking turns until you get home or die. Each turn has 4
phases.
while playing:
#phase 1 - fly every turn, you might die
#phase 2 - stuff shoots at you every turn, you might die
#phase 3 - may or may not get an event card, with certain cards you might
die
#phase 4
Can somebody explain the reason of the bug.
I think you have an indentation goof on line 24 in the wrong
version (the else clause).
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
When running it, either returned values are wrong or the script
seems to enter in an infinite loop showing no return values at all.
One other tip: for loops are usually more practical when you know
exactly how many times you want to loop (100 coin flips). while
loops are usually more practical
I started on an implementation of a solitaire board game simulating a
B52 bombing run ( http://victorypointgames.com/details.php?prodId=119
). It seems like there ought to be a better way to structure this
program flow, but it's escaping me at the moment.
(pseudo code)
-
playing=True
while
There is a name for this: it is called a RANK TABLE.
Handy. That should help.
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
What does the OP actually want?
I started writing another fake defrag program to entertain myself in a
little downtime at work. The FAT-styled drive is just a Python list
of integers where each element points to the the next block of the
fictitious file, with the last element of any given file
Given two lists, before and after a sort:
0 1 2 3 4
-
before: 3 1 2 5 4
after: 1 2 3 4 5
Is there a well-known algorithm that can give me the
list-of-transforms that got me from before to after?
e.g.:
first-to-zeroth,
zeroth-to-second,
second-to-first
my goal is to make it write all the picture url values separated by
a ';' in just one field and to input the data correctly.
I haven't used postgresql much. Could it be you're just missing
path_picture as part of your data value? i.e.
UPDATE hotel SET path_picture = + hotel_url
UPDATE hotel
2. Why use a class in the first place? What is the purpose of
constructing a class instead of just writing a program with a bunch
of functions?
Sometimes, you DO just write programs with functions.
A class can be useful if you have a bunch of a thing. Like a monster.
Each monster can know
People hunting for Python projects to work on might get a kick out of
this puzzle:
http://www.wired.com/geekdad/2012/08/geekdad-puzzle-of-the-week-extreme-products/
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
Hello learner404,
Tuesday, July 31, 2012, 8:02:26 AM, you wrote:
Hello List,
I'm very happy with PyDev plugin for Eclipse as a Python IDE (I'm
on Eclipse 3.7, WinXP with latest Pydev).
File C:\Documents and
Settings\myaccount\workspace\RemoteSystemsTempFiles\LOCALHOST\c\Documents
and
So starting from scratch, how-to?
print hello world
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
I really don't get it. What is lambda? I keep seeing it and I
couldn't understand anything online about it.
It took me a while to get it too. It's for those rare times when you
want a throwaway function. Like you want to do something kind of
functioney without going to the trouble of
I did get a semi-working version, but it was crazy inefficient because
it regenerated the swap list after every move, and it bombed out with
a IndexError about half the time. I found that moving a single block
at a time lacked the aesthetic appeal I was hoping for, so I bagged it
for now.
I
I really can't figure out what project to take on but would be
prepared to take on anything and get my hand dirtier than before.
Popular ones are:
http://www.pythonchallenge.com/
http://projecteuler.net/
I also like:
http://www.atariarchives.org/basicgames/
Since all the moves are swaps, it'll be guaranteed to be in a sequence
that converges on the correct final order. Will it be the minimum
number of moves? Definitely not. But that wasn't a requirement, and if
it were, you wouldn't start by building that list of tuples.
I did get a
I'm revisiting the fake defrag program I posted about a few months
ago. The concept is basically a screensaver or light show where you
can enjoy watching entropy being reversed as colored blocks order
themselves visually.
I set it aside for a while because it was too slow, but I finally came
up
achieve the cosmetic randomness, until I realized the real problem is
magically determining the correct sequence in which to perform the
moves without ruining a future move inadverently.
If I move 0-to-1 first, I've now ruined the future 1-to-22 which ought
to have taken place in advance.
There are 2 things I don't understand.
1. the %s
2. the (wins,loses)
Did you ever play Mad Libs when you were a kid?
http://en.wikipedia.org/wiki/Madlibs
Same concept. The %s in Python is just like the blank spaces in a Mad
Lib game. The items in parentheses after a percent sign are the
It was only tested on a Windows Box, but I see no reason why it would not
work on Unix family. https://github.com/janus/Text-Twist
I need you comments.
I think you forgot to upload some needed images along with the python
code:
['abase', 'abased', 'abed', 'ads', 'baa', 'baas', 'bad', 'bade',
/usr/local/bin/AddressBook: line 6: syntax error near unexpected token `('
/usr/local/bin/AddressBook: line 6: `name = raw_input(Type the Name - leave
blank to finish)'
Were you accidentally trying a python 3 tutorial when your machine
only has python 2 installed (or vice versa)?
Alan
Suggestions for a programmers font gratefully received.
DejaVu Sans Mono
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
a) How's the best way to make it so I can have a user type in a list of
symptoms and then have the computer tell the user the possible diseases that
share those symptoms?
Good question. The first decent idea that came to mind was searching
through a cartesian join of all diseases symptoms:
* Or you just get used to the fact that some numbers are not exact in
floating point.
This got me thinking. How many decimal places do you need to
accurately, say, aim a laser somewhere in a 180 degree arc accurately
enough to hit a dime on the surface of the moon?
Alan
Python's floats have 52 *binary* places of precision, or approximately
15 *decimal* places. So even though we may not be able to physically
build a machine capable of aiming a laser to a precision of
0.001 degrees, at least we can be comforted by the knowledge
that a C double or a
Hello, I am just learning Python 3.0 and I am working on this
problem. I need to know what the output would be.
What happened when you ran it on your computer? You _did_ try that,
right?
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or
I was reading Pygame API for a month and made out a very basic ,small game
named as Hungry Snake as practice.
Not bad!
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
R. Alan Monroe amon...@columbus.rr.com wrote
Neither of these seem like they'd scale very well (say, up to the
resolution of your screen, with one block per pixel). The end goal
is
just a basic do-nothing light show that simulates
fragmentation/defragmentation as eye candy
I'm trying to mentally plan out the most bare bones drive simulation
possible, but I have this nagging feeling that I'm missing something.
I was just going to start with, say, 16 or 64 blocks, then randomly
add and delete ficticious files (which won't have any actual
content - I'm just trying to
I'll freely admit that I do not come from an OOP programming
background, so designing classes is not my first impulse when
writing code. Am I missing something?
In my book, no, you're not missing something. I refer to it as
drinking the OO kool-aid. It's not compulsory. I just use it when it
I just have no idea of what kind of programs to build,
Some of the stock answers for this question are:
http://projecteuler.net/
http://www.pythonchallenge.com/
I usually suggest porting one of the old games in:
http://www.atariarchives.org/basicgames/
Alan
I've always disliked using if not n % 2 to test for even/odd ints
because of its convoluted logic. But I ran some speed tests and found
it was the way to go over if n % 2 == 0.
Did you try bitwise-and with 1?
Alan
___
Tutor maillist -
I've always disliked using if not n % 2 to test for even/odd ints
because of its convoluted logic. But I ran some speed tests and found
it was the way to go over if n % 2 == 0.
Did you try bitwise-and with 1?
What's that?
2 1
0
3 1
1
So what's the connection with the tests
Any suggestions for a newbie to program while learning python? I am new to
programming and python.
Port one of the old games from
http://www.atariarchives.org/basicgames/ or similar antique books.
Alan
___
Tutor maillist - Tutor@python.org
To
Is it better to learn Perl or Python since i can manage only writing
simple bash shell scripts.
Please suggest/guide.
Do you already have both installed (seeing bash, I bet you're on some
version of Linux, so it's likely you do). You could try writing a very
simple guess my number game or
I'm needing to transfer the following shell construct to Python,
plus save
the output of execution:
FTP_SITE='ftp.somesite.com'
ftp -a $FTP_SITE EOF
binary
prompt off
cd /some_dir
dir
bye
EOF
Are you sure? It looks like you would be better writing a python
program
using the ftp
the win32 lib, but is there any way to simply examine a loaded dll
to see all of the functions and attributes it exposes for use? I would
http://www.dependencywalker.com/
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription
if coinToss(1,2) == 1:
heads += 1
tossNo += 1
else:
tails += 1
tossNo += 1
Looking good. You can hoist tossNo += 1 out of each branch of your if
statement too, if you like, to make it even more streamlined (In
other words, execute it once, right after
Any modern multi-tasking operating system will ensure than a while loop
doesn't kill your computer's responsiveness. A decent operating system
will still remain responsive even at 100% CPU usage. Even Windows does
that!
Opinions vary. If you try this on a laptop, the end user will be quite
That's the goal of the latest version of my script at
http://tutoree7.pastebin.com/5XYaaNfp. The best I've been able to do
so far is a file with 800 million digits.
I don't think anyone else has suggested this: the numpy module can
generate random bytes and has a built-in tofile() method.
On Tue, Jun 15, 2010 at 2:27 PM, Pete O'Connell pedrooconn...@gmail.com
wrote:
Hi I was wondering if anyone could give me some insight as to the best way
to get and save variables from a user the first time a script is opened. For
example if the script prompts something like What is the path
odd = numbers[::2]
I can't find a way to easily list the even numbers,
Hint: You can designate a start number before the first colon.
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
1 1.1 Write a Python program with a loop that prints out a sequence
of numbers as follows:15 13 11...3 1 -1
Hint 1: Learn about FOR loops.
Hint 2: Learn about the RANGE command.
Hint 3: Show us some code you have written. Even if yours doesn't
work, we can probably spot WHY it doesn't work.
i just don wana index all the characters rather i wana double it too like
['d','a','v','i','d']
would b
['d','dd','a','aa','v','vv','i','ii','d','dd']
and then i wana replace all non 'd' characters with '.' a dot
i know how replace a specific character, but i don know how to
replace
I am learning Python slowly. I would like to begin learning all
about how computers work from the bottom up. I have an
understanding of binary code. Where should I go from here; can you
suggest continued reading, on line or off to continue my education?
This might be worth a look:
I'm looking for an efficient way to create all the unique, non-duplicated
permutations of a list
This may or may not help:
http://code.activestate.com/recipes/190465/
Alan
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
Hi folks,
I'm trying to do something like this:
evildict= {'good' : 'bad' , 'love' : 'hate' , 'God': 'Satan'}
def make_evil(text)
... for a in evildict:
... text=text.replace(a, evildict[a])
... return text
This works fine, but it soon gets too
Varnish has a dedicated (but not always) reliable logger service. I'd
like to monitor the logs - specifically I want to check that a known
entry appears in there every minute (it should be there about 10 times
a minute).
What's going to be the best way to carry out this kind of check? I
i know how to print for bubble sort in python, is there a way to
print each pass in the sort so i can see what happens at each step?
thanks
A good first guess would be to try sticking print list in there in a
few different places.
Others will probably point out that list is a built-in
gradesfile = open(grades.dat, r
for lines in gradesfile:
[snip]
That's what I have so far but I have a feeling I shouldn't use a for
loop.
Actually a for loop seems like the right tool for this job, assuming
you really _do_ want to process every line in the file.
Alan
for letter in python:
print Current letter:, letter
for chic in python:
print chic:, chic
When you write a for-in loop, you can use any variable name you feel
like using (letter, chic, mycoolvariable, x, etc.) It's that simple :)
Alan
___
while type(start)!=float:
Did you try quotes around the word float?
Alan
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Newbie here who can't figure out why this doesn't work:
start = input(Please enter the starting number.\n)
print(type(start))
while type(start)!=float:
start = input(Sorry, that number was invalid.\nPlease enter the
starting number.\n)
print(type(start))
Google to the rescue. Try
Is there a text graphics module that does say scatter plots or
histograms? I'm thinking of stuff prior to the graphics era of
computing. I'm looking for something really simple.
Here's a quick and dirty way to do basic histogram of dice rolls:
import random
rolls={}
for x in range(1):
I'd suggest googling for 'trie'. Tries are method of
indexing sets of strings by prefix.
Ah, will look it up.
As I recall, English words are more similar at the
front, so once you have an indexing scheme you'll
probably to do even less work if you index and search
from the back of the
Any bright ideas on how I can speed this up? It seems REALLY slow for
as little as it does.
I'm trying to generate word squares like this:
P R E Y
L A V A
O V E R
T E N D
except 6x6 rather than 4x4.
In particular, the profiler indicates that {method 'join' of 'str'
objects} is eating an awful
Here you call join() at the third level of nested for loops.
And then you call solve recursively at that same level
where join gets called inside 3 more levels of loop.
That effectively means join is getting called at 6 levels
of loop nesting for just one recursive call, but you could
be
Given a list of 6-letter words:
['abject','poetry','keypad']
How do I derive this list:
['apk', 'boe', 'jey']
(The original list's first letters, second letters, third letters,
etc.)
I have a text file of 15280 six-letter words and I want to robotically
generate 6x6 word squares.
My first
Given a list of 6-letter words:
['abject','poetry','keypad']
How do I derive this list:
['apk', 'boe', 'jey']
(The original list's first letters, second letters, third letters,
etc.)
I have a text file of 15280 six-letter words and I want to robotically
generate 6x6 word squares.
My
R. Alan Monroe wrote:
def checksolution(sol):
maybes = []
big = ''.join(solution)
for x in range(len(sol)):
maybes.append( big[x::6] )
print maybes
solution=['abject','poetry','keypad']
checksolution(solution)
['apk', 'boe', 'jey']
That's nice. Why do you
I would like to learn and teach my 2 girls a mini
database GUI program in Python and
They are Girl Scouts (and advanced MS HS
students)
http://davidbau.com/archives/2005/07/29/haaarg_world.html
Alan
___
Tutor maillist -
Is is possible to get python to differentiate between CR, LF, and CRLF
in a string (not a file)? This is a triple quoted string I've pasted
into the source (putting r to indicate raw string made no difference).
It contains a mixture of CR, LF and CRLF (I can see this by enabling
visible End of
logger.info(Checked %s records in %s seconds, yielding an average of
\
%s seconds per record. % (len(self.data), duration, avgquery) )
^
Remove these spaces. It makes the source code look weird, but the
output will be correct.
Alan
Noufal Ibrahim [EMAIL PROTECTED] wrote
I think such treatment of the various python constructs should be
reserved for documents like say, Python for C programmers(
Actually that's not a bad idea, except I'm not sure such convertion
courses exist?
But it would be useful to have a set of
I want to be able to calculate in the program,.. the total score,..
either at each successive score,... or when they finally get out.
Not sure how to do that at this point.
You're on the right track. You need an additional variable to hold the
running total.
Alan
when you are doing print these two characters keep showing up in this book
%s %
What do they do?
Fill in the blank
Kind of like generic paper forms where they have a blank underline for
you to fill in your information.
Give it a variable name, and it will fill in the blank (the %s) with
the
I'm starting graduate school (econ!) in the Fall; the school I'll be
attending uses Lotus for email
You can drive the fat client via COM if you install the Win32
extensions for python.
(I know I could do it with a torturous combination of applescript and
Except judging by this, you're on a
I have written a Python app, a company who don't use Python want to integrate
its back end with their C++ coded GUI.
At the moment they are proposing using CSV files to communicate between the
Python C++, ie C++ GUI generates a CSV, calls Python back end, back end
does the work and
Is there a way to have the output of print tis in the same format as
print now and print tafmsd in the code below?
Thanks,
Will
savage:~ wallison$ python
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type help, copyright, credits
Hi. I want to learn how to break down a string into its component
words, and then process each word somehow.
Is there a way in Python to separate a string into its component words.
Like this:
I would like to convert an English string (sentence) into Pig Latin.
for word in
On Fri, 23 Mar 2007, Luke Paireepinart wrote:
I've also thought of having a twist here for MP3 files, specifically,
distinguishing between the files' audio frames and identification info
frames, and checksumming only the audio portion; so that two otherwise
identical MP3 files with different
Luke Paireepinart [EMAIL PROTECTED] wrote
forth ... while very good for small programs
to imbed into controller cpu's to bury inside some machine,
It's a relatively little known fact that Sun use Forth as the
monitor/bootloader in their servers. When you do a shutdown
on a Sun box it
odd =1
while odd =100:
if (odd%2)==1:
print odd
odd = odd + 1
-
I get a list of the odd numbers from 1 to 99. But now if I wanted to add
those number together
So my plan is to use Python, has anyone try to learn kids this way, and
could
giv som ide how-to.
I witch way to introduce every part of the language,,,
http://davidbau.com/archives/2005/07/29/haaarg_world.html
Alan
___
Tutor maillist -
right now i can make something move up and down, or left and right, but
if I want to rotate a triangle, then move it so that the 'tip' always
points in the direction it's going to move, I get stuck.
http://freespace.virgin.net/hugo.elias/routines/rotate.htm
Alan
I want to make a GUI in which user can write text in a text box and then
click a button to save it to a text file. I'm using wxPython's TextCtrl
widget.
Then later I would want the user to be able to open it back into that
window.
Any help appreciated, thank you.
Have you learnt how
Message: 4
Date: Sat, 23 Sep 2006 08:38:37 +0100
From: Alan Gauld [EMAIL PROTECTED]
Subject: Re: [Tutor] Fatal error after RE-installing Python 2.3.4
To: tutor@python.org
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; format=flowed; charset=iso-8859-1;
reply-type=original
I just ran into the following link; it's a tutorial on writing
adventure games (circa 1983):
http://www.atariarchives.org/adventure
Would anyone be interested in porting the examples over from BASIC to
Python? It might make a fun project for us here on Tutor; a few of us
appear to
I'd try the screen saver settings first, its much easier!
This is not Python specific, but very informative:
http://www.codeproject.com/cpp/holsavers.asp
Alan
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 8/24/06, John Fouhy [EMAIL PROTECTED] wrote:
On 25/08/06, Joe Gamman [EMAIL PROTECTED] wrote:
Anyway, would appreciate any comments on the idea.
It seems like the sort of thing you find in textbooks or learn to
program books -- most books of this nature have suitable exercises at
the
my email program does not insert the sign like the standard email
program does.
The Bat mail client does a great job of it, but it's not free.
http://www.ritlabs.com/
You might try Pegasus Mail, although I don't remember how well it does
it. http://www.pmail.com/
If you were desperate and
5100- 3
5100 foo 1
5200 - 1
5200 foo 1
I want to count the frequency of the second column of data that I can
access.
It's kind of the long way around, but putting it into a sql database
and doing a groupby query might work.
Alan
Dunno if this is the best way, but it works...
Replace this:
if events.key == K_DOWN:
with this:
if events.key == K_DOWN and not imagerect.colliderect(imagerects):
Alan
___
Tutor maillist - Tutor@python.org
Someone on edu-sig tried to get it working on her computer running Windows
XP home edition (just like mine, where it works fine!). However, she gets an
error message about
port 8080 not free on local host. This is after she made sure nothing
else internet-related was working. [This kind
I'm searching through SQL logs and want to find lines that have
WHERE-less (unbounded) queries. I can't come up with a regex to say:
SELECT.*FROM.*(the word WHERE must not exist anywhere in the remainder
of the line)
Am I forgetting something simple or would this take two passes?
Alan
R. Alan Monroe wrote:
I'm searching through SQL logs and want to find lines that have
WHERE-less (unbounded) queries. I can't come up with a regex to say:
SELECT.*FROM.*(the word WHERE must not exist anywhere in the remainder
of the line)
Am I forgetting something simple or would
Dear all,
I'm trying to call an executable program in Python. I did the following, but
it doesn't work. Any help is appreciated.
os.system('C:\Program Files\EPANET2\epanet2d.exe C:\simulation
test\Network3_1.inp C:\simulation test\Network3_1.out')
My first guess: you need quotes around
If I can get it for free, I might as well go with say wxPython. Thanks
Yes, free as in beer, as in speech, and cross platform. Oh, and better
documented.
Sadly, you still pay for it in RAM usage :^)
Alan
___
Tutor maillist - Tutor@python.org
Thanks for the prompt response. My real problem is that there is no
place inside a tutorial where all the terms like object, data, method,
operation, attributes are explained on a single page *with* one small
example of each. I am *really* confused when they occur now. I found
The _Head
1 - 100 of 154 matches
Mail list logo