[Tutor] os.getcwd() confusion

2013-05-19 Thread spangled spanner
G'day, I have a comprehension issue here! I have made two simple scripts: ## script1 import os print os.getcwd() - ## script 2 import os f = open('test', 'wb') f.write(os.getcwd()) f.close() _ Both scripts are in my home directory. Using bash I c

Re: [Tutor] Retrieving data from a web site

2013-05-19 Thread Phil
On 19/05/13 18:05, Peter Otten wrote: The original Python 2 code: $ cat parse.py import urllib2 import json url = "http://*/goldencasket"; s = urllib2.urlopen(url).read() s = s.partition("latestResults_productResults")[2].lstrip(" =") s = s.partition(";")[0] data = json.loads(s) lot

Re: [Tutor] from import works but I'm flubbing a package import

2013-05-19 Thread Dave Angel
On 05/19/2013 09:30 PM, Jim Mooney wrote: Still puzzling on imports. I have the jimlib module in Lib with the proper __init__.py . Inside it is the program bark.py, with data item zarf that contains string 'fraz' It also contains the function barker. def barker(): print 'bark, bark' If I

[Tutor] from import works but I'm flubbing a package import

2013-05-19 Thread Jim Mooney
Still puzzling on imports. I have the jimlib module in Lib with the proper __init__.py . Inside it is the program bark.py, with data item zarf that contains string 'fraz' It also contains the function barker. def barker(): print 'bark, bark' If I do the below everything works: from jimlib i

Re: [Tutor] model methods in Django

2013-05-19 Thread eryksun
On Sun, May 19, 2013 at 10:49 AM, Matthew Ngaha wrote: > On Sun, May 19, 2013 at 3:34 PM, Steven D'Aprano wrote: >> Matthew, who are you quoting? Your email program should automatically insert >> an attribution line, such as the one just below. Without that attribution >> line, it is hard to foll

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
On Sun, May 19, 2013 at 3:34 PM, Steven D'Aprano wrote: > Matthew, who are you quoting? Your email program should automatically insert > an attribution line, such as the one just below. Without that attribution > line, it is hard to follow the conversation, as we can't tell who you are > quoting.

Re: [Tutor] Beginner level: Why doesn't my code work?

2013-05-19 Thread Peter Otten
Rafael Knuth wrote: > Thank you, I am using Python 3.3.0 [Oscar] > In Python 3 you should use input(). In Python 2 you should use > raw_input(). I'm guessing that you're using Python 2. In Python 2 the > input() function tries to evaluate whatever the user types in as if it > was Python code. Sin

Re: [Tutor] model methods in Django

2013-05-19 Thread Steven D'Aprano
Matthew, who are you quoting? Your email program should automatically insert an attribution line, such as the one just below. Without that attribution line, it is hard to follow the conversation, as we can't tell who you are quoting. On 20/05/13 00:23, Matthew Ngaha wrote: class Poll(models.Mo

Re: [Tutor] Beginner level: Why doesn't my code work?

2013-05-19 Thread Steven D'Aprano
On 19/05/13 23:38, Rafael Knuth wrote: Thank you, I am using Python 3.3.0 Based on the error you show, I doubt that very much. As for the HTML ... I copied the code from the Python Shell - should I post code as a screenshot? Would that resolve that issue you mentioned? No. It has nothing t

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
> options.py is the biggest module in the admin package. The link I > posted is to the get_actions method of ModelAdmin. In the tutorial, > PollAdmin extends this class. > oh ok thanks, yes i will definately look through it > I'm not coming from any framework. My knowledge of web development is >

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
> class Poll(models.Model): > > question = models.CharField(max_length=200) > pub_date = models.DateTimeField('date published') > > > > def was_published_recently(self): > return self.pub_date >= timezone.now() - datetime.timedelta(days=1) > > # > > > was_published_recen

Re: [Tutor] model methods in Django

2013-05-19 Thread eryksun
On Sun, May 19, 2013 at 7:20 AM, Matthew Ngaha wrote: > Thanks that does clear it up. Also thats a huge script you linked, can options.py is the biggest module in the admin package. The link I posted is to the get_actions method of ModelAdmin. In the tutorial, PollAdmin extends this class. > i a

Re: [Tutor] Beginner level: Why doesn't my code work?

2013-05-19 Thread Rafael Knuth
Hello, please post in plain text (not html) in future. Also you should mention what version of Python you're using as it makes a dfference in this case. Thank you, I am using Python 3.3.0 As for the HTML ... I copied the code from the Python Shell - should I post code as a screenshot? Would that r

Re: [Tutor] model methods in Django

