python cookbook

2004-12-21 Thread emami
L.S.,
I have heard that Python cookbook is free! Could somebody tell me where 
I can find it?

The second one is that I am busy to translate some "csh/bash" scripts to 
Python script. Where can I find a good reference to do easy this work?

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


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


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


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


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


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


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


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


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


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


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


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: 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-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


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


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