Re: [Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread Albert-Jan Roskam
From: Tutor on behalf of GMX Sent: Monday, September 11, 2017 9:38 AM To: tutor@python.org Subject: [Tutor] How to create an object in database only if the object is not already there? Now when I create a Course object

Re: [Tutor] question about calendar module in standard libriary

2017-09-11 Thread Peter Otten
Айнур Зулькарнаев wrote: > Hello all! > > > There is a class Calendar in calendar.py in standard libriary. > > > class Calendar(object): > """ > Base calendar class. This class doesn't do any formatting. It > simply provides data to subclasses. > """ > >

Re: [Tutor] question about calendar module in standard libriary

2017-09-11 Thread Steven D'Aprano
On Mon, Sep 11, 2017 at 10:58:51AM +, Айнур Зулькарнаев wrote: > class Calendar(object): > def __init__(self, firstweekday=0): > self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday > > def getfirstweekday(self): > return self._firstweekday % 7 > > def

Re: [Tutor] question about calendar module in standard libriary

2017-09-11 Thread Alan Gauld via Tutor
On 11/09/17 11:58, Айнур Зулькарнаев wrote: > So, the question is why not explicitly raise ValueError if > user enters the firstweekday parameter bigger that 6 Its a valid question but you probably need to find the original PEP document to find the answer and that module has been around for a

Re: [Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread Alan Gauld via Tutor
On 11/09/17 10:38, GMX wrote: > I am using `pony` orm to write a simple class as my model. pony is not a standard module (indeed I only heard about it from your email) so you are probably best asking on the pony support forum if such exists or via the author. > from pony.orm import Database >

[Tutor] question about calendar module in standard libriary

2017-09-11 Thread Айнур Зулькарнаев
Hello all! There is a class Calendar in calendar.py in standard libriary. class Calendar(object): """ Base calendar class. This class doesn't do any formatting. It simply provides data to subclasses. """ def __init__(self, firstweekday=0):

[Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread GMX
Hi,  I am using `pony` orm to write a simple class as my model. Here is the class.  ``` from pony.orm import Database from pony.orm import Required, Optional from pony.orm import db_session from pony.orm import select, commit DB_PATH = ‘db.sqlite’ db = Database() class Course(db.Entity):