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

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 rece

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 an

Re: locale, format monetary values

2006-04-17 Thread deelan
cale.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: mod_python

2005-10-11 Thread deelan
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: Python, Mysql, insert NULL

2005-10-05 Thread deelan
nverted 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

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

2005-09-30 Thread deelan
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: Code for generating validation codes (in images)

2005-09-04 Thread Giuseppe di Sabato (aka deelan)
<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

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 l

Re: MySQL help

2005-08-01 Thread deelan
m/doc/mysql/en/replace.html> -- 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: namespaces

2005-07-31 Thread deelan
tup_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: tuple to string?

2005-07-22 Thread deelan
nother 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: urllib2 - basic authentication and the put and delete methods

2005-07-08 Thread deelan
les 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. -- dee

Re: How to get/set class attributes in Python

2005-06-12 Thread deelan
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://

Re: case/switch statement?

2005-06-11 Thread deelan
tements. 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: about accessing mysql

2005-06-10 Thread deelan
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: MySQLDBAPI

2005-06-10 Thread deelan
nclude 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: MySQLDBAPI

2005-06-09 Thread deelan
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: <ht

Re: Trouble Encoding

2005-06-07 Thread deelan
; >>> 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: something like CPAN, PPMs?

2005-06-01 Thread deelan
/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: Design problem, call function from HTML?

2005-05-30 Thread deelan
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: MySQLdb and Unicode

2005-05-20 Thread deelan
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: problems with  character

2005-03-22 Thread deelan
ect 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: Why tuple with one item is no tuple

2005-03-15 Thread deelan
uple 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: 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."

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

2005-03-12 Thread deelan
commit 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: 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/m

Re: what is wrong?

2005-02-24 Thread deelan
e 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&

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

2005-02-23 Thread deelan
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: Problem in importing MySQLdb

2005-01-20 Thread deelan
-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:ni

Re: File Handling Problems Python I/O

2005-01-06 Thread deelan
; 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: 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

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.

Re: Keyword arguments - strange behaviour?

2004-12-21 Thread deelan
d 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&q

Re: Persistent objects

2004-12-13 Thread deelan
sn'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