Re: [Tutor] Creating a webcrawler

2016-01-09 Thread Alan Gauld
On 09/01/16 02:01, Whom Isac wrote:
> Hi I want to create a web-crawler but dont have any lead to choose any
> module. I have came across the Jsoup but I am not familiar with how to use
> it in 3.5 as I tried looking at a similar web crawler codes from 3.4 dev
> version.

I don't know Jsoup and have no idea about how it works with 3.5.
However there are some modules in the standard library you can
use including htmlib, urllib and so on.

Beautiful soup is good at parsing badly constructed html and
etree is good for xml/xhtml.

Requests is also a good bet for working with http requests.

> I just want to build that crawler to crawl through a javascript enable site
> and automatically detect a download link (for video file)

Depending on what exactly the Javascript does it might not
be possible (at least not directly) Many modern sites simply
load up the document structure before calling a Javascript
function to fetch all the data (including inks and images)
from a server via JSON.

If that's what your site does you'll need to find the call to
the server and emulate it from Python.

> And should I be using pickles to write the data in the text file/ save file.

You could. You could also use a database such as SQLite.
It really depends on what you plan on doing with it after
you save it.


-- 
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@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Some error that you may find funny but I can't fix.

2016-01-09 Thread Steven D'Aprano
Hi Lawrence, and welcome!


On Sat, Jan 09, 2016 at 01:17:55PM +, Lawrence Lorenzo wrote:
> 
> Hey, I am very new to the ways of python and am currently experiencing 
> this error. This program is just a novice project set by my school to 
> create an adventure game however I am having issues with being able to 
> set skill points (500) to the users desired skills. Here is what I 
> have done and the error it gives me in the email.

Unfortunately you seem to have forgotten to include the code or error. 
Assuming your code is not too big (say, no more than one or two 
hundred lines), please copy and paste both the code and the full error 
into the body of your email.

Please make sure you turn off "Rich Text" or HTML mail, as that often 
messes up the code and makes it really hard to understand.

Thanks,


-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] idle??

2016-01-09 Thread Chris Warrick
On 8 January 2016 at 20:07, bruce  wrote:
> Hey guys/gals - list readers
>
> Recently came across someone here mentioning IDLE!! -- not knowing
> this. I hit google for a look.
>
> Is IDLE essentially an ide for doing py dev? I see there's a
> windows/linux (rpms) for it.
>
> I'm running py.. I normally do $$python to pop up the py env for quick
> tests.. and of course run my test scripts/apps from the cmdline via
> ./foo.py...
>
> So, where does IDLE fit into this

IDLE is a sad little “IDE”, which is really ugly, because it’s written
in Tk. It lacks many IDE features. It comes with a really basic
debugger (that doesn’t even highlight the line that is being currently
executed…), function signature hinting, and some code completion.

And it doesn’t even do something as basic as line numbering.

Pretty much anything is better than IDLE. I recommend using vim with
the python-mode plugin and YouCompleteMe. The Atom editor can also be
a good Python environment. For fans of full-blown IDEs, there’s
PyCharm.

For experiments, IPython, Jupyter (aka IPython Notebook) or bpython
should be used. They are more capable than the basic interpreter, and
even have more features than IDLE.

-- 
Chris Warrick 
PGP: 5EAAEA16
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Creating a webcrawler

2016-01-09 Thread Steven D'Aprano
On Sat, Jan 09, 2016 at 12:01:35PM +1000, Whom Isac wrote:
> Hi I want to create a web-crawler but dont have any lead to choose any
> module. I have came across the Jsoup but I am not familiar with how to use
> it in 3.5 as I tried looking at a similar web crawler codes from 3.4 dev
> version.
> I just want to build that crawler to crawl through a javascript enable site
> and automatically detect a download link (for video file)
> .

I admire your enthusiasm, but you have set yourself a HUGELY complicated 
project.

If you just want to extract some videos, you might find this 
existing tool (written in Python!) helpful:

http://rg3.github.io/youtube-dl/



> And should I be using pickles to write the data in the text file/ save file.

No.



-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Some error that you may find funny but I can't fix.

2016-01-09 Thread Lawrence Lorenzo



Hey, I am very new to the ways of python and am currently experiencing this 
error. This program is just a novice project set by my school to create an 
adventure game however I am having issues with being able to set skill points 
(500) to the users desired skills. Here is what I have done and the error it 
gives me in the email.


  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Printing a list without square brackets, was Re: Hi Tutor

