int out "---bla---"
http://docs.python.org/lib/module-doctest.html
When the output goes a bit more complicated, consider splitting such
method in parts: some generate the output, others just print it. Then
you can test the former using th
you don't have to use a full-blown web server to
implement it. SimpleHTTPServer
in the standard library may be enough.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías
At Tuesday 29/8/2006 00:04, alf wrote:
is there any way in Python to have iostream like __str__ operator?
Define a method writeTo(f) if you want, and instead of:
f.write('%s' % obj)
use:
obj.writeTo(f)
Gabriel Genellina
S
that the problem is with the way the list is being passed in... but I
could be wrong)
...like above, where you missed a quote.
Can anyone see something I can't?
Not on the code fragment you posted.
Gabriel Genellina
Softlab SRL
how this supports the original claim that
strict type checking input params is good practice.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginaba
that
> strict type checking input params is good practice.
I'm not defending that claim. I'm just putting question marks
with the claim that strict type checking input parameters is
bad practice.
I think others have shown enough examples of good things that can be
done by *not* enf
ate over all
of them, using another dir() to find the .pep files needed.
directory = 'pub/kegg/genomes/ afm'
Is that whitespace intentional?
(If you just want to download the files and don't need really a
Python
of 2).
In fact it's the other way - losing a factor of 2 is irrelevant,
O(2N)=O(N). The logN factor is crucial here.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías s
way to explain is by code example:
Already done: itertools.chain
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas
or last field.
Are there tools in the csv module that make this
easier?
Yes, just use the csv module and forget all that split&joins...
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo q
clear (but definitively I prefer an if
statement), and the former simply sucks.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respue
need to know about sockets more than you need to know how a
diesel engine works in order to drive a car.
A webservice *uses* HTTP as a transport protocol - any HTTP server would do.
PS: Top posting is not a good
as obj with
sometiing like:
(i know that this syntax wont work )
obj.(d['function one'])
obj.(d['function two'])
You can use dir(obj) to get its list of attributes (including method
names) then use getattr to invoke the method.
methodname='func1'
getattr(obj,me
r ZeroConf, UPnP or other techniques used for service discovery.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (
At Thursday 31/8/2006 10:01, alper soyler wrote:
I changed the script as you wrote below:
directory = 'pub/kegg/genomes'
Sorry, in the original comment I said "change it to be an absolute
path" but didn't write it well.
This line should read:
directory = '
At Thursday 31/8/2006 12:44, Nico Grubert wrote:
in a text with no carriage returns I need to look for all occurancies of
this string:
...
Try Beautiful Soup, or if your input is simple enough, the re module.
Gabriel Genellina
Softlab SRL
d is on the path -
for example, the following code works and doesn't cause any errors:
import re
re.compile('a')
What else could cause such an error?
Your *own* module is called re.py, right?
Try another name...
Gabriel Genellina
Softlab SRL
lass) are not good, but for an utility script like yours I
think it's fine.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo
lah blah blah\r" % whatever,
(notice the \r and the final , )
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas
ons as the former is portable, and does look to have a means of
working...
Just don't use defaults to be safe...
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber,
if obj:
This checks whether obj is considered True, not whether it is None.
e.g. obj=[] would not pass.
if None!=obs:
Would be OK, but the next one is better:
if obj is not None:
This is what you are looking for! :)
Gabriel Genellina
S
#x27;,first_name)
because it's rather clear, and I think you would not use such things a lot.
Remember that a single object may be known as many names, or even
anonymous - they are not unique.
Gabriel Genellina
Softlab SRL
ops does that (and a lot more) - but it's not written in Python,
it uses LUA.
http://www.freepops.org/
It puts a POP server on top of the webmail, letting you use your
favorite mail program.
The Hotmail plugin works perfectly for me.
any* object
to *any* database column? Looks a lot more "pythonic" for me. Of
course, a true object database (like ZODB) is better.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí
Python tutorial which comes with the documentation?
You can read it online at <http://docs.python.org/tut/tut.html>
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querí
At Thursday 7/9/2006 22:35, Roger wrote:
Anyone have an updated version of PILGraph beyond 0.1a7 or a suggestion
for a light-weight alternative?
pychart
Gabriel Genellina
Softlab SRL
__
Preguntá
it's well written) and only then, try to
embed it inside a C++ program.
Even if you are not going to write the Python scripts yourself.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
T
n minutes I spent looking
> this up.
I remember that one of my very first Python scripts was to convert
the SQL92 grammar -unusable otherwise- into an html cross-referenced version...
Gabriel Genellina
Softlab SRL
___
is always executed, whether or not an
exception is raised.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta
?
Look at filecmp.dircmp in the standard library
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya
choose whatever tastes you more.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://w
c=4.0
[run_two]
a=456
b=Whatever
c=0.1
config = ConfigParser.ConfigParser()
config.read(filename)
a = config.getint('run_two','a') # a==456
b = config.get('run_name_one','b') # b=='Test'
section
and
easy to follow.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/r
://www.cs.sunysb.edu/~algorith/files/set-cover.shtml
Full text (not-so-legal, I presume):
http://www2.toki.or.id/book/AlgDesignManual/BOOK/BOOK/NODE4.HTM
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. D
the Python Tutorial: http://docs.python.org/tut/node10.html
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo
an error, just a very small number
i want to be able to round this number to 3 places, but round() does
not work
Does not work, or you get 0.000? That's normal.
Gabriel Genellina
Softlab SRL
_
ay, why are you using dtml-mime and such? Using the email package
is easier and a lot more powerful.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imagin
e and such? Using the email package
is easier and a lot more powerful.
i'm using zope & jsonserver & maildrop to develop this part , so the
main problem how to send mail with json-rpc structure.
You can use the email package from inside Zope; an external method will do.
Gabrie
At Monday 18/9/2006 02:07, =?GB2312?B?0vzP6cH6?= wrote:
I want to send LVM_SETITEMSTATE message using win32gui. But I don't
know how to do in Python.
The obvious way is win32api.PostMessage - but I feel you have
another, higher-level, problem...
Gabriel Genellina
Softla
At Monday 18/9/2006 12:32, SS Hares wrote:
I'm encountering an issue where the InvokeTypes method is returning
None and I'm unable to Dispatch a particular COM object from
I think you will get better responses if you post on
http://mail.python.org/mailman/listinfo/python-win32
t/355683.html>
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respu
able in the imported module; this way you import exactly what is
needed (and the rest is kept as "private")
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y
t_widget("path2")
self.paths[3] = self.wTree.get_widget("path3")
self.paths[4] = self.wTree.get_widget("path4")
self.paths[5] = self.wTree.get_widget("path5")
what about if i have 30 widgets? how can i "get" them all?
Is this what you wa
, so I don't think the above is true...
Nope, a python string has both a length *and* a null terminator (for
ease of interfacing C routines, I guess) so you can't just share a substring.
Gabriel Genellina
S
emove(temp_str) is fairly slow - it has to *scan* the
list to locate temp_str. Just keep its index instead, and use del
list_initial[index]
- as a general sorting routine, that 'zzz' does not look very
good, try to avoid it.
Gabriel Genell
- like the unicode object, it has
no "encoding" by itself.
You can go back and forth between an integer number and its decimal
representation - like astring.decode() and ustring.encode()
Gabriel Genellina
Softlab SRL
is as follows:
import commands
x = commands.getstatusoutput('dir')
According to the documentation:
Availability: Unix.
Try the subprocess module, which intents to replace it.
Gabriel Genell
At Wednesday 20/9/2006 21:30, Ted Zeng wrote:
But if I use server's ip address instead of localhost in the client,
then it could not access the server.
Maybe you have a firewall blocking access?
Gabriel Genellina
Softla
namespace:
class X: pass
x = X()
a = 'hello'
b = (1,2,3,4)
setattr(x, a, b)
print x.hello # prints (1,2,3,4)
getattr(x, a) # returns the same
but perhaps if you explain better what you want, we can figure out
how to do that...
Gabriel G
porary variable to be able to close it.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
At Thursday 21/9/2006 06:03, yxh wrote:
how to use timer in python.
the functionnality is like the MFC SetTimer()
Use the Timer class.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo
things about the language. You can read it online at
<http://docs.python.org/tut/tut.html>
[1] kinda... remember that classes don't determine the available
attributes; class attributes are inherited, and any attribute you set
on an instance will be accessible by any method of the
ionship).
Hope it becomes clearer now.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www
xplain that to a beginner would just make things
worse... You must grab the inheritance concept first.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginaba
I would get the needed info using javadoc (in
Java) and then process the output in Python.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Y
the string?
This is for simple char* strings, ASCIIZ. If your C code can accept
embedded nulls, surely has made other provisions - like receiving the
buffer length as a parameter. If not, it will see only a truncated string.
Gabriel Genellina
nce at 033C8290) (/Softlab/otros)
[328] denied. Your user account, softlab, exists at /acl_users. Access
[328] requires one of the following roles: ['Softlab']. Your roles in this
[328] context are ['Authenticated', &
bj):
print '' + repr(obj)
>>> sys.displayhook = f
Sometimes I enable a similar approach on my sitecustomize.py, using
the pprint module. But I don't *always* like the outpu
r.
That is, if you never have to access its fields, or create/destroy it
in the "python" code (using an external function would be ok).
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
At Monday 25/9/2006 21:27, [EMAIL PROTECTED] wrote:
Q: The C idea of (pv != NULL) is said most directly in Python ctypes
how?
Perhaps reading the ctypes tutorial? (both in the 2.5 docs and in
<http://starship.python.net/crew/theller/ctypes/tutorial.html>)
Gabriel Genellina
Softl
y and pretend it said
quote=True:
import cgi
cgi.escape.func_defaults = (True,)
del cgi
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está
s the Python docs.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respu
th an .exe file
compiled with py2exe extension? Do I have to write a batch script
separately?
I don't remember the details, but in your setup.py replace:
console=myscript.py to windows=myscript.py (or maybe
noconsole=myscript.py? I dont remember, but look at the distutils docs)
Gabriel G
At Monday 25/9/2006 20:09, walterbyrd wrote:
I do.
If so, I doubt there are many.
That's why they get well paid :)
(uhm, not really... :( )
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Des
and a bunch of
BASIC/Pascal/FORTRAN legacy code which I wish I could throw away ...
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
e
documentation of a
published standard module? Just modify the behavior in *your* own
cgi.escape and all of us will be happy...
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo
r kind of tests, and really should not
depend on the details of cgi.escape - as the usability test of an MP3
player does not care about some transitor's hFE used inside...
Gabriel Genellina
Softlab SRL
__
*always* like the output format.
Can you please show this approach using "pprint"?
Sure. Put these two lines into your sitecustomize.py:
import sys, pprint
sys.displayhook = pprint.pprint
and see what happens when you eval things inside the interpreter.
Gabriel Genellina
Softlab S
he original PEP for details
http://www.python.org/dev/peps/pep-0217/
And notice that this replaces the output of *evaluated* expressions,
not any print statement executed inside your code.
Gabriel Genellina
Softlab SRL
-
It's really the same as bool([])==False, bool(any_non_empty_list)==True:
L = [1,2,3]
while L:
print L.pop()
You don't say:
while bool(L)==True:
(do you?)
Gabriel Genellina
Softlab SRL
available to the extension in step 3 (which uses malloc).
Can you modify the C source? If you can, use the Python memory
allocation functions PyMem_Malloc/PyMem_Realloc/PyMem_Free.
Gabriel Genellina
S
for use with or without Python.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http
to (or use --color=always)
auto means "use colors *only* when *not* redirected"
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yah
At Wednesday 27/9/2006 01:39, placid wrote:
Using Tim Golden's wmi module you can get the service names
but how do i start services that are stopped?
Surely there are fancier ways:
>net start servicename
Gabriel Genellina
Sof
zip(*sorted([(a[i],i) for i in range(len(a))]))
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
htt
the Samurai] did not resist"?
The "resisted" believing all the buzz,
e.g.: "armies made of dudes with guns" ...
From the name I guess Ramon speaks Spanish; "resistir" in Spanish
has a similar mean
place it.
I've looked a little at the code, but get immediately demotivated
seeing 72 files within a flat directroy:
http://svn.python.org/view/python/trunk/Lib/idlelib/?rev=52013
Remember that packages have not existed forever... I've seen worse things :)
Gab
- in
fact, you are iterating along the *letters* in the file name, that
explains your error that "c" doesn't exist.
Just say: filelist = glob.glob(fileData)
Gabriel Genellina
Softlab SRL
__
Pre
At Wednesday 27/9/2006 13:35, Fred Kitoogo wrote:
I wish to create a recursive tree and test in Python for combining
classifiers, below are the two Algorithms (Training & Testing):-
Can somebody please help?
Sure. See <http://www.catb.org/~esr/faqs/smart-questions.html#homework>
es into python:
if ptr1: ...
if ptr2: ...
if not ptr3: ...
Oh that's exactly how my newbie innocence led me astray.
Don't apologize, it's not easy to learn Python *and* learn to link an
external library at the same time...
Gabriel Genellina
Softlab SRL
None is *not* a pointer (neither any other
kind of ctypes object), it's an object -a singleton, i.e., there
exist exactly a single one instance of None).
If you want to check if some kind of pointer is NULL or not, do *not*
check if it is None or not, check its Boolean value, again:
if p
ith me, using Zope.
The scripting language or machinery used is an implementation detail,
so it should not appear on a URL, if you want them to be more or less
permanents.
Gabriel Genellina
Softlab SRL
__
At Wednesday 27/9/2006 20:43, Leif K-Brooks wrote:
> I'm trying to plot some points in an image. Each point has an
> associating type and I'd like to have different colors (preferrably of
> high contrast) for different types. The number of types in the data
> file is unknown a priori. Is ther
ll_foo
dll_foo.argtypes = [POINTER(c_char_p), POINTER(c_long)]
status = dll_foo(byref(data), byref(size))
Are you sure your function is compiled using the stdcall calling
convention? I'm not sure what
>
> But, can string formatting be used to convert an integer to its binary
> form ?
a = 199
a_bin_str = pack('L', a)
Notice that the OP was looking for another thing, given the examples.
Perhaps a better wording would h
x27;
whatever = value.strip().lower()
Here we split the line on the ":" character; key is the text on the
left, value the remaining text on the right.
If you are using Python 2.5, the partition() string method would be
useful here.
Gabriel Genellina
Softlab SRL
hon, having the built-in dict type which is rather efficient?
I would not use Python to teach *basic* data structures, instead, I'd
use it as a second stage to teach more complex structures and how to
design algorithms.
Gabriel G
complex. This idea extends to the
parser. Restricting Python's grammar to an LL(1) parser is a
blessing, not a curse. It puts us in handcuffs that prevent us from
going overboard and ending up with funky grammar rules like some
other dynamic languages that will go unnamed, like Perl.&
e a binary string you have to import the math
module, convert the integer to float, compute a non-standard
logarithm, and then...
What if n<=0?
Too much, don't you think? :)
Gabriel Genellina
Softlab SRL
___
combining
characters. For example é can be represented in
Unicode as U+0065 (Latin small letter e) followed
by U+0301 (combining acute) but it can also be
represented as the precomposed character U+00E9
(Latin small letter e with acute)."
Gabriel Genellina
Softlab SRL
ole (that is, using
file.read()) you'll get something like 'one\ntwo\nthree\n'
As I said before, make sure your script works fine testing it
*alone*, after then, try it with CVSNT. If it doesnt work, maybe what
you get is not what you expect it to be - use print r
#x27;\\n')
(I'm not sure if all involved parties interpret \n the same way...)
--
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imagina
lag is reset, but in this
case the newline was provided by the input, so you get a space at the
start of the next output.
You could try using
print '\rQuestion?',
Gabriel Genellina
Softlab SRL
__
P
s missing in your code.
Gabriel Genellina
Softlab SRL
__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar
o much, except in cases like yours).
You can get the values using sys.exc_info()
(Don't store the traceback more than needed
because it holds a reference to all previous stack frames...)
Gabriel Genellina
Softlab SRL
rations should make you to change your data, or the
way you access your data. You invoke them at the presentation stage,
depending on the final target.
Gabriel Genellina
Softlab SRL
__
Preguntá. Resp
return;
}
In Python your functions have formal arguments:
def myfunc(plain_var, some_dict, some_list):
# ...
return
You also have positional and keyword arguments, and default values.
Read the Python tutorial <http://www.python.org/doc/current/tut/tut.html>
Gabriel Gen
At Tuesday 3/10/2006 11:53, Bryan Leber wrote:
Gabriel, actually what I did was go ahead and write the whole
sequence of the commit(i.e. PATCH_NUMBER, BUG_NUMBER, etc) to a
file, and then I read in that file and put them into a list. Then I
used line.startswith() to go through and pull out
ce types. Perhaps there needs to be a 'seq' type containing
those common methods, that is the superclass of 'str', 'bytes',
'list', 'tuple' et cetera.
find() could be useful sometimes.
But
At Friday 17/11/2006 11:14, Sheldon wrote:
Can someone tell me how to remove the conflicts here ?
Wrong group!
Anyway, there is no need to reinvent the wheel, there are many array
libraries for C...
--
Gabriel Genellina
Softlab SRL
401 - 500 of 5091 matches
Mail list logo