reading from a gzip file

2008-06-18 Thread Nader
Hello,

I have a gzip file and I try to read from this file withe the next
statements:

 gunziped_file = gzip.GzipFile('gzip-file')
 input_file = open(gunziped_file,'r')

But I get the nezt error message:

Traceback (most recent call last):
  File "read_sfloc_files.py", line 131, in ?
input_file = open(gunziped_file,'r')
TypeError: coercing to Unicode: need string or buffer, instance found

I think that I do some mistake. Would some body tell me what is my
mistake?

Nader
--
http://mail.python.org/mailman/listinfo/python-list


reading from an a gzip file

2008-06-18 Thread Nader
Hello,

I have a gzip file and I try to read from this file withe the next
statements:

 gunziped_file = gzip.GzipFile('gzip-file')
 input_file = open(gunziped_file,'r')

But I get the nezt error message:

Traceback (most recent call last):
  File "read_sfloc_files.py", line 131, in ?
input_file = open(gunziped_file,'r')
TypeError: coercing to Unicode: need string or buffer, instance found

I think that I do some mistake. Would some body tell me what is my
mistake?

Nader
--
http://mail.python.org/mailman/listinfo/python-list


Re: Checking list by using of exception

2008-06-13 Thread Nader
On Jun 13, 11:34 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Fri, 13 Jun 2008 04:37:44 -0300, Nader <[EMAIL PROTECTED]> escribió:
>
> > Hello,
>
> > I read some files name from a directory and then I put these name in a
> > list. I will check whether it is empty or not, and I would do it with
> > an exception. With if statement it is very simple:
>
> > If list_of_files != ""  :# this can be if list_of_files !=
> > []:
> >   get the files
> > elas:
> >there is no file
>
> If it is simple, just do it! Why do you want to make things more
> complicated? This would be enough:
>
> if list_of_files:
>  get_the_files(list_of_files)
> else:
>  print "there is no file"
>
> (a list has a false boolean value when it is empty)
>
> > But with exception, I can write something as:
>
> > try:
> >list_of_files != []
> >get the files
> > except ValueError:
> > Print " there is no file"
>
> > What can the first statement be inside 'try' if I don't want to use if
> > statement?
>
> If you insist on using an exception (and assuming list_of_files is
> actually a list, not a string or other kind of sequence):
>
> try:
>  list_of_files[0]
> except IndexError:
>  ...no files...
>
> This way you're checking that list_of_files contains at least one element.
> But I would not reccomend it.
>
> --
> Gabriel Genellina

I would accept your suggestion in raltion of checking a list whether
it is empty or not with "if" statement. It is more expressive and
clear. But In this case I would learn more about the "try  except"
exception.

Nader
--
http://mail.python.org/mailman/listinfo/python-list


Checking list by using of exception

2008-06-13 Thread Nader
Hello,

I read some files name from a directory and then I put these name in a
list. I will check whether it is empty or not, and I would do it with
an exception. With if statement it is very simple:

If list_of_files != ""  :# this can be if list_of_files !=
[]:
  get the files
elas:
   there is no file

But with exception, I can write something as:

try:
   list_of_files != []
   get the files
except ValueError:
Print " there is no file"

What can the first statement be inside 'try' if I don't want to use if
statement?
Maybe my understandig of exception is enough to got it.

Would somebody explain me about this?

Regards,
Nader


try and except   in a dircMaybe this quetion will be simple enough for
you.
--
http://mail.python.org/mailman/listinfo/python-list


Re: get keys with the same values

2008-06-12 Thread Nader
On Jun 12, 2:05 pm, Chris <[EMAIL PROTECTED]> wrote:
> On Jun 12, 1:48 pm, Nader <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 12, 1:35 pm, [EMAIL PROTECTED] wrote:
>
> > > Nader:
>
> > > > d = {('a' : 1), ('b' : 3), ('c' : 2),('d' : 3),('e' : 1),('f' : 4)}
> > > > I will something as :
> > > > d.keys(where their values are the same)
>
> > > That's magic.
>
> > > > With this statement I can get two lists for this example:
> > > > l1= ['a','e']
> > > > l2=['b','d']
> > > > Would somebody tell me how I can do it?
>
> > > You can create a new dict where the keys are the values of the input
> > > dict and the values are a list of the keys of the original dict. So
> > > scanning the keys, values of the input dict, you can fill the second
> > > dict. Then you can scan the second dict, and create a list that
> > > contains only value lists longer than one.
>
> > > Bye,
> > > bearophile
>
> > Is it niet possible with one or two statement, maybe with list
> > comprehension. For exmple:
>
> > l = [(k,v) for k in d.keys() for v in d.values() | en here we need
> > some extra logic (v = 1)]
>
> > I don;t konw how we can define a logic statement in a list
> > comprehension.
> > It will be very compact, if it would possible.
>
> > Nader
>
> If you are going to use this reverse look-up alot you'd be better off
> building another dictionary with the original values being keys and
> the original keys being values, if it is used infrequently enough you
> can search for it with result_list = [k for k,v in dictionary.items()
> if v == search_value]

Thank you! It is the anwser which I was looking for. [(k,v) for k,v
in  d.items() if v is pattern].
But I don't understand what tou mean of "reverse look-up a lot"! I
have to read some informations inclusive (latitudes and longitudes)
form a file and after some processing to save part of this information
to other file.
Why do I make a new dictionary?

Nader
--
http://mail.python.org/mailman/listinfo/python-list


Re: get keys with the same values

2008-06-12 Thread Nader
On Jun 12, 1:41 pm, David C. Ullrich <[EMAIL PROTECTED]> wrote:
> On Thu, 12 Jun 2008 03:58:53 -0700 (PDT), Nader <[EMAIL PROTECTED]>
> wrote:
>
> >Hello,
>
> >I have a dictionary and will get all keys which have the same values.
>
> >d = {('a' : 1), ('b' : 3), ('c' : 2),('d' : 3),('e' : 1),('f' : 4)}
>
> That's not a dictionary, it's a syntax error. If you actually
> have a dictionary you could say
>
> d = {'a' : 1, 'b' : 3, 'c' : 2,'d' : 3,'e' : 1,'f' : 4}
>
> dd = {}
>
> for key, value in d.items():
>   try:
> dd[value].append(key)
>   except KeyError:
> dd[value] = [key]
>
> Possibly dd is now what you really want; if you really
> want what you said you want you could use
>
> [l for l in dd.values() if len(l) > 1]
>
> >I will something as :
>
> >d.keys(where their values are the same)
>
> >With this statement I can get two lists for this example:
> >l1= ['a','e']
> >l2=['b','d']
>
> >Would somebody tell me how I can do it?
>
> >Regards,
> >Nader
>
> David C. Ullrich

Thank for your type about the syntax error. This an example example,
the keys of my dictionary are tuples:
d = {(37.75, 42.22): 1 , (37.51, 40.02): 3 (45.55, 24.27): 4 (47.08,
30.99) : 1}

But what I will is to get all keys which has the same valus. And not
the keys that have value more than 1!

Nader
--
http://mail.python.org/mailman/listinfo/python-list


Re: get keys with the same values

2008-06-12 Thread Nader
On Jun 12, 1:35 pm, [EMAIL PROTECTED] wrote:
> Nader:
>
> > d = {('a' : 1), ('b' : 3), ('c' : 2),('d' : 3),('e' : 1),('f' : 4)}
> > I will something as :
> > d.keys(where their values are the same)
>
> That's magic.
>
> > With this statement I can get two lists for this example:
> > l1= ['a','e']
> > l2=['b','d']
> > Would somebody tell me how I can do it?
>
> You can create a new dict where the keys are the values of the input
> dict and the values are a list of the keys of the original dict. So
> scanning the keys, values of the input dict, you can fill the second
> dict. Then you can scan the second dict, and create a list that
> contains only value lists longer than one.
>
> Bye,
> bearophile

Is it niet possible with one or two statement, maybe with list
comprehension. For exmple:

l = [(k,v) for k in d.keys() for v in d.values() | en here we need
some extra logic (v = 1)]

I don;t konw how we can define a logic statement in a list
comprehension.
It will be very compact, if it would possible.

Nader
--
http://mail.python.org/mailman/listinfo/python-list


get keys with the same values

2008-06-12 Thread Nader
Hello,

I have a dictionary and will get all keys which have the same values.

d = {('a' : 1), ('b' : 3), ('c' : 2),('d' : 3),('e' : 1),('f' : 4)}

I will something as :

d.keys(where their values are the same)

With this statement I can get two lists for this example:
l1= ['a','e']
l2=['b','d']

Would somebody tell me how I can do it?

Regards,
Nader
--
http://mail.python.org/mailman/listinfo/python-list


Re: str to float (rounded)

2008-06-10 Thread Nader
On Jun 10, 4:30 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Nader wrote:
> > Hello,
>
> > I have a list of tuple with strin elements. These elements are number,
> > but they are save as string. Now I will change the string to number
> > which will be rounded. An example will make it more clear.
>
> > t = [('35.757', '-0.239'), ('33.332', '-2.707'), ('33.640', '-2.423')]
>
> > And I will have the next list:
>
> > t = [(35.76, -2.24), (33.33, -2.71), (33.64, -2.42)]
>
> > The elements of tuple are not more as string.
>
> > Would somebody tell me how I can do that?
>
> use
>
> float("123.45")
>
> to convert a string to a float.
>
> Of course you need to do that on all your elements above by e.g. a
> list-comprehension.
>
> Diez

If I do the next :

 t1 = [(round(float(x),1), round(float(y),2)) for x, y in t]

I get the long float as :

[(35.797, -0.23999), (33.297,
-2.71), (33.601,-2.4199)]

But I would have a float with 2 decimal numbers.


--
http://mail.python.org/mailman/listinfo/python-list


str to float (rounded)

2008-06-10 Thread Nader
Hello,

I have a list of tuple with strin elements. These elements are number,
but they are save as string. Now I will change the string to number
which will be rounded. An example will make it more clear.

t = [('35.757', '-0.239'), ('33.332', '-2.707'), ('33.640', '-2.423')]

And I will have the next list:

t = [(35.76, -2.24), (33.33, -2.71), (33.64, -2.42)]

The elements of tuple are not more as string.

Would somebody tell me how I can do that?

Regards,
Nader

--
http://mail.python.org/mailman/listinfo/python-list


Re: lists to save in a tuple

2008-06-09 Thread Nader
On Jun 9, 3:34 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Nader wrote:
> > Hello,
>
> > I have two lists and would save them in a tuple.
>
> > a = [1,2,3]
> > b = ['a','b','c']
>
> > with the next statement I can do that:
>
> > t = [(x,y), for x in a for y in b]
>
> > This gives the next list:
>
> > [(1,'a'),(1,'b'),(1,'c'), (2,'a'),(2,'b'),(2,'c'), (3,'a'),(3,'b'),
> > (3,'c')]
>
> > But I want the next list:
>
> > [(1,'a'),(2,'b'),(3,'c')]
>
> > Would somebody tell me how I can solve this problem?
>
> zip(a, b)
>
> Diez

Thank you!
--
http://mail.python.org/mailman/listinfo/python-list


lists to save in a tuple

2008-06-09 Thread Nader
Hello,

I have two lists and would save them in a tuple.

a = [1,2,3]
b = ['a','b','c']

with the next statement I can do that:

t = [(x,y), for x in a for y in b]

This gives the next list:

[(1,'a'),(1,'b'),(1,'c'), (2,'a'),(2,'b'),(2,'c'), (3,'a'),(3,'b'),
(3,'c')]

But I want the next list:

[(1,'a'),(2,'b'),(3,'c')]

Would somebody tell me how I can solve this problem?

Regards,
Nader
--
http://mail.python.org/mailman/listinfo/python-list


Re: installing "pysqlite"

2007-03-01 Thread Nader
On Mar 1, 2:40 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote:
> On 1 Mar, 12:46, "Nader" <[EMAIL PROTECTED]> wrote:
>
>
>
> > ldd returens the next result:
> > ldd /usr/people/emami/lib/python2.4/site-packages/pysqlite2/_sqlite.so
> > linux-gate.so.1 =>  (0xe000)
> > libpthread.so.0 => /lib/tls/libpthread.so.0 (0x4004)
> > libc.so.6 => /lib/tls/libc.so.6 (0x4005)
>
> I think you pasted the nm result in here, but you seem to be missing
> libsqlite3.so.0 (from what I see myself). From what I've just read
> about linux-gate.so, the linker can't seem to find the SQLite
> libraries. More on linux-gate.so here:
>
> http://www.trilithium.com/johan/2005/08/linux-gate/
>
> > and the 'nm' gives this:
>
> > nm usr/people/emami/lib/libsqlite3.so | grep  sqlite3_set_authorize
> > ce40 T sqlite3_set_authorizer
>
> That looks alright.
>
> > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x8000)
>
> I guess this was the end of the ldd result.
>
> I'm out of ideas, unfortunately. I think you should experiment with
> LD_LIBRARY_PATH and run ldd again to see if you can get it to show
> libsqlite3.so.0. The pysqlite mailing list might be the best place to
> ask for help if that doesn't work. Sorry!
>
> Paul

Hello Paul,

I have returnd to the begining and have installed everthing again.
Fortunately now I have the 'pysqlite2' module, because the test.test()
workd after importing of 'pysqlite2'

 >>> from pysqlite2 import test
>>> test.test

>>> test.test()
.
--
Ran 173 tests in 0.585s

OK
>>>

And the result of running of 'ldd' is :
[EMAIL PROTECTED]:~> ldd lib/python2.4/site-packages/pysqlite2/_sqlite.so
linux-gate.so.1 =>  (0xe000)
libsqlite3.so.0 => /usr/people/emami/lib/libsqlite3.so.0
(0x4001)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40096000)
libc.so.6 => /lib/tls/libc.so.6 (0x400a7000)