2016-01-09 Thread Peter Otten
yehudak . wrote:

> I wrote this short program for my grandson:

Nothing against a little help here and there, but solving a problem can be 
fun, and you are taking away some of that fun. 

Does your grandson speak English? You might encourage him to post here 
himself. We bite, but only grandpas ;)
 
> from random import sample
> 
> soups = ['Onion soup', 'Veggie soup', 'Chicken soup', 'Corn soup']
> salads = ['Veggie', 'Onion', 'Cabbage', 'Lettuce', 'Caesar', 'Tomato']
> main = ['Crab cake', 'Catfish', 'Ribs', 'Chopped liver', 'Meat balls']
> beverage = ['Wine', 'Rum', 'Lemonade', 'Red bull', 'Margarita', 'Jin']
> 
> def dish(soups):
> return (sample(soups, 1))
> 
> print('Soup:\t\t', dish(soups))
> print('Salad:\t\t', dish(salads))
> print('Main dish:\t', dish(main))
> print('Beverage:\t', dish(beverage))
> 
> A possible output could be:
> 
> Soup: ['Chicken soup']
> Salad: ['Caesar']
> Main dish: ['Meat balls']
> Beverage: ['Wine']
> 
> How do I get rid from the square brackets and the quotation marks in the
> output?

random.sample(items, n) returns a list of length n. As your sample size is 
one you could use random.choice(items) instead.

>>> import random
>>> soups = ['Onion soup', 'Veggie soup', 'Chicken soup', 'Corn soup']
>>> print("Soup:", random.choice(soups))
Soup: Chicken soup

When you actually want to print multiple strings you can preprocess the list 
with the str.join() method:

>>> print("Two soups:", ", ".join(random.sample(soups, 2)))
Two soups: Veggie soup, Chicken soup


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Hi Tutor

2016-01-09 Thread Martin A. Brown

>I wrote this short program for my grandson:
>
>from random import sample
>
>soups = ['Onion soup', 'Veggie soup', 'Chicken soup', 'Corn soup']
>salads = ['Veggie', 'Onion', 'Cabbage', 'Lettuce', 'Caesar', 'Tomato']
>main = ['Crab cake', 'Catfish', 'Ribs', 'Chopped liver', 'Meat balls']
>beverage = ['Wine', 'Rum', 'Lemonade', 'Red bull', 'Margarita', 'Jin']
>
>def dish(soups):
>return (sample(soups, 1))
>
>print('Soup:\t\t', dish(soups))
>print('Salad:\t\t', dish(salads))
>print('Main dish:\t', dish(main))
>print('Beverage:\t', dish(beverage))
>
>A possible output could be:
>
>Soup: ['Chicken soup']
>Salad: ['Caesar']
>Main dish: ['Meat balls']
>Beverage: ['Wine']
>
>How do I get rid from the square brackets and the quotation marks 
>in the output?

There are many possible answers to this question.  Here's my answer:

  from random import choice

  def dish(options):
  return choice(options)

Then, the function dish() will return exactly one element from the 
options.  Since each of soup, salads, main and beverage are lists 
with string elements, the dish() function will return a string.

I would like to have some Onion soup, the Crab cake, Rum and a 
Caesar, please.

Good luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Creating a webcrawler

2016-01-09 Thread bruce
Hi Isac.

I'm not going to get into the pythonic stuff.. People on the list are
way better than I.  I've been doing a chunk of crawling, it's not too
bad, depending on what you're trying to accomplish and the site you're
targeting.

So, no offense, but I'm going to treat you like a 6 year old (google
it - from a movie!)

You need to back up, and analyze the site/pages/structure you're going
after. Use the tools - firefox - livehttpheaders/nettraffic/etc..
  -you want to be able to see what the exchange is between the
client/browser, as well as the server..
  -often, this gives you the clues/insite to crafting the request from
your client back to the server for the item/data you're going for...

Once you've gotten that together, setup the basic process with
wget/curl etc to get a feel for any weird issues - cert issues?
-security issues - are cookies required - etc.. A good deal of this
stuff can be resolved/checked out at this level, without jumping into
coding..

Once you're comfortable at this point, you can crank out some simple
code to go after the site you're targeting.

In the event you really have a javascript/dynamic site that you can't
handle in any other manner, you're going to need to go use a 'headless
browser' process.

