Re: Timezones in python
On 5 Dec, 13:59, Gabriel Genellina [EMAIL PROTECTED] wrote: En Wed, 05 Dec 2007 06:43:49 -0300, [EMAIL PROTECTED] escribió: Thanks guys for your answers! I know those library's but I was wondering is there something build-in for this simple convert convert. I have to do it only from +4 to +0. Copying the example from the tzinfo docs: from datetime import tzinfo, timedelta, datetime ZERO = timedelta(0) HOUR = timedelta(hours=1) # A class building tzinfo objects for fixed-offset time zones. # Note that FixedOffset(0, UTC) is a different way to build a # UTC tzinfo object. class FixedOffset(tzinfo): Fixed offset in minutes east from UTC. def __init__(self, offset, name): self.__offset = timedelta(minutes = offset) self.__name = name def utcoffset(self, dt): return self.__offset def tzname(self, dt): return self.__name def dst(self, dt): return ZERO UTC = FixedOffset(0, 'UTC') Argentina = FixedOffset(-3*60, 'UTC-3') UTCPlus4 = FixedOffset(4*60, 'UTC+4') py now = datetime.now(Argentina) py print now.strftime('%c %Z') 12/05/07 10:52:28 UTC-3 py print now.astimezone(UTC).strftime('%c %Z') 12/05/07 13:52:28 UTC py print now.astimezone(Argentina).strftime('%c %Z') 12/05/07 10:52:28 UTC-3 py print now.astimezone(UTCPlus4).strftime('%c %Z') 12/05/07 17:52:28 UTC+4 -- Gabriel Genellina Thank you that iwll help a lot -- http://mail.python.org/mailman/listinfo/python-list
Re: Timezones in python
Thanks guys for your answers! I know those library's but I was wondering is there something build-in for this simple convert convert. I have to do it only from +4 to +0. -- http://mail.python.org/mailman/listinfo/python-list
Timezones in python
Hello, Is there any build in solution in python to handle timezones? My problem is I have to convert +4 time to +0. In the worst case i can just add +4 to the houer but I'm not very happy about that. Another problem is the summer/winter timechange which happen with one week difference. I am looking for something what can convert different timezone to localtime. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
cx_Oracle + array parameter
Hello, I'm trying to pass array as an argument into PL/SQL procedure. According to cursor manual (http://cx-oracle.sourceforge.net/html/ cursorobj.html) arrayvar() should be use to do it. I've created my array type in PL/SQL: CREATE OR REPLACE TYPE cx_array_string is table of varchar2(200); and simple procedure: CREATE OR REPLACE PROCEDURE text(ret IN cx_array_string) IS BEGIN null; END text; My python code: p_array = curs.arrayvar(cx_Oracle.STRING, ['1','3']) curs.execute('BEGIN text( :1 ); end;', [p_array] ) And it gives me back an error: cx_Oracle.DatabaseError: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'TEXT' ORA-06550: line 1, column 7: PL/SQL: Statement ignored It's the same when i try to use callproc() instead of execute(). I've searched whole internet with no luck. Could anyone please give me a working example python + pl/sql how to pass string array form py to oracle procedure, please. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle + array parameter
On 3 Gru, 19:07, Ian Clark [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hello, I'm trying to pass array as an argument into PL/SQL procedure. According to cursor manual (http://cx-oracle.sourceforge.net/html/ cursorobj.html) arrayvar() should be use to do it. I've created my array type in PL/SQL: CREATE OR REPLACE TYPE cx_array_string is table of varchar2(200); and simple procedure: CREATE OR REPLACE PROCEDURE text(ret IN cx_array_string) IS BEGIN null; END text; My python code: p_array = curs.arrayvar(cx_Oracle.STRING, ['1','3']) curs.execute('BEGIN text( :1 ); end;', [p_array] ) And it gives me back an error: cx_Oracle.DatabaseError: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'TEXT' ORA-06550: line 1, column 7: PL/SQL: Statement ignored It's the same when i try to use callproc() instead of execute(). I've searched whole internet with no luck. Could anyone please give me a working example python + pl/sql how to pass string array form py to oracle procedure, please. Thank you! First off I've never used cxOracle or done any PL/SQL from python, but it looks like you're passing a list of a list to text(). p_array = curs.arrayvar(cx_Oracle.STRING, ['1','3']) curs.execute('BEGIN text( :1 ); end;', [p_array] ) p_array appears to be some sort of cxOracle array, but when you pass it to curs.execute you wrap it in a new list: [p_array]. Try removing the parens and see what happens. Ian Hello, Thanks for your reply. The secound parameter in curs.execute have to be list. I passed only one parameter so it looks bizzare but this is right. Anyway i know why it was wrong. Problem is in the cx_array_string. This type has to be INDEX BY BINARY_INTEGER I hope it will help somebody in the future. -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle + array parameter
On 3 Gru, 19:07, Ian Clark [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hello, I'm trying to pass array as an argument into PL/SQL procedure. According to cursor manual (http://cx-oracle.sourceforge.net/html/ cursorobj.html) arrayvar() should be use to do it. I've created my array type in PL/SQL: CREATE OR REPLACE TYPE cx_array_string is table of varchar2(200); and simple procedure: CREATE OR REPLACE PROCEDURE text(ret IN cx_array_string) IS BEGIN null; END text; My python code: p_array = curs.arrayvar(cx_Oracle.STRING, ['1','3']) curs.execute('BEGIN text( :1 ); end;', [p_array] ) And it gives me back an error: cx_Oracle.DatabaseError: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'TEXT' ORA-06550: line 1, column 7: PL/SQL: Statement ignored It's the same when i try to use callproc() instead of execute(). I've searched whole internet with no luck. Could anyone please give me a working example python + pl/sql how to pass string array form py to oracle procedure, please. Thank you! First off I've never used cxOracle or done any PL/SQL from python, but it looks like you're passing a list of a list to text(). p_array = curs.arrayvar(cx_Oracle.STRING, ['1','3']) curs.execute('BEGIN text( :1 ); end;', [p_array] ) p_array appears to be some sort of cxOracle array, but when you pass it to curs.execute you wrap it in a new list: [p_array]. Try removing the parens and see what happens. Ian Hello, Thanks for your reply. The secound parameter in curs.execute has to be list. I passed only one parameter so it looks bizzare but this is right. Anyway i know why it was wrong. Problem is in the cx_array_string. This type has to be INDEX BY BINARY_INTEGER I hope it will help somebody in the future. -- http://mail.python.org/mailman/listinfo/python-list
dynamic invoke
Hello, Is there any way (other then eval) to invoke a method by passing method name in a string. It's very simple in php: $oFoo = new Foo(); $dynamiMethod = bar; $oFoo-$dynamiMethod(); Unfortunately I can't find a good solution to do the same thing in python. Does it have some build-in function to do it? Kind Regards, Lukasz. -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamic invoke
On 19 Oct, 11:45, Jarek Zgoda [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] napisa³(a): Is there any way (other then eval) to invoke a method by passing method name in a string. It's very simple in php: $oFoo = new Foo(); $dynamiMethod = bar; $oFoo-$dynamiMethod(); Unfortunately I can't find a good solution to do the same thing in python. Does it have some build-in function to do it? foo = getattr(module_or_object, 'function_name') foo() -- Jarek Zgoda Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101 We read Knuth so you don't have to. (Tim Peters) Superb! I was lookig for something like this. Belive me or not but i spent lots of time looking for this simple solution :) Cheers. -- http://mail.python.org/mailman/listinfo/python-list
MOD_PYTHON + packages reloading
Hello, I came across annoying problem during my fun with mod_python. I turned out that mod_python load package only onca and don't care about any changes to it. Obviously it makes sense on production server but during development is more then annoying. I find a way to reload my module: m = apache.import_module(name) reload(m) But this solution doesn't satisfy my. Is there any way to use old good import x.x.x or from x.x.x import y and somehow set mod_python to autoreload packages? apache.import_module(name,autoreload=1) didn't work. What is more interesting if a file is in the same directory (no in the package) i don't need to wory about reloading, python doesn't cache it. Please help me :) -- http://mail.python.org/mailman/listinfo/python-list
Re: MOD_PYTHON + packages reloading
On 18 Oct, 09:55, Duncan Booth [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I came across annoying problem during my fun with mod_python. I turned out that mod_python load package only onca and don't care about any changes to it. Obviously it makes sense on production server but during development is more then annoying. Have you read the mod_python manual? http://www.modpython.org/live/current/doc-html/dir-other-par.html 5.4.8 PythonAutoReload Syntax: PythonAutoReload {On, Off} Default: PythonAutoReload On Context: server config, virtual host, directory, htaccess Override: not None Module: mod_python.c If set to Off, instructs mod_python not to check the modification date of the module file. By default, mod_python checks the time-stamp of the file and reloads the module if the module's file modification date is later than the last import or reload. This way changed modules get automatically reimported, eliminating the need to restart the server for every change. Disabling autoreload is useful in production environment where the modules do not change; it will save some processing time and give a small performance gain. Yes I have read it. This is my config file VirtualHost *:80 ServerName info DocumentRoot D:/web/info/ Directory D:/web/info/ AddHandler mod_python .py PythonHandler index PythonDebug On PythonAutoReload On AllowOverride All Allow from All AllowOverride All /Directory /VirtualHost Even when autoreload is ON mod_python doesn't care about any changes if I import something from package in traditional way :( -- http://mail.python.org/mailman/listinfo/python-list