Now I can ggo on with TurboGears! I have at home a Laptop and I have
installed the 'gentoo' on it, and have no problem. But I would like to
experiment with TurboGears at my work and It was a problem that I had
no 'root' password.
However I appreciate well your help in this case. I you like Indian or
oriental music I can send you some!

With regards,

Nader

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing "pysqlite"

2007-03-01 Thread Nader
On Mar 1, 11:46 am, "Paul Boddie" <[EMAIL PROTECTED]> wrote:
> On 1 Mar, 10:34, "Nader" <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have expanded the LD_LIBRARY_PATH to my home lib (export
> > LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/people/emami/lib).
> > I have built and installed the 'pysqlite-2.3.3' with the next
> > 'setup.cfg' :
>
> > [build_ext]
> > define=
> > include_dirs=/usr/people/emami/include
> > library_dirs=/usr/people/emami/lib
> > #libraries=/usr/people/emami/lib/libsqlite3.so  (this line as a
> > comment)
>
> This looks alright. Be sure to verify that libsqlite3.so is in /usr/
> people/emami/lib, although I suppose you've done this, looking at your
> comment.
>
> > The resutl of this process was:
>
> > running install_lib
> > copying build/lib.linux-i686-2.4/pysqlite2/_sqlite.so -> /usr/people/
> > emami/lib/python2.4/site-packages/pysqlite2
> > running install_data
>
> > This message had given after installing. I have controll the '/usr/
> > people/emami/lib/python2.4/site-packages/pysqlite2' whether the
> > '_sqlite.so' has copied there. Yes it has. Okay!
>
> So pysqlite2 has installed properly at least.
>
> > I go to python and I give the next command:
>
> > >>> from pysqlite import test
>
> > and Unfortunately I get the next error message:
>
> [...]
>
> > ImportError: /usr/people/emami/lib/python2.4/site-packages/pysqlite2/
> > _sqlite.so: undefined symbol: sqlite3_set_authorizer
>
> I'm running out of ideas here, but you could try doing this:
>
> ldd /usr/people/emami/lib/python2.4/site-packages/pysqlite2/_sqlite.so
>
> This should show a list of references to libraries, but if one of them
> is missing in some way then it means that it isn't found by the linker
> and it's not on the LD_LIBRARY_PATH. Another thought is that
> sqlite3_set_authorizer isn't found in the SQLite library - you can
> test this by doing the following:
>
> nm /usr/people/emami/lib/libsqlite3.so
>
> I get something like this in response:
>
> 000110b0 T sqlite3_set_authorizer
>
> If you don't get anything in response or if you see "U" instead of
> "T", then this might indicate an problem with the way SQLite has been
> configured.
>
> > Do you know what option I have to give to if I want to use the
> > 'easy_install" tool?
> > %easy_install pysqlite (with some optione with which it cab find the
> > installed 'libsqlite.so')
>
> I'm no easy_install expert, I'm afraid. You might want to talk to the
> pysqlite people directly if what I've suggested doesn't help you
> further:
>
> http://www.initd.org/tracker/pysqlite/wiki/pysqlite
>
> Paul

Hello

ldd returens the next result:
ldd /usr/people/emami/lib/python2.4/site-packages/pysqlite2/_sqlite.so
linux-gate.so.1 =>  (0xe000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x4004)
libc.so.6 => /lib/tls/libc.so.6 (0x4005)

and the 'nm' gives this:

nm usr/people/emami/lib/libsqlite3.so | grep  sqlite3_set_authorize
ce40 T sqlite3_set_authorizer


/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x8000)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing "pysqlite"

2007-03-01 Thread Nader
On Feb 28, 12:51 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote:
> On 28 Feb, 12:07, Nader Emami <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am back with another problem. I suppose that I can tell it!
> > I have installed both, 'sqlite' and 'pysqlite' without any problem. But
> > If I try to test whether the 'pysqlite' interface works, I get the next
> > error message:
>
> [...]
>
> > /usr/people/emami/lib/python2.4/site-packages/pysqlite2/_sqlite.so:
> > undefined symbol: sqlite3_set_authorizer
>
> > I don't understand it. Could you tell me how I can solve this last
> > point? I hope so!
>
> It looks like Python (although it's really the dynamic linker) can't
> locate the SQLite libraries. If you have installed SQLite into a non-
> standard place, which I'm guessing is the case, then you will need to
> set your LD_LIBRARY_PATH environment variable to refer to the
> directory where the libraries were installed.
>
> So, if you installed SQLite into /usr/people/emami and you see files
> like libsqlite3.so in /usr/people/emami/lib, then you need to change
> your LD_LIBRARY_PATH as follows:
>
> export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/people/emami/lib
>
> (The actual directory should be the same as the one you specified for
> library_dirs in the setup.cfg file for pysqlite.)
>
> If you're not using bash as your shell, the syntax for the command may
> be different. Don't forget to add this command to your shell
> configuration file (eg. .bashrc) so that your system remembers this
> information.
>
> Paul

Hello

I have expanded the LD_LIBRARY_PATH to my home lib (export
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/people/emami/lib).
I have built and installed the 'pysqlite-2.3.3' with the next
'setup.cfg' :

[build_ext]
define=
include_dirs=/usr/people/emami/include
library_dirs=/usr/people/emami/lib
#libraries=/usr/people/emami/lib/libsqlite3.so  (this line as a
comment)