There are a number of headless browser projects - I think most run on
the webit codebase (don't quote me). Casper/phantomjs, there are also
pythonic implementations as well...

So, there you go, should/hopefully this will get you on your way!



On Fri, Jan 8, 2016 at 9:01 PM, Whom Isac  wrote:
> Hi I want to create a web-crawler but dont have any lead to choose any
> module. I have came across the Jsoup but I am not familiar with how to use
> it in 3.5 as I tried looking at a similar web crawler codes from 3.4 dev
> version.
> I just want to build that crawler to crawl through a javascript enable site
> and automatically detect a download link (for video file)
> .
> And should I be using pickles to write the data in the text file/ save file.
> Thanks
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] get aws path from argParser

2016-01-09 Thread ashish makani
+1 to what Alan said.

Its not clear what you are asking & if you are asking something at all.

( to me, it seems like you are answering someone's query & accidentally
posted here on the python tutor mailing list)

sent from mobile device ;
excuse typos & auto-correct errors
On Jan 9, 2016 00:17, "Alan Gauld"  wrote:

> On 08/01/16 14:04, sebastian cheung via Tutor wrote:
> > * take an s3 destination path as an argument optionally containing the
> string ++DATE++ as a placeholder (e.g. s3://my-bucket/objects/++DATE++/,
> s3://my-bucket/objects/++DATE++/file-++DATE++.txt and
> s3://my-bucket/objects/ should all be valid)
> > I already have something for something more simple, but for s3 maybe use
> awscli etc? Thanks Seb
>
> I have no idea what you are asking about (other than I
> assume its something related to AWS?). This is the python
> tutor list for answering questions about the Python language
> and its standard library. Did you mean to post here?
>
> If so you need to give us a bit more information about
> what you are doing and what exactly you want help with.
>
> > def dateType(string):
> > """
> > Convert a date string to a date object
> > """
> > try:
> > date = datetime.datetime.strptime(string, '%Y-%m-%d').date()
> > except ValueError:
> > msg = "%r is not a valid date" % string
> > raise argparse.ArgumentTypeError(msg)
> > return date
> >
> >
> > def is_valid_file(parser, arg):
> > if not os.path.exists(arg):
> > parser.error("The file %s does not exist!" % arg)
> > else:
> > return open(arg, 'r')parser = argparse.ArgumentParser(
> > description="Take CLI options called start-date and end-date,
> which must be formatted -MM-DD. "
> > "These should default to today if not supplied",
> > epilog="See http://bitbucket.org/niceseb/ for details about the
> Project Time Tracker.")
> > parser.add_argument('-e', '--end-date', metavar='DATE', type=dateType,
> default=datetime.date.today(),
> > help='the date tracking data should start at,
> inclusive in the format -MM-DD (defaults to today)')
> > parser.add_argument('-s', '--start-date', metavar='DATE', type=dateType,
> default=datetime.date.today(),
> > help='the date tracking data should end at,
>  inclusive in the format -MM-DD (defaults to today)')
> > parser.add_argument('-v', action='version', version='%(prog)s 1.0')
> > parser.add_argument('-i', dest="filename", required=False, help="input
> file name", metavar="FILE",
> > type=lambda x: is_valid_file(parser, x))
>
>
> --
> 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@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Hi Tutor

2016-01-09 Thread yehudak .
I wrote this short program for my grandson:

from random import sample

soups = ['Onion soup', 'Veggie soup', 'Chicken soup', 'Corn soup']
salads = ['Veggie', 'Onion', 'Cabbage', 'Lettuce', 'Caesar', 'Tomato']
main = ['Crab cake', 'Catfish', 'Ribs', 'Chopped liver', 'Meat balls']
beverage = ['Wine', 'Rum', 'Lemonade', 'Red bull', 'Margarita', 'Jin']

def dish(soups):
return (sample(soups, 1))

print('Soup:\t\t', dish(soups))
print('Salad:\t\t', dish(salads))
print('Main dish:\t', dish(main))
print('Beverage:\t', dish(beverage))

A possible output could be:

Soup: ['Chicken soup']
Salad: ['Caesar']
Main dish: ['Meat balls']
Beverage: ['Wine']

How do I get rid from the square brackets and the quotation marks in the
output?

Thank you.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Some error that you may find funny but I can't fix.

2016-01-09 Thread Lawrence Lorenzo


From: mcshiz...@hotmail.co.uk
To: tutor@python.org
Subject: Some error that you may find funny but I can't fix.
Date: Sat, 9 Jan 2016 13:17:55 +







Hey, I am very new to the ways of python and am currently experiencing this 
error. This program is just a novice project set by my school to create an 
adventure game however I am having issues with being able to set skill points 
(500) to the users desired skills. Here is what I have done and the error it 
gives me in the email.

RE: [Tutor] Some error that you may find funny but I can't fix.Lawrence Lorenzo 
 16:35 To: Steven D'Aprano> Date: Sun, 10 Jan 2016 00:59:18 +1100> From: 
st...@pearwood.info> To: tutor@python.org> CC: mcshiz...@hotmail.co.uk> 
Subject: Re: [Tutor] Some error that you may find funny but I can't fix.> > Hi 
Lawrence, and welcome!> > > On Sat, Jan 09, 2016 at 01:17:55PM +, Lawrence 
Lorenzo wrote:> > > > Hey, I am very new to the ways of python and am currently 
experiencing > > this error. This program is just a novice project set by my 
school to > > create an adventure game however I am having issues with being 
able to > > set skill points (500) to the users desired skills. Here is what I 
> > have done and the error it gives me in the email.> > Unfortunately you seem 
to have forgotten to include the code or error. > Assuming your code is not too 
big (say, no more than one or two > hundred lines), please copy and paste both 
the code and the full error > into the body of your email.> > P
 lease make sure you turn off "Rich Text" or HTML mail, as that often > messes 
up the code and makes it really hard to understand.> > Thanks,> > > -- > 
Stevenimport randomimport timeimport math#the player and NPC class.class 
char(object): #character attributesdef __init__(self, name, health, attack, 
rng, magic, speed):self.name = nameself.health = health
self.attack = attackself.speed = rngself.magic = magic
self.speed =speedskillpoints = 500print(" You have 500 skill points to spend on 
character development so use them wisely.")print("There are 5 skills ""health, 
attack, range, magic and speed"" which you can decide to spend sillpoints 
on.")print("Each skill has a weakness apart from speed which determines who 
attacks first in a battle and if you can flee.")print("You may want to enforce 
a single ability rather than have multiple weaker abilities.")print("note that 
melee beats range, range beats magic, magic beats melee. If you have 
 the same skill points in 2 skills then you won't have a 
weakness.")time.sleep(1)count = 500while (count) > 0:name = input("Please 
enter a character name. ")health = int(input("Enter a number for the 
ammount of points you would like to designate to your characters health. 
Remember you only have 500 and have 5 skills to set. "))(count) = count 
- healthattack = int(input("Enter a number for the ammount of points you 
would like to designate to your characters attack. You only have ", count, " 
remaining and 4 skills to set. "))(count) = count - attackrng = 
int(input("enter a number for the ammount of points you would like to designate 
to your characters range. You only have ", count, " remaining and 3 skills to 
set. "))(count) = count - rngmagic = int(input("enter a number for 
the ammount of points you would like to designate to your characters magic. You 
only have ", count," remaining and 2 skills to set "))(count) = count - 
magicp
 rint ("Your character speed has been set at (", count, ")")speed = 
(count)(count) = 0 
print ("" + name + "your health has been set to " (health))print ("" + name + 
"your attack has been set to " (attack))print ("" + name + "your range has been 
set to " (rng))print ("" + name + "your magic has been set to " (magic))print 
("" + name + "your speed has been set to " (speed))player = [()]
Traceback (most recent call last):  File 
"C:\Users\mcshizney\Desktop\adventuregame.py", line 29, in attack = 
int(input("Enter a number for the ammount of points you would like to designate 
to your characters attack. You only have ", count, " remaining and 4 skills to 
set. "))TypeError: input expected at most 1 arguments, got 3'Code not done 
obviously however here is the error and code.

  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] PLEASE I NEED HELP URGENTLY

2016-01-09 Thread precious akams via Tutor
PLEASE I NEED A LITTLE HELP .
I can figure out what Iam missing in this project

Create a class called BankAccount
.Create a constructor that takes in an integer and assigns this to a `balance` 
property.
.Create a method called `deposit` that takes in cash deposit amount and updates 
the balance accordingly.
.Create a method called `withdraw` that takes in cash withdrawal amount and 
updates the balance accordingly. if amount is greater than balance return 
`"invalid transaction"`
.Create a subclass MinimumBalanceAccount of the BankAccount class

THIS IS MY SOLUTION

class BankAccount:
def_init_(self, initial_amount):
self.balance=initial_amount

def deposit (self, amount):
self.balance+=amount

def withdraw (self, amount):
if self.balance>=amount:
return ('invalid transaction')

class MinimumBalanceAccount(BankAccount):
def _init_(self):
BankAccount_init_(self)

THIS IS THE ERROR MESSAGE I GOT

Internal Error: runTests aborted: TestOutcomeEvent(handled=False, test=, 
result=, outcome='error', exc_info=(, TypeError('this constructor takes no 
arguments',), ), reason=None, expected=False, shortLabel=None, longLabel=None) 
is not JSON serializable
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Python error that you may find funny but I don't get. :)

2016-01-09 Thread Lawrence Lorenzo
Hey, I am very new to the ways of python and am currently experiencing this 
error. This program is just a novice project set by my school to create an 
adventure game however I am having issues with being able to set skill points 
(500) to the users desired skills. Here is what I have done and the error it 
gives me in the email.



import randomimport timeimport math
#the player and NPC class.class char(object): #character attributesdef 
__init__(self, name, health, attack, rng, magic, speed):self.name = 
nameself.health = healthself.attack = attackself.speed 
= rngself.magic = magicself.speed =speedskillpoints = 
500print(" You have 500 skill points to spend on character development so use 
them wisely.")print("There are 5 skills ""health, attack, range, magic and 
speed"" which you can decide to spend sillpoints on.")print("Each skill has a 
weakness apart from speed which determines who attacks first in a battle and if 
you can flee.")print("You may want to enforce a single ability rather than have 
multiple weaker abilities.")print("note that melee beats range, range beats 
magic, magic beats melee. If you have the same skill points in 2 skills then 
you won't have a weakness.")time.sleep(1)
count = 500
while (count) > 0:name = input("Please enter a character name. ")health 
= int(input("Enter a number for the ammount of points you would like to 
designate to your characters health. Remember you only have 500 and have 5 
skills to set. "))(count) = count - healthattack = int(input("Enter 
a number for the ammount of points you would like to designate to your 
characters attack. You only have ", count, " remaining and 4 skills to set. ")) 
   (count) = count - attackrng = int(input("enter a number for the 
ammount of points you would like to designate to your characters range. You 
only have ", count, " remaining and 3 skills to set. "))(count) = count 
- rngmagic = int(input("enter a number for the ammount of points you would 
like to designate to your characters magic. You only have ", count," remaining 
and 2 skills to set "))(count) = count - magicprint ("Your 
character speed has been set at (", count, ")")speed = (count)(count
 ) = 0 

print ("" + name + "your health has been set to " (health))print ("" + name + 
"your attack has been set to " (attack))print ("" + name + "your range has been 
set to " (rng))print ("" + name + "your magic has been set to " (magic))print 
("" + name + "your speed has been set to " (speed))

player = [()]


Traceback (most recent call last):  File 
"C:\Users\mcshizney\Desktop\adventuregame.py", line 29, in attack = 
int(input("Enter a number for the ammount of points you would like to designate 
to your characters attack. You only have ", count, " remaining and 4 skills to 
set. "))TypeError: input expected at most 1 arguments, got 3'



Code not done obviously however here is the error and code.
  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PLEASE I NEED HELP URGENTLY

2016-01-09 Thread David Rock
* precious akams via Tutor  [2016-01-09 19:54]:
> PLEASE I NEED A LITTLE HELP .
> I can figure out what Iam missing in this project
> 
> Create a class called BankAccount
> .Create a constructor that takes in an integer and assigns this to a 
> `balance` property.
> .Create a method called `deposit` that takes in cash deposit amount and 
> updates the balance accordingly.
> .Create a method called `withdraw` that takes in cash withdrawal amount and 
> updates the balance accordingly. if amount is greater than balance return 
> `"invalid transaction"`
> .Create a subclass MinimumBalanceAccount of the BankAccount class
> 
> THIS IS MY SOLUTION
> 
> class BankAccount:
> def_init_(self, initial_amount):
> self.balance=initial_amount
> 
> def deposit (self, amount):
> self.balance+=amount
> 
> def withdraw (self, amount):
> if self.balance>=amount:
> return ('invalid transaction')
> 
> class MinimumBalanceAccount(BankAccount):
> def _init_(self):
> BankAccount_init_(self)
> 
> THIS IS THE ERROR MESSAGE I GOT
> 
> Internal Error: runTests aborted: TestOutcomeEvent(handled=False, test=, 
> result=, outcome='error', exc_info=(, TypeError('this constructor takes no 
> arguments',), ), reason=None, expected=False, shortLabel=None, 
> longLabel=None) is not JSON serializable

This doesn't appear to be all of your code.  What's the code you are running 
that actually generates the traceback?

-- 
David Rock
da...@graniteweb.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PLEASE I NEED HELP URGENTLY

2016-01-09 Thread Alan Gauld
On 09/01/16 19:54, precious akams via Tutor wrote:
> PLEASE I NEED A LITTLE HELP .
> I can figure out what Iam missing in this project
> 

Please post in plain text otherwise the code formatting
gets messed up.

> class BankAccount:
> def_init_(self, initial_amount):
> self.balance=initial_amount

init should have two underscores on each side.
ie
__init__
not
_init_

> TypeError('this constructor takes no arguments'

I'm not sure how you are running your code but thats
not the usual error message format. If posting again
please include details of your OS, python version and
any IDE you are using.


-- 
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@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Some error that you may find funny but I can't fix.

2016-01-09 Thread Alan Gauld
On 09/01/16 19:49, Lawrence Lorenzo wrote:

> Hey, I am very new to the ways of python and am currently experiencing this 
> error. This program is just a novice project set by my school to create an 
> adventure game however I am having issues with being able to set skill points 
> (500) to the users desired skills. Here is what I have done and the error it 
> gives me in the email.

Can you post in plain text please?
Otherwise all your code gets messed up making it
impossible to guess what might be wrong.

> RE: [Tutor] Some error that you may find funny but I can't fix.Lawrence 
> Lorenzo  16:35 To: Steven D'Aprano> Date: Sun, 10 Jan 2016 00:59:18 +1100> 
> From: st...@pearwood.info> To: tutor@python.org> CC: mcshiz...@hotmail.co.uk> 
> Subject: Re: [Tutor] Some error that you may find funny but I can't fix.> > 
> Hi Lawrence, and welcome!> > > On Sat, Jan 09, 2016 at 01:17:55PM +, 
> Lawrence Lorenzo wrote:> > > > Hey, I am very new to the ways of python and 
> am currently experiencing > > this error. This program is just a novice 
> project set by my school to > > create an adventure game however I am having 
> issues with being able to > > set skill points (500) to the users desired 
> skills. Here is what I > > have done and the error it gives me in the email.> 
> > Unfortunately you seem to have forgotten to inc
>  lude the code or error. > Assuming your code is not too big (say, no more 
> than one or two > hundred lines), please copy and paste both the code and the 
> full error > into the body of your email.> > P
>  lease make sure you turn off "Rich Text" or HTML mail, as that often > 
> messes up the code and makes it really hard to understand.> > Thanks,> > > -- 
> > Stevenimport randomimport timeimport math#the player and NPC class.class 
> char(object): #character attributesdef __init__(self, name, health, 
> attack, rng, magic, speed):self.name = nameself.health = 
> healthself.attack = attackself.speed = rngself.magic 
> = magicself.speed =speedskillpoints = 500print(" You have 500 skill 
> points to spend on character development so use them wisely.")print("There 
> are 5 skills ""health, attack, range, magic and speed"" which you can decide 
> to spend sillpoints on.")print("Each skill has a weakness apart from speed 
> which determines who attacks first in a battle and
>   if you can flee.")print("You may want to enforce a single ability rather 
> than have multiple weaker abilities.")print("note that melee beats range, 
> range beats magic, magic beats melee. If you have 
>  the same skill points in 2 skills then you won't have a 
> weakness.")time.sleep(1)count = 500while (count) > 0:name = input("Please 
> enter a character name. ")health = int(input("Enter a number for the 
> ammount of points you would like to designate to your characters health. 
> Remember you only have 500 and have 5 skills to set. "))(count) = 
> count - healthattack = int(input("Enter a number for the ammount of 
> points you would like to designate to your characters attack. You only have 
> ", count, " remaining and 4 skills to set. "))(count) = count - 
> attackrng = int(input("enter a number for the ammount of points you would 
> like to designate to your characters range. You only have ", count, " 
> remaining and 3 skills to set. "))(count) = count - rngmagic = in


-- 
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@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PLEASE I NEED HELP URGENTLY

2016-01-09 Thread Sefa Yıldız
2016-01-09 21:54 GMT+02:00 precious akams via Tutor :
> PLEASE I NEED A LITTLE HELP .

http://www.catb.org/esr/faqs/smart-questions.html

-- 
sayz
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Not sure why the code is giving weird result?

2016-01-09 Thread Whom Isac
Hi, today I tried to help with one of the request in Python tutor about
trailing zeros -6days old.
I don't know why my code is incrementing in number.
Here is the code:

def factorial():
print("Here you will put your factorial")
factVar=int(input("Please input what number to be factorial: \t"))
TValue=0
for i in range(0,factVar+1):
TValue+=i*i+1
print("Your total factorial: "+str(TValue))
return TValue


def trailing_zeros():
   value=factorial()
   dvdVal=1
   divider=1
   totalTrailingZeroes=0

   while dvdVal !=0:
   try:
   answer=0
   answer=int(value/5**(divider))
   totalTrailingZeroes+=answer
   while answer !=0:
   if answer >0:
   answer=int(value/5**(divider+1))
   newanswer=round(answer,1)
   totalTrailingZeroes+=newanswer
   elif answer <=0:
   dvdVal=0
   print(str(TrailingZeroes))


   except Exception:
   print("Sorry About that")


trailing_zeros()



Here is what I tried After ward


###And here is why I tried Afterwards

def factorial():
print("Here you will put your factorial")
factVar=int(input("Please input what number to be factorial: \t"))
TValue=0
for i in range(0,factVar+1):
TValue+=i*i+1
print("Your total factorial: "+str(TValue))

value=TValue
dvdVal=1
divider=1
totalTrailingZeroes=0

answer=int(value/5**(divider))
totalTrailingZeroes+=answer
newanswer=round(answer,1)
while newanswer !=0:
if newanswer >0:
answer=int(value/(5**(divider+1)))
newanswer=round(answer,1)
totalTrailingZeroes+=newanswer
print(str(totalTrailingZeroes))
else:
newanswer=0
print(str(TrailingZeroes))
factorial()

"""
def trailing_zeros():
   value=factorial()
   dvdVal=1
   divider=1
   totalTrailingZeroes=0

   while dvdVal !=0:
   try:
   answer=0
   answer=value/5**(divider)
   totalTrailingZeroes+=answer
   while answer !=0:
   if answer >0:
   answer=value/5**(divider+1)
   newanswer=round(answer,1)
   totalTrailingZeroes+=newanswer
   elif answer <=0:
   dvdVal=0
   print(str(TrailingZeroes))


   except Exception:
   print("Sorry About that")


trailing_zeros()

"""
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Creating a webcrawler

2016-01-09 Thread Whom Isac
Hi I want to create a web-crawler but dont have any lead to choose any
module. I have came across the Jsoup but I am not familiar with how to use
it in 3.5 as I tried looking at a similar web crawler codes from 3.4 dev
version.
I just want to build that crawler to crawl through a javascript enable site
and automatically detect a download link (for video file)
.
And should I be using pickles to write the data in the text file/ save file.
Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Not sure why the code is giving weird result?

2016-01-09 Thread Peter Otten
Whom Isac wrote:

> Hi, today I tried to help with one of the request in Python tutor about
> trailing zeros -6days old.
> I don't know why my code is incrementing in number.
> Here is the code:
> 
> def factorial():
> print("Here you will put your factorial")
> factVar=int(input("Please input what number to be factorial: \t"))
> TValue=0
> for i in range(0,factVar+1):
> TValue+=i*i+1

That's not the "factorial". Look up its definition, change the loop 
accordingly, and if the result still isn't correct put 

  print(TValue)

in the for loop to ensure that it calculates what you think it does.

>   answer=int(value/5**(divider))

Just a general remark as I haven't checked the complete function. Python has 
an integer division operator that allows to write this

answer = value // 5**divider

This gives the correct answer where the use of float in intermediate values 
introduces errors. Compare:

>>> int(10**24 / 5)
199983222784
>>> 10**24 // 5
2000


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor