Martin Mwaka | 29 Aug 23:37 2015
Picon

Query regarding loop problem

Hello

I would be grateful for some help please.  I have recently started learning
python and I am attemping to write a programme where a user enters a number
between 1 and 5, and the computer generates random numbers until an
equivalent number is achieved.  The code (see below) runs, but the else
part of the loop does not run when the computer generates an equivalent
number. I have tried to resolve this a number of ways and have run the code
under a debugger, but cannot work out why the else part is not running.  I
would be grateful for your help / guidance with this.

Many thanks

Martin

*Full code below:*

# User enters a number between 1 - 5
# Computer generates random number until an equivalent number is achieved

import random
computerNumber = 0
myNumber = input("Input a number between 1 and 5: ")
print ("Your chosen number is: ", myNumber)
computerNumber = input("Press enter to prompt the computer to enter a
number: ")

while computerNumber != 0:
    if myNumber != computerNumber:
        computerNumber = random.randint(1,5)
(Continue reading)

bruce | 29 Aug 02:24 2015
Picon

aws/cloud questions..

Evening group!

Hope wee'all doing well, having fun. yada yada..!!

I'm considering taking a dive into the "cloud" with an app that would
be comprised of distributed machines, running py apps, talking to db
on different server(s), etc..

So, I was wondering if anyone has good docs/tutorials/walk through(s)
that you can provide, or even if someone is willing to play the role
of online mentor/tutor!!

Thanks
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Albert-Jan Roskam | 28 Aug 17:53 2015
Picon

FW: value range checker

(sorry, Peter, Alan, I sent two mails to you privately. I just switched from Yahoo to Hotmail for DMARC
reasons. Still getting used to Hotmail.)

> Subject: RE: [Tutor] value range checker
> Date: Fri, 28 Aug 2015 10:14:49 +0000
>
> ----------------------------------------
>> To: tutor <at> python.org
>> From: __peter__ <at> web.de
>> Date: Thu, 27 Aug 2015 09:48:46 +0200
>> Subject: Re: [Tutor] value range checker
>>
>> Albert-Jan Roskam wrote:
>>
>>> I have a written a function checks the validity of values. The ranges of
>>> valid values are stored in a database table.
>>>
>>> Such a table contains three columns: category, min and max. One record of
>>> such a table specifies the range for
>>>
>>> a certain category, but a category may be spread out over multiple
>>> records.
>>
>>> My questions:
>>
>>> def get_valid_value_lookup(records):
>>> """
>>> Translates value range information (from a database table)
>>> into a dictionary of the form {<category>: [<range of accepted
>>> values>]} """
(Continue reading)

Albert-Jan Roskam | 28 Aug 12:17 2015
Picon

Re: value range checker


----------------------------------------
> Subject: Re: value range checker
> To: sjeik_appie <at> hotmail.com
> CC: tutor <at> python.org
> From: matt.ruffalo <at> gmail.com
> Date: Thu, 27 Aug 2015 12:41:45 -0400
>
> On 2015-08-26 09:19, Albert-Jan Roskam wrote:
>> For example, the category-min-max tuples
>>
>> ("cat a", 1, 1),
>>
>> ("cat a", 3, 3),
>>
>> ("cat a", 6, 10),
>>
>> correspond to a range of category A of 1-1, 3-3, 6-10, which is the same as 1, and 3, and 6, 7, 8, 9, 10.
>
> Hi-
>
> An interval tree ( https://en.wikipedia.org/wiki/Interval_tree ) is the
> typical choice of data structure for storing and searching sets of
> intervals, and the bx-python package (
> https://bitbucket.org/james_taylor/bx-python ) has a high-quality Cython
> implementation of one. I have used that interval tree implementation for
> storing intervals of genome coordinates, and it worked very well. I
> don't remember whether that implementation deals with single points very
> well (i.e. start and end are the same value) -- some interval tree
> implementations handle that well and some do not. It shouldn't be much
(Continue reading)

Alan Gauld | 27 Aug 23:32 2015

Re: tkinter in Python 3

On 27/08/15 18:21, Michael Thomas wrote:
> I'm trying to move a Python 2.x program to Python 3.x. When I try to import
> tkinter I get the error message that no module _tkinter can be found. I've
> tried sudo apt-get install python-tk.

Thats the Python2 version

Try

apt-get install python3-tk

Note that there are a lot of changes in Tkinter in Python 3,
the modules are drastically rearranged and renamed.
Good luck.

HTH
--

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

(Continue reading)

Rohan S | 27 Aug 23:29 2015
Picon

Re: tkinter in Python 3

I am trying to download a version of Pygame that is compatible with Python
2.7.10; when I try to run a simple program, I get an error message stating
that terms like "livewires", "Sprite", "pygame", and "screen", are
unresolved references, and so I assume that downloading pygame could solve
this problem. However,  even after I downloaded it, the same messages still
appear. Might anyone have any alternatives or suggestions?

        Thank you very much,
         Rohan

On Thu, Aug 27, 2015 at 1:21 PM, Michael Thomas <murphy19804 <at> gmail.com>
wrote:

> I'm trying to move a Python 2.x program to Python 3.x. When I try to import
> tkinter I get the error message that no module _tkinter can be found. I've
> tried sudo apt-get install python-tk. While this command works, there is no
> difference in the result. This problem has only cropped up after I changed
> to Ubuntu 15.04. Does anyone have any suggestions?
> Thanks in advance for any help.
> Mike
> _______________________________________________
> Tutor maillist  -  Tutor <at> python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

(Continue reading)

Michael Thomas | 27 Aug 19:21 2015
Picon

tkinter in Python 3

I'm trying to move a Python 2.x program to Python 3.x. When I try to import
tkinter I get the error message that no module _tkinter can be found. I've
tried sudo apt-get install python-tk. While this command works, there is no
difference in the result. This problem has only cropped up after I changed
to Ubuntu 15.04. Does anyone have any suggestions?
Thanks in advance for any help.
Mike
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

boB Stepp | 27 Aug 02:11 2015
Picon

How should my code handle db connections? Should my db manager module use OOP?

My ongoing project will be centered around an SQLite db.  Since almost
all data needed by the program will be stored in this db, my thought
is that I should create a connection to this db shortly after program
startup and keep this connection open until program closure.  I am
assuming that opening and closing a db connection has enough overhead
that I should only do this once.  But I do not *know* that this is
true.  Is it?  If not, then the alternative would make more sense,
i.e., open and close the db as needed.

In the first iteration of my project, my intent is to create and
populate the db with tables external to the program.  The program will
only add entries to tables, query the db, etc.  That is, the structure
of the db will be pre-set outside of the program, and the program will
only deal with data interactions with the db.  My intent is to make
the overall design of the program OO, but I am wondering how to handle
the db manager module.  Should I go OO here as well?  With each
pertinent method handling a very specific means of interacting with
the db?  Or go a procedural route with functions similar to the
aforementioned methods?  It is not clear to me that OOP provides a
real benefit here, but, then again, I am learning how to OOP during
this project as well, so I don't have enough knowledge yet to
realistically answer this question.

TIA!
--

-- 
boB
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
(Continue reading)

Albert-Jan Roskam | 26 Aug 15:19 2015
Picon

value range checker

Hello,

I have a written a function checks the validity of values. The ranges of valid values are stored in a database table.

Such a table contains three columns: category, min and max. One record of such a table specifies the range for

a certain category, but a category may be spread out over multiple records.

For example, the category-min-max tuples

("cat a", 1, 1), 

("cat a", 3, 3), 

("cat a", 6, 10),

correspond to a range of category A of 1-1, 3-3, 6-10, which is the same as 1, and 3, and 6, 7, 8, 9, 10.

The code below does exactly what I want:

import collections
import bisect
import math
import pprint

def get_valid_value_lookup(records):
    """
    Translates value range information (from a database table)
    into a dictionary of the form {<category>: [<range of accepted values>]}
    """
(Continue reading)

Ankit Pareek | 25 Aug 12:51 2015
Picon

PyQt4 Draggable button

How can I create Draggable buttons in PyQt4 , which can be moved using
mouse. Can I create using Qt Designer or I have to code.

Please help me.
Thanks in advance.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Gonzalo V | 25 Aug 02:08 2015
Picon

Help error 504

how can simulate or emulate an error 504?
i am new in python and its very intuitive! but i am in problems with that
code.

i wrote this code and it cant handle 504 error:
import urllib.request
import urllib.error
from bs4 import BeautifulSoup
import re, csv
from FuncionCsv import LlenarCsv

fhand=open('isbn.txt')
#csvfile=open('ResultadoScrapping.csv', 'w', newline='')
for line in fhand:
    req=urllib.request.urlopen('XXXXXXXX'+line)
    resp=req.read()
    soup=BeautifulSoup(resp,'html.parser')
    try:
        origen=soup.find(string=re.compile("Origen:
")).find_next().get_text()
        nombre=soup.find(name="h1",itemprop="name").get_text()
        precioAhora=soup.find(name="p",class_="precioAhora").get_text()
        d=soup.find(name="p",class_="stock").get_text()
        disp=d.split()
    except AttributeError:
        disp="no encontrado"
        nombre=''
        origen=''
        precioAhora=''
    except urllib.error.HTTPError as e:
(Continue reading)


Gmane