Re: 'ascii' codec can't encode character u'\u2013'

2005-09-30 Thread deelan
thomas Armstrong wrote:
(...)
> when trying to execute a MySQL query:
> 
> query = "UPDATE blogs_news SET text = '" + text_extrated + "'WHERE
> id='" + id + "'"
> cursor.execute (query)  #<--- error line
> 

well, to start it's not the best way to do an update,
try this instead:

query = "UPDATE blogs_news SET text = %s WHERE id=%s"
cursor.execute(query, (text_extrated, id))

so mysqldb will take care to quote text_extrated automatically. this
may not not your problem, but it's considered "good style" when dealing
with dbs.

apart for this, IIRC feedparser returns text as unicode strings, and
you correctly tried to encode those as latin-1 str objects before to 
pass it to mysql, but not all glyphs in the orginal utf-8 feed can be 
translated to latin-1. the charecter set of latin-1 is very thin 
compared to the utf-8.

you have to decide:

* switch your mysql db to utf-8 and encode stuff before
insertion to UTF-8

* lose those characters that cannot be mapped into latin-1,
using the:

text_extrated.encode('latin-1', errors='replace')

so unrecognized chars will be replaced by ?

also, mysqldb has some support to manage unicode objects directly, but 
things changed a bit during recent releases so i cannot be precise in 
this regard.

HTH.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>




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


Re: Python, Mysql, insert NULL

2005-10-05 Thread deelan
Python_it wrote:
> I know how to insert values in a database.
> That's not my problem!
> My problem is how i insert NULL values in de mysql-database.
> None is een object in Python and NULL not.
> None is not converted to NULL?
> Table shows None and not NULL!

None is converted to mysql's NULL and vice versa. It sounds
you are passing the *string* "None" to mysql, with it isn't
the same thing.

Adapting the Laszlo's example already posted:

cursor.execute("insert into tablename(fieldname) values (%s)", [None])

HTH.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>




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


Re: mod_python

2005-10-11 Thread deelan
Python_it wrote:
(...)
> But my problem is where I have to place te following code in de
> httpd.conf?
> 
> 
> AddHandler mod_python .py
> PythonHandler mptest
> PythonDebug On
> 
> 
> Because al the tutorials write this. But where?

try put it at the end of your http.conf file.

 >
 > If I try to put the code some where,
 > apache give the following message by testing the configure:
 > Multiple  arguments not (yet) supported
 > But what i have to change or replace.

just an idea, try:


...


because it sounds like apache parser gets confused
with all those slashes.

> 
> I test with the next file:
> 
> C:\Program Files\Apache Group\Apache2\htdocs\project\
> mptest.py
> 
> from mod_python import apache
> 
> def handler(req):
>req.content_type = 'text/plain'
>req.send_http_header()
>req.write('mptest.py\n')
>return apache.OK
> 
> Is this code enough for testing?
> 

i believe so.

also check this:
"Getting mod_python Working"
<http://www.dscpl.com.au/articles/modpython-001.html>

-- 
deelan <http://www.deelan.com/>




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


Re: File Handling Problems Python I/O

2005-01-06 Thread deelan
Josh wrote:
Peter,
Thank you for the rookie correction. That was my exact problem. I
changed the address to use forward slashes and it works perfect. I did
not know that a backslash had special meaning within a string, but now
I do! Thanks again
you may want to check "python gotchas" to avoid
other typical newbie errors:
<http://www.ferg.org/projects/python_gotchas.html>
HTH,
deelan
--
"Vedrai come ti tratteranno le mie TV"
Berlusconi a Follini (Luglio 2004)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem in importing MySQLdb

2005-01-20 Thread deelan
Gurpreet Sachdeva wrote:
I am using Mysql version 5.0.2-alpha on RedHat 9.0 (python2.2)
When I try to import MySQldb
i' not completely sure mysqldb works with mysql 5.0 and its
bundled client libraries.
to be more precise:
'' MySQL-5.0 and newer are not currently supported,
but might work.''
from:
<http://sourceforge.net/project/shownotes.php?release_id=293608>

Is there any problem in library files?? Do I need to install anything
I have installed MySQL-shared-3.23.54a-1.i386.rpm,
MySQL-devel-5.0.2-0.i386.rpm, MySQL-client-5.0.2-0.i386.rpm,
MySQL-server-5.0.2-0.i386.rpm
are u sure you have compiled mysqldb against 5.0
client libs?
you may want to post on the mysqldb forum of ask
for help there:
<http://sourceforge.net/forum/forum.php?forum_id=70461>
HTH,
deelan
--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
--
http://mail.python.org/mailman/listinfo/python-list


