From shashidhar85 at gmail.com Fri Feb 1 08:19:04 2013 From: shashidhar85 at gmail.com (Shashidhar Paragonda) Date: Fri, 1 Feb 2013 12:49:04 +0530 Subject: [BangPypers] [ OpenGL ] [ Python ] [ Library ] ? In-Reply-To: <510A373D.4050200@jtoomim.org> References: <510A373D.4050200@jtoomim.org> Message-ID: Hi Jonathan, >>> Thanks for suggestions, I'll definately have a look of this library. On Thu, Jan 31, 2013 at 2:49 PM, Jonathan Toomim wrote: > Take a look at pyglet. It's an AV library built on top of OpenGL with a > ton of additional features; it also makes all of OpenGL available in the > pyglet.gl module using a ctypes interface. > > http://www.pyglet.org/doc/**programming_guide/the_opengl_**interface.html > > It might not be the best package for you (pyopengl may be better), but > it's definitely worth a look. > > Jonathan > > > On 1/30/2013 1:20 AM, Shashidhar Paragonda wrote: > >> Dear Python hackers, >> >> >>> I am new to OpenGL world and staring to work on some 3D >> graphics >> project. >> >>> My request is which is best / good python OpenGL library to >> start working ( with documnetation ) ? >> >>> Thanks in advance for you help / suggestions / guidelines >> >> > ______________________________**_________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/**mailman/listinfo/bangpypers > -- ----------------------------------- Regards, Shashidhar N.Paragonda shashidhar85 at gmail.com +919449073835 From nitin.nitp at gmail.com Fri Feb 1 10:46:38 2013 From: nitin.nitp at gmail.com (Nitin Kumar) Date: Fri, 1 Feb 2013 15:16:38 +0530 Subject: [BangPypers] trust/certify python exe Message-ID: Hi All, I am trying to automate one of the application. This application (few fuctions which need high security) allow only those exe to access there APIs which are trusted. As python is not trusted, is there way we can trust/certify python exe/dlls? I tried blow command but of no use for me d:\visual studio 2010p\vc\bin>signtool sign /a c:\Python27\python.exe SignTool Error: No certificates were found that met all the given criteria. -- Nitin K From baiju.m.mail at gmail.com Fri Feb 1 11:14:33 2013 From: baiju.m.mail at gmail.com (Baiju M) Date: Fri, 1 Feb 2013 15:44:33 +0530 Subject: [BangPypers] trust/certify python exe In-Reply-To: References: Message-ID: Hi Nitin, The procedure to verify Python EXEs is given here (using PGP/GPG): http://www.python.org/download/#openpgp-public-keys On Fri, Feb 1, 2013 at 3:16 PM, Nitin Kumar wrote: > Hi All, > > I am trying to automate one of the application. > This application (few fuctions which need high security) allow only those > exe to access there APIs which are trusted. > > As python is not trusted, is there way we can trust/certify python exe/dlls? > > I tried blow command but of no use for me > > d:\visual studio 2010p\vc\bin>signtool sign /a c:\Python27\python.exe > SignTool Error: No certificates were found that met all the given criteria. > > -- > Nitin K > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers From saager.mhatre at gmail.com Fri Feb 1 11:55:51 2013 From: saager.mhatre at gmail.com (Saager Mhatre) Date: Fri, 1 Feb 2013 16:25:51 +0530 Subject: [BangPypers] Interactive shell for python application In-Reply-To: References: Message-ID: On Mon, Jan 28, 2013 at 7:42 PM, JAGANADH G wrote: > I need a shell like environment for my program batteries included? http://docs.python.org/3/library/cmd.html - d From anandology at gmail.com Mon Feb 4 06:29:48 2013 From: anandology at gmail.com (Anand Chitipothu) Date: Mon, 4 Feb 2013 10:59:48 +0530 Subject: [BangPypers] [Commercial] Python Training Course Message-ID: Hi, I'm conducting a two day hands-on training course on Python programming on February 16 & 17. For more information and registration, please visit the course page at: http://pythontraining-feb2013.doattend.com/ Please contact me offline if you have any questions. Thanks, Anand http://anandology.com/ From nitin.nitp at gmail.com Mon Feb 4 07:07:22 2013 From: nitin.nitp at gmail.com (Nitin Kumar) Date: Mon, 4 Feb 2013 11:37:22 +0530 Subject: [BangPypers] trust/certify python exe In-Reply-To: References: Message-ID: Thanks Baiju, But as the link suggest "Source and binary executables are signed by the release manager using *their* OpenPGP key" These personal signature wont work. Isn't there any sign from trusted source say Microsoft, verisign etc? Nitin K Nitin K On Fri, Feb 1, 2013 at 3:44 PM, Baiju M wrote: > Hi Nitin, > > The procedure to verify Python EXEs is given here (using PGP/GPG): > http://www.python.org/download/#openpgp-public-keys > > On Fri, Feb 1, 2013 at 3:16 PM, Nitin Kumar wrote: > > Hi All, > > > > I am trying to automate one of the application. > > This application (few fuctions which need high security) allow only those > > exe to access there APIs which are trusted. > > > > As python is not trusted, is there way we can trust/certify python > exe/dlls? > > > > I tried blow command but of no use for me > > > > d:\visual studio 2010p\vc\bin>signtool sign /a c:\Python27\python.exe > > SignTool Error: No certificates were found that met all the given > criteria. > > > > -- > > Nitin K > > _______________________________________________ > > BangPypers mailing list > > BangPypers at python.org > > http://mail.python.org/mailman/listinfo/bangpypers > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From baiju.m.mail at gmail.com Mon Feb 4 07:38:09 2013 From: baiju.m.mail at gmail.com (Baiju M) Date: Mon, 4 Feb 2013 12:08:09 +0530 Subject: [BangPypers] trust/certify python exe In-Reply-To: References: Message-ID: Hi Nithin, Those individuals keys will be signed by many others. Sometimes during key signing party: http://en.wikipedia.org/wiki/Key_signing_party See somebody who you can trust has been signed those keys. On Mon, Feb 4, 2013 at 11:37 AM, Nitin Kumar wrote: > Thanks Baiju, > > But as the link suggest "Source and binary executables are signed by the > release manager using *their* OpenPGP key" > These personal signature wont work. Isn't there any sign from trusted > source say > Microsoft, verisign etc? > > Nitin K > > > Nitin K > > > On Fri, Feb 1, 2013 at 3:44 PM, Baiju M wrote: > >> Hi Nitin, >> >> The procedure to verify Python EXEs is given here (using PGP/GPG): >> http://www.python.org/download/#openpgp-public-keys >> >> On Fri, Feb 1, 2013 at 3:16 PM, Nitin Kumar wrote: >> > Hi All, >> > >> > I am trying to automate one of the application. >> > This application (few fuctions which need high security) allow only those >> > exe to access there APIs which are trusted. >> > >> > As python is not trusted, is there way we can trust/certify python >> exe/dlls? >> > >> > I tried blow command but of no use for me >> > >> > d:\visual studio 2010p\vc\bin>signtool sign /a c:\Python27\python.exe >> > SignTool Error: No certificates were found that met all the given >> criteria. >> > >> > -- >> > Nitin K >> > _______________________________________________ >> > BangPypers mailing list >> > BangPypers at python.org >> > http://mail.python.org/mailman/listinfo/bangpypers >> _______________________________________________ >> BangPypers mailing list >> BangPypers at python.org >> http://mail.python.org/mailman/listinfo/bangpypers >> > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers From maniandram01 at gmail.com Mon Feb 4 13:53:56 2013 From: maniandram01 at gmail.com (Ramchandra Apte) Date: Mon, 4 Feb 2013 18:23:56 +0530 Subject: [BangPypers] trust/certify python exe In-Reply-To: References: Message-ID: I don't think the Python binaries are signed by Microsoft; it is quite costly to certify every release (even minor ones) On 4 February 2013 12:08, Baiju M wrote: > Hi Nithin, > > Those individuals keys will be signed by many others. Sometimes during > key signing party: > http://en.wikipedia.org/wiki/Key_signing_party > > See somebody who you can trust has been signed those keys. > > > On Mon, Feb 4, 2013 at 11:37 AM, Nitin Kumar wrote: > > Thanks Baiju, > > > > But as the link suggest "Source and binary executables are signed by the > > release manager using *their* OpenPGP key" > > These personal signature wont work. Isn't there any sign from trusted > > source say > > Microsoft, verisign etc? > > > > Nitin K > > > > > > Nitin K > > > > > > On Fri, Feb 1, 2013 at 3:44 PM, Baiju M wrote: > > > >> Hi Nitin, > >> > >> The procedure to verify Python EXEs is given here (using PGP/GPG): > >> http://www.python.org/download/#openpgp-public-keys > >> > >> On Fri, Feb 1, 2013 at 3:16 PM, Nitin Kumar > wrote: > >> > Hi All, > >> > > >> > I am trying to automate one of the application. > >> > This application (few fuctions which need high security) allow only > those > >> > exe to access there APIs which are trusted. > >> > > >> > As python is not trusted, is there way we can trust/certify python > >> exe/dlls? > >> > > >> > I tried blow command but of no use for me > >> > > >> > d:\visual studio 2010p\vc\bin>signtool sign /a c:\Python27\python.exe > >> > SignTool Error: No certificates were found that met all the given > >> criteria. > >> > > >> > -- > >> > Nitin K > >> > _______________________________________________ > >> > BangPypers mailing list > >> > BangPypers at python.org > >> > http://mail.python.org/mailman/listinfo/bangpypers > >> _______________________________________________ > >> BangPypers mailing list > >> BangPypers at python.org > >> http://mail.python.org/mailman/listinfo/bangpypers > >> > > _______________________________________________ > > BangPypers mailing list > > BangPypers at python.org > > http://mail.python.org/mailman/listinfo/bangpypers > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From karra.etc at gmail.com Tue Feb 5 11:47:08 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 5 Feb 2013 16:17:08 +0530 Subject: [BangPypers] Interactive shell for python application In-Reply-To: References: Message-ID: On Mon, Jan 28, 2013 at 7:42 PM, JAGANADH G wrote: > Is there any way to do the same. Any pointers to some examples or > tutorials. > Er, did you try printing some log messages to keep you updated about the progress? In case you want something more heavy weight: (and perhaps a bit over kill for this..) Check out: http://code.activestate.com/recipes/576515/ Go through that link. It's awesome. With that code included in your program once you send your program a SIGUSR1 it will interrupt the execution of your code and immediately drop into a python prompt so you can access the complete program state. As I said it is perhaps over kill if you jus want to know if your script is running or not... but wth, really. :) From karra.etc at gmail.com Tue Feb 5 17:28:36 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 5 Feb 2013 21:58:36 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column Message-ID: I have a Declarative table defined as follows: class Consultation(Base): __tablename__ = 'consultation' id = Column(Integer, primary_key=True) patient_id = Column(Integer, ForeignKey('patient.id')) doctor_id = Column(Integer, ForeignKey('doctor.id')) date = Column(Date(), default=MyT.today()) Each row in this table represents a single consultation instance of a patient seeing a doctor on a given day. I would like an additional attribute called "cid" that should be an auto-incrementing value representing how many-th consultation it was in that day. Basically it is an auto-incrementing counter, which gets reset to 0 at the start of a day (hence not unique, whereas the id will be unique). No row is ever deleted. How do I do achieve this with the least amount of additional database space? It is trivial to have another table with one column for date and another column for the total consultations thus far. Any help? -Karra P.S. This is for PRS - an open source patient record system for small clinics I am developing, and available at: https://github.com/skarra/PRS From vinod.narasimhaiah at gmail.com Wed Feb 6 06:45:39 2013 From: vinod.narasimhaiah at gmail.com (Vinod Kumar Narasimhaiah) Date: Wed, 6 Feb 2013 11:15:39 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: I am not a python programmer, but how about this logic? add new field called "consultation_count" to the same table before every insert to the table: Check if the date field on the last record (you might want to add a timestamp field to get the last record easily) = today's date If yes, then it's the same day- take the consultation count from the last record, increment it by one and create the new record. If No, then it's a start of the new day- set the counter to 1 and create the new record. On Tue, Feb 5, 2013 at 9:58 PM, Sriram Karra wrote: > I have a Declarative table defined as follows: > > class Consultation(Base): > __tablename__ = 'consultation' > > id = Column(Integer, primary_key=True) > patient_id = Column(Integer, ForeignKey('patient.id')) > doctor_id = Column(Integer, ForeignKey('doctor.id')) > date = Column(Date(), default=MyT.today()) > > Each row in this table represents a single consultation instance of a > patient seeing a doctor on a given day. > > I would like an additional attribute called "cid" that should be an > auto-incrementing value representing how many-th consultation it was in > that day. Basically it is an auto-incrementing counter, which gets reset to > 0 at the start of a day (hence not unique, whereas the id will be unique). > No row is ever deleted. > > How do I do achieve this with the least amount of additional database > space? It is trivial to have another table with one column for date and > another column for the total consultations thus far. > > Any help? > > -Karra > > P.S. This is for PRS - an open source patient record system for small > clinics I am developing, and available at: https://github.com/skarra/PRS > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From dhruvbaldawa at gmail.com Wed Feb 6 07:02:45 2013 From: dhruvbaldawa at gmail.com (Dhruv Baldawa) Date: Wed, 6 Feb 2013 11:32:45 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: I would do a: class Consultation(Base): __tablename__ = 'consultation' id = Column(Integer, primary_key=True) patient_id = Column(Integer, ForeignKey('patient.id')) doctor_id = Column(Integer, ForeignKey('doctor.id')) date = Column(Date(), default=MyT.today()) @property def consultation_count(self): ''' returns the consultation count for current date ''' return self.query.filter_by(date=self.date).count() # the syntax might not be correct c = Consultation.query.get(1) print c.consultation_count This way its computed on the fly and you dont need to store it. -- Dhruv Baldawa (http://www.dhruvb.com) On Wed, Feb 6, 2013 at 11:15 AM, Vinod Kumar Narasimhaiah < vinod.narasimhaiah at gmail.com> wrote: > I am not a python programmer, but how about this logic? > > add new field called "consultation_count" to the same table > > before every insert to the table: > > Check if the date field on the last record (you might want to add a > timestamp field to get the last record easily) = today's date > > If yes, then it's the same day- > take the consultation count from the last record, increment it by one > and create the new record. > If No, then it's a start of the new day- > set the counter to 1 and create the new record. > > > > On Tue, Feb 5, 2013 at 9:58 PM, Sriram Karra wrote: > > > I have a Declarative table defined as follows: > > > > class Consultation(Base): > > __tablename__ = 'consultation' > > > > id = Column(Integer, primary_key=True) > > patient_id = Column(Integer, ForeignKey('patient.id')) > > doctor_id = Column(Integer, ForeignKey('doctor.id')) > > date = Column(Date(), default=MyT.today()) > > > > Each row in this table represents a single consultation instance of a > > patient seeing a doctor on a given day. > > > > I would like an additional attribute called "cid" that should be an > > auto-incrementing value representing how many-th consultation it was in > > that day. Basically it is an auto-incrementing counter, which gets reset > to > > 0 at the start of a day (hence not unique, whereas the id will be > unique). > > No row is ever deleted. > > > > How do I do achieve this with the least amount of additional database > > space? It is trivial to have another table with one column for date and > > another column for the total consultations thus far. > > > > Any help? > > > > -Karra > > > > P.S. This is for PRS - an open source patient record system for small > > clinics I am developing, and available at: https://github.com/skarra/PRS > > _______________________________________________ > > BangPypers mailing list > > BangPypers at python.org > > http://mail.python.org/mailman/listinfo/bangpypers > > > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From karra.etc at gmail.com Wed Feb 6 07:17:52 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Wed, 6 Feb 2013 11:47:52 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: On Wed, Feb 6, 2013 at 11:32 AM, Dhruv Baldawa wrote: > I would do a: > > class Consultation(Base): > __tablename__ = 'consultation' > > id = Column(Integer, primary_key=True) > patient_id = Column(Integer, ForeignKey('patient.id')) > doctor_id = Column(Integer, ForeignKey('doctor.id')) > date = Column(Date(), default=MyT.today()) > > @property > def consultation_count(self): > ''' returns the consultation count for current date ''' > return self.query.filter_by(date=self.date).count() # the syntax > might not be correct > > c = Consultation.query.get(1) > print c.consultation_count > > This way its computed on the fly and you dont need to store it. > If I read your code correctly this would mean: (a) the consultation_count property for all the consutlations that happened on a given day will be the same value (b) for a given row this value will keep changing as we insert more records into the table. So this will not work, no? From karra.etc at gmail.com Wed Feb 6 07:20:13 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Wed, 6 Feb 2013 11:50:13 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: Vinod, thanks for these inputs. Part of hte problem is the SQLAlchemy syntax itself and getting it to work! Further, in the actual use case, I cannot assume that the records will be inserted in the serial order of day. A patient can call and make an appointment for a later date, and after that a patient might walk in for the same day. Hm... -Karra On Wed, Feb 6, 2013 at 11:15 AM, Vinod Kumar Narasimhaiah < vinod.narasimhaiah at gmail.com> wrote: > I am not a python programmer, but how about this logic? > > add new field called "consultation_count" to the same table > > before every insert to the table: > > Check if the date field on the last record (you might want to add a > timestamp field to get the last record easily) = today's date > > If yes, then it's the same day- > take the consultation count from the last record, increment it by one > and create the new record. > If No, then it's a start of the new day- > set the counter to 1 and create the new record. > > > > On Tue, Feb 5, 2013 at 9:58 PM, Sriram Karra wrote: > > > I have a Declarative table defined as follows: > > > > class Consultation(Base): > > __tablename__ = 'consultation' > > > > id = Column(Integer, primary_key=True) > > patient_id = Column(Integer, ForeignKey('patient.id')) > > doctor_id = Column(Integer, ForeignKey('doctor.id')) > > date = Column(Date(), default=MyT.today()) > > > > Each row in this table represents a single consultation instance of a > > patient seeing a doctor on a given day. > > > > I would like an additional attribute called "cid" that should be an > > auto-incrementing value representing how many-th consultation it was in > > that day. Basically it is an auto-incrementing counter, which gets reset > to > > 0 at the start of a day (hence not unique, whereas the id will be > unique). > > No row is ever deleted. > > > > How do I do achieve this with the least amount of additional database > > space? It is trivial to have another table with one column for date and > > another column for the total consultations thus far. > > > > Any help? > > > > -Karra > > > > P.S. This is for PRS - an open source patient record system for small > > clinics I am developing, and available at: https://github.com/skarra/PRS > > _______________________________________________ > > BangPypers mailing list > > BangPypers at python.org > > http://mail.python.org/mailman/listinfo/bangpypers > > > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From dhruvbaldawa at gmail.com Wed Feb 6 07:35:05 2013 From: dhruvbaldawa at gmail.com (Dhruv Baldawa) Date: Wed, 6 Feb 2013 12:05:05 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: OK I misread. Let me see if I understood your problem correctly. 1. All the consultations will be stored in that table. 2. When you have a Consultation object, you need a `consultation_count` property for the number of consultation for that day. So, this should work now, according to me: def generate_consultation_id(date): return Consultation.query.filter_by(data=data).count() + 1 class Consultation(Base): ... cid = Column(Integer, default=generate_consultation_id) This should work, according to me. The function is called while adding the id to the database. Reference -- Dhruv Baldawa (http://www.dhruvb.com) On Wed, Feb 6, 2013 at 11:47 AM, Sriram Karra wrote: > On Wed, Feb 6, 2013 at 11:32 AM, Dhruv Baldawa >wrote: > > > I would do a: > > > > class Consultation(Base): > > __tablename__ = 'consultation' > > > > id = Column(Integer, primary_key=True) > > patient_id = Column(Integer, ForeignKey('patient.id')) > > doctor_id = Column(Integer, ForeignKey('doctor.id')) > > date = Column(Date(), default=MyT.today()) > > > > @property > > def consultation_count(self): > > ''' returns the consultation count for current date ''' > > return self.query.filter_by(date=self.date).count() # the syntax > > might not be correct > > > > c = Consultation.query.get(1) > > print c.consultation_count > > > > This way its computed on the fly and you dont need to store it. > > > > If I read your code correctly this would mean: > > (a) the consultation_count property for all the consutlations that happened > on a given day will be the same value > (b) for a given row this value will keep changing as we insert more records > into the table. > > So this will not work, no? > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From thavamuni at gmail.com Wed Feb 6 09:07:12 2013 From: thavamuni at gmail.com (Thava Alagu) Date: Wed, 6 Feb 2013 13:37:12 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column Message-ID: Hi Karra, > Further, in the actual use case, I cannot assume that the records will be > inserted in the serial order of day. A patient can call and make an > appointment for a later date, and after that a patient might walk in for > the same day. Hm... > > -Karra Since you want more flexible system, I recommend that you add more columns-- apt date, reservation date, actual visit date and *time* of consultation. To maintain our own sanity when records are accidentally updated, this will help to trace the problem. Not sure if you want the 'consultation-day-id' as a handy parameter for reference *after* the consultation or even before the consultation. If it is for before-use, then you can generate the 'priority-of-the-day-id' by writing a query which depends on the apt-date. If it is for later-use, you can require that the consultation-time be unique, (data-entry operator can probably re-enter the record to adjust the minute or even seconds to make the record unique). You can derive the consultation-id from the consultation time either by post bulk processing or generating it on the fly. I have not used SQLAlchemy, but almost all database systems require you that there is only one built-in auto-increment column per table. If you want more, you will have to simulate it. One alternative is to use just another 'auxilary-table' just for the purpose of generating auto-increment value which you can use it to explicitly insert on to other table-- not recommended, but there is a way. In a nutshell, it seems to me that the real information you need in there is the actual-consultation-time to be precise. Ignoring that and adding numerous other data and trying to keep them consistent may not help. Just some initial thoughts and impressions from me. Regards, -thava On Wed, Feb 6, 2013 at 11:50 AM, wrote: > Send BangPypers mailing list submissions to > bangpypers at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/bangpypers > or, via email, send a message with subject or body 'help' to > bangpypers-request at python.org > > You can reach the person managing the list at > bangpypers-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of BangPypers digest..." > > > Today's Topics: > > 1. SQLAlchemy and 'non-trivial' default values for a column > (Sriram Karra) > 2. Re: SQLAlchemy and 'non-trivial' default values for a column > (Vinod Kumar Narasimhaiah) > 3. Re: SQLAlchemy and 'non-trivial' default values for a column > (Dhruv Baldawa) > 4. Re: SQLAlchemy and 'non-trivial' default values for a column > (Sriram Karra) > 5. Re: SQLAlchemy and 'non-trivial' default values for a column > (Sriram Karra) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 5 Feb 2013 21:58:36 +0530 > From: Sriram Karra > To: Bangalore Python Users Group - India > Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for > a column > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > I have a Declarative table defined as follows: > > class Consultation(Base): > __tablename__ = 'consultation' > > id = Column(Integer, primary_key=True) > patient_id = Column(Integer, ForeignKey('patient.id')) > doctor_id = Column(Integer, ForeignKey('doctor.id')) > date = Column(Date(), default=MyT.today()) > > Each row in this table represents a single consultation instance of a > patient seeing a doctor on a given day. > > I would like an additional attribute called "cid" that should be an > auto-incrementing value representing how many-th consultation it was in > that day. Basically it is an auto-incrementing counter, which gets reset to > 0 at the start of a day (hence not unique, whereas the id will be unique). > No row is ever deleted. > > How do I do achieve this with the least amount of additional database > space? It is trivial to have another table with one column for date and > another column for the total consultations thus far. > > Any help? > > -Karra > > P.S. This is for PRS - an open source patient record system for small > clinics I am developing, and available at: https://github.com/skarra/PRS > > > ------------------------------ > > Message: 2 > Date: Wed, 6 Feb 2013 11:15:39 +0530 > From: Vinod Kumar Narasimhaiah > To: Bangalore Python Users Group - India > Subject: Re: [BangPypers] SQLAlchemy and 'non-trivial' default values > for a column > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > I am not a python programmer, but how about this logic? > > add new field called "consultation_count" to the same table > > before every insert to the table: > > Check if the date field on the last record (you might want to add a > timestamp field to get the last record easily) = today's date > > If yes, then it's the same day- > take the consultation count from the last record, increment it by one > and create the new record. > If No, then it's a start of the new day- > set the counter to 1 and create the new record. > > > > On Tue, Feb 5, 2013 at 9:58 PM, Sriram Karra wrote: > >> I have a Declarative table defined as follows: >> >> class Consultation(Base): >> __tablename__ = 'consultation' >> >> id = Column(Integer, primary_key=True) >> patient_id = Column(Integer, ForeignKey('patient.id')) >> doctor_id = Column(Integer, ForeignKey('doctor.id')) >> date = Column(Date(), default=MyT.today()) >> >> Each row in this table represents a single consultation instance of a >> patient seeing a doctor on a given day. >> >> I would like an additional attribute called "cid" that should be an >> auto-incrementing value representing how many-th consultation it was in >> that day. Basically it is an auto-incrementing counter, which gets reset to >> 0 at the start of a day (hence not unique, whereas the id will be unique). >> No row is ever deleted. >> >> How do I do achieve this with the least amount of additional database >> space? It is trivial to have another table with one column for date and >> another column for the total consultations thus far. >> >> Any help? >> >> -Karra >> >> P.S. This is for PRS - an open source patient record system for small >> clinics I am developing, and available at: https://github.com/skarra/PRS >> _______________________________________________ >> BangPypers mailing list >> BangPypers at python.org >> http://mail.python.org/mailman/listinfo/bangpypers >> > > > ------------------------------ > > Message: 3 > Date: Wed, 6 Feb 2013 11:32:45 +0530 > From: Dhruv Baldawa > To: Bangalore Python Users Group - India > Subject: Re: [BangPypers] SQLAlchemy and 'non-trivial' default values > for a column > Message-ID: > > Content-Type: text/plain; charset=UTF-8 > > I would do a: > > class Consultation(Base): > __tablename__ = 'consultation' > > id = Column(Integer, primary_key=True) > patient_id = Column(Integer, ForeignKey('patient.id')) > doctor_id = Column(Integer, ForeignKey('doctor.id')) > date = Column(Date(), default=MyT.today()) > > @property > def consultation_count(self): > ''' returns the consultation count for current date ''' > return self.query.filter_by(date=self.date).count() # the syntax > might not be correct > > c = Consultation.query.get(1) > print c.consultation_count > > This way its computed on the fly and you dont need to store it. > > -- > Dhruv Baldawa > (http://www.dhruvb.com) > > > On Wed, Feb 6, 2013 at 11:15 AM, Vinod Kumar Narasimhaiah < > vinod.narasimhaiah at gmail.com> wrote: > >> I am not a python programmer, but how about this logic? >> >> add new field called "consultation_count" to the same table >> >> before every insert to the table: >> >> Check if the date field on the last record (you might want to add a >> timestamp field to get the last record easily) = today's date >> >> If yes, then it's the same day- >> take the consultation count from the last record, increment it by one >> and create the new record. >> If No, then it's a start of the new day- >> set the counter to 1 and create the new record. >> >> >> >> On Tue, Feb 5, 2013 at 9:58 PM, Sriram Karra wrote: >> >> > I have a Declarative table defined as follows: >> > >> > class Consultation(Base): >> > __tablename__ = 'consultation' >> > >> > id = Column(Integer, primary_key=True) >> > patient_id = Column(Integer, ForeignKey('patient.id')) >> > doctor_id = Column(Integer, ForeignKey('doctor.id')) >> > date = Column(Date(), default=MyT.today()) >> > >> > Each row in this table represents a single consultation instance of a >> > patient seeing a doctor on a given day. >> > >> > I would like an additional attribute called "cid" that should be an >> > auto-incrementing value representing how many-th consultation it was in >> > that day. Basically it is an auto-incrementing counter, which gets reset >> to >> > 0 at the start of a day (hence not unique, whereas the id will be >> unique). >> > No row is ever deleted. >> > >> > How do I do achieve this with the least amount of additional database >> > space? It is trivial to have another table with one column for date and >> > another column for the total consultations thus far. >> > >> > Any help? >> > >> > -Karra >> > >> > P.S. This is for PRS - an open source patient record system for small >> > clinics I am developing, and available at: https://github.com/skarra/PRS >> > _______________________________________________ >> > BangPypers mailing list >> > BangPypers at python.org >> > http://mail.python.org/mailman/listinfo/bangpypers >> > >> _______________________________________________ >> BangPypers mailing list >> BangPypers at python.org >> http://mail.python.org/mailman/listinfo/bangpypers >> > > > ------------------------------ > > Message: 4 > Date: Wed, 6 Feb 2013 11:47:52 +0530 > From: Sriram Karra > To: Bangalore Python Users Group - India > Subject: Re: [BangPypers] SQLAlchemy and 'non-trivial' default values > for a column > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Feb 6, 2013 at 11:32 AM, Dhruv Baldawa wrote: > >> I would do a: >> >> class Consultation(Base): >> __tablename__ = 'consultation' >> >> id = Column(Integer, primary_key=True) >> patient_id = Column(Integer, ForeignKey('patient.id')) >> doctor_id = Column(Integer, ForeignKey('doctor.id')) >> date = Column(Date(), default=MyT.today()) >> >> @property >> def consultation_count(self): >> ''' returns the consultation count for current date ''' >> return self.query.filter_by(date=self.date).count() # the syntax >> might not be correct >> >> c = Consultation.query.get(1) >> print c.consultation_count >> >> This way its computed on the fly and you dont need to store it. >> > > If I read your code correctly this would mean: > > (a) the consultation_count property for all the consutlations that happened > on a given day will be the same value > (b) for a given row this value will keep changing as we insert more records > into the table. > > So this will not work, no? > > > ------------------------------ > > Message: 5 > Date: Wed, 6 Feb 2013 11:50:13 +0530 > From: Sriram Karra > To: Bangalore Python Users Group - India > Subject: Re: [BangPypers] SQLAlchemy and 'non-trivial' default values > for a column > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > Vinod, thanks for these inputs. Part of hte problem is the SQLAlchemy > syntax itself and getting it to work! > > Further, in the actual use case, I cannot assume that the records will be > inserted in the serial order of day. A patient can call and make an > appointment for a later date, and after that a patient might walk in for > the same day. Hm... > > -Karra > > > On Wed, Feb 6, 2013 at 11:15 AM, Vinod Kumar Narasimhaiah < > vinod.narasimhaiah at gmail.com> wrote: > >> I am not a python programmer, but how about this logic? >> >> add new field called "consultation_count" to the same table >> >> before every insert to the table: >> >> Check if the date field on the last record (you might want to add a >> timestamp field to get the last record easily) = today's date >> >> If yes, then it's the same day- >> take the consultation count from the last record, increment it by one >> and create the new record. >> If No, then it's a start of the new day- >> set the counter to 1 and create the new record. >> >> >> >> On Tue, Feb 5, 2013 at 9:58 PM, Sriram Karra wrote: >> >> > I have a Declarative table defined as follows: >> > >> > class Consultation(Base): >> > __tablename__ = 'consultation' >> > >> > id = Column(Integer, primary_key=True) >> > patient_id = Column(Integer, ForeignKey('patient.id')) >> > doctor_id = Column(Integer, ForeignKey('doctor.id')) >> > date = Column(Date(), default=MyT.today()) >> > >> > Each row in this table represents a single consultation instance of a >> > patient seeing a doctor on a given day. >> > >> > I would like an additional attribute called "cid" that should be an >> > auto-incrementing value representing how many-th consultation it was in >> > that day. Basically it is an auto-incrementing counter, which gets reset >> to >> > 0 at the start of a day (hence not unique, whereas the id will be >> unique). >> > No row is ever deleted. >> > >> > How do I do achieve this with the least amount of additional database >> > space? It is trivial to have another table with one column for date and >> > another column for the total consultations thus far. >> > >> > Any help? >> > >> > -Karra >> > >> > P.S. This is for PRS - an open source patient record system for small >> > clinics I am developing, and available at: https://github.com/skarra/PRS >> > _______________________________________________ >> > BangPypers mailing list >> > BangPypers at python.org >> > http://mail.python.org/mailman/listinfo/bangpypers >> > >> _______________________________________________ >> BangPypers mailing list >> BangPypers at python.org >> http://mail.python.org/mailman/listinfo/bangpypers >> > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > > > ------------------------------ > > End of BangPypers Digest, Vol 66, Issue 4 > ***************************************** From kracethekingmaker at gmail.com Fri Feb 8 12:24:55 2013 From: kracethekingmaker at gmail.com (kracekumar ramaraju) Date: Fri, 8 Feb 2013 16:54:55 +0530 Subject: [BangPypers] Feb meetup Message-ID: All, Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in CIS or for other place, do suggest, Feel free to propose lighting talk/30 mins talk. -- * Thanks & Regards "Talk is cheap, show me the code" -- Linus Torvalds kracekumar www.kracekumar.com * From chirag740 at gmail.com Sun Feb 10 01:03:09 2013 From: chirag740 at gmail.com (Chirag Vora) Date: Sun, 10 Feb 2013 05:33:09 +0530 Subject: [BangPypers] Using emacs for python development Message-ID: http://www.bio-python.com/2012/12/developing-python-ide-using-emacs.html Hope some of you find this useful. Regards, *Chirag Vora* From shabda at agiliq.com Mon Feb 11 09:41:19 2013 From: shabda at agiliq.com (Shabda Raaj) Date: Mon, 11 Feb 2013 14:11:19 +0530 Subject: [BangPypers] [Hyderabad] Introduction to Python Workshop on February 15th, 2013 Message-ID: (Cross posting here as Bangpypers member probably know a lot of Hyd people who may be interested in this.) Announcement: http://agiliq.com/blog/2013/02/introduction-to-python-workshop-on-february-15th-2/ Details: We are conducting an *"Introduction to Python"* workshop at our officeon *February 15th, 2013 (Friday)* between *5-8PM IST*. This workshop is geared towards those who are planning to learn python. Topics: - Language features - Variables - Built in data structures - Functions - Object Oriented Programming - Demo writing a simple program Prerequisites to attend this session: - A laptop with any linux flavour (OR) a laptop with Python installed in it. Register for the workshop by filling up the form. -- Thanks, Shabda Agiliq.com - Building Amazing Apps agiliq.com/blog/ | github.com/agiliq US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj Our Android Apps | Our iOS Apps From jtoomim at jtoomim.org Mon Feb 11 13:25:55 2013 From: jtoomim at jtoomim.org (Jonathan Toomim) Date: Mon, 11 Feb 2013 17:55:55 +0530 Subject: [BangPypers] Feb meetup In-Reply-To: References: Message-ID: <5118E353.8000605@jtoomim.org> I can give a quick talk on my HEG/near-infrared spectroscopy work. On 2/8/2013 4:54 PM, kracekumar ramaraju wrote: > All, > > Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in CIS > or for other place, do suggest, Feel free to propose lighting talk/30 mins > talk. > From kracekumar at hasgeek.com Mon Feb 11 16:59:06 2013 From: kracekumar at hasgeek.com (Kracekumar Ramaraju) Date: Mon, 11 Feb 2013 21:29:06 +0530 Subject: [BangPypers] Feb meetup In-Reply-To: <5118E353.8000605@jtoomim.org> References: <5118E353.8000605@jtoomim.org> Message-ID: Hope there are uses of python in the project. On Mon, Feb 11, 2013 at 5:55 PM, Jonathan Toomim wrote: > I can give a quick talk on my HEG/near-infrared spectroscopy work. > > > On 2/8/2013 4:54 PM, kracekumar ramaraju wrote: > >> All, >> >> Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in CIS >> or for other place, do suggest, Feel free to propose lighting talk/30 mins >> talk. >> >> > ______________________________**_________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/**mailman/listinfo/bangpypers > -- Regards Kracekumar.R "Talk is cheap, show me the code" -- Linus Torvalds From jtoomim at jtoomim.org Tue Feb 12 00:15:34 2013 From: jtoomim at jtoomim.org (Jonathan Toomim) Date: Tue, 12 Feb 2013 04:45:34 +0530 Subject: [BangPypers] Feb meetup In-Reply-To: References: <5118E353.8000605@jtoomim.org> Message-ID: <51197B96.1040703@jtoomim.org> The software I wrote to give people realtime feedback on their brain state is open source and 100% Python. On 2/11/2013 9:29 PM, Kracekumar Ramaraju wrote: > Hope there are uses of python in the project. > > On Mon, Feb 11, 2013 at 5:55 PM, Jonathan Toomim wrote: > >> I can give a quick talk on my HEG/near-infrared spectroscopy work. >> >> >> On 2/8/2013 4:54 PM, kracekumar ramaraju wrote: >> >>> All, >>> >>> Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in CIS >>> or for other place, do suggest, Feel free to propose lighting talk/30 mins >>> talk. >>> >>> >> ______________________________**_________________ >> BangPypers mailing list >> BangPypers at python.org >> http://mail.python.org/**mailman/listinfo/bangpypers >> > > From karra.etc at gmail.com Tue Feb 12 02:43:51 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 12 Feb 2013 07:13:51 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: On Wed, Feb 6, 2013 at 12:05 PM, Dhruv Baldawa wrote: > OK I misread. Let me see if I understood your problem correctly. > > 1. All the consultations will be stored in that table. > 2. When you have a Consultation object, you need a `consultation_count` > property for the number of consultation for that day. > > So, this should work now, according to me: > > def generate_consultation_id(date): > return Consultation.query.filter_by(data=data).count() + 1 > > I assume you meant 'date=date' in the method body. > class Consultation(Base): > ... > cid = Column(Integer, default=generate_consultation_id) > > This should work, according to me. The function is called while adding the > id to the database. Thanks a lot. It does appear to work. Just a clarification - I have two sessions initialized - one for a demo database and one for a production database and allow the users to switch between the two (for staff training, or feature exploration purposes). I tested it briefly and the counts are correctly incremented for whichever session is currently active. Just wanted to confirm that behaviour will be consistent. From karra.etc at gmail.com Tue Feb 12 02:49:12 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 12 Feb 2013 07:19:12 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: On Wed, Feb 6, 2013 at 1:37 PM, Thava Alagu wrote: > Hi Karra, > > > Since you want more flexible system, I recommend that you add more > columns-- > apt date, reservation date, actual visit date and *time* of consultation. > I have some of those fields, but did not show them in my mail in the interest of clarity. > To maintain our own sanity when records are accidentally updated, > this will help to trace the problem. > > Not sure if you want the 'consultation-day-id' as a handy parameter for > reference *after* the consultation or even before the consultation. > It is a quirk of how the clinic operates. I generate a printout with patient detail, doctor details etc. during registration. During subsequent visits the clerk will (a) enter details in teh system and (b) make a note by pen on the paper the patient is expected to bring with him/her. A new printout is issued only when the paper gets fully used or the patient loses it. So we just need a unique ID per visit to be noted on the paper by hand for reference. the actual format of the unique ID was a request from the administration. Dhruv had suggested a solution that works. I'll go with it Cheers, -Karra. From dhruvbaldawa at gmail.com Tue Feb 12 04:38:56 2013 From: dhruvbaldawa at gmail.com (Dhruv Baldawa) Date: Tue, 12 Feb 2013 09:08:56 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: -- Dhruv Baldawa (http://www.dhruvb.com) On Tue, Feb 12, 2013 at 7:13 AM, Sriram Karra wrote: > On Wed, Feb 6, 2013 at 12:05 PM, Dhruv Baldawa >wrote: > > > OK I misread. Let me see if I understood your problem correctly. > > > > 1. All the consultations will be stored in that table. > > 2. When you have a Consultation object, you need a > `consultation_count` > > property for the number of consultation for that day. > > > > So, this should work now, according to me: > > > > def generate_consultation_id(date): > > return Consultation.query.filter_by(data=data).count() + 1 > > > > > I assume you meant 'date=date' in the method body. > Yes, sorry for the typo. > > > > class Consultation(Base): > > ... > > cid = Column(Integer, default=generate_consultation_id) > > > > This should work, according to me. The function is called while adding > the > > id to the database. > > > Thanks a lot. It does appear to work. Just a clarification - I have two > sessions initialized - one for a demo database and one for a production > database and allow the users to switch between the two (for staff training, > or feature exploration purposes). I tested it briefly and the counts are > correctly incremented for whichever session is currently active. Just > wanted to confirm that behaviour will be consistent. > Yes, this will be consistent. Just to explain in brief how it works. The default function gets executed in runtime, when a new record is created, it just go throughs the database, finds the number of records for that particular date and increments it by one and returns it. As long as the same procedure is followed, it would be consistent, but if someone specifies the value explicitly, it might create a problem. Also, I have found a bug which can be solved using context-based default functions def generate_consultation_id(context): return Consultation.query.filter_by(date=context.current_parameters['date']).count() + 1 > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From karra.etc at gmail.com Tue Feb 12 07:05:16 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 12 Feb 2013 11:35:16 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: On Tue, Feb 12, 2013 at 9:08 AM, Dhruv Baldawa wrote: > > Yes, this will be consistent. Just to explain in brief how it works. The > default function gets executed in runtime, when a new record is created, it > just go throughs the database, finds the number of records for that > particular date and increments it by one and returns it. As long as the > same procedure is followed, it would be consistent, but if someone > specifies the value explicitly, it might create a problem. Also, I have > found a bug which can be solved using context-based default > functions< > http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#context-sensitive-default-functions > > > > def generate_consultation_id(context): > return > Consultation.query.filter_by(date=context.current_parameters['date']).count() + > 1 Hey, I think I spoke too early and in error. I was explicitly setting the cid field and not hitting the default setter, and I mistakenly thought the solution actually worked. I keep getting the error: sqlalchemy.exc.StatementError: type object 'Consultation' has no attribute 'query' (original cause: AttributeError: type object 'Consultation' has no attribute 'query') 'INSERT INTO consultation (patient_id, doctor_id, dept_id, date, charge, notes, cid) VALUES (?, ?, ?, ?, ?, ?, ?)' [{'notes': 'Lorem Ipsum Gypsum zero sum', 'patient_id': 1, 'date': datetime.date(2013, 1, 16), 'charge': 30, 'dept_id': 7, 'doctor_id': None}] query appears to be an attribute of a session class. Know what's going on? From dhruvbaldawa at gmail.com Tue Feb 12 07:08:21 2013 From: dhruvbaldawa at gmail.com (Dhruv Baldawa) Date: Tue, 12 Feb 2013 11:38:21 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: try session.query(Consultation).filter_by(), sorry I am actually used to using the above specified syntax because I usually use Flask-SQLAlchemy. -- Dhruv Baldawa (http://www.dhruvb.com) On Tue, Feb 12, 2013 at 11:35 AM, Sriram Karra wrote: > On Tue, Feb 12, 2013 at 9:08 AM, Dhruv Baldawa >wrote: > > > > > Yes, this will be consistent. Just to explain in brief how it works. The > > default function gets executed in runtime, when a new record is created, > it > > just go throughs the database, finds the number of records for that > > particular date and increments it by one and returns it. As long as the > > same procedure is followed, it would be consistent, but if someone > > specifies the value explicitly, it might create a problem. Also, I have > > found a bug which can be solved using context-based default > > functions< > > > http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#context-sensitive-default-functions > > > > > > > def generate_consultation_id(context): > > return > > > Consultation.query.filter_by(date=context.current_parameters['date']).count() > + > > 1 > > > Hey, I think I spoke too early and in error. I was explicitly setting the > cid field and not hitting the default setter, and I mistakenly thought the > solution actually worked. I keep getting the error: > > sqlalchemy.exc.StatementError: type object 'Consultation' has no attribute > 'query' (original cause: AttributeError: type object 'Consultation' has no > attribute 'query') 'INSERT INTO consultation (patient_id, doctor_id, > dept_id, date, charge, notes, cid) VALUES (?, ?, ?, ?, ?, ?, ?)' [{'notes': > 'Lorem Ipsum Gypsum zero sum', 'patient_id': 1, 'date': datetime.date(2013, > 1, 16), 'charge': 30, 'dept_id': 7, 'doctor_id': None}] > > query appears to be an attribute of a session class. Know what's going on? > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From karra.etc at gmail.com Tue Feb 12 07:35:23 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 12 Feb 2013 12:05:23 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: On Tue, Feb 12, 2013 at 11:38 AM, Dhruv Baldawa wrote: > try session.query(Consultation).filter_by(), sorry I am actually used to > using the above specified syntax because I usually use Flask-SQLAlchemy. Oh, well. the session object is not available inside Consultation class. And as I mentioned I have two session objects of which one is live at any given time... From dhruvbaldawa at gmail.com Tue Feb 12 08:02:01 2013 From: dhruvbaldawa at gmail.com (Dhruv Baldawa) Date: Tue, 12 Feb 2013 12:32:01 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: Then I guess you are doing it the wrong way. You should only have a single session object (unless working with multiple databases simultaneously). The object should be binded with whatever connection is required. if PRODUCTION: engine = create_engine(...) else: engine = create_engine(...) session = sessionmaker(bind=engine) then import session from whichever module you have added the above code. I don't know how you are doing the model-based queries, if you have someother way of querying models you can follow that, the concept and method still remains the same. Configurations can be controlled by an optional command-line argument or environment variable or a flag, its upto you. I run 4 different configurations for my app using command-line arguments. -- Dhruv Baldawa (http://www.dhruvb.com) On Tue, Feb 12, 2013 at 12:05 PM, Sriram Karra wrote: > On Tue, Feb 12, 2013 at 11:38 AM, Dhruv Baldawa >wrote: > > > try session.query(Consultation).filter_by(), sorry I am actually used to > > using the above specified syntax because I usually use Flask-SQLAlchemy. > > > Oh, well. the session object is not available inside Consultation class. > And as I mentioned I have two session objects of which one is live at any > given time... > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From karra.etc at gmail.com Tue Feb 12 09:32:42 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 12 Feb 2013 14:02:42 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: On Tue, Feb 12, 2013 at 12:32 PM, Dhruv Baldawa wrote: > Then I guess you are doing it the wrong way. You should only have a single > session object (unless working with multiple databases simultaneously). The > object should be binded with whatever connection is required. I do have two separate databases - a demo database for training purposes and a live production database. Both have to be functional and available simultaneously. Anyway, thanks for your help. I was only trying to figure out some way of achieving what I wanted without accessing the session object. I guess that's not possible. Good to know that. Cheers, Karra From saager.mhatre at gmail.com Tue Feb 12 17:54:07 2013 From: saager.mhatre at gmail.com (Saager Mhatre) Date: Tue, 12 Feb 2013 22:24:07 +0530 Subject: [BangPypers] Feb meetup In-Reply-To: References: Message-ID: On Fri, Feb 8, 2013 at 4:54 PM, kracekumar ramaraju < kracethekingmaker at gmail.com> wrote: > All, > > Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in CIS Just checking, is this confirmed? - d From kracethekingmaker at gmail.com Tue Feb 12 18:04:24 2013 From: kracethekingmaker at gmail.com (kracekumar ramaraju) Date: Tue, 12 Feb 2013 22:34:24 +0530 Subject: [BangPypers] Feb meetup In-Reply-To: References: Message-ID: On Tue, Feb 12, 2013 at 10:24 PM, Saager Mhatre wrote: > On Fri, Feb 8, 2013 at 4:54 PM, kracekumar ramaraju < > kracethekingmaker at gmail.com> wrote: > > > All, > > > > Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in CIS > > > Just checking, is this confirmed? > > Yes, people have gone ahead and made this as venue http://www.meetup.com/BangPypers/events/102484032/. Hence confirmed. > - d > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- * Thanks & Regards "Talk is cheap, show me the code" -- Linus Torvalds kracekumar www.kracekumar.com * From noufal at nibrahim.net.in Wed Feb 13 14:32:35 2013 From: noufal at nibrahim.net.in (Noufal Ibrahim) Date: Wed, 13 Feb 2013 19:02:35 +0530 Subject: [BangPypers] [X-post] Pycon India meeting on IRC. Message-ID: <878v6snxu4.fsf@sanitarium.localdomain> Hello everyone, Sorry about the cross posting but this needs a wide audience. Let's get the ball rolling for PyCon India with an IRC meeting this Friday (15/Feb) at 1900 on IRC. The channel is #python-india on irc.freenode.net (not #pythonindia). Thanks -- Cordially, Noufal http://nibrahim.net.in From vnbang2003 at yahoo.com Thu Feb 14 03:49:12 2013 From: vnbang2003 at yahoo.com (vijay) Date: Thu, 14 Feb 2013 10:49:12 +0800 (SGT) Subject: [BangPypers] [X-post] Pycon India meeting on IRC. In-Reply-To: <878v6snxu4.fsf@sanitarium.localdomain> References: <878v6snxu4.fsf@sanitarium.localdomain> Message-ID: <1360810152.1220.YahooMailNeo@web192206.mail.sg3.yahoo.com> +1 ________________________________ From: Noufal Ibrahim To: Python Pune ; Bangalore Python Users Group ; Mailing list for the PyCon India conference ; chennaipy ; Kerala Python User Group Sent: Wednesday, 13 February 2013 7:02 PM Subject: [BangPypers] [X-post] Pycon India meeting on IRC. Hello everyone, ? ? ? ? Sorry about the cross posting but this needs a wide audience. ? ? ? ? Let's get the ball rolling for PyCon India with an IRC meeting this Friday (15/Feb) at 1900 on IRC. ? ? ? ? The channel is #python-india on irc.freenode.net (not #pythonindia). Thanks ? ? ? ? -- Cordially, Noufal http://nibrahim.net.in _______________________________________________ BangPypers mailing list BangPypers at python.org http://mail.python.org/mailman/listinfo/bangpypers From deepakgarg.iitg at gmail.com Thu Feb 14 18:15:37 2013 From: deepakgarg.iitg at gmail.com (Deepak Garg) Date: Thu, 14 Feb 2013 09:15:37 -0800 Subject: [BangPypers] Feb meetup In-Reply-To: References: Message-ID: I have updated Jonathan's Talk on the agenda http://www.meetup.com/BangPypers/events/102484032/ Please let know if anyone would like to present as well. Deepak On Tue, Feb 12, 2013 at 9:04 AM, kracekumar ramaraju < kracethekingmaker at gmail.com> wrote: > On Tue, Feb 12, 2013 at 10:24 PM, Saager Mhatre >wrote: > > > On Fri, Feb 8, 2013 at 4:54 PM, kracekumar ramaraju < > > kracethekingmaker at gmail.com> wrote: > > > > > All, > > > > > > Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in > CIS > > > > > > Just checking, is this confirmed? > > > > Yes, people have gone ahead and made this as venue > http://www.meetup.com/BangPypers/events/102484032/. Hence confirmed. > > > - d > > _______________________________________________ > > BangPypers mailing list > > BangPypers at python.org > > http://mail.python.org/mailman/listinfo/bangpypers > > > > > > -- > * > Thanks & Regards > > "Talk is cheap, show me the code" -- Linus Torvalds > kracekumar > www.kracekumar.com > * > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- Deepak Garg, Software Engineer, Amazon Development Center India, Phone-no.:+917829866870 Github: https://github.com/gargdeepak LinkedIn: http://in.linkedin.com/in/deepakgargiit Slideshare: http://www.slideshare.net/khinnu4u/presentations Skype-id: deepakgarg.iit From sriramnrn at gmail.com Fri Feb 15 00:29:04 2013 From: sriramnrn at gmail.com (Sriram Narayanan) Date: Fri, 15 Feb 2013 04:59:04 +0530 Subject: [BangPypers] Fwd: Python Software Foundation: Python Trademark at Risk In-Reply-To: References: Message-ID: Fyi ---------- Forwarded message ---------- From: "Dmitrijs Ledkovs" Date: Feb 15, 2013 3:17 AM Subject: Python Software Foundation: Python Trademark at Risk To: , , < debian-legal at lists.debian.org> Dear All, Full article: http://pyfound.blogspot.co.uk/2013/02/python-trademark-at-risk-in-europe-we.html There is a company in the UK that is trying to trademark the use of the term "Python" for all software, services, servers... pretty much anything having to do with a computer. Specifically, it is the company that got a hold on the python.co.uk domain 13 years ago. According to our London counsel, some of the best pieces of evidence we can submit to the European trademark office are official letters from well-known companies "using PYTHON branded software in various member states of the EU" so that we can "obtain independent witness statements from them attesting to the trade origin significance of the PYTHON mark in connection with the software and related goods/services." We also need evidence of use throughout the EU. Further instructions on how to submit letters of support are in the blog article linked above. Please help defend python trademark. Regards, Dmitrijs. -- To UNSUBSCRIBE, email to debian-legal-REQUEST at lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster at lists.debian.org Archive: http://lists.debian.org/CANBHLUh5LzzB3=fYjWMbFmGSEw452zjV=XFP0OExUxzEMfb0Mg at mail.gmail.com From baiju.m.mail at gmail.com Fri Feb 15 10:11:02 2013 From: baiju.m.mail at gmail.com (Baiju M) Date: Fri, 15 Feb 2013 14:41:02 +0530 Subject: [BangPypers] Fwd: Python Software Foundation: Python Trademark at Risk In-Reply-To: References: Message-ID: Few discussion links: http://news.ycombinator.com/item?id=5221093 http://www.reddit.com/r/Python/comments/18j8dd/python_software_foundation_news_python_trademark/ On Fri, Feb 15, 2013 at 4:59 AM, Sriram Narayanan wrote: > Fyi > ---------- Forwarded message ---------- > From: "Dmitrijs Ledkovs" > Date: Feb 15, 2013 3:17 AM > Subject: Python Software Foundation: Python Trademark at Risk > To: , , < > debian-legal at lists.debian.org> > > Dear All, > > Full article: > http://pyfound.blogspot.co.uk/2013/02/python-trademark-at-risk-in-europe-we.html > > There is a company in the UK that is trying to trademark the use of > the term "Python" for all software, services, servers... pretty much > anything having to do with a computer. Specifically, it is the company > that got a hold on the python.co.uk domain 13 years ago. > > According to our London counsel, some of the best pieces of evidence > we can submit to the European trademark office are official letters > from well-known companies "using PYTHON branded software in various > member states of the EU" so that we can "obtain independent witness > statements from them attesting to the trade origin significance of the > PYTHON mark in connection with the software and related > goods/services." We also need evidence of use throughout the EU. > > Further instructions on how to submit letters of support are in the > blog article linked above. > > Please help defend python trademark. > > Regards, > > Dmitrijs. > > > -- > To UNSUBSCRIBE, email to debian-legal-REQUEST at lists.debian.org > with a subject of "unsubscribe". Trouble? Contact > listmaster at lists.debian.org > Archive: > http://lists.debian.org/CANBHLUh5LzzB3=fYjWMbFmGSEw452zjV=XFP0OExUxzEMfb0Mg at mail.gmail.com > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers From anandology at gmail.com Fri Feb 15 10:40:35 2013 From: anandology at gmail.com (Anand Chitipothu) Date: Fri, 15 Feb 2013 15:10:35 +0530 Subject: [BangPypers] Fwd: Python Software Foundation: Python Trademark at Risk In-Reply-To: References: Message-ID: I'm glad that we blocked the python.org.in domain and started using for Python community in India. Anand On Fri, Feb 15, 2013 at 4:59 AM, Sriram Narayanan wrote: > Fyi > ---------- Forwarded message ---------- > From: "Dmitrijs Ledkovs" > Date: Feb 15, 2013 3:17 AM > Subject: Python Software Foundation: Python Trademark at Risk > To: , , < > debian-legal at lists.debian.org> > > Dear All, > > Full article: > http://pyfound.blogspot.co.uk/2013/02/python-trademark-at-risk-in-europe-we.html > > There is a company in the UK that is trying to trademark the use of > the term "Python" for all software, services, servers... pretty much > anything having to do with a computer. Specifically, it is the company > that got a hold on the python.co.uk domain 13 years ago. > > According to our London counsel, some of the best pieces of evidence > we can submit to the European trademark office are official letters > from well-known companies "using PYTHON branded software in various > member states of the EU" so that we can "obtain independent witness > statements from them attesting to the trade origin significance of the > PYTHON mark in connection with the software and related > goods/services." We also need evidence of use throughout the EU. > > Further instructions on how to submit letters of support are in the > blog article linked above. > > Please help defend python trademark. > > Regards, > > Dmitrijs. > > > -- > To UNSUBSCRIBE, email to debian-legal-REQUEST at lists.debian.org > with a subject of "unsubscribe". Trouble? Contact > listmaster at lists.debian.org > Archive: > http://lists.debian.org/CANBHLUh5LzzB3=fYjWMbFmGSEw452zjV=XFP0OExUxzEMfb0Mg at mail.gmail.com > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers -- Anand http://anandology.com/ From chinny143charan at gmail.com Fri Feb 15 16:19:34 2013 From: chinny143charan at gmail.com (charantej.S) Date: Fri, 15 Feb 2013 20:49:34 +0530 Subject: [BangPypers] [JOBS] Python Django expert In-Reply-To: References: Message-ID: Hi Hrishikesh Kulkarni, I'm charantej s having 4+ years of experience in python /Django. I'm interested in this project. My contact no 7845278933. On Mon, Jan 21, 2013 at 10:43 AM, Hrishikesh Kulkarni wrote: > I am looking for an expert on Python based Django web framework on > contract basis. If interested please contact me at > rishi at turtleyogi.com > > regards, > Rishi > Founder - Turtleyogi > (Incubated at IIM-B) > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- Thanks & Regards, CharanTej.S From kracethekingmaker at gmail.com Sat Feb 16 21:04:39 2013 From: kracethekingmaker at gmail.com (kracekumar ramaraju) Date: Sun, 17 Feb 2013 01:34:39 +0530 Subject: [BangPypers] Feb meetup In-Reply-To: References: Message-ID: Turn out for the meetup was fantastic. 25 people attended out which 17 were first time participants. There were 2 talks one by Jonathan and other by Lavakumar. 2 lighting talks. On Thu, Feb 14, 2013 at 10:45 PM, Deepak Garg wrote: > I have updated Jonathan's Talk on the agenda > http://www.meetup.com/BangPypers/events/102484032/ > > Please let know if anyone would like to present as well. > > > > Deepak > > > On Tue, Feb 12, 2013 at 9:04 AM, kracekumar ramaraju < > kracethekingmaker at gmail.com> wrote: > > > On Tue, Feb 12, 2013 at 10:24 PM, Saager Mhatre > >wrote: > > > > > On Fri, Feb 8, 2013 at 4:54 PM, kracekumar ramaraju < > > > kracethekingmaker at gmail.com> wrote: > > > > > > > All, > > > > > > > > Feb Meetup will be on 16th, as usual 3.00 PM, shall we have meetup in > > CIS > > > > > > > > > Just checking, is this confirmed? > > > > > > Yes, people have gone ahead and made this as venue > > http://www.meetup.com/BangPypers/events/102484032/. Hence confirmed. > > > > > - d > > > _______________________________________________ > > > BangPypers mailing list > > > BangPypers at python.org > > > http://mail.python.org/mailman/listinfo/bangpypers > > > > > > > > > > > -- > > * > > Thanks & Regards > > > > "Talk is cheap, show me the code" -- Linus Torvalds > > kracekumar > > www.kracekumar.com > > * > > _______________________________________________ > > BangPypers mailing list > > BangPypers at python.org > > http://mail.python.org/mailman/listinfo/bangpypers > > > > > > -- > > Deepak Garg, > > Software Engineer, > Amazon Development Center India, > Phone-no.:+917829866870 > > Github: https://github.com/gargdeepak > LinkedIn: http://in.linkedin.com/in/deepakgargiit > Slideshare: http://www.slideshare.net/khinnu4u/presentations > Skype-id: deepakgarg.iit > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- * Thanks & Regards "Talk is cheap, show me the code" -- Linus Torvalds kracekumar www.kracekumar.com * From jace at pobox.com Mon Feb 18 09:59:47 2013 From: jace at pobox.com (Kiran Jonnalagadda) Date: Mon, 18 Feb 2013 14:29:47 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: Sriram, I just noticed this thread. What you are seeking is fairly trivial once you figure out SQLAlchemy a little better. Here is how I implemented container-unique incrementing ids: https://github.com/hasgeek/coaster/blob/master/coaster/sqlalchemy.py#L197 The trick is to override __init__ and set the value of the column to an SQL expression that is evaluated database-side on commit. In my case, I'm checking for the max value from existing instances that share the same parent. In your case, it'll be instances that share the same date. Kiran -- Kiran Jonnalagadda http://jace.zaiki.in/ http://hasgeek.com/ On Tuesday, 12 February 2013 at 2:02 PM, Sriram Karra wrote: > On Tue, Feb 12, 2013 at 12:32 PM, Dhruv Baldawa wrote: > > > Then I guess you are doing it the wrong way. You should only have a single > > session object (unless working with multiple databases simultaneously). The > > object should be binded with whatever connection is required. > > > > > > > I do have two separate databases - a demo database for training purposes > and a live production database. Both have to be functional and available > simultaneously. > > Anyway, thanks for your help. I was only trying to figure out some way of > achieving what I wanted without accessing the session object. I guess > that's not possible. Good to know that. > > Cheers, > Karra > _______________________________________________ > BangPypers mailing list > BangPypers at python.org (mailto:BangPypers at python.org) > http://mail.python.org/mailman/listinfo/bangpypers > > From jaganadhg at gmail.com Mon Feb 18 16:00:11 2013 From: jaganadhg at gmail.com (JAGANADH G) Date: Mon, 18 Feb 2013 20:30:11 +0530 Subject: [BangPypers] Django Jquey List View issu Message-ID: Hi , I am working with a private Django project. In the project once the user clicks on "Go" button he has to be redirected to a page with JQury list view (Looks like a tabbed page). To get redirected to "TabbedPage.html" I am using render_to_response("TabbedPage.html",{'user':username'}. When the page is redirected it is not at all showing the JQuery lists. For each list page I have a Class bases generic view defined and mentioned in the urls.py too. Is there any way to get it rendered properly . I am not that much familier with Django too :-( -- ********************************** JAGANADH G http://jaganadhg.in *ILUGCBE* http://ilugcbe.org.in From abhat38 at gmail.com Mon Feb 18 17:56:29 2013 From: abhat38 at gmail.com (anirudh bhat) Date: Mon, 18 Feb 2013 22:26:29 +0530 Subject: [BangPypers] Django Jquey List View issu In-Reply-To: References: Message-ID: Hello Jaganadh, your question is too abstract.Maybe you can show us some code u have written if you dont mind.There maybe lot of things that can go wrong here....one such example is that maybe there is some problem with your Jquery code.Is page redirecting done right?? what does your django error log says?? On Mon, Feb 18, 2013 at 8:30 PM, JAGANADH G wrote: > Hi , > I am working with a private Django project. In the project once the user > clicks on "Go" button he has to be redirected to a page with JQury list > view (Looks like a tabbed page). > > To get redirected to "TabbedPage.html" I am using > render_to_response("TabbedPage.html",{'user':username'}. > When the page is redirected it is not at all showing the JQuery lists. > > For each list page I have a Class bases generic view defined and mentioned > in the urls.py too. > > Is there any way to get it rendered properly . > > I am not that much familier with Django too :-( > > -- > ********************************** > JAGANADH G > http://jaganadhg.in > *ILUGCBE* > http://ilugcbe.org.in > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From jaganadhg at gmail.com Tue Feb 19 03:20:12 2013 From: jaganadhg at gmail.com (JAGANADH G) Date: Tue, 19 Feb 2013 07:50:12 +0530 Subject: [BangPypers] Django Jquey List View issu In-Reply-To: References: Message-ID: On Mon, Feb 18, 2013 at 10:26 PM, anirudh bhat wrote: > Hello Jaganadh, your question is too abstract.Maybe you can show us some > code u have written if you dont mind.There maybe lot of things that can go > wrong here....one such example is that maybe there is some problem with > your Jquery code.Is page redirecting done right?? what does your django > error log says?? > > > Hi, There is no error shown in Django log . The page is getting redirected too. I will post some code too Best regards -- ********************************** JAGANADH G http://jaganadhg.in *ILUGCBE* http://ilugcbe.org.in From jaganadhg at gmail.com Tue Feb 19 08:00:30 2013 From: jaganadhg at gmail.com (JAGANADH G) Date: Tue, 19 Feb 2013 12:30:30 +0530 Subject: [BangPypers] Django Jquey List View issu In-Reply-To: References: Message-ID: On Mon, Feb 18, 2013 at 10:26 PM, anirudh bhat wrote: > Hello Jaganadh, your question is too abstract.Maybe you can show us some > code u have written if you dont mind.There maybe lot of things that can go > wrong here....one such example is that maybe there is some problem with > your Jquery code.Is page redirecting done right?? what does your django > error log says?? > > > Hi This is the code which redirects the page def user_login(request): cache.clear() request.session.flush() """ Logging the user to the system """ state = "Login using your credentials" username,password = "","" if request.POST: username = request.POST.get('username') password = request.POST.get('password') user = authenticate(username= username,password=password) request.COOKIES['username'] = username if user is not None and user.is_authenticated(): if user.is_active: login(request,user) state = "Your login was successful !" cookie_name = request.COOKIES['username'] #return redirect('/index/',{'username':username},RequestContext(request,{'username':username})) #return HttpResponseRedirect('/index/',{'username':cookie_name}) #return redirect('/index/',{'username':cookie_name}) #return render_to_response('Index.html',{'username':cookie_name}) #return redirect('/index/',{'username':cookie_name}) return render_to_response('Index.html',{'username':cookie_name}) else: state = "Your credentials are incorrect !" return render_to_response("Login.html",{'state':state,'username':username}) -- ********************************** JAGANADH G http://jaganadhg.in *ILUGCBE* http://ilugcbe.org.in From ragsagar at gmail.com Tue Feb 19 08:10:35 2013 From: ragsagar at gmail.com (ragsagar) Date: Tue, 19 Feb 2013 12:40:35 +0530 Subject: [BangPypers] Django Jquey List View issu In-Reply-To: References: Message-ID: It would have better if you have shared the code using dpase or some pastebin, because it not that readable here. I am assuming your problem is this. After login, the index.html page is rendering but you cannot the see the list of items. If this is the problem do the following. 1) Get the url name of the url which is mapped to the view which renders index.html. 2) if 'render_index_page' is the url name, do the following. if user is not None and user.is_active: login(request, user) return HttpResponseRedirect(reverse('render_index_page')) else: # Not logged Then you don't have to set username in cookie or pass it to template like that. You can access username like this without passing anything in template if user is logged in. {{ user.username }} Thanks, Rag On Tue, Feb 19, 2013 at 12:30 PM, JAGANADH G wrote: > On Mon, Feb 18, 2013 at 10:26 PM, anirudh bhat wrote: > > > Hello Jaganadh, your question is too abstract.Maybe you can show us some > > code u have written if you dont mind.There maybe lot of things that can > go > > wrong here....one such example is that maybe there is some problem with > > your Jquery code.Is page redirecting done right?? what does your django > > error log says?? > > > > > > > > Hi > This is the code which redirects the page > > def user_login(request): > cache.clear() > request.session.flush() > """ > Logging the user to the system > """ > state = "Login using your credentials" > username,password = "","" > if request.POST: > username = request.POST.get('username') > password = request.POST.get('password') > > user = authenticate(username= username,password=password) > request.COOKIES['username'] = username > if user is not None and user.is_authenticated(): > if user.is_active: > login(request,user) > state = "Your login was successful !" > cookie_name = request.COOKIES['username'] > #return > > redirect('/index/',{'username':username},RequestContext(request,{'username':username})) > #return > HttpResponseRedirect('/index/',{'username':cookie_name}) > #return > redirect('/index/',{'username':cookie_name}) > #return > render_to_response('Index.html',{'username':cookie_name}) > #return > redirect('/index/',{'username':cookie_name}) > return > render_to_response('Index.html',{'username':cookie_name}) > else: > state = "Your credentials are incorrect !" > return > render_to_response("Login.html",{'state':state,'username':username}) > > > -- > ********************************** > JAGANADH G > http://jaganadhg.in > *ILUGCBE* > http://ilugcbe.org.in > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- blog : ragsagar.wordpress.com mail id : python -c "print '@'.join(['ragsagar','.'.join([x for x in ['gmail','com']])])" From jaganadhg at gmail.com Tue Feb 19 09:21:27 2013 From: jaganadhg at gmail.com (JAGANADH G) Date: Tue, 19 Feb 2013 13:51:27 +0530 Subject: [BangPypers] Django Jquey List View issu In-Reply-To: References: Message-ID: On Tue, Feb 19, 2013 at 12:40 PM, ragsagar wrote: > It would have better if you have shared the code using dpase or some > pastebin, because it not that readable here. I am assuming your problem is > this. After login, the index.html page is rendering but you cannot the see > the list of items. If this is the problem do the following. > 1) Get the url name of the url which is mapped to the view which renders > index.html. > 2) if 'render_index_page' is the url name, do the following. > > if user is not None and user.is_active: > login(request, user) > return HttpResponseRedirect(reverse('render_index_page')) > else: > # Not logged > > Then you don't have to set username in cookie or pass it to template like > that. You can access username like this without passing anything in > template if user is logged in. > {{ user.username }} > > > Hi Here is the code in dpaste http://dpaste.com/947018/ Error Reverse for 'Index.html' with arguments '()' and keyword arguments '{}' not found -- ********************************** JAGANADH G http://jaganadhg.in *ILUGCBE* http://ilugcbe.org.in From ragsagar at gmail.com Tue Feb 19 09:42:29 2013 From: ragsagar at gmail.com (ragsagar) Date: Tue, 19 Feb 2013 14:12:29 +0530 Subject: [BangPypers] Django Jquey List View issu In-Reply-To: References: Message-ID: Refer the following link for the usage of reverse(). You need pass the url name, not template name. https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-resolution-of-urls On Tue, Feb 19, 2013 at 1:51 PM, JAGANADH G wrote: > On Tue, Feb 19, 2013 at 12:40 PM, ragsagar wrote: > > > It would have better if you have shared the code using dpase or some > > pastebin, because it not that readable here. I am assuming your problem > is > > this. After login, the index.html page is rendering but you cannot the > see > > the list of items. If this is the problem do the following. > > 1) Get the url name of the url which is mapped to the view which renders > > index.html. > > 2) if 'render_index_page' is the url name, do the following. > > > > if user is not None and user.is_active: > > login(request, user) > > return HttpResponseRedirect(reverse('render_index_page')) > > else: > > # Not logged > > > > Then you don't have to set username in cookie or pass it to template like > > that. You can access username like this without passing anything in > > template if user is logged in. > > {{ user.username }} > > > > > > Hi > > Here is the code in dpaste > > http://dpaste.com/947018/ > Error Reverse for 'Index.html' with arguments '()' and keyword arguments > '{}' not found > > -- > ********************************** > JAGANADH G > http://jaganadhg.in > *ILUGCBE* > http://ilugcbe.org.in > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- blog : ragsagar.wordpress.com mail id : python -c "print '@'.join(['ragsagar','.'.join([x for x in ['gmail','com']])])" From karra.etc at gmail.com Wed Feb 20 08:15:52 2013 From: karra.etc at gmail.com (Sriram Karra) Date: Wed, 20 Feb 2013 12:45:52 +0530 Subject: [BangPypers] SQLAlchemy and 'non-trivial' default values for a column In-Reply-To: References: Message-ID: On Mon, Feb 18, 2013 at 2:29 PM, Kiran Jonnalagadda wrote: > > The trick is to override __init__ and set the value of the column to an > SQL expression that is evaluated database-side on commit. In my case, I'm > checking for the max value from existing instances that share the same > parent. In your case, it'll be instances that share the same date. > I try to keep my code free of any SQL expressions - in equal measure out a real lack of understanding SQL subtleties and to keep the code 'pure' ORM-ish. But this is definitely interesting and something I could try next time I need it. From satishsagar83 at gmail.com Wed Feb 20 08:24:24 2013 From: satishsagar83 at gmail.com (L Radhakrishna Rao) Date: Wed, 20 Feb 2013 12:54:24 +0530 Subject: [BangPypers] Python related jobs for me Message-ID: Hi guys and girls, I am software engineer and also an enthusiastic programmer. I have learned python on my own, though not knowledgeable as you people are. I have learned python purely out of my interest. Now i would like to get involved in some serious python development activities. Any suggestions? The problem with HRs is that they will usually treat me as a freshers, especially in india. Your advice will definitely change my careers and also, I will get to do the thing which I love. Thanks and Regards, Radhakrishna From gora at mimirtech.com Wed Feb 20 08:31:25 2013 From: gora at mimirtech.com (Gora Mohanty) Date: Wed, 20 Feb 2013 13:01:25 +0530 Subject: [BangPypers] Python related jobs for me In-Reply-To: References: Message-ID: On 20 February 2013 12:54, L Radhakrishna Rao wrote: > Hi guys and girls, > > I am software engineer and also an enthusiastic programmer. > > I have learned python on my own, though not knowledgeable as you people > are. I have learned python purely out of my interest. > > Now i would like to get involved in some serious python development > activities. Any suggestions? [...] This is a little off-topic, but nevertheless: * Learning something on a candidate's own initiative would be a big plus in our book when it comes to a hiring decision. * You should decide on a more specific area that you want to work in. One possibility is web development with Django, and Python, but you should pick an area that interests you. * If your experience in that area is not very extensive, consider finding a company/organisation that works in the area, and do an internship with them. * Another good way of gaining expertise, and getting noticed, is to find an open-source project in that area of work, and contributing to it. Regards, Gora From kracethekingmaker at gmail.com Wed Feb 20 08:33:01 2013 From: kracethekingmaker at gmail.com (kracekumar ramaraju) Date: Wed, 20 Feb 2013 13:03:01 +0530 Subject: [BangPypers] Python related jobs for me In-Reply-To: References: Message-ID: On Wed, Feb 20, 2013 at 12:54 PM, L Radhakrishna Rao < satishsagar83 at gmail.com> wrote: > Hi guys and girls, > > I am software engineer and also an enthusiastic programmer. > > I have learned python on my own, though not knowledgeable as you people > are. I have learned python purely out of my interest. > > Now i would like to get involved in some serious python development > activities. Any suggestions? > > The problem with HRs is that they will usually treat me as a freshers, > especially in india. > > Your advice will definitely change my careers and also, I will get to do > the thing which I love. > > There are lot of python projects in github in case you want to contribute, the best way is to create an desktop app or webapp or python module or python package. Ask suggestions from Friends and other programmers for your code. Kindly find your own interest(Music or cricket app or wget in python) since path I followed may or maynot work out for you. To have look of programmers in Bangalore, you can try https://github.com/search?q=bangalore&ref=commandbar&type=Users , same logic can be extended for python projects. > Thanks and Regards, > > Radhakrishna > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- * Thanks & Regards "Talk is cheap, show me the code" -- Linus Torvalds kracekumar www.kracekumar.com * From satishsagar83 at gmail.com Wed Feb 20 08:37:44 2013 From: satishsagar83 at gmail.com (L Radhakrishna Rao) Date: Wed, 20 Feb 2013 13:07:44 +0530 Subject: [BangPypers] Python related jobs for me In-Reply-To: References: Message-ID: Hi Gora, Thanks for responding back. I am actually interested in web services and also looking to contribute in opene erp or tiny erp, as I have knowledge of ERP. I have checked their websites, but could not figure it out, also because of time constraints. So I am searching for people who contribute in open erp. Besides, I am posting code in www.projecteuler.net using python as my programming langauge. I want to use Django, but again, for python 3, there is no release available I guess. Regards, Radhakrishna From govind.menon at beacon.in Wed Feb 20 08:38:15 2013 From: govind.menon at beacon.in (Govind Menon) Date: Wed, 20 Feb 2013 13:08:15 +0530 Subject: [BangPypers] Python related jobs for me Message-ID: Hi, i am anh consultant. Can you mail me your phone details? We can then have a chat. Or you could call me on +91 94483 79144. Regards...Govind Menon -original message- Subject: [BangPypers] Python related jobs for me From: L Radhakrishna Rao Date: 20/02/2013 12:56 pm Hi guys and girls, I am software engineer and also an enthusiastic programmer. I have learned python on my own, though not knowledgeable as you people are. I have learned python purely out of my interest. Now i would like to get involved in some serious python development activities. Any suggestions? The problem with HRs is that they will usually treat me as a freshers, especially in india. Your advice will definitely change my careers and also, I will get to do the thing which I love. Thanks and Regards, Radhakrishna _______________________________________________ BangPypers mailing list BangPypers at python.org http://mail.python.org/mailman/listinfo/bangpypers From satishsagar83 at gmail.com Wed Feb 20 08:44:39 2013 From: satishsagar83 at gmail.com (L Radhakrishna Rao) Date: Wed, 20 Feb 2013 13:14:39 +0530 Subject: [BangPypers] Python related jobs for me In-Reply-To: References: Message-ID: Hi Govind, I will call you after 7 P.M. Thanks and Regards, Radhakrishna From me at bibhas.in Wed Feb 20 08:56:48 2013 From: me at bibhas.in (Bibhas Ch Debnath) Date: Wed, 20 Feb 2013 13:26:48 +0530 Subject: [BangPypers] Python related jobs for me In-Reply-To: References: Message-ID: - Keep learning. Write small apps. Put all your code on Github. Consider it as your resume. - Attend events. Meet new people. Talk to them. There are a Lot of opportunities you can't find sitting at home. - Don't expect or try to jump start. Take it slow. Internship is a good idea. ---- Bibhas http://bibhas.in On 20 February 2013 13:14, L Radhakrishna Rao wrote: > Hi Govind, > > I will call you after 7 P.M. > > Thanks and Regards, > > Radhakrishna > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From satishsagar83 at gmail.com Wed Feb 20 08:58:46 2013 From: satishsagar83 at gmail.com (L Radhakrishna Rao) Date: Wed, 20 Feb 2013 13:28:46 +0530 Subject: [BangPypers] Python related jobs for me In-Reply-To: References: Message-ID: Hi Bibhas, Thanks for the advice. With Best Regards, Radhakrishna From aditya.athalye at gmail.com Wed Feb 20 12:26:57 2013 From: aditya.athalye at gmail.com (Aditya Athalye) Date: Wed, 20 Feb 2013 16:56:57 +0530 Subject: [BangPypers] Python related jobs for me (L Radhakrishna Rao) Message-ID: <000301ce0f5d$341cf050$9c56d0f0$@gmail.com> Radhakrishna, ERPnext, recently posted a job opening at the MumPy mailing list: https://groups.google.com/forum/?fromgroups=#!topic/mumpy/lAEjNqZEpJI They describe themselves as a small Python + JS + FOSS company. And looks like their area of work matches your area of interest. Only, they are based in Mumbai, so I guess they will like their ideal candidate to be based there. Best, Aditya. From satishsagar83 at gmail.com Wed Feb 20 12:41:37 2013 From: satishsagar83 at gmail.com (L Radhakrishna Rao) Date: Wed, 20 Feb 2013 17:11:37 +0530 Subject: [BangPypers] Python related jobs for me (L Radhakrishna Rao) In-Reply-To: References: <000301ce0f5d$341cf050$9c56d0f0$@gmail.com> Message-ID: Hi Aditya, They are hiring for 0-4 years of experience. This april, i will complete my 7 years of work experience. Thanks a lot for sharing this with me. With Best Regards, Radhakrishna. From satishsagar83 at gmail.com Wed Feb 20 12:40:10 2013 From: satishsagar83 at gmail.com (L Radhakrishna Rao) Date: Wed, 20 Feb 2013 17:10:10 +0530 Subject: [BangPypers] Python related jobs for me (L Radhakrishna Rao) In-Reply-To: <000301ce0f5d$341cf050$9c56d0f0$@gmail.com> References: <000301ce0f5d$341cf050$9c56d0f0$@gmail.com> Message-ID: Hi Aditya, Thanks a lot for sharing this with me. With Best Regards, Radhakrishna From anandology at gmail.com Thu Feb 21 05:50:56 2013 From: anandology at gmail.com (Anand Chitipothu) Date: Thu, 21 Feb 2013 10:20:56 +0530 Subject: [BangPypers] list comprehensions and generator expressions in Python 3 Message-ID: Hi, PEP 289 says "the semantic definition of a list comprehension in Python 3.0 will be equivalent to list(). http://www.python.org/dev/peps/pep-0289/ I've just come across a bug reported by Peter Norvig, showing counterexamples. http://bugs.python.org/issue14845 Very informative to understand the subtle differences between the semantics of list comprehensions and generator expressions. Anand From workforsiva at gmail.com Thu Feb 21 09:13:43 2013 From: workforsiva at gmail.com (Siva Ranganath) Date: Thu, 21 Feb 2013 13:43:43 +0530 Subject: [BangPypers] regarding installation of python Message-ID: hello BangPypers at python.org I have RedHat linux in my Laptop where iam accessing through VMware. how can install python librearies in Linux to execute some python scripts. please help me Siva Ranganath 9000163232 From gora at mimirtech.com Thu Feb 21 09:52:23 2013 From: gora at mimirtech.com (Gora Mohanty) Date: Thu, 21 Feb 2013 14:22:23 +0530 Subject: [BangPypers] regarding installation of python In-Reply-To: References: Message-ID: On 21 February 2013 13:43, Siva Ranganath wrote: > hello BangPypers at python.org > > > I have RedHat linux in my Laptop where iam accessing through VMware. how > can install python librearies in Linux to execute some python scripts. > please help me This is better suited to a Redhat forum, or RHEL support if you purchased that. It is also a very basic question about maintaining system packages, and you would do well to learn such things on your own. Been a while since I used RPM-based systems, but yum install python should do the trick. You will need to have set up network access on your VM. Regards, Gora From satishsagar83 at gmail.com Thu Feb 21 10:13:40 2013 From: satishsagar83 at gmail.com (L Radhakrishna Rao) Date: Thu, 21 Feb 2013 14:43:40 +0530 Subject: [BangPypers] list comprehensions and generator expressions in Python 3 In-Reply-To: References: Message-ID: Dive into python 3 by mark pilgirm has mentioned about this. Regards, Radhakrishna From steve at lonetwin.net Thu Feb 21 11:09:51 2013 From: steve at lonetwin.net (steve) Date: Thu, 21 Feb 2013 15:39:51 +0530 Subject: [BangPypers] regarding installation of python In-Reply-To: References: Message-ID: <5125F26F.7040504@lonetwin.net> Hello Siva, On Thursday 21 February 2013 01:43 PM, Siva Ranganath wrote: > hello BangPypers at python.org > > > I have RedHat linux in my Laptop where iam accessing through VMware. how > can install python librearies in Linux to execute some python scripts. > please help me > If you've installed a recent Red Hat based distribution(*), most likely python is already installed on your system, since a lot of tools (including yum, the package manager) are written in python. Just run 'python' from the prompt to verify. It is possible though that you do not have the entire python standard library installed. To do this, simply execute 'yum install python-devel'. Assuming that your VM is able communicate with a yum repository (over the network or on the host), this command would install the set of standard python libraries/modules. cheers, - steve (*) There hasn't been a distribution named Red Hat Linux for a while now, there's either - Red Hat Enterprise Linux (ie: RHEL) or Fedora. From smchawla at cisco.com Fri Feb 22 07:11:32 2013 From: smchawla at cisco.com (Smriti) Date: Fri, 22 Feb 2013 06:11:32 +0000 (UTC) Subject: [BangPypers] Openings with Cisco Bangalore - Server side Python Web Application Development Experts Message-ID: Hi All, I have some very exciting openings with Cisco Bangalore for Python Web Application Development Experts. If you feel that the opportunity matches your career aspirations, kindly revert back to me with you updated profile and I shall get in touch with you to discuss the position in more detail. Job Title - Server side Python Web Application Development Experts Job Description CISCO SRTG (Security and Routing Technology Group) seeks a bright, motivated Software Engineer to join a highly driven and talented team involved in development of security solutions for branch routers and cloud deployments. As enterprises migrate to cloud based services, security solutions have to be tailored to meet the security challenges of this environment. The next generation routing platforms that embedding security in the network, also demand security solutions that are intelligent and highly reactive. If security and cloud excites you, reach out to us. Seeking highly passionate and self-driven young individuals to work on cutting edge technologies and platforms Responsibilities: Work on development of Cisco Cloud Connector platform. Network Focused Web applications Required Skill set ? 5+ to 10 years of development experience with one or more programming languages(C/C++/Java). ? Expert python programming skills with 3+ years with python ? Hands-on experience in building high-performance and scalable python based web applications ? Developed REST APIs, Web Services using one or more Python frameworks and cloud experience is a huge plus. ? Familiarity with python web frameworks like Django, Tornado, Web2Py, Google AppEngine etc ? Working knowledge of asynchronous frameworks like twisted, gevent/eventlet, coroutines will be an advantage ? Good understanding of networking concepts and L7 protocols like HTTP is a plus ? Linux system level knowledge (system calls, pthreads, mutexes, shared memory, non-blocking IO etc) would be well appreciated ? Excellent communication skills. ? Ability to articulate thoughts and ideas clearly. ? Quick to learn new technologies. Warm Regards, Smriti Chawla smchawla at cisco.com From tsk.kamath at gmail.com Mon Feb 25 15:11:08 2013 From: tsk.kamath at gmail.com (T S KAMATH) Date: Mon, 25 Feb 2013 19:41:08 +0530 Subject: [BangPypers] help to understand this code.. In-Reply-To: <5125F26F.7040504@lonetwin.net> References: <5125F26F.7040504@lonetwin.net> Message-ID: <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> Hi, I have no cue on php and its usage.. i am stuck.. I just wanted to list all the files and dir of the folder on webpage and unfortunately the web-server is set up for php.. http://www.php.net/manual/en/function.scandir.php#109115 "; foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { echo "
  • [`] ".$entry."
  • "; } } echo ""; //-- separator echo "
      "; foreach($directories as $entry) { if(is_file($dir_path.$entry)) { echo "
    • [ ] ".$entry."
    • "; } } echo "
    "; } dir_nav(); //-- optional placement if (isset($_GET["file"])) { echo "
    "; highlight_file($dir_path.$_GET['file']); echo "
    "; } //-- until here //-- //-- Because I love php.net ?>
    can i get someone to show me some direction.. Srikanth Kamath From gora at mimirtech.com Mon Feb 25 15:44:28 2013 From: gora at mimirtech.com (Gora Mohanty) Date: Mon, 25 Feb 2013 20:14:28 +0530 Subject: [BangPypers] help to understand this code.. In-Reply-To: <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> References: <5125F26F.7040504@lonetwin.net> <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> Message-ID: On 25 February 2013 19:41, T S KAMATH wrote: > Hi, > > I have no cue on php and its usage.. i am stuck.. I just wanted to list all the files and dir of the folder on webpage and unfortunately the web-server is set up for php.. [...] So, why are you asking here? It is off-topic, and you would probably have better luck at getting an answer on a PHP forum. Regards, Gora From tsk.kamath at gmail.com Mon Feb 25 16:10:20 2013 From: tsk.kamath at gmail.com (Srikanth Kamath) Date: Mon, 25 Feb 2013 20:40:20 +0530 Subject: [BangPypers] help to understand this code.. In-Reply-To: References: <5125F26F.7040504@lonetwin.net> <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> Message-ID: <91E2813E-7E18-4B87-AA12-278E9187415F@gmail.com> Oops Regards Srikanth Kamath, BDM SAARC Sent from my Mobil Device ~ I unable to access emails from laptop, maybe in meeting or ~~travelling hence response will be delayed, thanks for understanding and cooperation. On 25-Feb-2013, at 8:14 PM, Gora Mohanty wrote: On 25 February 2013 19:41, T S KAMATH wrote: > Hi, > > I have no cue on php and its usage.. i am stuck.. I just wanted to list all the files and dir of the folder on webpage and unfortunately the web-server is set up for php.. [...] So, why are you asking here? It is off-topic, and you would probably have better luck at getting an answer on a PHP forum. Regards, Gora _______________________________________________ BangPypers mailing list BangPypers at python.org http://mail.python.org/mailman/listinfo/bangpypers From pranjal.mittal.ece10 at iitbhu.ac.in Mon Feb 25 16:21:58 2013 From: pranjal.mittal.ece10 at iitbhu.ac.in (Pranjal Mittal) Date: Mon, 25 Feb 2013 20:51:58 +0530 Subject: [BangPypers] Python dictionaries, deleting elements while iterating. Message-ID: Hi all, I was writing a piece of code that deletes items from Python Dictionaries when a certain condition is met. while iterating over the dictionary. http://dpaste.com/hold/995010/ However that leads to a RunTime Error. Though I figured out an alternate solution, I still wonder why shouldn't something like *Case-1 *(in the code) work ideally. - Pranjal Mittal -- B.Tech. Part III, Indian Institute of Technology, BHU, Varanasi -221005 From anandology at gmail.com Mon Feb 25 17:03:06 2013 From: anandology at gmail.com (Anand Chitipothu) Date: Mon, 25 Feb 2013 21:33:06 +0530 Subject: [BangPypers] Python dictionaries, deleting elements while iterating. In-Reply-To: References: Message-ID: On Mon, Feb 25, 2013 at 8:51 PM, Pranjal Mittal < pranjal.mittal.ece10 at iitbhu.ac.in> wrote: > > Hi all, > > I was writing a piece of code that deletes items from Python Dictionaries > when a certain condition is met. while iterating over the dictionary. > > http://dpaste.com/hold/995010/ > > However that leads to a RunTime Error. > Though I figured out an alternate solution, I still wonder why shouldn't > something like *Case-1 *(in the code) work ideally. You can iterate over items: for key, value in dictionary.items(): if value == 1: del dictionary[key] Sometimes it is easier to create a new dictionary instead of modifying the existing one. dictionary = dict((k, v) for k, v in dictionary.items() if v != 1) Anand http://anandology.com/ From ragsagar at gmail.com Mon Feb 25 17:20:25 2013 From: ragsagar at gmail.com (ragsagar) Date: Mon, 25 Feb 2013 21:50:25 +0530 Subject: [BangPypers] Python dictionaries, deleting elements while iterating. In-Reply-To: References: Message-ID: On Mon, Feb 25, 2013 at 9:33 PM, Anand Chitipothu wrote: > > You can iterate over items: > > for key, value in dictionary.items(): > if value == 1: > del dictionary[key] > I think in Python 3.*, dict.items() returns iterator. If so it won't work in Python 3.* . So converting it to list would be a better option. for key in list(dictionary): if dictionary[key] == 1: del dictionary[key] -- blog : ragsagar.wordpress.com mail id : python -c "print '@'.join(['ragsagar','.'.join([x for x in ['gmail','com']])])" From anandology at gmail.com Mon Feb 25 17:45:11 2013 From: anandology at gmail.com (Anand Chitipothu) Date: Mon, 25 Feb 2013 22:15:11 +0530 Subject: [BangPypers] Python dictionaries, deleting elements while iterating. In-Reply-To: References: Message-ID: On Mon, Feb 25, 2013 at 9:50 PM, ragsagar wrote: > On Mon, Feb 25, 2013 at 9:33 PM, Anand Chitipothu >wrote: > > > > > You can iterate over items: > > > > for key, value in dictionary.items(): > > if value == 1: > > del dictionary[key] > > > > I think in Python 3.*, dict.items() returns iterator. If so it won't work > in Python 3.* . So converting it to list would be a better option. > > for key in list(dictionary): > if dictionary[key] == 1: > del dictionary[key] > I think, the second solution I suggested is more Pythonic than using a for loop. In Python 3, it can be written as a dictionary-comprehension. dictionary = {(k, v) for k, v in dictionary.items() if v != 1} Anand From ragsagar at gmail.com Mon Feb 25 17:55:20 2013 From: ragsagar at gmail.com (ragsagar) Date: Mon, 25 Feb 2013 22:25:20 +0530 Subject: [BangPypers] Python dictionaries, deleting elements while iterating. In-Reply-To: References: Message-ID: On Mon, Feb 25, 2013 at 10:15 PM, Anand Chitipothu wrote: > > > I think, the second solution I suggested is more Pythonic than using a for > loop. In Python 3, it can be written as a dictionary-comprehension. > > dictionary = {(k, v) for k, v in dictionary.items() if v != 1} > > True. Using dictionary comprehension is the apt solution. I was just talking about the first solution you suggested. -- blog : ragsagar.wordpress.com mail id : python -c "print '@'.join(['ragsagar','.'.join([x for x in ['gmail','com']])])" From thavamuni at gmail.com Mon Feb 25 18:17:06 2013 From: thavamuni at gmail.com (Thava Alagu) Date: Mon, 25 Feb 2013 22:47:06 +0530 Subject: [BangPypers] Python dictionaries, deleting elements while iterating Message-ID: Hi, Earlier answers have rightly pointed out elegant solutions, out of which dictionary comprehension is the most pythonic. btw, dictionary comprehension is available in Python 2.7 and 3+. with regards to why deleting while iterating is a problem -- it is like cutting the branch of the tree while standing on it. For efficiency reasons, the python implementations of iterators are free to use some sort of linked list like representation for iterators-- when you delete the current element the iterator gets confused how to go to next element. Regards, -thava On Mon, Feb 25, 2013 at 10:15 PM, wrote: > Message: 4 > Date: Mon, 25 Feb 2013 20:51:58 +0530 > From: Pranjal Mittal > To: Bangalore Python Users Group - India > Subject: [BangPypers] Python dictionaries, deleting elements while > iterating. > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > Hi all, > > I was writing a piece of code that deletes items from Python Dictionaries > when a certain condition is met. while iterating over the dictionary. > > http://dpaste.com/hold/995010/ > > However that leads to a RunTime Error. > Though I figured out an alternate solution, I still wonder why shouldn't > something like *Case-1 *(in the code) work ideally. > > > > - Pranjal Mittal > > -- > B.Tech. Part III, > Indian Institute of Technology, BHU, > Varanasi -221005 From tsk.kamath at gmail.com Tue Feb 26 03:47:40 2013 From: tsk.kamath at gmail.com (T S KAMATH) Date: Tue, 26 Feb 2013 08:17:40 +0530 Subject: [BangPypers] help to understand this code In-Reply-To: <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> References: <5125F26F.7040504@lonetwin.net> <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> Message-ID: <26C1411C-BB82-4465-8E77-95DFC30356A3@gmail.com> My Apologies for yesterdays post.. It was click "send" instead of "draft".. Moderator pls "del" the earlier post. I am no developer nor a hardcore programer. I just use open Source to find "work around" to issues and or to automate. all my stuff is open source and free to use. Hence pls excuse if some of my post.. I shall send my correct post.. with the correct heading.. Thanks in advance From tsk.kamath at gmail.com Tue Feb 26 03:49:43 2013 From: tsk.kamath at gmail.com (T S KAMATH) Date: Tue, 26 Feb 2013 08:19:43 +0530 Subject: [BangPypers] Listing files in a folder using python In-Reply-To: <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> References: <5125F26F.7040504@lonetwin.net> <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> Message-ID: <1FBF9C96-C062-4769-A942-1725DFEEE970@gmail.com> as a newbie to python, I am looking for some advance examples for some functions.. so that my learning curve is short.. I have used a code in php http://www.php.net/manual/en/function.scandir.php#109115, which works fine, My question is can a similar featured listing be done in Python.. if you could guide me it would be great.. From b.ghose at gmail.com Tue Feb 26 03:58:29 2013 From: b.ghose at gmail.com (Baishampayan Ghose) Date: Tue, 26 Feb 2013 08:28:29 +0530 Subject: [BangPypers] Listing files in a folder using python In-Reply-To: <1FBF9C96-C062-4769-A942-1725DFEEE970@gmail.com> References: <5125F26F.7040504@lonetwin.net> <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> <1FBF9C96-C062-4769-A942-1725DFEEE970@gmail.com> Message-ID: I didn't read the whole PHP code, but I guess you are trying to scan a directory for files, etc. This can be accomplished using the os.walk function in Python - http://docs.python.org/2/library/os.html#os.walk Regards, BG On Tue, Feb 26, 2013 at 8:19 AM, T S KAMATH wrote: > as a newbie to python, I am looking for some advance examples for some functions.. so that my learning curve is short.. > > I have used a code in php http://www.php.net/manual/en/function.scandir.php#109115, which works fine, > > My question is can a similar featured listing be done in Python.. if you could guide me it would be great.. > > > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers -- Baishampayan Ghose b.ghose at gmail.com From gopalakrishnan.subramani at gmail.com Tue Feb 26 04:12:34 2013 From: gopalakrishnan.subramani at gmail.com (Gopalakrishnan Subramani) Date: Tue, 26 Feb 2013 08:42:34 +0530 Subject: [BangPypers] help to understand this code In-Reply-To: <26C1411C-BB82-4465-8E77-95DFC30356A3@gmail.com> References: <5125F26F.7040504@lonetwin.net> <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> <26C1411C-BB82-4465-8E77-95DFC30356A3@gmail.com> Message-ID: I still recommend you go through the fundamentals of Python, I don't see any hurry in learning something new. Starts with printing "hello world", then conditions, loops, functions, Class, Objects. You don't need more than 2 weeks for this homework. Couple of late nights and weekends help you, It is worth for the effort. On Tue, Feb 26, 2013 at 8:17 AM, T S KAMATH wrote: > My Apologies for yesterdays post.. It was click "send" instead of > "draft".. Moderator pls "del" the earlier post. > > I am no developer nor a hardcore programer. I just use open Source to find > "work around" to issues and or to automate. all my stuff is open source and > free to use. Hence pls excuse if some of my post.. > > I shall send my correct post.. with the correct heading.. Thanks in advance > _______________________________________________ > BangPypers mailing list > BangPypers at python.org > http://mail.python.org/mailman/listinfo/bangpypers > From navin.kabra at gmail.com Tue Feb 26 06:01:57 2013 From: navin.kabra at gmail.com (Navin Kabra) Date: Tue, 26 Feb 2013 10:31:57 +0530 Subject: [BangPypers] Python dictionaries, deleting elements while iterating. In-Reply-To: References: Message-ID: <87621fy8fu.fsf@smriti.com> Anand Chitipothu writes: > loop. In Python 3, it can be written as a dictionary-comprehension. Dictionary and set comprehensions are also available in Python 2.7 From benignbala at gmail.com Tue Feb 26 13:15:27 2013 From: benignbala at gmail.com (Balachandran Sivakumar) Date: Tue, 26 Feb 2013 17:45:27 +0530 Subject: [BangPypers] Listing files in a folder using python In-Reply-To: <1FBF9C96-C062-4769-A942-1725DFEEE970@gmail.com> References: <5125F26F.7040504@lonetwin.net> <631E8584-BF19-4691-9675-760B060C8DBB@gmail.com> <1FBF9C96-C062-4769-A942-1725DFEEE970@gmail.com> Message-ID: Hi, On Tue, Feb 26, 2013 at 8:19 AM, T S KAMATH wrote: > as a newbie to python, I am looking for some advance examples for some functions.. so that my learning curve is short.. > > I have used a code in php http://www.php.net/manual/en/function.scandir.php#109115, which works fine, If it is not a production-grade script, you can just do python -m SimpleHTTPServer from your bash after getting into the folder that you want to server. Python will server it for you :) Thanks -- Thank you Balachandran Sivakumar Arise Awake and stop not till the goal is reached. - Swami Vivekananda Mail: benignbala at gmail.com Blog: http://benignbala.wordpress.com/