2013-05-19 Thread John Steedman
For the benefit of others,I believe the full class (from the Django Tutorial) is class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def was_published_recently(self): return self.pub_date >= timezone.now() - d

Re: [Tutor] Beginner level: Why doesn't my code work?

2013-05-19 Thread Oscar Benjamin
On 19 May 2013 14:04, Rafael Knuth wrote: > Hello, Hello, please post in plain text (not html) in future. Also you should mention what version of Python you're using as it makes a dfference in this case. > > here's a tiny little program I wrote: > > import random > > print(""" > > This is a magi

Re: [Tutor] Retrieving data from a web site

2013-05-19 Thread Phil
On 19/05/13 21:46, Dave Angel wrote: Have you simply tried using urlib.request ? That should be built into Python 3.3 without any outside packages from Kubuntu. (I haven't used Kubuntu, just making some bald assumptions) Thanks Dave, Thanks Dave, The urllib.request package has the same depe

[Tutor] Beginner level: Why doesn't my code work?

2013-05-19 Thread Rafael Knuth
Hello, here's a tiny little program I wrote: import random print(""" This is a magic super computer. He will ask you a couple of questions. An ultra-complicated algorithm will then figure out what your favorite meal is. """) name = str(input("What is your name? ")) age = int(input("How old

[Tutor] Fwd: spyder

2013-05-19 Thread bob gailer
Original Message Subject:spyder Date: Sat, 18 May 2013 19:20:12 -0400 From: bob gailer To: ricar...@gmail.com Following your recommendation I installed spyder using the Windows installer. Now what do I do to run it. I found no useful guidance in the online do

Re: [Tutor] Retrieving data from a web site

2013-05-19 Thread Dave Angel
On 05/19/2013 07:30 AM, Phil wrote: On 19/05/13 18:05, Peter Otten wrote: Phil wrote: My apatite having been whetted I'm now stymied because of a Ubuntu dependency problem during the installation of urllib3. This is listed as a bug. Has anyone overcome this problem? Perhaps there's another li

Re: [Tutor] Retrieving data from a web site

2013-05-19 Thread Phil
On 19/05/13 18:05, Peter Otten wrote: Phil wrote: My apatite having been whetted I'm now stymied because of a Ubuntu dependency problem during the installation of urllib3. This is listed as a bug. Has anyone overcome this problem? Perhaps there's another library that I can use to download data

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
> The default description is the name with underscores removed, unless > you set a custom description in the function's "short_description" > attribute. I'm not experienced with Django, so I can't ramble off lots > of examples, but hopefully you get the gist. Thanks that does clear it up. Also tha

Re: [Tutor] model methods in Django

2013-05-19 Thread eryksun
On Sun, May 19, 2013 at 6:35 AM, Matthew Ngaha wrote: > > if you look at the diagram under that function, why is the value of > "was_published_recently.short_description" the title of that field? > replacing the old title? is a "short_desccription" attribute set > somewhere in django being inactiv

Re: [Tutor] why is unichr(sys.maxunicode) blank?

2013-05-19 Thread Albert-Jan Roskam
- Original Message - > From: Steven D'Aprano > To: tutor@python.org > Cc: > Sent: Sunday, May 19, 2013 3:34 AM > Subject: Re: [Tutor] why is unichr(sys.maxunicode) blank? > > On 19/05/13 02:45, Albert-Jan Roskam wrote about locales: > >> It is pretty sick that all these things can b

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
Thanks guys i had no idea about these method attributes and also these underlying oop __objects__ @ eryksun i understand your explanation, im still having trouble figuring out how django is being used in the tutorial. class Poll(models.Model): # ... def was_published_recently(self):

Re: [Tutor] Retrieving data from a web site

2013-05-19 Thread Peter Otten
Phil wrote: > My apatite having been whetted I'm now stymied because of a Ubuntu > dependency problem during the installation of urllib3. This is listed as > a bug. Has anyone overcome this problem? > > Perhaps there's another library that I can use to download data from a > web page? You mean y

Re: [Tutor] Tutor Digest, Vol 111, Issue 61

2013-05-19 Thread eryksun
On Sun, May 19, 2013 at 3:37 AM, Jim Mooney wrote: > > Since Python on Win 7 can already find modules in Lib (and in > site-packages, under Lib) can I assume that it will find any > directories fabricated as mentioned, that are put in Lib or one of its > subdirectories, without doing anything furt

Re: [Tutor] Tutor Digest, Vol 111, Issue 61

2013-05-19 Thread Jim Mooney
> 1) The directory must be somewhere that Python will see it, no different from > a single file module. That means, in the current directory, or your > PYTHONPATH. Since Python on Win 7 can already find modules in Lib (and in site-packages, under Lib) can I assume that it will find any director