Re: urllib2 - basic authentication and the put and delete methods

2005-07-08 Thread deelan
news.corp.adobe.com wrote:
(...)
> 
> But despite much searching, I have yet to discover how to then use PUT and 
> DELETE to copy files / delete files on the server.

i believe you have to use httplib for that:
<http://docs.python.org/lib/module-httplib.html>

examples here:
<http://docs.python.org/lib/httplib-examples.html>

basically you pass auth headers whie
using PUT/DELETE verbs:

## untested! ##

headers = {
   "Authorization": authheader # your base 64 str
}
conn.request("PUT", "/your/url/here", body, headers)

HTH,
deelan.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>




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


Re: tuple to string?

2005-07-22 Thread deelan
Francois De Serres wrote:
> hiho,
> 
> what's the clean way to translate the tuple (0x73, 0x70, 0x61, 0x6D) to 
> the string 'spam'?

one way is to use a list expression:

 >>> ''.join([chr(c) for c in (0x73, 0x70, 0x61, 0x6D)])
'spam'

another is to use map:

 >>> ''.join(map(chr, (0x73, 0x70, 0x61, 0x6D)))
'spam'

HTH,
deelan.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>




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


Re: namespaces

2005-07-31 Thread deelan
Paolino wrote:
(...)
> What I'm needing as a global (in globals() or at the module level or in 
> the module namespace) is 'translate'.The rest of bindings (all,badcars 
> and table) is something which is 'polluting' the module namespace.

try this:

## yourmodule.py ##

def _setup_table():
   import string
   all=string.maketrans('','')
   badcars=all.translate(all,string.letters+string.digits)
   return string.maketrans(badcars,'_'*len(badcars))

TABLE = _setup_table()

# optional, get rid of _setup_table symbol
del _setup_table()

def translate(text):
   return text.translate(TABLE)



HTH,
deelan.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: namespaces

2005-07-31 Thread deelan
deelan wrote:
(...)
> # optional, get rid of _setup_table symbol
> del _setup_table()

damn copy and paste :) of course i meant:

del _setup_table


-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL help

2005-08-01 Thread deelan
[EMAIL PROTECTED] wrote:
> So i'm writing this program to check if a row exists in a table.  If it
> doesn't it inserts it if it does it will update that row with the
> current info.

(...)

quick tip: are you aware of the mysql's REPLACE command?
<http://dev.mysql.com/doc/mysql/en/replace.html>


-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert float to string ...

2005-08-23 Thread deelan
Konrad Mühler wrote:
> Hi,
> 
> a simple question but i found no solution:
> 
> How can i convert a float value into a string value?
> 

just use the "str" built-in type:

 >>> f = 9.99
 >>> str(f)
'9.99'


-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: display VARCHAR(mysql) and special chars in html

2005-02-23 Thread deelan
Jonas Meurer wrote:
(...)
i've changed my plans, and now will transform the comments to html
before saving them in mysql. this way, the comment never contains
special chars except they weren't filtered out when safed in mysql.
do any filters exist, to transform plain text to html? otherwise i might
use third-party products, as text2html.
what do you think?
as you may known mysql 4.1 offers utf-8 support. il would be
wise to keep everything as utf-8: db, html generation and finally
serve, with correct HTTP headers, pages encoded as utf-8.
to do this you might have to fiddle with mysql settings and make
sure that issuing a:
show varibles;
almost all of these settings:
character_set_clientlatin1 
  character_set_connectionlatin1 

character_set_database  latin1 

character_set_results   latin1 
  character_set_serverlatin1 
 character_set_systemutf8 

use utf-8 (as you can see my copy of mysql does not), otherwise i
think bad things  will occur.
if you prefer to filter out weird characters and
encode as html &# entities textile[1] does the job
just fine, you can specify input and output encoding.
cheers,
deelan.
[1] http://dealmeida.net/en/Projects/PyTextile/
--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
--
http://mail.python.org/mailman/listinfo/python-list


Re: what is wrong?