The resutl of this process was:

running install_lib
copying build/lib.linux-i686-2.4/pysqlite2/_sqlite.so -> /usr/people/
emami/lib/python2.4/site-packages/pysqlite2
running install_data

This message had given after installing. I have controll the '/usr/
people/emami/lib/python2.4/site-packages/pysqlite2' whether the
'_sqlite.so' has copied there. Yes it has. Okay!
I go to python and I give the next command:
>>> from pysqlite import test

and Unfortunately I get the next error message:

Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/people/emami/lib/python2.4/site-packages/pysqlite2/test/
__init__.py", line 25, in ?
from pysqlite2.test import dbapi, types, userfunctions, factory,
transactions,\
  File "/usr/people/emami/lib/python2.4/site-packages/pysqlite2/test/
dbapi.py", line 26, in ?
import pysqlite2.dbapi2 as sqlite
  File "/usr/people/emami/lib/python2.4/site-packages/pysqlite2/
dbapi2.py", line 27, in ?
from pysqlite2._sqlite import *
ImportError: /usr/people/emami/lib/python2.4/site-packages/pysqlite2/
_sqlite.so: undefined symbol: sqlite3_set_authorizer

Do you know what option I have to give to if I want to use the
'easy_install" tool?
%easy_install pysqlite (with some optione with which it cab find the
installed 'libsqlite.so')

Nader

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing "pysqlite"

