I have rewritten my "hypotenuse" program as follows:>>> #This program
calculates the width and diagonal of a golden rectangle
>>> print "Calculate the width and diagonal of a golden rectangle."
Calculate the width and diagonal of a golden rectangle.
>>> height = input ("Input height:")
Input height
Hi All,
Just wondering if there are any basic conventions for including code
snippets that are for testing / debugging only?
For example, you could set a boolean variable called DEBUG, then have
snippets of code like:
if DEBUG:
do stuff
else:
do otherstuff
The use case I'm dealing with
Hey Alan! Is there a dict program for the MacOS flavour of *nix? That's a
slick little bit of code but it doesn't work on my Mac:
robertk01$ dict
-bash: dict: command not found
but it works fine when I ssh into a Linux box...
>
> OTOH, if you are happy with those ideas:
>
>>> word = raw_inp
g works fine on
my system. Anyone how knows what the cause of this is?
Regards, Robert
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
u will
get from this group as long as you are willing to show what you have accomplished.
Best of luck.
Robert Berman
W W wrote:
A quick google search for "Python tutorial" will yeild several results.
I recommend "Think Python" - http://greenteapress.com/thinkpython/
HT
d IDLE to encode
utf8 but it doesn't make any difference.
This works fine on my PC with WinXP but other things are strange there. When
I write a documentation for my functions in Swedish it gets completely
mashed up.
Regards/Robert
__
s)
34
>>>
Have you by any chance assigned the function len to something else?
Otherwise, it should work really well. If you do help(len) in the
shell, wha dos it tell you.
Robert
Joshua Nikkel wrote:
I've
pasted the following from my python shell. Please note that the first
tw
grateful.
/Robert
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 8/17/08, Robert Johansson <[EMAIL PROTECTED]> wrote:
> Hi, I have problems using characters from the Swedish language. I tried
the
> following in IDLE under MacOS X leopard (running Python 2.5.1) :
> S='ö'
> Displaying error message: "unsupported charac
Perhaps because preNumber is a character and not an
integer?
Robert
Dotan Cohen wrote:
I was missing the quotes in the if statement. Changing
if preNumber[0] == 0:
to
if preNumber[0] == "0":
fixed the problem.
Why did I need those quotes? The 0 is numerical, so it should no
, etc.
Hope this helps a bit.
Robert
Dotan Cohen wrote:
2008/8/21 Robert Berman <[EMAIL PROTECTED]>:
Perhaps because preNumber is a character and not an integer?
Perhaps. In php the distinction was made by the fact that there were
no non-numerical characters in a string. I
Excellent idea. Its simplicity makes it both doable with ease and very
reliable. Thanks for this suggestion.
Robert
Alan Gauld wrote:
"Alan Gauld" <[EMAIL PROTECTED]> wrote
$ program.py addMe
create the server with a socket that listens for c
Nope.
Kirk Bailey wrote:
is my
posting getting through?
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
it found the correct
integer. Any and all suggestions as well as more efficient ways to code
the algorithm will be most appreciated.
Please see attached source code.
Robert Berman
#!/usr/bin/env python
#It can easily be seen that 6! = 720 and has exactly one trailing zero.
#What is the lowest i
Thank you very much for the help and the math
explanation from Omer. Much of my math background is based on brute
force methodology. Obviously, things have changed. Really changed.
Time to do some reading about regex. And here I thought I was slick
working with lists and strings.
Robert
Chris,
Thank you very much for this. It is very helpful. I will check my
answer against yours in the morning.
Robert
Chris Fuller wrote:
I spent the day mulling over this problem, and then implemented my solution
when I got home. This is for the easier problem of 7**8 zeros: On my
logic paths. I am learning by leaps and bounds, and knowing the value
of such a collective group willing to share ideas and information is
even a greater inducement.
Robert
Terry Carroll wrote:
On Thu, 4 Sep 2008, Robert Berman wrote:
"It can easily be seen that 6! = 720 and has e
.
Robert
[EMAIL PROTECTED] wrote:
This is from the MIT Opencourseware intro to computer
science course, which I've been working my way through. I understand
what needs to be done (I think), which is basically to test each
possibility and return the list of states with the most electoral votes
ck no matter which path you pursue.
Robert
[EMAIL PROTECTED] wrote:
I'm actually not enrolled in the course; MIT puts some of
its course materials available online as a general resource. I am out
of school and trying to teach myself python on my own. I'm very much a
beginner, and sinc
That it is.
Jaggo wrote:
Lol. And here I said to myself only, "What a nice
challenge".
On Sun, Sep 21, 2008 at 10:28 PM, Robert
Berman <[EMAIL PROTECTED]>
wrote:
A very interesting problem. Given this is
homework, I
am not sure what it is you want.
This might help you.
http://blog.modp.com/2008/09/sorting-python-dictionary-by-value-take.html
Robert
Joe Python wrote:
Hi Pythonistas,
I have a large dictionary of dictionary (50,000+ keys) which has a
structure as follows:
DoD = {
'flintstones' : {
the word.
Wowee! Golleee! Gosh! That sure be some fine number crunching.
Robert
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
grams=Get_Anagrams(db,word_in)
if Anagrams != None:
print 'Anagrams for ',word_in,' are ',Anagrams
else:
print word_in,' has no anagrams.'
db.close
return 0
if __name__ == '__main__': main()
Thanks,
Robert
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Kent,
Thank you for two excellent suggestions. I will implement your
suggestion of indexing by the sorted letters in the word.
Robert
Kent Johnson wrote:
On Sun, Oct 5, 2008 at 1:52 PM, Robert Berman <[EMAIL PROTECTED]> wrote:
The database item consists of the key; the
Yet another approach to experiment with. Thank you all
very much,
Robert
Kent Johnson wrote:
On Tue, Oct 7, 2008 at 1:15 PM, Richard Lovely
<[EMAIL PROTECTED]> wrote:
In a slightly related matter, Is is possible to use all() with a list
comprehension to check if a word co
If you want a real exe rewrite it in C or C++. Python
is an interpretive language; my apologies to those who say it is
'semi-compilable'.
Robert Berman
Abah Joseph wrote:
I have written a small application of about 40-45 lines which
is about 4KB, so I want to create a single
tutorials would be most appreciated.
I am using Linux (ubuntu -- 8.10) with Eric as my editor.
Thanks,
Robert
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I have a number of functions written in a python script
called script1.py. In another script, script2.py, I need to use a
number of the functions residing in script1.py. How do I make these
functions known to script2.py.
Thank you,
Robert
bob gailer wrote:
A.T.Hofkamp
wrote:
(I would suggest to use more meaningful names
than scriptX.py)
Perhaps Robert uses (as I do) Python for Windows. "Save" proposes
script1, script2, ... as the initial filename.
WIBNI it could cleverly guess a meaningf
oblem with
installing Psyco remains. Anyone how knows what to do?
/Robert
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
RTFM.
Ajo Augustine wrote:
hi all;
can u let me know how to read an input string from the keyboard?
--
Ajo
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Rather than being impressed, perhaps you might consider
performing the action.
spir wrote:
Robert
Berman a écrit :
RTFM.
how clever!
I'm impressed...
Denis
___
Tutor maillist - Tutor@python.org
http://mail.pytho
erations that get a true result so list1 prints twice.
That should clear up the confusion. If not please tel us what is still
not clear.
Robert Berman
Eduardo Vieira wrote:
Hello, I'm trying to teach my self programming with python and there
are some basic things that stumps me:
Given thi
me.
Interesting problem. If it is homework, there must be an answer.
It's also an interview question I've seen reasonably often, particularly with
that last complication.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is m
ode. I am trying
to become more Python concise but I think that is a matter of writing
more and more python code.
All suggestions, ideas, critiques are most welcome.
Thank you,
Robert
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
nly no need to carry the previous responses in
either a list or a dictionary. They do not duplicate since they cannot
repeat. Other than to include extraneous code, why include repetitive
checking at all?
In spite of that, your code and your remarks are most appreciated.
Robert
Michael Langford wr
Kent Johnson wrote:
On Thu, Jan 8, 2009 at 10:49 AM, Robert Berman wrote:
Hi,
One of the challenges on the challenge you web page appropriately titled
'Brute force' reads as follows:
"The password you have to guess is 'loner' . Try all combinations o
used combinations.
or itertools.product
I just looked itertools up using google; and I are truly impressed.
Thank you very much,
Robert
---
Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
www.theJNP.com
___
Tuto
Thank you again. I now have enough to keep me happily busy for days.
Robert
Michael Langford wrote:
I understand that each response is unique Robert and no caching is
required to solve the problem at hand. However in a real program, the
chance you're brute forcing just one password is
forums, but the forums are currently down.
You might want to use Google to track this under Python 3.0 + Ubuntu
8.10.
The overall consensus of opinion is to wait until Python 3.0 became the
default under Ubuntu before using it.
YMMV.
Robert Berman
Emad Nawfal (عماد نوفل) wrote:
Hi Tutors,I
threads on this topic within the Ubuntu forums?
Thanks,
Robert Berman
Vern Ceder wrote:
Hi,
I have Python 3.0/Tkinter/IDLE working fine on Ubuntu 8.10, but it
takes a certain amount of fiddling.
1. Make sure the stock Ubuntu Python 3.0 package is not installed
2. download the Python 3.0 source
Very good and most welcome.
Robert Berman
Vern Ceder wrote:
Since there was some interest in the question of how to get a full
Python 3.0, including Tkinter and IDLE, compiled on Ubuntu Intrepid
8.10, I've written up what I've done and posted it at
http://learnpython.wordpress.com/
ect python oriented solution for
extracting those substrings?
Thanks,
Robert Berman
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
thank everyone who replied.
Robert Berman
Tim Golden wrote:
Robert
Berman wrote:
Given a string consisting of numbers
separated by spaces such as '1234 5678 1 233 476'. I can see I have two
obvious choices to extract or parse out the numbers. The first relying
on iteration so
have made it more concise with some
more detailed examination. If there are some obvious glaring
deficiencies, please, anyone feel free to comment.
Thanks,
Robert Berman
#!/usr/bin/env python
#findsum.py
import string
def openinput(thepath = '/home/bermanrl/usbdirbig/Challenges/su
Kent,
Wow! That is all worth knowing. I am fascinated by the single sum
over a double loop.
Thanks,
Robert Berman
Kent Johnson wrote:
On Wed, Jan 21, 2009 at 2:02 PM, Robert Berman wrote:
myfile = openinput()
for line in myfile:
jlist = line.split()
for x
doing wrong.
Thanks for the assistance.
Robert Berman
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
.
Thank you for the key that unlocked the obvious.
Robert
Alan Gauld wrote:
"Robert Berman" wrote
from testwin import Ui_TestWindow
I receive the following error message: Import error: No module named
testwin.
If I use ipython and do the from statement, it works just fine. I
th
need to provide it 1 argument and that you gave it 0 instead.
>
> If you called
>
> grade_score(3, 150)
>
> you would get a similar error, only it would say (2 given) instead.
>
> HTH,
> Wayne
On a related note, do all functions implicitly contain "return None&quo
with each key when the attribute changes. I don't want to spoil the
challenge of working it out yourself, but when I asked I was told to
check out how values() and sum() worked.
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ke yourself a coffee first :)
[snipped wall of text]
That was quite an interesting read, thanks for the lesson!
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ibutes dictionary (remember, dictionaries work by key: value
pairs). sum() won't work on a dictionary that contains both strings
and integers, . If you only use integers in your values, the list will
only contain integers, and so you can easily use sum() on it.
> I am pretty sure I will change
in function input in module __builtin__:
input(...)
input([prompt]) -> value
Equivalent to eval(raw_input(prompt)).
I've been told to use input() if I know that I'll only get integers,
and raw_input() for "everything." Would you say it's better to use
m 1.1 EAP
Thank you for any and all assistance.
Robert
--
I am using the free version of SPAMfighter.
We are a community of 7 million users fighting spam.
SPAMfighter has removed 174 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len
The Professional versio
From: Noah Hall [mailto:enali...@gmail.com]
Sent: Friday, December 24, 2010 2:36 PM
To: Robert Berman
Subject: Re: [Tutor] A class list
Alright, I'll begin by saying that you shouldn't use a list for cards , and a
separate one for players. Instead, you should use dictionaries. F
hile in one of the pypdf
functions. The trace is below. Any insight into how to resolve this
situation will be most appreciated.
Thank you,
Robert
===
The trace I get is:
de
ll you are running to the end or not; we certainly
have nothing showing 'a best fit' algorithm. If we can see the actual
code we can at least show you where you might want to look for current
and/or potential problems.
Also, what OS are you using?
Wh
Hi
I have a wxpython control in which users are intended to enter control
characters used to define binary string delimiters, eg. '\xBA\xBA' or
'\t\r\n' .
The string returned by the control is a unicode version of the string
entered by the user, eg. u'\\xBA\\xBA' or u'\\t\\r\\n' .
I wo
e the byte order was different than the default
assumed for the buffer.
Thanks
Robert Clement
--
202 Crew Building
West Mains Road
Edinburgh
UK, EH9 3JN
phone +44 131 650 7732
The University of Edinburgh is a charitable body, registered in
Scotland, with registra
change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Look at this page and pick your challenge. Have a great time.
http://sixrevisions.com/resources/10-puzzle-websites-to-sharpen-your-programming-skills/
HTH,
Robert
___
Tutor
but I figure one step at a
time, and the current step is this one), but I'm quite the newbie at
programming. Still.
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
e been lost to me. I think that for now it'll be enough to store
the data in a list but I'll definitely keep databases in mind. I know
that I'll probably have to learn them sooner or later, if not for this
project then for some other project down the road.
My issue (small as it may
On Tue, Apr 5, 2011 at 6:59 PM, michael scott wrote:
> Hello guys,
>
> Since sqlite gives an error if you try to create a table that's already
> there, how do I test if a table is already present?
>
>
> for example in
>
> def database(info):
> import sqlite3
>
> connection = sqlite3.connec
@swiftone.org
>> ___
>> Tutor maillist - Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
>
> --
> Jorge Romero
> ---
t seem to grasp the concept or syntax very well, and none of the
sources I've found go to great lengths explaining them to someone as
thick-headed as me. So if anyone could take the time to explain, or point me to
sources to read, I'd be grateful
Thank
nations I'm slowly getting my head around it
all. I'm sure I'll be back with more questions as soon as I can
formulate them. My biggest problem, which everyone (except this list)
skimmed over was the __init__ and self parts. Now that I've had those
explained to me, it's starti
dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ------
| Data and other attributes inherited from BaseHandler:
|
| handler_order = 500
best regards,
Robert S.
_
On 2 June 2011 22:50, Brett Ritter wrote:
> On Thu, Jun 2, 2011 at 4:06 PM, Robert Sjoblom
> wrote:
>> Python already has the urllib/urllib2 package that automatically
>> follow redirects, so I don't see why you'd need a 3rd-party module to
>> deal with it? Wh
o the telescope on earth the beam is about 9 miles wide.
Again, only 1 in 30 million *of the returning* photons will hit the
telescope. Now imagine scaling the retroflector in size to a dime.
To bring it back on topic: could python handle these numbers reliably?
--
best regards,
Robert S.
___
before the exclamation mark. I want this:
Hello world!
I tried to solve the problem with e.g.:
print("Hello",name.strip(),"!")
but the result is the same.
Can anyone out there help me? Thank you.
Regards,
Robert
_
nt, most code is
understandable if you know python), wjile Python 3 is very dry and technical,
but really goes in-depth with OO programming and the philosophies behind it
(the first chapter really helped me wrap my head around OO and inheritance and
encapsulation and what have you). As for dia
ut when I run it in commandline it will just repeat
"is not a valid choice." Note that it does this no matter what I
actually enter, it won't actually get any kind of input except the
enter key. So I suppose it's a problem with input() (I'm using python
3.2 btw). Anyone
> Robert Sjoblom wrote:
>> I have a quite odd problem, and I've come across it before but
>> probably ignored it at the time because I had other concerns. I've
>> tried googling for the answer but haven't really come closer to
>> solving it.
>> This
as does menu.py (except the search function, but that's a
different problem). Thank you (and everyone else who put time and
effort into trying to solve this)!
--
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Now it works fine but I don't understand why the first example fails. I'm not
very pleased with any of these two solutions so I would be grateful for any
suggestions of improvements. I use Python 2.7.2 under Windows 7 and I ran this
in Python shell in IDLE.
Cheers, Robert
_
the dirname() function, so if we try calling dirname()
we will get a TypeError exception because dirname now refers to a
string, and we can't call strings.
However, given that Tkinter is such a huge package to begin with, I'd
say that you should continue to use from
e class
(remembering that an object is an instance of a class - the class is
the definition, the object is an instance of that data)
Credit where credit is due:
http://stackoverflow.com/questions/155609/what-is-the-difference-between-a-method-and-a-function
/Robert S.
_
ttplib2.Http('.cache') # I prefer to use
folders when working with httplib2
response, content = h.request(url)
Response headers are put in response, the content is accessible as a
byte object in content.
--
best regards,
Robert S.
__
>Don't know, works fine for me..
>
>Greets
>Sander
Are you using Python 3 and urllib, and not using httplib2? Because I
honestly can't get urllib.request.urlopen to work with
http://www.boursorama.com/ -- I only get b'' fro
>> Are you using Python 3 and urllib, and not using httplib2? Because I
>> honestly can't get urllib.request.urlopen to work with
>> http://www.boursorama.com/ -- I only get b'' from there.
>
> Yes, Python 3.2 which version one are you using? I tried both with
> debug and without.
Python 3.2.1 64
15:
if roll[1] >= 2:
print("Critical success!")
elif roll[2] >= 2:
print("Failure")
else:
print("Success")
This handles all the test cases I've come up with, but it feels very
ugly. Is there a better way to do this?
--
best
even if there's a better way to handle it. I'll
probably send it through a function, something like (pseudocode):
def check_result(diceroll_result, initial_mins, initial_max):
check for success/failure and so on
return result
But even so, i
practice, so I'm going to suggest that
instead:
badMacs = [item for item in scanResults if item not in verifiedList]
Other than that, there's not much to say; the standard is 4 spaces
indentation, personally I feel that 1 space is too little, since it's
hard to see where on
> shantanoo, Andre, and Robert:
>
> All of your solutions seem to work (and thank you for the tips!), however,
> with each solution there seems to be 2 MACs that should not be in the
> results.
>
> 00:1C:14:BA:D9:E9 and
> 00:16:3E:EB:04:D9
>
> should not be be tur
Well everybody, sorry for the incomplete sentences
and overall poor English but I wanted to make this
simple to read and understand for someone who
is completely inexperienced in any sort of programming,
as I am (very first day messing with this stuff, e.g.,
terminal). This is the result of hou
and OS 10.7). IDLE had serious problems and
TextWrangler had no interactive shell. There's a lot of other stuff to try and
I would be grateful if someone could spare me some time on this.
Cheers, Robert
___
Tutor maillist - Tutor@python.org
T
Wing IDE looks promising on my windows machine. I will start by checking out
their trial under OSX.
Thanks for all suggestions,
Robert
Från: tutor-bounces+robert.johansson=math.umu...@python.org
[mailto:tutor-bounces+robert.johansson=math.umu...@python.org] För Tom Tucker
Skickat: den 29
2index=='pumpkin' and wheel3index==
> 'candie':
>
> print ('wins pumpkin, ghost, and candy.')
Here you've misspelled "candy" as well as having it in the wrong case.
ANYWAY, I'm sure there's some better way to compare stuff lik
= random.sample(range(1,42), 7)
random.sample returns k unique random elements from a population
sequence; in this case the population sequence is range(1, 42) (I
think python 2.x it'd be xrange()?) and the second argument would be
the number of elements we wan
le is better because it does (for this purpose, at
least) and it stores the result in a list automatically.
Let's hope this email goes to the right thread. :/
--
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or
same subject and are unsolvable because the standard version
doesn't work. So just to give you a heads up: don't overextend your
welcome.
--
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
be honest. This wasn't too bad, but even for problems 1 and 2 I've
relied on brute forcing the answer instead of looking for a
mathematical solution.
--
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
actor):
factor = x
n = n // x
if n == 1:
return factor
else:
return factor
x += 2
print(factorization(600851475143))
>
> HTH,
> Wayne
--
best regards,
Robert S.
__
> from math import sqrt
>
> def isprime(n, factor):
> if n == 1:
> return False
> for x in range(2, round(sqrt(n))):
Ooops, this should obviously read
for x in range(factor, round(sqrt(n))):
best regards,
Robert S.
uns is because it
accidentally finds x = 25 and 5*25 = 200 (1000//5 = 200), thus ending
the loop.
I'm not sure how to fix that. Recursion? It obviously happens when the
answer is something like 2*2*5*5.
--
best regards,
Robert S.
___
Tutor maillist
cost.
--
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
rkable code to do that task reasonably well.
Thank you for your assistance.
Robert
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 12/08/2011 04:27 PM, bod...@googlemail.com wrote:
That won't work because l1[0] is ['a', 1]
What happens if you don't change the code?
l1.index('c')
Bodsda
Sent from my BlackBerry® wireless device
-----Original Message-
From: Robert Berman
Sender: t
On 12/08/2011 05:03 PM, Steven D'Aprano wrote:
Robert Berman wrote:
Hi,
Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I
want to get the index of 'c'.
You will need to explain what you mean by "the index of 'c
ial:Downloadcode/Factorials_with_prime_factorization_%28Python%29
(Well, excepting actually storing prime numbers in a list which would
be much, much faster)
--
best regards,
Robert S.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscripti
201 - 300 of 381 matches
Mail list logo