2005-02-24 Thread deelan
[EMAIL PROTECTED] wrote:
(B(...)
(B> self.feed = feed# I wrote this
(B> AttributeError: can't set attribute
(B> 
(B> I add some codes to a program on a book. The lines that have "I wrote
(B> this" comment is the added codes. Could anyone tell me what is worng
(B> here?
(B
(Bthe line:
(B
(Bfeed = property(__get_feed) # I wrote this
(B
(Bmakes "feed" a *readonly* attribute.
(B
(Bcheers,
(Bdeelan.
(B
(B-- 
(B@prefix foaf: <http://xmlns.com/foaf/0.1/> .
(B<#me> a foaf:Person ; foaf:nick "deelan" ;
(Bfoaf:weblog <http://blog.deelan.com/> .
(B-- 
(Bhttp://mail.python.org/mailman/listinfo/python-list

Re: Ruby on Rails or Perl's Maypole..is there a Python equivalent

2005-03-03 Thread deelan
Gary Nutbeam wrote:
(...)
Does anyone know of something similar to Rails or Maypole in Python?
you may want to take a look at subway:
<http://subway.python-hosting.com/>
it glues together cherrypy2, sqlobject
and cheetah using an MVC approach.
HTH,
deelan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can't seem to insert rows into a MySQL table

2005-03-12 Thread deelan
grumfish wrote:
I'm trying to add a row to a MySQL table using insert. Here is the code:
connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", 
db="japanese")
cursor = connection.cursor()
cursor.execute("INSERT INTO edict (kanji, kana, meaning) VALUES (%s, %s, 
%s)", ("a", "b", "c") )
connection.close()
which version of MySQLdb are you running? versions
1.1.6 and below gained a connection.autocommit) method set by default
to *false*.
Try this, instead:
connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", 
db="japanese")

connection.autocommit(True)   # <--- note this
cursor = connection.cursor()
...other commands...
doing this you tell MySQL to automatically commit changes to db after
every UPDATE or INSERT.  turning autocommit to false is useful when
you wish to do changes in batches and maybe rollback the entire operation
if something went wrong (see commit() and rollback() methods for this).
hope this helps,
deelan.
--
"Però è bello sapere che, di questi tempi spietati, almeno
un mistero sopravvive: l'età di Afef Jnifen." -- dagospia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can't seem to insert rows into a MySQL table

2005-03-12 Thread deelan
deelan wrote:
which version of MySQLdb are you running? versions
1.1.6 and below gained a connection.autocommit) method set by default
ehm, 1.1.6 and *above*, of course.  :)
--
"Però è bello sapere che, di questi tempi spietati, almeno
un mistero sopravvive: l'età di Afef Jnifen." -- dagospia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why tuple with one item is no tuple

2005-03-15 Thread deelan
Gregor Horvath wrote:
Hi,
 >>>type(['1'])

 >>>type(('1'))

I wonder why ('1') is no tuple
Because I have to treat this "special" case differently in my code.
you need to tell python that ('1') isn't a string inside
a couple parens but a tuple, look:
>>> t = ('1', )
>>> type(t)

if there's no ambiguity you can omit the parens:
>>> t = '1',
>>> type(t)

HTH,
deelan
--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
--
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-13 Thread deelan
Paul Rubin wrote:
I've had this recurring half-baked desire for long enough that I
thought I'd post about it, even though I don't have any concrete
proposals and the whole idea is fraught with hazards.
Basically I wish there was a way to have persistent in-memory objects
in a Python app, maybe a multi-process one.  So you could have a
persistent dictionary d, and if you say 
   d[x] = Frob(foo=9, bar=23)
that creates a Frob instance and stores it in d[x].  Then if you
exit the app and restart it later, there'd be a way to bring d back
into the process and have that Frob instance be there.
this sounds like the "orthogonal persistence" of
unununium python project:
Orthogonal Persistence
''A system in which things persist only until they are no longer needed 
is said to be orthogonally persistant. In the context of an OS, this 
means that should the computer be turned off, its state will persist 
until it is on again. Some popular operating systems implement non-fault 
tolerant persistence by allowing the user to explicitly save the state 
of the machine to disk. However, Unununium will implement fault tolerant 
persistence in which state will be saved even in the case of abnormal 
shutdown such as by power loss.''

from:
<http://unununium.org/introduction>
check also this thread:
<http://unununium.org/pipermail/uuu-devel/2004-September/000218.html>
''Such a solution isn't orthogonal persistence. The "orthogonal" means 
how the data is manipulated is independent of how it is stored. Contrast
this with the usual way of doing things that requires huge amounts of
code, time, and developer sanity to shuffle data in and out of
databases.''

''In fact, we do plan to write to RAM every 5 minutes or so. But, it's 
not slow. In fact, it's faster in many cases. Only dirty pages need to 
be written to the drive, which is typically a very small fraction of all
RAM. Because there is no filesystem thus the drive spends little time
seeking. Furthermore, serializing all data to some database is not
required, which saves CPU cycles and code, resulting in reduced memory
usage and higher quality in software design.''

''The resulting system is fully fault tolerant (a power outage will 
never hose your work), requires no network, and doesn't introduce any 
new points of failure of complexity.''

you may want to investigate how the UUU guys think to
implememt this in their project.
bye.
--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://www.netspyke.com/> .
--
http://mail.python.org/mailman/listinfo/python-list


Re: Keyword arguments - strange behaviour?

2004-12-21 Thread deelan
[EMAIL PROTECTED] wrote:
Can anyone explain the behaviour of python when running this script?
(...)
Is there a good reason why these scripts are not the same? I can
understand how/why they are different, it's just not what I expected.
(It seems strange to me that the result of the first method can only be
determined if you know how many times it has already been called)
see "python gotchas":
<http://www.ferg.org/projects/python_gotchas.html#bct_sec_5>
bye.
--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://www.netspyke.com/> .
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie namespace question

2004-12-22 Thread deelan
[EMAIL PROTECTED] wrote:
I have a variable that I want to make global across all modules, i.e. I
want it added to the builtin namespace.  Is there a way to do this?
i would not pollute built-ins namespace.
how about:
### a.py
FOO = "I'm a global foo!"
### b.py
import a
print a.FOO
HTH,
deelan
--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie namespace question

2004-12-22 Thread deelan
[EMAIL PROTECTED] wrote:
(...)
Run it and get a name error, which, makes sense.
If I try to use the standard import solution as deelan suggests I have
a circular reference on the imports and I get an error that it can't
import class DataSource (presumbably because it hasn't gotten far
enough through jdbc.py to realize that there's a DataSource class
defined.
oh, i see. so the scenario is more complex.
Any insight would be greatly appreciated, and thanks to both deelan and
Steve for your help.
i believe that to avoid circular refs errors remember you can 
lazy-import,  for example here i'm importing the email package:

m = __import__('email')
m

check help(__import__) for futher details.
bye.
--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
--
http://mail.python.org/mailman/listinfo/python-list


Re: problems with  character

2005-03-22 Thread deelan
jdonnell wrote:
I have a mysql database with characters like      » in it. I'm
trying to write a python script to remove these, but I'm having a
really hard time.
use the "hammer" recipe. i'm using it to create URL-friendly
fragment from latin-1 album titles:
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/251871>
(check the last comment, "a cleaner solution"
for a better implementation).
it basically hammers down accented chars like à and Â
to the most near ASCII representation.
since you receive string data as str from mysql
object first convert them as unicode with:
u = unicode('Â', 'latin-1')
then feed u to the hammer function (the fix_unicode at the
end).
HTH,
deelan
--
"Però è bello sapere che, di questi tempi spietati, almeno
un mistero sopravvive: l'età di Afef Jnifen." -- dagospia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb and Unicode

2005-05-20 Thread deelan
Achim Domma (Procoders) wrote:
> Hi,
> 
> I try to write unicode strings to a MySQL database via MySQLdb. 
> According to the documentation I should pass 'utf-8' as keyword 
> parameter to the connect method. But then I get the following error:
> 
(...)
> 
> 
> I'm using version 1.2 of MySQLdb. Any hint what I'm doing wrong?

this is changed in 1.2, from the Connection class docstring:

"use_unicode"

''If True, text-like columns are returned as unicode objects
using the connection's character set.  Otherwise, text-like
columns are returned as strings.  columns are returned as
normal strings. Unicode objects will always be encoded to
the connection's character set regardless of this setting.''

-- 
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Design problem, call function from HTML?

2005-05-30 Thread deelan
bart wrote:
(...)
> Is there any remote possibility u can pulloff the same in python? Now
> i have to process my data to display page and do it again to generate
> my image (execute same code twice).
> 
> One solution would be to save the image to harddisk and then load it.
> But rather keep it clean as return value.

something like Cheetah might help here:

 >>> from Cheetah.Template import Template
 >>> t = ''

 >>> data = {}
 >>> data['img'] = 'foo.jpg'
 >>> def image(): return data['img']
...
 >>> T = Template(source=t, searchList=[{'image':image}])
 >>> T


...or you can access "img" directly in the template:

 >>> t = ''
 >>> data = {}
 >>> data['img'] = 'foo.jpg'
 >>> T = Template(source=t, searchList=[{'image':data}])
 >>> T


say that "data" changes, you don't have to compile the template
again, just issue a render command again:

 >>> data['img'] = 'BAZ.jpg'
 >>> T



see:
<http://cheetahtemplate.org/>



-- 
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: something like CPAN, PPMs?

2005-06-01 Thread deelan
Maurice LING wrote:
> Hi Alex,
> 
> I am actually working on something like that as an academic project. At 
> this stage, at least for the purpose of my scope, it will not be as 
> extensive as CPAN but a set of mechanisms for the same effect for Python.

don't foget to keep an eye on python's eggs:

<http://peak.telecommunity.com/DevCenter/PythonEggs>

and related blog posts:

<http://dirtsimple.org/2005/05/eggs-get-closer-to-hatching.html>
<http://dirtsimple.org/2005/05/dirt-simple-download-and-install-cpan.html>
<http://dirtsimple.org/2005/05/easyinstall-new-era-in-python-package.html>

HTH.

-- 
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trouble Encoding

2005-06-07 Thread deelan
[EMAIL PROTECTED] wrote:
> I'm using feedparser to parse the following:
> 
> Adv: Termite Inspections! Jenny Moyer welcomes
> you to her HomeFinderResource.com TM A "MUST See &hellip;
> 
> I'm receiveing the following error when i try to print the feedparser
> parsing of the above text:
> 
> UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c' in
> position 86: ordinal not in range(256)
> 
> Why is this happening and where does the problem lie?

it seems that the unicode character 0x201c isn't part
of the latin-1 charset, see:

"LEFT DOUBLE QUOTATION MARK"
<http://www.fileformat.info/info/unicode/char/201c/index.htm>

try to encode the feedparser output to UTF-8 instead, or
use the "replace" option for the encode() method.

 >>> c = u'\u201c'
 >>> c
u'\u201c'
 >>> c.encode('utf-8')
'\xe2\x80\x9c'
 >>> print c.encode('utf-8')

ok, let's try replace

 >>> c.encode('latin-1', 'replace')
'?'

using "replace" will not throw an error, but it will replace
the offending characther with a question mark.

HTH.

-- 
deelan <http://www.deelan.com/>




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


Re: MySQLDBAPI

2005-06-09 Thread deelan
Gregory Piñero wrote:
> Hey guys,
(...)
> 
> My first question is if there is anything built into python as far as
> a Database API that will work with MySQL.  It seems like there should
> be because Python without it is kinda useless for web development.  If
> there is then I'd probably prefer to use that instead.

there is not. mysqldb module is the answer.

(...)
>>>cd MySQL-python-1.2.0
>>>python2.4 setup.py install --home=~
> 
> running install
> running build
> running build_py
> running build_ext
> building '_mysql' extension
> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
> -Wstrict-prototypes -fPIC -I/usr/local/include/python2.4 -c _mysql.c
> -o build/temp.linux-i686-2.4/_mysql.o
> -I'/usr/local/mysql/include/mysql'
> _mysql.c:41:19: mysql.h: No such file or directory
> _mysql.c:42:26: mysqld_error.h: No such file or directory
> _mysql.c:43:20: errmsg.h: No such file or directory
> error: command 'gcc' failed with exit status 1

you need mysql-devel package installed to compile the "_mysql" extension.

just look a the release notes:
<https://sourceforge.net/project/shownotes.php?group_id=22307&release_id=303257>

HTH.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>




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


Re: MySQLDBAPI

2005-06-10 Thread deelan
Gregory Piñero wrote:
> I didn't see anything about mysql-devel package in the release notes. 

it's there, section "Prerequisites".

> Is that something I can install all to my home directory?

never tried, but sounds hard to do. mysql-devel is a bunch of libs and 
include files tied to mysql. the "_mysql" extension will be complied 
against such files and then wrapped by python code.

HTH.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>




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


Re: about accessing mysql

2005-06-10 Thread deelan
sinan , wrote:
(...)
> these command works at my computer but when i want to do in my server,
> i get these messages as you seen, my both computer and server have
> same python, same MySQLdb module and same database with same
> priviliges.also how can i connect to remote database? is that work ?
> db=MySQLdb.Connection(host="192.168.0.120",user="root",db="nux")
> thank you.

in addition to Diez observations please tell us:

1) version of mysql server you are trying to connect
   1a) is the the mysql db been complied to support Innodb tables?
   please issue a "SHOW VARIBLES" command on the mysql console, there
   should be some mention on innodb support somewhere.

2) version of mysqldb you are using

bye.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>




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


Re: case/switch statement?

2005-06-11 Thread deelan
Joe Stevenson wrote:
> Hi all,
> 
> I skimmed through the docs for Python, and I did not find anything like 
> a case or switch statement.  I assume there is one and that I just 
> missed it.  

strictly speaking, python does not
have a switch stamenent.

"Why isn't there a switch or case statement in Python?"
<http://www.python.org/doc/faq/general.html#why-isn-t-there-a-switch-or-case-statement-in-python>

> Can someone please point me to the appropriate document, or 
> post an example?  I don't relish the idea especially long if-else 
> statements.

topic already beated to death, feel
free to browse the group archives:
<http://groups-beta.google.com/groups?q=comp.lang.python+switch+statement>

HTH.

-- 
deelan <http://www.deelan.com>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get/set class attributes in Python

2005-06-12 Thread deelan
Kalle Anke wrote:
> I'm coming to Python from other programming languages. I like to
> hide all attributes of a class and to only provide access to them
> via methods. 
(...)
> Is this the "Pythonic" way of doing it or should I do it in a different
> way or do I have to use setX/getX (shudder)

the pythonic way is to use "property" (as others have already explained)
only when is *stricly necessary*. this may clarify things up:

"Python Is Not Java"
<http://dirtsimple.org/2004/12/python-is-not-java.html>

HTH.

-- 
deelan <http://www.deelan.com>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subway

2007-01-31 Thread deelan
Daniel Nogradi wrote:
> Does anyone know what has happened to the codebase of the subway
> project? It seems the whole project has been shut down leaving no
> trace of the code on net but I would be very happy to see it,
> apparently it had some cool features that would be fun to look at.
> Does anyone have access to the code and/or is willing to make it
> publically available?

Try:



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


Re: subway

2007-01-31 Thread deelan
Daniel Nogradi wrote:
(...)
> 
> the egg file can not be downloaded completely, the connection is
> closed at byte 138903 all the time and the file is bigger than that.
> If anyone managed to grab the file please let me know so far I tried
> wget and firefox.

I've checked on my hd and found a recent (Jun 2006) checkout
on the original SVN repos.

There's everything in it: Subway code, web site and examples:



HTH

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


Re: Getting a class name

2007-02-17 Thread deelan
Harlin Seritt wrote:
> Hi,
> 
> How does one get the name of a class from within the class code? I
> tried something like this as a guess:
> 
> self.__name__

Get the class first, then inspect its name:

 >>> class Foo(object): pass
...
 >>> f = Foo()
 >>> f.__class__.__name__
'Foo'
 >>>

HTH


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


Re: locale, format monetary values

2006-04-17 Thread deelan
Rares Vernica wrote:
> Hi,
> 
> Can I use locale to format monetary values? If yes, how? If no, is there 
> something I can use?
> 
> E.g.,
> I have 1 and I want to get "$10,000".

try something like:

 >>> import locale
 >>> locale.setlocale(locale.LC_ALL, "en-US")
'English_United States.1252'
 >>> locale.format("%f", 1, True)
'10,000.00'
 >>> locale.format("$%.2f", 1, True)
'$10,000.00'

bye.

-- 
deelan
http://www.deelan.com/
http://blog.deelan.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code for generating validation codes (in images)

2005-09-04 Thread Giuseppe di Sabato (aka deelan)
morphex wrote:
> Hi,
> 
> does anyone of you know of some code I can use to generate validation
> code images?
> 
> Those images you can see on various login forms used to prevent bots
> for performing a brute-force attack..

take a look at the "pycaptcha" package:
<http://freshmeat.net/projects/pycaptcha/>

later,
deelan.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>
-- 
http://mail.python.org/mailman/listinfo/python-list