2007-02-28 Thread Nader
On Feb 28, 12:51 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote:
> On 28 Feb, 12:07, Nader Emami <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am back with another problem. I suppose that I can tell it!
> > I have installed both, 'sqlite' and 'pysqlite' without any problem. But
> > If I try to test whether the 'pysqlite' interface works, I get the next
> > error message:
>
> [...]
>
> > /usr/people/emami/lib/python2.4/site-packages/pysqlite2/_sqlite.so:
> > undefined symbol: sqlite3_set_authorizer
>
> > I don't understand it. Could you tell me how I can solve this last
> > point? I hope so!
>
> It looks like Python (although it's really the dynamic linker) can't
> locate the SQLite libraries. If you have installed SQLite into a non-
> standard place, which I'm guessing is the case, then you will need to
> set your LD_LIBRARY_PATH environment variable to refer to the
> directory where the libraries were installed.
>
> So, if you installed SQLite into /usr/people/emami and you see files
> like libsqlite3.so in /usr/people/emami/lib, then you need to change
> your LD_LIBRARY_PATH as follows:
>
> export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/people/emami/lib
>
> (The actual directory should be the same as the one you specified for
> library_dirs in the setup.cfg file for pysqlite.)
>
> If you're not using bash as your shell, the syntax for the command may
> be different. Don't forget to add this command to your shell
> configuration file (eg. .bashrc) so that your system remembers this
> information.
>
> Paul

I see now your respond to my problem, but i can check it tomorrow
because I don't have at this moment on this machine. However thank for
the reaction and I will tell about it after assiging the new lib to
its PATH.

Nader

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing "pysqlite"

2007-02-28 Thread Nader Emami
Paul Boddie wrote:
> On 27 Feb, 10:31, Nader Emami <[EMAIL PROTECTED]> wrote:
>> I have installed "TurboGears" and I would install 'pysqlite' also. I am
>> a user on a Linux machine. If I try to install the 'pysqlite' with
>> 'easy_install' tool I get the next error message. The error message is
>> longer than what I send here.
> 
> [...]
> 
>> src/connection.h:33:21: sqlite3.h: No such file or directory
> 
> [...]
> 
>> Could somebody tell me what I have to do to install 'pysqlite'?
> 
> Install SQLite, perhaps? If the pysqlite build process can't find
> sqlite3.h then you either don't have SQLite installed, or you don't
> have the headers for SQLite installed. I'd recommend that you check
> your installed packages for the SQLite libraries (eg. libsqlite3-0 on
> Ubuntu) and/or the user interface (eg. sqlite3) and for the
> development package (eg. libsqlite3-dev).
> 
> If you can't install the packages, install SQLite from source (see
> http://www.sqlite.org/) and try and persuade pysqlite to use your own
> SQLite installation - there's a setup.cfg file in the pysqlite
> distribution which may need to be changed to achieve this, but I don't
> know how that interacts with setuptools.
> 
> Paul
> 
Hello,

I am back with another problem. I suppose that I can tell it!
I have installed both, 'sqlite' and 'pysqlite' without any problem. But 
If I try to test whether the 'pysqlite' interface works, I get the next 
error message:

 >>>from pysqlite2 import dbapi2 as sqlite
Traceback (most recent call last):
   File "", line 1, in ?
   File 
"/usr/people/emami/lib/python2.4/site-packages/pysqlite2/dbapi2.py", 
line 27, in ?
 from pysqlite2._sqlite import *
ImportError: 
/usr/people/emami/lib/python2.4/site-packages/pysqlite2/_sqlite.so: 
undefined symbol: sqlite3_set_authorizer

I don't understand it. Could you tell me how I can solve this last 
point? I hope so!

With regards,

Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing "pysqlite"

2007-02-27 Thread Nader Emami
Paul Boddie wrote:
> On 27 Feb, 13:35, "Nader" <[EMAIL PROTECTED]> wrote:
>> Thank for your reaction. I don't know also how the interaction sith
>> 'easy_install' is. I think that I have to install 'pysqlite' from
>> source code also, because i can change ther the 'setup.cfg' file and I
>> can give there where the 'libsqlie3' is.
> 
> What I did was to go to the pysqlite site (http://www.initd.org/
> tracker/pysqlite/wiki/pysqlite), download the sources for the latest
> version, then change the setup.cfg file so that include_dirs refers to
> the place where the SQLite headers (eg. sqlite.h) were installed, and
> that library_dirs refers to the place where the SQLite libraries were
> installed. For example:
> 
> include_dirs=/opt/sqlite/usr/include
> library_dirs=/opt/sqlite/usr/lib
> 
> (You'd get the above if you configured SQLite to install into /opt/
> sqlite/usr.)
> 
> Then, just do the usual build:
> 
> python setup.py build
> 
> And install with a prefix:
> 
> python setup.py install --prefix=/opt/pysqlite/usr
> 
> Since you seem to be installing things in non-root-controlled places,
> I imagine you're familiar with specifying things like the --prefix
> above, as well as setting up your PYTHONPATH afterwards.
> 
> Paul
> 
I have first installed "sqlite" and then I have configure the 
"setup.cfg" file of "pysqlite" package. I had to do two things in
'pysqlite' directory:
1- python setup.py build
2- python setup.py install

It has done without any error. I suppose that the installation is well 
done, but I haven't yet test whether I can import the 'pysqlite' module 
in python. But how you mean about "PYTHONPATH"? If I do "echo 
$PYTHONPAT" i get an empty string. That meant that I don't have any 
"PYTHONPATH". How can I assign a correct "path" to this variable?

Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing "pysqlite"

2007-02-27 Thread Nader
On Feb 27, 12:44 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote:
> On 27 Feb, 10:31, Nader Emami <[EMAIL PROTECTED]> wrote:
>
> > I have installed "TurboGears" and I would install 'pysqlite' also. I am
> > a user on a Linux machine. If I try to install the 'pysqlite' with
> > 'easy_install' tool I get the next error message. The error message is
> > longer than what I send here.
>
> [...]
>
> > src/connection.h:33:21: sqlite3.h: No such file or directory
>
> [...]
>
> > Could somebody tell me what I have to do to install 'pysqlite'?
>
> Install SQLite, perhaps? If the pysqlite build process can't find
> sqlite3.h then you either don't have SQLite installed, or you don't
> have the headers for SQLite installed. I'd recommend that you check
> your installed packages for the SQLite libraries (eg. libsqlite3-0 on
> Ubuntu) and/or the user interface (eg. sqlite3) and for the
> development package (eg. libsqlite3-dev).
>
> If you can't install the packages, install SQLite from source 
> (seehttp://www.sqlite.org/) and try and persuade pysqlite to use your own
> SQLite installation - there's a setup.cfg file in the pysqlite
> distribution which may need to be changed to achieve this, but I don't
> know how that interacts with setuptools.
>
> Paul

Thank for your reaction. I don't know also how the interaction sith
'easy_install' is. I think that I have to install 'pysqlite' from
source code also, because i can change ther the 'setup.cfg' file and I
can give there where the 'libsqlie3' is.

Nader

-- 
http://mail.python.org/mailman/listinfo/python-list


installing "pysqlite"

2007-02-27 Thread Nader Emami
I have installed "TurboGears" and I would install 'pysqlite' also. I am 
a user on a Linux machine. If I try to install the 'pysqlite' with 
'easy_install' tool I get the next error message. The error message is 
longer than what I send here.


% easy_install  pysqlite
Searching for pysqlite
Reading http://cheeseshop.python.org/pypi/pysqlite/
Reading http://pysqlite.org/
Reading http://cheeseshop.python.org/pypi/pysqlite/2.3.3
Best match: pysqlite 2.3.3
Downloading 
http://initd.org/pub/software/pysqlite/releases/2.3/2.3.3/pysqlite-2
.3.3.tar.gz
Processing pysqlite-2.3.3.tar.gz
Running pysqlite-2.3.3/setup.py -q bdist_egg --dist-dir 
/tmp/easy_install-71B-Y0
/pysqlite-2.3.3/egg-dist-tmp-Wj2VRc
warning: no files found matching 'doc/*.html'
In file included from src/module.c:24:
src/connection.h:33:21: sqlite3.h: No such file or directory
In file included from src/module.c:24:
src/connection.h:38: error: parse error before "sqlite3"


Could somebody tell me what I have to do to install 'pysqlite'?


With regards,
Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ez_setup.py

2007-02-26 Thread Nader Emami
Tim Golden wrote:
> Nader Emami wrote:
>> L.S.,
>>
>> I have installed locally Python-2.4.4 without any problem. Then I 
>> would install the "ez_setup.py" to be able using of "easy_install" 
>> tool, but I get the next error:
>>
>> %python ez_setup.py
>> Traceback (most recent call last):
>>File "ez_setup.py", line 223, in ?
>>  main(sys.argv[1:])
>>File "ez_setup.py", line 155, in main
>>  egg = download_setuptools(version, delay=0)
>>File "ez_setup.py", line 111, in download_setuptools
>>  import urllib2, shutil
>>File "/usr/people/emami/lib/python2.4/urllib2.py", line 108, in ?
>>  import cookielib
>>File "/usr/people/emami/lib/python2.4/cookielib.py", line 35, in ?
>>  from calendar import timegm
>>File "/usr/people/emami/calendar.py", line 23, in ?
>>  import pygtk
>> ImportError: No module named pygtk
>>
>> I don't understand what is the problem! Could somebody tell me what I 
>> have to do to solve it?
> 
> 
> You have a module called "calendar" in your user directory
> /usr/people/emami/calendar.py which is shadowing the stdlib
> calendar module -- which doesn't get used much so you've
> probably never noticed. Either rename your local one or take
> your home folder off the Python path... at least for long enough
> for ez_setup to do its stuff.
> 
> TJG
How can do the second solution, (take off the home from Python path)?

-- 
http://mail.python.org/mailman/listinfo/python-list


ez_setup.py

2007-02-26 Thread Nader Emami
L.S.,

I have installed locally Python-2.4.4 without any problem. Then I would 
install the "ez_setup.py" to be able using of "easy_install" tool, but I 
get the next error:

%python ez_setup.py
Traceback (most recent call last):
   File "ez_setup.py", line 223, in ?
 main(sys.argv[1:])
   File "ez_setup.py", line 155, in main
 egg = download_setuptools(version, delay=0)
   File "ez_setup.py", line 111, in download_setuptools
 import urllib2, shutil
   File "/usr/people/emami/lib/python2.4/urllib2.py", line 108, in ?
 import cookielib
   File "/usr/people/emami/lib/python2.4/cookielib.py", line 35, in ?
 from calendar import timegm
   File "/usr/people/emami/calendar.py", line 23, in ?
 import pygtk
ImportError: No module named pygtk

I don't understand what is the problem! Could somebody tell me what I 
have to do to solve it?

Regards,
Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


compile python with sqlite3

2007-02-23 Thread Nader Emami
L.S.,

I have to compile (install) locally Python 2.5, because I don't have 
'root' permission. Besides I would use 'sqlite3' as a database for 
TurboGears/Django. I have installed 'sqlite3' somewhere on my Linux 
(/path/to/sqlite'). What do I have to do if I want to compile 'Python' 
with 'sqlite3'? I would appreciate if somebody tells me to solve this 
problem.

With regards,
Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


which one?

2006-05-16 Thread Nader Emami
L.S.,

I have read your replay about web development with python. I would agree
with you that web design is depends on specific requirements. I would
like to develop some in which the animation is well important. It will
be an animation of a radar file. I have looked for a lot of alternative
but I do not which of them I can choose for my application.
I will appreciate you if you would give me some advice in this case.

With regards,

Nader

-- 
http://mail.python.org/mailman/listinfo/python-list


a question

2006-05-16 Thread Nader Emami
L.S.,

I have read all replays about web development with python. I would agree
with somebody who have said that web design is depends on specific 
requirements. I would like to develop some in which the animation is 
well important. It will be an animation of a radar file. I have looked 
for a lot of alternative but I do not which of them I can choose for my 
application.
I will appreciate everyone if he/she would give me some advice in this case.

With regards,

Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: binary file

2005-06-20 Thread Nader Emami
Kent Johnson wrote:
> Nader Emami wrote:
> 
>> L.S.,
>>
>> I have used the profile module to measure some thing as the next command:
>>
>> profile.run('command', 'file')
>>
>> But this make a binary file! How can I write the result of 'profile' 
>> in a ascii file? Others how can I read (or convert) the binary file to 
>> am ascii file?
> 
> 
> Use an instance of pstats.Stats to interpret the results:
> 
> from pstats import Stats
> s = Stats('file')
> s.print_stats()
> 
> etc.
> http://docs.python.org/lib/profile-stats.html
> 
> Kent
I got the same result as the execution of command. But I would like to 
write to the an external 'ascii' file!

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


binary file

2005-06-20 Thread Nader Emami
L.S.,

I have used the profile module to measure some thing as the next command:

profile.run('command', 'file')

But this make a binary file! How can I write the result of 'profile' in 
a ascii file? Others how can I read (or convert) the binary file to am 
ascii file?

Regards,
Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


test

2005-06-08 Thread Nader Emami
L.S.,

I would like to learn how does work the "unit test" concept in Python. I 
have try the 'romantest.py' of the "Dive in Python" book and I get the 
next problem:

Traceback (most recent call last):
   File "romantest.py", line 153, in ?
 unittest.main()
   File "/usr/lib/python2.3/unittest.py", line 721, in __init__
 self.runTests()
   File "/usr/lib/python2.3/unittest.py", line 758, in runTests
 result = self.testRunner.run(self.test)
   File "/usr/lib/python2.3/unittest.py", line 657, in run
 startTime = time.time()
AttributeError: 'module' object has no attribute 'time'

I can't understand it! Would somebody tell me how I can solve this 
problem. Thanks,

Nader
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: datetime

2005-05-19 Thread Nader
I have the next on my machine:
Python 2.3.3 (#1, Apr  6 2004, 01:47:39)
[GCC 3.3.3 (SuSE Linux)] on linux2

Maybe this is a problem!

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


datetime

2005-05-19 Thread Nader Emami
L.S.,

It is very simple question: Why doesn't work the next statments?

import datetime

today = datetime.date.today()

and I get the next error:

today = datetime.date.today()
Traceback (most recent call last):
   File "", line 1, in ?
AttributeError: time

I can't understand it!
-- 
http://mail.python.org/mailman/listinfo/python-list


a question

2005-01-19 Thread Nader Emami
L.S.,
I have a long command in Unix and I have to use os.system(cmd) 
statement. I do the following:

cmd = '%s/mos user wmarch, cd /fa/wm/%s/%s, mkdir %s, put %s, chmod 644 
%s' % (mosbin, jaar, filetype, filetype)
status = os.system(cmd)

This is not very clear, and I have to break this long line in two 
segment by means of the next character '\' :
cmd = '%s/mos user wmarch, cd /fa/wm/%s/%s, mkdir %s, put %s, \
   chmod 644 %s' % (mosbin, jaar, filetype, filetype)

But in this case I get a syntax error! I don't know how I can solve this 
problem. Could somebody tell me about this?

With regards,
Nader
 (this
--
http://mail.python.org/mailman/listinfo/python-list


here document

2005-01-11 Thread Nader Emami
L.S.,
Would somebody help me how i can write the 'here document' in
Python script please? I have a csh script in which a program
is invoked with some argument in the form of here document:
/bin/exe.x << End_Here
CategorY   = GRIB
etc.
End_Here
I translate this script to Python and i don't know how can I
do this!
with regards,
Nader
--
http://mail.python.org/mailman/listinfo/python-list


date/time

2005-01-05 Thread Nader Emami
L.S.,
Could somebody help me how I can get the next format of date
from the time module?
example: I have to have this time 20050105. It is the next
attributes of format %Y%m%d.
with regards,
Nader
--
http://mail.python.org/mailman/listinfo/python-list


csh to Python

2005-01-04 Thread Nader Emami
Hello,
I am new in Python world, and would like to begin with
translate a csh file to a python script. Could somebody give
me an advise (documentation or web-site) where I can do that.
with regards,
Nader
--
http://mail.python.org/mailman/listinfo/python-list