Re: [Tutor] hypotenuse

2008-03-14 Thread Robert Childers
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

[Tutor] Conventions for code snippets for debugging and testing?

2008-04-10 Thread Robert Kirkpatrick
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

Re: [Tutor] put?

2008-05-06 Thread Robert Kirkpatrick
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

[Tutor] search path

2008-07-06 Thread Robert Johansson
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

[Tutor] New to Python

2008-07-07 Thread Robert Berman
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

[Tutor] character encoding

2008-07-08 Thread Robert Johansson
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 __

Re: [Tutor] something is fundamentally wrong...

2008-08-10 Thread Robert Berman
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

[Tutor] unsupported characters

2008-08-17 Thread Robert Johansson
grateful. /Robert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] unsupported characters

2008-08-18 Thread Robert Johansson
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

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Robert Berman
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

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Robert Berman
, 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

Re: [Tutor] pass argument into running program *outside* of program

2008-08-22 Thread Robert Berman
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

Re: [Tutor] test

2008-08-25 Thread Robert Berman
Nope. Kirk Bailey wrote: is my posting getting through? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
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

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
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

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
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

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-05 Thread Robert Berman
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

Re: [Tutor] Exhaustive Enumeration

2008-09-21 Thread Robert Berman
. 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

Re: [Tutor] Exhaustive Enumeration

2008-09-21 Thread Robert Berman
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

Re: [Tutor] Exhaustive Enumeration

2008-09-21 Thread Robert Berman
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.

Re: [Tutor] Sorting Dictionary of Dictionary by certain Value

2008-09-23 Thread Robert Berman
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' : {   

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Robert Berman
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

[Tutor] More Pythonesque or a more efficient method

2008-10-05 Thread Robert Berman
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

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-05 Thread Robert Berman
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

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Robert Berman
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

Re: [Tutor] Creating a single .exe file without py2exe and pyinstaller

2008-10-19 Thread Robert Berman
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

[Tutor] A tutorial for Python and QT4

2008-11-12 Thread Robert Berman
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

[Tutor] referencing external functions

2008-11-14 Thread Robert Berman
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

Re: [Tutor] referencing external functions

2008-11-14 Thread Robert Berman
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

[Tutor] Psyco module

2008-12-07 Thread Robert Johansson
oblem with installing Psyco remains. Anyone how knows what to do? /Robert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Robert Berman
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

Re: [Tutor] reading inputs from keyboard

2008-12-14 Thread Robert Berman
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

Re: [Tutor] Very basic question about lists

2008-12-22 Thread Robert Berman
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

Re: [Tutor] linked list with cycle structure

2009-01-07 Thread Robert Kern
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

[Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
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

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
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

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
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

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
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

Re: [Tutor] Suggestions for more efficient and optimized coding technique,

2009-01-08 Thread Robert Berman
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

Re: [Tutor] python3.0 and tkinter on ubuntu 8.10

2009-01-13 Thread Robert Berman
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

Re: [Tutor] python3.0 and tkinter on ubuntu 8.10

2009-01-13 Thread Robert Berman
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

Re: [Tutor] Python3.0 and Tkinter on ubuntu 8.10 HOWTO

2009-01-14 Thread Robert Berman
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/

[Tutor] The better Python approach

2009-01-21 Thread Robert Berman
ect python oriented solution for extracting those substrings? Thanks, Robert Berman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] The better Python approach

2009-01-21 Thread Robert Berman
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

Re: [Tutor] The better Python approach

2009-01-21 Thread Robert Berman
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

Re: [Tutor] The better Python approach

2009-01-21 Thread Robert Berman
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

[Tutor] No module named 'module name'

2009-01-25 Thread Robert Berman
doing wrong. Thanks for the assistance. Robert Berman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] No module named 'module name'

2009-01-25 Thread Robert Berman
. 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

Re: [Tutor] REport Card Question

2010-11-29 Thread Robert Sjöblom
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

Re: [Tutor] role playing game - help needed

2010-12-06 Thread Robert Sjöblom
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

Re: [Tutor] Python vs. MATLAB

2010-12-07 Thread Robert Sjöblom
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

Re: [Tutor] role playing game - help needed

2010-12-07 Thread Robert Sjöblom
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

Re: [Tutor] role playing game - help needed

2010-12-07 Thread Robert Sjöblom
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

[Tutor] A class list

2010-12-24 Thread Robert Berman
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

Re: [Tutor] A class list

2010-12-24 Thread Robert Berman
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

[Tutor] PDF to TXT

2011-01-23 Thread Robert Berman
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

Re: [Tutor] nested loops

2011-02-07 Thread Robert Berman
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

[Tutor] string conversion

2011-02-28 Thread Robert Clement
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

[Tutor] binary string parsing

2011-03-08 Thread Robert Clement
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

Re: [Tutor] Resources

2011-03-11 Thread Robert Berman
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

[Tutor] if value not in dictionary, do a?

2011-03-25 Thread Robert Sjoblom
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

Re: [Tutor] if value not in dictionary, do a?

2011-03-25 Thread Robert Sjoblom
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

Re: [Tutor] (sqlite3) Testing if a table has been created.

2011-04-05 Thread Robert Helmer
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

Re: [Tutor] folder and file list (Jorge Romero)

2011-05-10 Thread Robert Sjöblom
@swiftone.org >> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor >> > > > > -- > Jorge Romero > ---

[Tutor] Help with understanding classes

2011-05-21 Thread Robert Sjöblom
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

Re: [Tutor] Help with understanding classes

2011-05-22 Thread Robert Sjoblom
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

Re: [Tutor] Strategy to read a redirecting html page

2011-06-02 Thread Robert Sjoblom
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. _

Re: [Tutor] Strategy to read a redirecting html page

2011-06-02 Thread Robert Sjoblom
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

[Tutor] [OT] Re: Floating Point Crazines

2011-06-12 Thread Robert Sjoblom
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. ___

[Tutor] Hello World in Python without space

2011-07-10 Thread Robert H
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 _

Re: [Tutor] "Object designer" applications - are there any?

2011-08-05 Thread Robert Sjöblom
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

[Tutor] commandline unable to read numbers?

2011-08-06 Thread Robert Sjoblom
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

Re: [Tutor] commandline unable to read numbers? (Steven D'Aprano)

2011-08-07 Thread Robert Sjoblom
> 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

Re: [Tutor] commandline unable to read numbers?

2011-08-07 Thread Robert Sjoblom
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

[Tutor] function remember calls?

2011-08-09 Thread Robert Johansson
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 _

Re: [Tutor] Tkinter: no module named messagebox (brandon w)

2011-08-14 Thread Robert Sjoblom
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

Re: [Tutor] methods vs. functions

2011-08-22 Thread Robert Sjoblom
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. _

[Tutor] issues with urllib and loading a webpage.

2011-08-23 Thread Robert Sjoblom
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. __

Re: [Tutor] issues with urllib and loading a webpage.

2011-08-23 Thread Robert Sjoblom
>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

Re: [Tutor] issues with urllib and loading a webpage

2011-08-23 Thread Robert Sjoblom
>> 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

[Tutor] Help with if-elif-else structure

2011-08-25 Thread Robert Sjoblom
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

Re: [Tutor] Help with if-elif-else structure

2011-08-25 Thread Robert Sjoblom
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

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Robert Sjoblom
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

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Robert Sjoblom
> 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

Re: [Tutor] Running .py files in shell

2011-09-21 Thread Robert Layne
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

[Tutor] Mac IDE

2011-09-29 Thread Robert Johansson
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

Re: [Tutor] Mac IDE

2011-09-29 Thread Robert Johansson
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

Re: [Tutor] Running a loop

2011-10-15 Thread Robert Sjoblom
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

Re: [Tutor] 6 random numbers

2011-10-16 Thread Robert Sjoblom
= 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

Re: [Tutor] 6 random numbers

2011-10-17 Thread Robert Sjoblom
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

Re: [Tutor] Hello again. Still the same problem, different question.

2011-11-12 Thread Robert Sjoblom
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

[Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
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

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
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. __

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
> 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.

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
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

Re: [Tutor] Python Saved the Day

2011-12-04 Thread Robert Sjoblom
cost. -- best regards, Robert S. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] list.index() question

2011-12-08 Thread Robert Berman
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

Re: [Tutor] list.index() question

2011-12-08 Thread Robert Berman
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

Re: [Tutor] list.index() question

2011-12-08 Thread Robert Berman
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

Re: [Tutor] how to handle big numbers

2011-12-09 Thread Robert Sjoblom
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

<    1   2   3   4   >