how to duplicate array entries

2010-01-10 Thread Sebastian
Hi there,

I have an array  x=[1,2,3]

Is there an operator which I can use to get the result
[1,1,1,2,2,2,3,3,3] ?

I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3]
I also tried [[b,b,b] for b in x] which led to [[1,2,3],[1,2,3],
[1,2,3]], but this isn't what I want either.

Cheers, Sebastian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to duplicate array entries

2010-01-10 Thread Sebastian
On Jan 11, 4:21 pm, Sebastian  wrote:

> I also tried [[b,b,b] for b in x] which led to [[1,2,3],[1,2,3],
> [1,2,3]]

Sorry, I have to correct myself. The quoted line above resulted in
[[1,1,1],[2,2,2],[3,3,3]] of course!

Cheers, Sebastian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to duplicate array entries

2010-01-11 Thread Sebastian
Thank you for your answers! I actually implemented it using for loops
before I posted here, but I was curious if there is a more elegant
solution (judging from the post, Alf will probably say, that for loops
are already elegant).

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


a is b

2009-11-04 Thread Sebastian
I have a question from the pyar  list that may have been discussed on this
list, but i didn't catch it.
Have some common objects been somewhat hardcoded into python, like some
integers as shown in the examples below? What other object have been
hardcoded (strings ,etc) and what was the criteria used to select them?  Any
hints?
cheers,
- Seb

>>> p = 500
>>> q = 500
>>> p == q
True
>>> p is q
False
>>> n = 50
>>> m = 50
>>> n == m
True
>>> n is m
True
>>> p = 500; q = 500
>>> p is q
True

 >>> for i in range(-20,258):
...   a = i
...   b = i+0
...   if not (a is b): print i
...
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
257
-- 
http://mail.python.org/mailman/listinfo/python-list


Japanese (speaking) developer needed for a bit of regex magic

2010-04-20 Thread Sebastian
Hi all,

I'm working on Python bindings for the Amazon Product Advertising API
(http://pypi.python.org/pypi/python-amazon-product-api/) which
supports the different localised versions - among them a Japanese one
(for http://www.amazon.co.jp).

All locales return error messages in English. Only the Japanese uses
Japanese which my regular expressions cannot handle at the moment.

Is there anyone fluent enough in Japanese to give me a hand? The bit
of code that needed tweaking can be found here:
http://bitbucket.org/basti/python-amazon-product-api/src/tip/amazonproduct.py#cl-152

A simple diff would help me greatly.

Thanks for your effort!
Seb.

P.S. If you have questions, I've set up a mailing list at python-
amazon-product-api-de...@googlegroups.com.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Sebastian
> General advice with character sets in Python apply: always explicitly
> declare the encoding of input, then decode to Unicode interally as early
> as possible, and process all text that way. Only fix into an encoding
> when it's time to output.

Maybe I was too vague when describing my problem. As Chris correctly
guessed, I have a literal language problem.

> > All locales return error messages in English. Only the Japanese uses
> > Japanese which my regular expressions cannot handle at the moment.
>
> What exactly are you expecting to happen, and what exactly happens
> instead?

My regular expressions turn the Amazon error messages into Python
exceptions.

This works fine as long as they are in English: "??? is not a valid
value for BrowseNodeId. Please change this value and retry your
request.", for instance, will raise an InvalidParameterValue
exception. However, the Japanese version returns the error message "???
は、BrowseNodeIdの値として無効です。値を変更してから、再度リクエストを実行してください。" which will not be
successfully handled.

This renders the my module pretty much useless for Japanese users.

I'm was therefore wondering if someone with more knowledge of Japanese
than me can have a look at my expressions. Maybe the Japanese messages
are completely different...

I have a collection of sample messages here (all files *-jp-*.xml):
http://bitbucket.org/basti/python-amazon-product-api/src/tip/tests/2009-11-01/

Any help is appreciated!

Cheers,
Sebastian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Sebastian
> > My regular expressions turn the Amazon error messages into Python
> > exceptions.
>
> > This works fine as long as they are in English: "??? is not a valid
> > value for BrowseNodeId. Please change this value and retry your
> > request.", for instance, will raise an InvalidParameterValue
> > exception. However, the Japanese version returns the error message
> > "??? は、BrowseNodeIdの値として無効です。値を変更してから、再度リクエス
> > トを実行してください。" which will not be successfully handled.
>
> > This renders the my module pretty much useless for Japanese users.
>
> Your problem, then, appears to be that you're attacking the issue at the
> wrong layer. Parsing messages in natural language and hoping to
> reconstruct a structure is going to be an exercise in frustration.
>
> Doesn't the API have defined response codes and parameters that you can
> use, instead of parsing error strings in various natural languages?

No, unfortunately not. If it did, I would have used it.

The Amazon API returns an XML response which contains error messages
if a request fails. These messages consist of an error code and an
error description in natural language. Luckily, the description seems
to stick to the same format and is (in all but one case) in plain
English. Much to my dismay I discovered that the Japanese locale
translates the error message!

For example, this is the bit of XML returned for the German locale:

  

  AWS.InvalidParameterValue
  ??? is not a valid value for BrowseNodeId. Please
change this value and retry your request.

  

The corresponding part from the Japanese locale looks like this:

  

  AWS.InvalidParameterValue
  ???
は、BrowseNodeIdの値として無効です。値を変更してから、再度リクエストを実行してください。

  

Of course, one could argue that the type of error (in this case
"AWS.InvalidParameterValue") would be enough. However, in order to
return a maeningful error message, I would like to parse the
description itself - and for this some knowledge of Japanese would be
helpful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Sebastian
> > This works fine as long as they are in English:
> > "??? is not a valid  value for BrowseNodeId.
>
>  >  Please change this value and retry your request.",
>  > for instance, will raise an InvalidParameterValue
>
> > exception. However, the Japanese version returns the error message "???
> > は、BrowseNodeIdの値として無効です。値を変更してから、再度リクエストを実行してください。"
>
> My daughter, in 2nd year college Japanese, says that the above is
> basically a translation of the English boilerplate. The only variable
> info is 'BrowserNodeId', which you can read just fine already.
> So we do not understand what your problem is and what you want to
> accomplish.
>
> > I have a collection of sample messages here (all files *-jp-*.xml):
> >http://bitbucket.org/basti/python-amazon-product-api/src/tip/tests/20...
>
> Is this a commercial product? Are you willing to pay for serious help,
> if needed?
>
> Terry Jan Reedy

I just wanted to know if the Japanese version said the same. I'll
probably simply return the error message in full. Any Japanese
(speaking) developer will then know what caused the exception.

Thanks for your help.

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


Popen question (redundant processes)

2009-08-30 Thread Sebastian
Hello World!
This is my first post on the list and I'm hoping it is the right forum and
not OT, I've searched
a bit on this, but, none-the-wiser!

My question is on the Popen method, here is my snippet:

p1 = Popen(["cat", "georgi_ddr7_allmag_kcor_in_test.dat"], stdout=PIPE )
> p2 = Popen(["fit_coeffs"], stdin=p1.stdout, stdout=PIPE)
> p3 = Popen(["reconstruct_maggies"], stdin=p2.stdout,stdout=PIPE)
> output_maggies_z=p3.communicate()[0]
>
> p1 = Popen(["cat", "georgi_ddr7_allmag_kcor_in_test.dat"], stdout=PIPE )
> p2 = Popen(["fit_coeffs"], stdin=p1.stdout, stdout=PIPE)
> p4 = Popen(["reconstruct_maggies", "--band-shift", "0.1", "--redshift",
> "0."], stdin=p2.stdout,stdout=PIPE)
> output_maggies_z0=p4.communicate()[0]
>
>
That is, p1 and p2 are the same, but p3 and p4 which they are passed to, are
different.
Is there a way to pass p1 and p2 to p3 AND p4 simultaneously, so as to not
need to
run p1 and p2 twice, as above?
What arguments would I need to achieve this?

NOTE: "georgi_ddr7_allmag_kcor_in_test.dat" is a very large file (~1E6
records)

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


yield all entries of an iterable

2010-10-23 Thread Sebastian
Hi,
Is there a simpler way to yield all elements of a sequence than this?
for x in xs:
yield x

I tried googling but fond only the other direction (turning a generator
into a list with "list(my_generator())".

Sebastian


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


Runtime error

2010-10-28 Thread Sebastian

Hi all,

I am new to python and I don't know how to fix this error. I only try to 
execute python (or a cgi script) and I get an ouptu like


[...]
'import site' failed; traceback:
Traceback (most recent call last):
File "/usr/lib/python2.6/site.py", line 513, in 
main()
File "/usr/lib/python2.6/site.py", line 496, in main
known_paths = addsitepackages(known_paths)
File "/usr/lib/python2.6/site.py", line 288, in addsitepackages
addsitedir(sitedir, known_paths)
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
File "", line 1, in 
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
File "", line 1, in 
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
[...]
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
File "", line 1, in 
File "/usr/lib/python2.6/site.py", line 175, in addsitedir
sitedir, sitedircase = makepath(sitedir)
File "/usr/lib/python2.6/site.py", line 76, in makepath
dir = os.path.abspath(os.path.join(*paths))
RuntimeError: maximum recursion depth exceeded


What is going wrong with my python install? What do I have to change?

Thanks,
Sebastian
--
http://mail.python.org/mailman/listinfo/python-list


Runtime Error

2010-10-28 Thread Sebastian

Hi all,

I am new to python and I don't know how to fix this error. I only try to 
execute python (or a cgi script) and I get an ouptu like


[...]
'import site' failed; traceback:
Traceback (most recent call last):
File "/usr/lib/python2.6/site.py", line 513, in 
main()
File "/usr/lib/python2.6/site.py", line 496, in main
known_paths = addsitepackages(known_paths)
File "/usr/lib/python2.6/site.py", line 288, in addsitepackages
addsitedir(sitedir, known_paths)
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
File "", line 1, in 
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
File "", line 1, in 
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
[...]
File "/usr/lib/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib/python2.6/site.py", line 155, in addpackage
exec line
File "", line 1, in 
File "/usr/lib/python2.6/site.py", line 175, in addsitedir
sitedir, sitedircase = makepath(sitedir)
File "/usr/lib/python2.6/site.py", line 76, in makepath
dir = os.path.abspath(os.path.join(*paths))
RuntimeError: maximum recursion depth exceeded


What is going wrong with my python install? What do I have to change?

Thanks,
Sebastian
-- 
http://mail.python.org/mailman/listinfo/python-list


Discussion forum for typing Q&A and review requests

2021-09-13 Thread Sebastian Rittau
Typing with Python is hard and constantly evolving. This is why we set 
up a forum to help users with typing at 
https://github.com/python/typing/discussions 
<https://github.com/python/typing/discussions>. It's fairly new, but at 
the moment we have two categories for general Q&A and for asking for 
reviews. If you have questions about typing, please join us there or on 
our Gitter channel (https://gitter.im/python/typing 
<https://gitter.im/python/typing>). If you maintain a typing-related 
package or typing-related documentation, we would be happy if you could 
add a link to the discussions forum to your documentation. Contributors 
to the forum and suggestions on how to improve it are most welcome.


The forum is intended as a help forum. Discussions about new features, 
improvements, and implementation should continue to go to the typing-sig 
list or to the appropriate issue trackers.


- Sebastian

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


sharing data across Examples docstrings

2022-01-11 Thread Sebastian Luque
Hello,

I am searching for a mechanism for sharing data across Examples sections
in docstrings within a class.  For instance:

class Foo:

def foo(self):
"""Method foo title

The example generating data below may be much more laborious.

Examples

>>> x = list("abc")  # may be very long and tedious to generate

"""
pass

def bar(self):
"""Method bar title

Examples

>>> # do something else with x from foo Example

"""
pass


Thanks,
-- 
Seb
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sharing data across Examples docstrings

2022-01-11 Thread Sebastian Luque
On Wed, 12 Jan 2022 09:28:16 +1100,
Cameron Simpson  wrote:

[...]

> Personally I'd be inclined to put long identical examples in the class
> docstring instead of the method, but that may not be appropriate.

Good point, and perhaps it's best to put a comprehensive example in the
class docstring, rather than scatter it across the methods' docstrings.
The situation is one in which the methods are typically (but not always)
intended to be used as part of a pipeline of operations; e.g. Foo.foo()
would almost always be used before Foo.bar().

Thanks,
-- 
Seb
-- 
https://mail.python.org/mailman/listinfo/python-list


A news aggregator for the Python community

2019-10-18 Thread Sebastian Steins
Hi!

Over the last few weeks I've build a hacker news clone for the Python community:

https://news.python.sc

The source is at github.com/sebst/pythonic-news

I thought that might be of interest to you and I'd be more than happy
to hear your thoughts on this.

Best,
  --Sebastian
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-10 Thread Sebastian Bassi
On 9/30/05, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote:
> after Guido's pronouncement yesterday, in one of the next versions of Python
> there will be a conditional expression with the following syntax:
> X if C else Y

I don't understand why there is a new expression, if this could be
accomplished with:

if C:
 X
else:
 Y

What is the advantage with the new expression?

--
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Question about HTMLgen

2005-06-20 Thread Sebastian Bassi
Hello,

I am using HTMLgen. It is very nice. But I can't make it to generate
an arbitrary command.
For example I want to output this:



Each time I put "<" it gets escaped from HTML, instead of being inserted inside.

-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about HTMLgen

2005-06-21 Thread Sebastian Bassi
Thanks, you are right!

On 6/20/05, Konstantin Veretennicov <[EMAIL PROTECTED]> wrote:
> >  > type="image/svg+xml" name="wmap" wmode="transparent">
> 
> Works for me...



-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python certification

2005-07-20 Thread Sebastian Bassi
On 16 Jul 2005 09:51:55 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> i want to get a small certificate or diploma in python.
> it should be online cuz i live in pakistan and wont have teast centers
> near me.
> it should be low cost as i am not rich.
> and hopefully it would be something like a a begginer certification cuz
> i am new to python.

I could make a program, upload it to sourceforge (or similar OSS
repository) and add that to your resume. Another opcion is to help in
the development of any python-based program and work enought to be
included in the authors list. That could be useful too (because you
learn and do some good for more people). I believe more in a working
program than a paper based certificate.


-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


How to store "3D" data? (data structure question)

2005-07-20 Thread Sebastian Bassi
Hello,

I have to parse a text file (was excel, but I translated to CSV) like
the one below, and I am not sure how to store it (to manipulate it
later).

Here is an extract of the data:

Name,Allele,RHA280,RHA801,RHA373,RHA377,HA383
TDF1,181,
,188,
,190,
,193,*,*,,,
,None,,,*,*,*
,,
TDF2,1200,*,*,,,*
,None,,,*,*,
,,
TDF3,236,
,240,
,244,*,,*,,*
,252,*,*,,,
,None*,
,,

Should I use lists? Dictionary? Or a combination?
The final goal is to "count" how many stars (*) has any "LINE" (a line
is RHA280 for instance).
RHA280 has 1 star in TDF1 and 1 star in TDF2 and 2 stars in TDF3.

I am lost because I do analize the data "line by line" (for Line in
FILE) so it is hard to count by column.



-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to store "3D" data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 20 Jul 2005 10:47:50 -0700, Graham  Fawcett <[EMAIL PROTECTED]> wrote:
> This looks a lot like 2D data (row/column), not 3D. What's the third
> axis? It looks, too, that you're not really interested in storage, but
> in analysis...

I think it as 3D like this:
1st axis: [MARKER]Name, like TDF1, TDF2.
2nd axis: Allele, like 181, 188 and so on.
3rd axis: Line: RHA280, RHA801.

I can have a star in MarkerName TDF1, Allele 181 and Line RHA280.
I can have an empty (o none) in TDF1, Allele 181 and Line RHA801.

What I like to know is what would be a suitable structure to handle this data?
thank you very much!

-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to store "3D" data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 20 Jul 2005 10:47:50 -0700, Graham  Fawcett <[EMAIL PROTECTED]> wrote:
> # zip is your friend here. It lets you iterate
> # across your line names and corresponding values
> # in parallel.

This zip function is new to me, the only zip I knew was pkzip :). So
will read about it.

-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to store "3D" data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 20 Jul 2005 11:51:56 -0700, Graham  Fawcett <[EMAIL PROTECTED]> wrote:
> You get the idea: model the data in the way that makes it most useable
> to you, and/or most efficient (if this is a large data set).

I don't think this could be called a large dataset (about 40Kb all the file).
It would be an overkill to convert it in MySQL (or any *SQL).
I only need to parse it to reformat it.
May I send the text file to your email and a sample of the needed
output? It seems you understand a lot on this topic and you could do
it very easily (I've been all day trying to solve it without success
:(
I know this is not an usual request, but this would help me a lot and
I would learn with your code (I still trying to understand the zip
built-in function, that seems useful).




-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to store "3D" data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 7/20/05, Cyril Bazin <[EMAIL PROTECTED]> wrote:
> The question of the type of the data sutructure depends of your use of the
> data. 
>  You could avoid some confusion without naming your columns "lines"...

Yes, that is because they are "plant lines", that is why is called "lines" :)

>  Anyway, here is a piece of code that read the file and count the star on
> the fly:
>  (The result is a dict of dict of int.)

THANK YOU, I will check it out!

-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread Sebastian Bassi
On 19 Sep 2005 12:25:16 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> >>> rs='AUGCUAGACGUGGAGUAG'
> >>> rs[12:15]='GAG'
> Traceback (most recent call last):
>   File "", line 1, in ?
> rs[12:15]='GAG'
> TypeError: object doesn't support slice assignment

You should try Biopython (www.biopython.org). There is a sequence
method you could try.





-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugging during package development

2015-08-01 Thread Sebastian Luque
On Sat, 01 Aug 2015 15:30:34 +1000,
Ben Finney  wrote:

> Seb  writes:
>> With lots of debugging to do, the last thing I'd want is to worry
>> about the search path.

> Short answer: you need ‘python3 ./setup.py develop’.

> Medium-length answer: you need to add some infrastructure to get your
> project to the point where you can run ‘python3 ./setup.py develop’.

> Longer answer below.

>> So I've been searching for better ways to work, but I can't seem hit
>> the right keywords and come with all sorts of tangentially related
>> stuff.

> The Python module search path is an abstraction, with only a partial
> relationship to the location of modules files in the filesystem.

> The expectation is that a module (or a package of modules) will be
> *installed* to a location already in the module search path (with
> ‘python ./setup.py .

> This allows for cross-platform package management, especially on
> systems that don't have a working OS package manager. The trouble is
> that it does cause a significant learning curve for Python
> programmers, and is an ongoing sore point of Python.

>> I'm sure there must be some tool that sets up the development
>> environment when the package source is not on `sys.path`. Any advice
>> on this topic would be appreciated.

> What you need is to tell Distutils which Python modules form your
> project https://docs.python.org/3/library/distutils.html>.

> Once you've got a working ‘setup.py’ for your project, run ‘python3
> ./setup.py develop’ to allow your packages to be run in-place while
> you develop them.

This sounds exactly like what I was looking for.  I was growing tired of
doing 'python setup.py install', every time I wanted to debug something.
The subpackages' modules have inter-dependencies, which require the
whole package to be in `sys.path`.  Unfortunately, I have to stick with
Python 2.7...

Thank you,

-- 
Seb

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


An "alternative" to Learning Perl

2012-01-08 Thread Sebastian Rooks
Hello everyone,

I was wondering if you could help me. I'm looking for a python
introductory book, kind of like Learning Python only smaller (?!)
The thing is, I travel to and from work each day for about 1,5h in each
direction, and do most of my reading on the train :\

(seriously)

And I can't find one (just one) python book shorter than 500 pages that
is worth its weight in salt.

Anyone know of any, any at all?

All suggestions welcomed!

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


Re: An "alternative" to Learning Perl

2012-01-10 Thread Sebastian Rooks
On Mon, 9 Jan 2012 00:55:22 -0300, Sean Wolfe 
wrote:

>kindle? ipad? tablet?

I'm interested in books, not files ... 
(seriously, now ... I don't have any of those devices)

>also there is python programming for the absolute beginner, which is
>agreat book but it's pretty beginner. But well written. At least
>Iliked 
>it.http://www.amazon.com/Python-Programming-Absolute-Beginner-3rd/dp/1435455002
>Also byte of python ... I think there's a hardcover version you can
>buyhttp://www.swaroopch.com/buybook/

I think I saw that second one somewhere already. I'll check out the
first link, also. Thanks!

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


Re: To remove some lines from a file

2006-10-25 Thread Sebastian Busch
[EMAIL PROTECTED] wrote:
> ... I would like to remove two lines from a file.
> ...

I am quite new myself -- but wouldn't grep -v do that easier (and
perhaps faster)?

Greetings,
Sebastian.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: To remove some lines from a file

2006-10-25 Thread Sebastian Busch
Steve Holden wrote:
> Sebastian Busch wrote:
>> [EMAIL PROTECTED] wrote:
>>> ... I would like to remove two lines from a file. ...
>> ... grep -v ...
> ... show ...

grep -v "`grep -v "commentsymbol" yourfile | head -2`" yourfile


i frankly admit that there is also 'head' invoved ;)

i really have no idea -- but i always thought that these coreutils and
colleagues do their jobs as fast as possible, in particular faster than
interpreted languages... however, as i posted last time, i was actually
not aware that you have to call three of them.

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


Re: To remove some lines from a file

2006-10-26 Thread Sebastian Busch
Chetan wrote:
> Sebastian Busch <[EMAIL PROTECTED]> writes:
> 
>> Steve Holden wrote:
>>> Sebastian Busch wrote:
>>>> [EMAIL PROTECTED] wrote:
>>>>> ... I would like to remove two lines from a file. ...
>>>> ... grep -v ...
>>> ... show ...
>> grep -v "`grep -v "commentsymbol" yourfile | head -2`" yourfile
>> ...
> I don't have the original post to know exactly what is needed, but looks like
> something that can be done by a single sed script. 
> 
> -Chetan

Hey!

The task is:

"Remove the first two lines that don't begin with "@" from a file."


Actually, the grep-thing I offered will also delete copies of these two
lines that occur in another place. That should be no problem if the file
is something like

@comment
deleteme
deleteme
@comment
data: x-y-dy

However, if this is not the case, it cannot be done this way.
How would you do it with sed?

Best,
Sebastian.
-- 
http://mail.python.org/mailman/listinfo/python-list


Timeline for Python?

2006-08-31 Thread Sebastian Bassi
Hello all,

I am working on a Python book, since it could be completed in about a
year (writing time + edition + publishing) or more, I would like to
know what version to target since I don't want to release a book that
will be outdated just after is printed.
I use 2.4 for everyday work but most webservers still carry 2.2 (and
most programs runs w/o any modification, since I don't tend to use new
features), but publishers know that people like to buy lasted version
books.
So, if the book is published in October 2007, should feature Python 3
or Python 2.5?
I did read http://www.python.org/dev/peps/pep-3000/ but I still not
sure about timeline.

Best regards,
SB.

-- 
Bioinformatics news: http://www.bioinformatica.info
Lriser: http://www.linspire.com/lraiser_success.php?serial=318
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Timeline for Python?

2006-09-01 Thread Sebastian Bassi
On 1 Sep 2006 00:57:04 -0700, crystalattice <[EMAIL PROTECTED]> wrote:
> I'd write for 2.4, even though 2.5 should be coming out "shortly".
> There aren't many significant changes to the whole language between 2.4
> and 2.5.  Probably the best thing is write for 2.4 and have a sidenote
> stating where 2.5 operates differently.
> The Python 3 timeline is almost a moving target right now; personally,
> I don't think it will be out before next winter.  Maybe a beta but I
> doubt the full version.

Maybe I forgot to tell, but its going to take me at least 6 month to
finish the book, then there is a proofreading stage with the publisher
and then the release, so it will take about 1 year (about end of
2007), that is why I am thinking in 2.5 and 3.
What do you think about it?

-- 
Bioinformatics news: http://www.bioinformatica.info
Lriser: http://www.linspire.com/lraiser_success.php?serial=318
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: windev vs python SOS

2006-09-28 Thread Sebastian Kaliszewski
stéphane bard wrote:
> hello, my boss ask me to prefer windev to python.
> I have to argue
> 
>  - python work on multiple platform (linux, mac, windows)
> A good point but it didn't interest him. Because
> we want to choose a language for prototyping.
> So multi platform is not enough.
> 
>  - python and windev are fast to develop
> 
>  - windev as a good IDE, python? boa-constructor is ok with wxpython
> 
>  - python is open source (that's not an argument for my boss, sorry 
> it's a boss ...)
> 
> any idea for a strong argument ?

Python is widely known and tested, windev is not. Stuff not widely used (and 
thus not well verified by Real World(tm)) is a Big Business Risk(tm). Things 
looking pretty on marketing presentations might show its ugly head in Real 
Life(tm) where Real Money(tm) is at stake (and in fact they do in vast 
majority of cases).

Python is widely known and has Good Track Record(tm). Windev has not.

Python is known to integrate well into Windows. Is your boss really sure 
that windev is good there? How about various corner cases?

Does your boss know about .net? Tell him about IronPython (If Microsoft 
thinks its good, why your boss should not?). If your boss thinks .net is 
crap and Java rules, tell him about Jython.

It's relatively easy to find (hire) Python programmers. It's not true in 
case of windev programmers. If your boss needs more people or some people 
leave (and thus must be replaced), it's a Real Cost(tm) to train new people 
new windev tricks. Is your boss willing to take the risk that new people 
will need 1-2 months to get fluent with windev (as he may well forget about 
hiring trained windev developer in a reasonable amount of time, while hiring 
trained python developer is possible).


rgds
-- 
Sebastian Kaliszewski
-- 
http://mail.python.org/mailman/listinfo/python-list


How to refer to Python?

2006-11-28 Thread Sebastian Bassi
I am writing a paper where I refer to Python. Is there a paper that I
can refer the reader to? Or just use the Python web page as a
reference?
-- 
http://mail.python.org/mailman/listinfo/python-list


GNUmed - new version released

2006-12-21 Thread Sebastian Hilbert
Hello,

Today we are releasing a new GNUmed version. GNUmed is a package to manage 
medical offices. Version is up to 0.2.3 Version features and bug fixes are 
explained in our Wiki 

http://wiki.gnumed.de/bin/view/Gnumed/ReleaseStatus 
http://wiki.gnumed.de/bin/view/Gnumed/RoadMap 

Packages available as usual for GNU/Linux and MS Windows als well as Debian 
packages 
 MacOSX packages didn't make it yet due to unexplained problems with the Mac 
port. In general it looks like the code is getting much more stable and 
easier to fix and extent. 

Bug reports are appreciated.
-- 
Sebastian Hilbert 
Leipzig / Germany
[www.gnumed.de]  -> PGP welcome, HTML ->/dev/null
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where is python on linux?

2007-01-07 Thread Sebastian Busch
Frank Potter wrote:
> ... where is the executable python file? ...

does

whereis python

tell you what you want to know?
sebastian.
-- 
http://mail.python.org/mailman/listinfo/python-list


en la misma linea

2006-01-26 Thread Sebastian Bassi
Hola,

Aca con una pregunta basica:
A veces veo que hay programas que tienen varias instrucciones en la
misma linea, cuando lo que aprendi de Python era que se usaba el
espaciado para mantener la estructura (indent).
Por ejemplo:
if name != 'comic': return
Hay un return despues de los dos puntos, no se que significa.


--
Bioinformatics news: http://www.bioinformatica.info
Lriser: http://www.linspire.com/lraiser_success.php?serial=318
-- 
http://mail.python.org/mailman/listinfo/python-list


Detec nonascii in a string

2006-02-23 Thread Sebastian Bassi
Hello,

How do I detect non-ascii letters in a string?
I want to detect the condition that a string have a letter that is not
here: string.ascii_letters

Best regards,
SB.

--
Bioinformatics news: http://www.bioinformatica.info
Lriser: http://www.linspire.com/lraiser_success.php?serial=318
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Detec nonascii in a string

2006-02-23 Thread Sebastian Bassi
On 2/23/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> "äöü".decode("ascii")
> should do the trick -- you get an UnicodeError when there is anything ascii
> can't encode.

Thank you. This is good enought for me.
Best regards,
SB.

--
Bioinformatics news: http://www.bioinformatica.info
Lriser: http://www.linspire.com/lraiser_success.php?serial=318
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Output of HTML parsing

2007-06-15 Thread Sebastian Wiesner
[ Jackie <[EMAIL PROTECTED]> ]
> 1.The code above assume that each Prof has a tilte. If any one of them
> does not, the name and title will be mismatched. How to program to
> allow that title can be empty?
>
> 2.Is there any easier way to get the data I want other than using
> list?

Use BeautifulSoup.

> 3.Should I close the opened csv file("professor.csv")? How to close
> it?

Assign the file object to a separate name (e.g. stream) and then invoke its 
close method after writing all csv data to it.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 bug??

2007-06-17 Thread Sebastian Wiesner
[ Carsten Haese <[EMAIL PROTECTED]> ]
> On Sun, 2007-06-17 at 07:43 -0700, 7stud wrote:
> > Please report the whole docs as a bug.
>
> Calling the entire docs a bug is not helpful.

... unless he also comes up with the "bugfix". ;)

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: try/except/else/finally problem

2007-06-28 Thread Sebastian Wiesner
[ Ed Jensen <[EMAIL PROTECTED]> ]
> try:
> f = file('test.txt', 'r')
> except IOError:
> print 'except'
> else:
> print 'else'
> finally:
> print 'finally'
>
>
> And the results are:
>
>   File "./test.py", line 9
> finally:
>   ^
> SyntaxError: invalid syntax

A finally block isn't allowed to appear together with an except block for 
releases previous to 2.5. You need to split your exception handling into 
two separate blocks.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Building a Python app with Mozilla

2007-06-30 Thread Sebastian Wiesner
[ "Diez B. Roggisch" <[EMAIL PROTECTED]> ]
> And as it has been said in this thread already, Qt has an excellent free
> GUI-builder.

Free as long as you develop free software. Development of proprietary, 
non-gpl software with Qt requires a commercial licence from Trolltech.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: linecache and comparison with input

2007-06-30 Thread Sebastian Wiesner
[ Ross Hetherington <[EMAIL PROTECTED]> ]
> #!/usr/bin/env python
>
> import random
> import sys
> import linecache
>
> rnd = random.randint(1,3)
> line = linecache.getline('testfile', rnd)
>
> print line
Try print repr(line) ...
>
> gss = raw_input('Enter line: ',)
and print repr(gss) ;)

> if gss == line:
> print 'yes'
> sys.exit()
> else:
> print 'no'
>

Then you will see, that getline returns the line *including the newline 
character*, while raw_input does not.  Use line.strip('\n') to remove 
trailing newline characters from the return value of getline.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Building a Python app with Mozilla

2007-06-30 Thread Sebastian Wiesner
[ "Diez B. Roggisch" <[EMAIL PROTECTED]> ]
> > I'd like to build a Python GUI app. Neither Tkinter nor Wxpython nor
> > PyQT are actually what I want (because the lack of GUI builders and
> > they don't really look good on Windows and Linux).
>
> The latter statement is bogus. Qt is THE native look on KDE. GTK for
> Gnome. So how is it not "looking good on linux"?

I guess, "not looking good on linux" refers to Tkinter, which is in fact 
really ugly on linux systems.

> And as it has been said in this thread already, Qt has an excellent free
> GUI-builder. 

So have Gtk and WxWidgets.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: The file executing

2007-07-03 Thread Sebastian Wiesner
[ Benjamin <[EMAIL PROTECTED]> ]
> On Jul 2, 9:47 pm, Justin Ezequiel <[EMAIL PROTECTED]>
>
> wrote:
> > On Jul 3, 9:40 am, Benjamin <[EMAIL PROTECTED]> wrote:
> > > How does one get the path to the file currently executing (not the
> > > cwd). Thank you
> >
> > os.path.dirname(sys.argv[0])
>
> The returns the file that was called first, but not the one currently
> executing...

Use __file__ instead of sys.argv[0]

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

CSV without first line?

2007-07-14 Thread Sebastian Bassi
Hi,

In my CSV file, the first line has the name of the variables. So the
data I want to parse resides from line 2 up to the end. Here is what I
do:

import csv
lines=csv.reader(open("MYFILE"))
lines.next() #this is just to avoid the first line
for line in lines:
DATA PARSING

This works fine. But I don't like to do "lines.next()" just to get rid
of the first line. So I wonder if the reader function on the csv
module has something that could let me parse the file from the second
line (w/o doing that lines.next()).


-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Can a low-level programmer learn OOP?

2007-07-14 Thread Sebastian Bassi
On 7/13/07, Simon Hibbs <[EMAIL PROTECTED]> wrote:
> place. At the end of it you'll have a good idea how OOP works, and how
> Python works. Learning OOp this way is easy and painless, and what you
...

But this tutorial states "I assume you know how object-oriented
programming works"

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: CSV without first line?

2007-07-15 Thread Sebastian Bassi
On 7/15/07, John Machin <[EMAIL PROTECTED]> wrote:
> So you imagine that there is an undocumented feature?

No, I just think that is documented but I am not able to understand
it. Reading the list I've learned several things that are not directly
inferred from documentation (that is not the same as undocumented
feature).

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python CGI and Browser timeout

2007-04-26 Thread Sebastian Bassi
On 26 Apr 2007 14:48:29 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> In order to work around this problem, I started printing empty strings
> (i.e. print "") so that the browser does not timeout.

How do you print something while doing the query and waiting for the results?
I saw some pages that display something like: "This page will be
updated in X seconds to show the results" (X is an estimated time
depending of server load), after a JS countdown, it refresh itself and
show the result or another "This page will be updated in X seconds to
show the results".



-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python CGI and Browser timeout

2007-04-26 Thread Sebastian Bassi
On 26 Apr 2007 14:48:29 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Is there a better solution to avoid browser timeouts?

Raising timeout in Apache, by default is 300 seconds.
Limiting jobs size (both in the html form and from script size since
you should not trust on client validations).

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: SEO - Search Engine Optimization - Seo Consulting

2007-05-01 Thread Sebastian Kaliszewski
Bob Phillips wrote:
> You bottom posters really are a bunch of supercilious, self-righteous 
> bigots.

Whatever. When reading answers to some statements normal people like first 
to see the statement then the response, not the other way around. Just 
because you're using broken tool (Outlook Express) it does not excuse you of 
being rude.

Besides, reposting that spamming site address is idiotic by itself, 
regardless of top posting or not.

[...]
> And regardless of his response, Mr Bruney IS an MVP, he is clearly 
> knowledgeable in his subject, and his book is well enough thought of to make 
> me consider buying it.


Regardless of who Mr Bruney is, this if completely offtopic on 
comp.lang.python, misc.writing, alt.consumers.uk-discounts.and.bargains and 
uk.people.consumers.ebay

Just notice that you're posting to *more than one* group. Just please learn 
to use the damn reader! Even Outlook Express allows to set Followup-To: 
header and limit the polution.
EOT
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a nice formatted csv file

2007-05-02 Thread Sebastian Bassi
On 2 May 2007 07:14:04 -0700, redcic <[EMAIL PROTECTED]> wrote:
> And i get an out.txt file looking like:
> 1,2,3
> 10,20,30
> Whereas what I'd like to get is:
> 1,2,3,
> 10,  20,   30
> which is more readable.

The idea behind csv module is to produce and read csv files that are
"machine readable" rather than "human readable", so I think you should
write the file "by hand" to take into account those whitespace.



-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: default config has no md5 module?

2007-05-04 Thread Sebastian Bassi
On 5/4/07, Leo Jay <[EMAIL PROTECTED]> wrote:
> i want to compile a python by myself, but after configure and make, it
> seems that md5 is not built by default.
>
> what should i do to compile md5 as an module?

md5 module was deprecated, now it functions are in hashlib.
(see http://docs.python.org/lib/module-hashlib.html).
So you may not need to compile md5 module at all.


-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

Removing NS in ElementTree

2007-05-25 Thread Sebastian Bassi
I would like to remove the namespace information from my elements and
have just the tag without this information. This
"{http://uniprot.org/uniprot}"; is preapended into all my output.
I understand that the solution is related with "_namespace_map" but I
don't know much more.


>>> for x in eleroot[0]:
print x.tag
print x.text


{http://uniprot.org/uniprot}accession
Q9JJE1
{http://uniprot.org/uniprot}organism


{http://uniprot.org/uniprot}dbReference
None
{http://uniprot.org/uniprot}sequence

MPKKKPTPIQLNPAPDGSAVNGTSSAETNLEALQKKLEELELDEQQRKRL
EAFLTQKQKVGELKDDDFEKISELGAGNGGVVFKVSHKPSGLVMARKLIH
LEIKPAIRNQIIRELQVLHECNSPYIVGFYGAFYSDGEISICMEHMDGGS
LDQVLKKAGRIPEQILGKVSIAVIKGLTYLREKHKIMHRDVKPSNILV



-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

expat parser

2007-05-27 Thread Sebastian Bassi
I have this code:

import xml.parsers.expat
def start_element(name, attrs):
print 'Start element:', name, attrs
def end_element(name):
print 'End element:', name
def char_data(data):
print 'Character data:', repr(data)
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = start_element
p.EndElementHandler = end_element
p.CharacterDataHandler = char_data
fh=open("/home/sbassi/bioinfo/smallUniprot.xml","r")
p.ParseFile(fh)

And I get this on the output:

...
Start element: sequence {u'checksum': u'E0C0CC2E1F189B8A', u'length': u'393'}
Character data: u'\n'
Character data: u'MPKKKPTPIQLNPAPDGSAVNGTSSAETNLEALQKKLEELELDEQQRKRL'
Character data: u'\n'
Character data: u'EAFLTQKQKVGELKDDDFEKISELGAGNGGVVFKVSHKPSGLVMARKLIH'
...
End element: sequence
...

Is there a way to have the character data together in one string? I
guess it should not be difficult, but I can't do it. Each time the
parse reads a line, return a line, and I want to have it in one
variable.

(the file is here: http://sbassi.googlepages.com/smallUniprot.xml)
-- 
http://mail.python.org/mailman/listinfo/python-list


Combinatorial of elements in Python?

2007-08-15 Thread Sebastian Bassi
I have 2 (or more) groups of elements, and I want to get all possible
unique combinations from all of them. Is there a build-in method to do
it?

ADictionary={"one":["A","B","C","D"],"two":["H","I"]}

I want to have all possible combinations from "one" and "two", that is:

AH
BI
CH
DI
AI
BH
CI
DH

Sounds easy, but is not :)


-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Combinatorial of elements in Python?

2007-08-15 Thread Sebastian Bassi
On 8/15/07, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote:
> Oh but it is:
> >>> ADictionary={"one":["A","B","C","D"],"two":["H","I"]}
> >>> result = set()
> >>> for one in ADictionary["one"]:
> ... for two in ADictionary["two"]:
> ... result.add(one + two)

That was easy :)
What about extending it for N elements inside the dictionary? Sounds
like a work for a recursive function.

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Combinatorial of elements in Python?

2007-08-15 Thread Sebastian Bassi
On 8/15/07, Mikael Olofsson <[EMAIL PROTECTED]> wrote:
> What is unclear here is in what order the keys should be visited. The
> following assumes that the keys should be considered in alphanumeric order.

Yes, my fault. The orden should be given by a string, like:

DCDBA
Using this dictionay.
A={'A':['1','2'],'B':['4','5'],'C':['6','7','8'],'D':['9']}

Should return:

'96941'
'97941'
'97942'
'96942'
'98941'
'98942'
'96951'
'97951'
'97952'
'96952'
'98951'
'98952'



-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python on Computation, Math and Statistics

2007-08-19 Thread Sebastian Bassi
On 8/19/07, W. Watson <[EMAIL PROTECTED]> wrote:
> Google? What's that? Thanks. I like to get a insider's view when I know
> experts are out there. So now I ask a deeper question. Are there matrix
> computation libraries or even statistical (regression, factor analysis)
> libraries?

If you are so inclined you can use R functions from Python (look for R
and Python in your favorite search engine).

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Biased random?

2007-08-27 Thread Sebastian Bassi
On 8/27/07, J. Cliff Dyer <[EMAIL PROTECTED]> wrote:
>  Play with your log to get the range you want

Here you can get "true" random numbers (not pseudorandom, they claim
to use a quatum generaton (?)) by fetching them from:
http://random.irb.hr/
They give you a python class t insert into your code, but you need to
register to use it (free).
I am not affiliated to them in any way, I just used it once to play
with it and it worked.
Best,

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Generating HTML

2007-09-11 Thread Sebastian Bassi
Hello,

What are people using these days to generate HTML? I still use
HTMLgen, but I want to know if there are new options. I don't
want/need a web-framework a la Zope, just want to produce valid HTML
from Python.
Best,
SB.

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Box plot in Python

2007-03-14 Thread Sebastian Bassi
Hello,

Is there a graphic package for Python that provides support for box plots? (see
http://en.wikipedia.org/wiki/Box_plot and
http://en.wikipedia.org/wiki/Image:R-speed_of_light_boxplot.png for
information on box plots).

I have N sets of data, each with X "points".
Example:

Set 1:
Point 1: 0.21
Point 2: 0.92
Point 3: 0.18
Point 4: 0.12
... cut 
Point 203: 0.91

then:

Set 2:
Point 1: 0.11
Point 2: 0.3
Point 3: 0.82
Point 4: 0.11
... cut 
Point 191: 0.09



I know that R would do it, but I don't know how to use R and would
like to keep on working in Python.

Best,
SB.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Box plot in Python

2007-03-15 Thread Sebastian Bassi
On 3/15/07, Rob Clewley <[EMAIL PROTECTED]> wrote:
> Matplotlib supports boxplots in a very straightforward fashion and is
> reasonably documented (just google it!) I actually just submitted a
> patch for extra boxplot features in matplotlib, which you can find on
> the sourceforge patch tracker.

OK, I will try it.
Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to parse the os.system() output in python

2007-03-17 Thread Sebastian Bassi
On 17 Mar 2007 17:28:56 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I use os.system() to execute a system command in python.
> Can you please tell me how can I parse (in python) the output of the
> os.system()  ?

Maybe you mean to parse the output of the program you run using
os.system. If this is the case, you should redirect the putput of the
program to a file (with ">") and then parse that file.

Best,
SB.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to parse the os.system() output in python

2007-03-17 Thread Sebastian Bassi
On 3/18/07, bruce peng <[EMAIL PROTECTED]> wrote:
> how to redirect the putput of the
> program to a file?

like this:
program_name -parameters > outfile.txt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wikipedia and a little piece of Python History

2007-03-21 Thread Sebastian Bassi
On 21 Mar 2007 12:18:50 -0700, Paddy <[EMAIL PROTECTED]> wrote:
> I just had a link to Tim peters first post on doctest:
> http://groups.google.com/group/comp.lang.python/msg/1c57cfb7b3772763


AFAIK, Google doesn't offer a permalink to usenet/group post (since a
mayor "upgrade" they made some time ago). So this link may change in
the future and point to somewhere else.

Best,
SB.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why brackets & commas in func calls can't be ommited? (maybe it could be PEP?)

2007-03-22 Thread Sebastian Kaliszewski
dmitrey wrote:
> if you want
> result = func1(func2(arg))
> you should use
> result = func1 (func2 arg)

This is in conflict with current meanig, Ergo it breaks old code

rgds
\SK
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem installing Python 2.5

2007-04-03 Thread Sebastian Bassi
I was trying to install Python 2.5 compiling from sources. I used:
./compile
It run OK.
Then:
make altintall
After a lot of output, got this:
Listing /usr/local/lib/python2.5/xml/sax ...
Compiling /usr/local/lib/python2.5/xml/sax/__init__.py ...
Compiling /usr/local/lib/python2.5/xml/sax/_exceptions.py ...
Compiling /usr/local/lib/python2.5/xml/sax/expatreader.py ...
Compiling /usr/local/lib/python2.5/xml/sax/handler.py ...
Compiling /usr/local/lib/python2.5/xml/sax/saxutils.py ...
Compiling /usr/local/lib/python2.5/xml/sax/xmlreader.py ...
Compiling /usr/local/lib/python2.5/xmllib.py ...
Compiling /usr/local/lib/python2.5/xmlrpclib.py ...
Compiling /usr/local/lib/python2.5/zipfile.py ...
make: *** [libinstall] Error 1

It seems I am not the only one with this error:
http://www.thescripts.com/forum/thread613458.html
http://www.megasolutions.net/python/Python-installation-problem-(sorry-if-this-is-a-dup)-22624.aspx
http://ubuntuforums.org/showthread.php?p=1912370

System: Freespire 1.0.13 (based on Debian).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem installing Python 2.5

2007-04-03 Thread Sebastian Bassi
On 4/3/07, Jaroslaw Zabiello <[EMAIL PROTECTED]> wrote:
> After executing
>./configure
> you have to edito
>Modules/Setup
> file and uncomment the following line:
> #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
> Then continue with normal make; make install.

Thank you. I already did this:
make -i altinstall
and then:
make altinstall

And added a comment in bug#1669349
Best,
SB.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python editor/IDE on Linux?

2007-04-13 Thread Sebastian Bassi
On 4/13/07, Jack <[EMAIL PROTECTED]> wrote:
> I wonder what everybody uses for Python editor/IDE on Linux?
> I use PyScripter on Windows, which is very good. Not sure if
> there's something handy like that on Linux. I need to do some
> development work on Linux and the distro I am using is Xubuntu.

DrPython is very nice and is already in Ubuntu repos
(http://drpython.sourceforge.net/).
Eric is also available in Ubuntu
(http://www.die-offenbachs.de/detlev/eric.html).
-- 
http://mail.python.org/mailman/listinfo/python-list


Making a tree out of a 2 column list

2007-04-14 Thread Sebastian Bassi
I have a two column list like:

2,131
6,335
7,6
8,9
10,131
131,99
5,10

And I want to store it in a tree-like structure.
So if I request 131, it should return all the child of 131, like 2, 10
and 5 (since 5 is child of 10).
If I request 335, it should return: 6 and 7.
If I request 9, it should return 8.
I guess I could use tuples or dictionaries to do it, but I can't figure out how.

Best,
SB.


-- 
Sebastián Bassi
Diplomado Ciencia y Tecnología.
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a tree out of a 2 column list

2007-04-14 Thread Sebastian Bassi
On 14 Apr 2007 09:32:07 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> def tree_path(key,tree,indent):
> print '\t'*indent,key
> if tree.has_key(key):
> for m in tree[key]:
> tree_path(m,tree,indent+1)
> return

Thank you. It worked!.
I changed it a bit to return a list with the results:

def tree_path(key,tree,hijos):
hijos.append(key)
if tree.has_key(key):
for m in tree[key]:
tree_path(m,tree,hijos)
return hijos

Then I call it like this:

MyList=tree_path(9608,tree,[])

Best,
SB.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a tree out of a 2 column list

2007-04-15 Thread Sebastian Bassi
On 4/15/07, Peter Otten <[EMAIL PROTECTED]> wrote:
> Depending on your input data you may need to add some cycle detection.
> For example, try it with
> tree_path(1, {1:[2], 2:[1]}, [])

I guess this should make the program enter into a endless loop. But
the data won't have such a redundancy, because it was taken from a
philogenetic tree.

Best,
SB.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a tree out of a 2 column list

2007-04-15 Thread Sebastian Bassi
On 15 Apr 2007 15:44:47 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> But errors and bugs do happen, inside data too; so often it's better
> to be on safe side if the safe code is fast enough.

Yes, I agree since I've seen lot of errors in data. But this data
comes from a taxonomy tree made by the NCBI, that is why I assume the
data is right.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File DB instead of real database?

2007-04-16 Thread Sebastian Bassi
On 13 Apr 2007 21:14:36 -0700, Jia Lu <[EMAIL PROTECTED]> wrote:
>  I donot want to use a real DB like MySQL ... But I need something to
> save about more than 1000 articles.
>  Is there any good ways?

SQLite is a good option, as you were told. But what about put them in
a dictionary and then cPickle it to disk? (using 2 as optimization
setting in cPickle command).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Saving parameters between Python applications?

2007-09-16 Thread Sebastian Bassi
On 9/16/07, Stodge <[EMAIL PROTECTED]> wrote:
> python app1.py --location=c:\test1
> What I want to do is save the location parameter, so I can then do (in
> the same window):
> python app2.py
> And have app2.py automatically have access to the value of "location".

Do app1.py to save a pickle of the value you want app2 to read.

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Saving parameters between Python applications?

2007-09-17 Thread Sebastian Bassi
On 9/17/07, Stodge <[EMAIL PROTECTED]> wrote:
> Good idea, but I can't guarantee that the two scripts will be run from
> the same directory - so where to store the pickle?

It doesn't matter if is the same directory or not, as long as both
programs has access to the pickle file (one program should have write
access and the other program should have at least read access).

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to command..

2007-10-18 Thread Sebastian Bassi
On 10/18/07, Adam Atlas <[EMAIL PROTECTED]> wrote:
>
> Use the builtin function "eval".

What is the difference with os.system()?

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Module for SVG?

2007-01-25 Thread Sebastian Bassi
Hello,

I found http://www2.sfk.nl/svg as a Python module for writing SVG.
Last update was in 2004 and I am not sure if there is something
better.
Any recommendation for generating SVG graphics?
Best,
SB.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: A Primer on Python for Life Science Researchers

2007-11-30 Thread Sebastian Bassi
I'm happy to report the release of a PLOS paper: "A Primer on Python
for Life Science Researchers".
It is a six page education paper introducing Python. If you have a
friend that is a researchers in a biological area and you think that
he may need to know Python, please send him this e-mail:

URL: 
http://compbiol.plosjournals.org/perlserv/?request=get-document&doi=10.1371/journal.pcbi.0030199
(short URL: http://tinyurl.com/2az5d5)

A Primer on Python for Life Science Researchers  Bassi S PLoS
Computational Biology Vol. 3, No. 11, e199
doi:10.1371/journal.pcbi.0030199

Thanks,
-- Sebastián Bassi

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

centre of mass of protein

2008-01-09 Thread smriti Sebastian
hi all,
Is there any script or module in python where we can find the centre of mass
of protein?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Article of interest: Python pros/cons for the enterprise

2008-02-25 Thread Sebastian Kaliszewski
Jeff Schwab wrote:
>> You like managing your own memory, be my guest.  But please don't
>> imply that you're putting forth less effort because of it.  You're
>> just putting forth different effort.
> 
> I disagree with you completely.  Your points don't make any sense to me
> at all.  I believe I am putting forth less effort by having a generic
> resource-management infrastructure, rather than a memory-specific
> language feature -- that's not just an implication, it's my honest belief.

Yet your belief is provably wrong. It's been realised by langauge developers
long time ago.

It's quite simple. 

1. Your "generic" resource-management infrastructure is not generic to begin
with! It does not work for mutually dependant resources.
2. Your "generic" infrastructure increases burden on the programmer
everywhere any resorce (including trivial one like memory) is used, while
GC kills that burden in 95% of the cases. C++ish approach puts the notion
of ownership everywhere - both in 95% of cases where it's useless and in
remaining 5% where it's actually needed. That's not reduced effort by any
means.
3. You can't handle clean-up errors in reasonable way in C++ish approach, so
anything more complex should not by handled that way anyway.


rgds
-- 
"Never underestimate the power of human stupidity" -- L. Lang
-- 
http://mail.python.org/mailman/listinfo/python-list


Web site for comparing languages syntax

2008-02-25 Thread Sebastian Bassi
Hello,

I know there is one site with wikimedia software installed, that is
made for comparing the syntax of several computer languages (Python
included). But don't remember the URL. Anyone knows this site?

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Web site for comparing languages syntax

2008-02-26 Thread Sebastian Bassi
On 2/26/08, Andreas Tawn <[EMAIL PROTECTED]> wrote:
> Maybe http://www.rosettacode.org ? That's a wiki.

YES!!!. Thank you!!

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Problem trying to install ReportLab with easy_install

2009-02-21 Thread Sebastian Bassi
I don't understand what is wrong when I try to install ReportLab. This
is under Ubuntu and all build packages are installed.
Here is what I get when trying to install it: (I could install it with
apt-get, but I am testing virtualenv and easy_install).

(testbio149)vi...@maricurie:~/Public/testbio149$ easy_install ReportLab
Searching for ReportLab
Reading http://pypi.python.org/simple/ReportLab/
Reading http://www.reportlab.com/
Best match: reportLab 2.3
Downloading 
http://pypi.python.org/packages/source/r/reportlab/reportLab-2.3.zip#md5=7d98b26fa287a9e4be4d35d682ce64ac
Processing reportLab-2.3.zip
Running ReportLab_2_3/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-ZZcgFG/ReportLab_2_3/egg-dist-tmp-FqKULE

#Attempting install of _rl_accel, sgmlop & pyHnj
#extensions from '/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel'


#Attempting install of _renderPM
#extensions from '/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/renderPM'
# installing with freetype version 21

/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:
In function âhex32â:
/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:793:
warning: format â%8.8Xâ expects type âunsigned intâ, but argument 3
has type âlong unsigned intâ
/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:
In function â_instanceStringWidthUâ:
/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1200:warning:
pointer targets in assignment differ in signedness
/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1123:warning:
âfâ may be used uninitialized in this function
/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1123:warning:
âtâ may be used uninitialized in this function
/tmp/easy_install-ZZcgFG/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1123:warning:
âLâ may be used uninitialized in this function
/usr/bin/ld: cannot find -l_renderPM_libart
collect2: ld returned 1 exit status
error: Setup script exited with error: command 'gcc' failed with exit status 1
(testbio149)vi...@maricurie:~/Public/testbio149$
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem trying to install ReportLab with easy_install

2009-02-22 Thread Sebastian Bassi
On Sun, Feb 22, 2009 at 10:07 AM, Garrett Cooper  wrote:

>It's not building lib_renderPM_libart properly, or it's a typo
> that supposed to be librenderPM_libart, or bad LDFLAGS...
>More details need to be provided like an ls of your site-packages
> directory and a partial ls of your local library directory (ls
> /usr/?local/?lib/lib*render*libart*, etc).
>

sba...@hp:~$ ls /usr/lib/lib*ren*
/usr/lib/libktorrent.la/usr/lib/libXrender.la
/usr/lib/libktorrent.so/usr/lib/libXrender.so
/usr/lib/libktorrent.so.0  /usr/lib/libXrender.so.1
/usr/lib/libktorrent.so.0.0.0  /usr/lib/libXrender.so.1.3.0
/usr/lib/libXrender.a
sba...@hp:~$ ls /usr/lib/libart*
/usr/lib/libart_lgpl_2.so.2/usr/lib/libartsflow_idl.so.1
/usr/lib/libart_lgpl_2.so.2.3.16   /usr/lib/libartsflow_idl.so.1.0.0
/usr/lib/libart_lgpl.so.2  /usr/lib/libartsflow.so.1
/usr/lib/libart_lgpl.so.2.2.0  /usr/lib/libartsflow.so.1.0.0
/usr/lib/libartscbackend.la/usr/lib/libartsgslplayobject.la
/usr/lib/libartscbackend.so.0  /usr/lib/libartsgslplayobject.so.0
/usr/lib/libartscbackend.so.0.0.0  /usr/lib/libartsgslplayobject.so.0.0.0
/usr/lib/libartsc.so.0 /usr/lib/libartskde.so.1
/usr/lib/libartsc.so.0.0.0 /usr/lib/libartskde.so.1.2.0
/usr/lib/libartsdsp.so.0   /usr/lib/libartswavplayobject.la
/usr/lib/libartsdsp.so.0.0.0   /usr/lib/libartswavplayobject.so.0
/usr/lib/libartsdsp_st.so.0/usr/lib/libartswavplayobject.so.0.0.0
/usr/lib/libartsdsp_st.so.0.0.0

(t6)sba...@hp:~/test/virtualenv-1.3.2/t6$ ls lib/python2.5/site-packages/
easy-install.pthsetuptools.pth
setuptools-0.6c9-py2.5.egg  xlwt-0.7.0-py2.5.egg

This is a virtualenv created with --no-site-packages (to have a clean start).
Other easy_install works, but this one, doesn't :(
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python advocacy ... HELP!

2008-12-04 Thread Sebastian Kaliszewski

Michael_D_G wrote:

how do I refute
the notion that Python
is a "marginal" language because according to TOBIE it only less than
a  6% market share.


According to the same TIOBE, C++ has less than 11%. So it must be niche 
then as well :)


--
"Never underestimate the power of human stupidity" -- L. Lang
--
http://www.tajga.org -- (some photos from my travels)
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to find the beginning of last line of a big text file ?

2009-01-01 Thread Sebastian Bassi
On Thu, Jan 1, 2009 at 2:19 PM, Barak, Ron  wrote:
> I have a very big text file: I need to find the place where the last line
> begins (namely, the offset of the one-before-the-last '\n' + 1).
> Could you suggest a way to do that without getting all the file into memory
> (as I said, it's a big file), or heaving to readline() all lines (ditto) ?

for line in open(filename):
lastline = line
print "the lastline is: %s",%lastline

This will read all the lines, but line by line, so you will never have
the whole file in memory.
There may be more eficient ways to do this, like using the itertools.

Best,
SB.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to store passwords?

2009-01-07 Thread Sebastian Bassi
On Wed, Jan 7, 2009 at 6:42 PM, Oltmans  wrote:
> I'm writing a program in which I will ask users to enter user name and
> password once only. It's a console based program that will run on

In general you don't store the password, but a "hash" of it. Then when
the user logs-in, you hash it and compare the result with the stored
hash.
About hash, use sha, look here:
http://docs.python.org/library/hashlib.html#module-hashlib

> Windows XP. Actually, I'm trying to provide the similar functionality
> as "Remember me" thing in browsers. For that, I will need to store
> user name and passwords on the disk. I don't have a background in

I don't understand how this is supposed to work. "Remember me" in
browser doesn't store passwords.

> using? Moreover, I cannot use a whole library to do that due to
> certain issues. However, I can use like 1--2 files that will be
> shipped along with the main script. Any ideas? Any help will be really
> appreciated. Thanks.

The library I pointed out before is built-in.

Best,
SB.



-- 
Sebastián Bassi. Diplomado en Ciencia y Tecnología.
Book: Python for bioinformatics. http://tinyurl.com/biopython
Vendo isla: http://www.genesdigitales.com/isla
What's new in Python 3: http://tinyurl.com/5cd89r
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
--
http://mail.python.org/mailman/listinfo/python-list


Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-17 Thread Sebastian Wiesner
At Thu, 16 Oct 2008 18:21:38 +0200 wrote Bruno Desthuilliers
<[EMAIL PROTECTED]>:
>>  It doesn't look like there's
>> any way to browse the subversion any more, though.
> 
> Doh :(
> 
> Is there any way to get this version then ???
svn co https://python-mode.svn.sourceforge.net/svnroot/python-mode/trunk/
python-mode


-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial Products in Python

2008-10-21 Thread Sebastian Bassi
On Tue, Oct 21, 2008 at 2:50 PM, Paulo J. Matos <[EMAIL PROTECTED]> wrote:
> I was just wondering, if you wish to commercialize an application
> developed in Python, what's the way to go?

You choose the conditions. Nothing in Python license prevents you of
selling your work.

> I guess the only way is to sell the source, right?

No

> This is because (and tell me if I am wrong):
> 1) You can't sell an executable because Python doesn't compile to native
> code (the usual approach, afaik);

There are py2exe utilities to compile Python applications.

> 2) You can't sell the bytecode, otherwise you get the client stuck with
> a specific python version (given bytecode might vary between versions)
> (the alternative);

Never heard of people selling bytecode, but I guess yes, it is tied to
the same version where is was produced.

-- 
Sebastián Bassi. Diplomado en Ciencia y Tecnología.
Vendo isla: http://www.genesdigitales.com/isla
What's new in Python 3: http://tinyurl.com/5cd89r
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
--
http://mail.python.org/mailman/listinfo/python-list


IDLE home page?

2008-10-21 Thread Sebastian Bassi
If I put IDLE in the search box at python.org, the first hit is:
http://www.python.org/idle/
But this page is a directory without any index file:

Index of /idle

Icon  NameLast modified  Size
Description[DIR] Parent Directory -
[   ] Makefile26-Aug-2005 10:30   90
[DIR] doc/26-Aug-2005 10:30-
[TXT] links.h 26-Aug-2005 10:30  235

If I see the "ABOUT" windows (under HELP in the IDLE menu), there is
also a link to http://www.python.org/idle/
(see here: http://imagebin.ca/view/0OE3jc.html)

So the question is: Is there an official page for IDLE or a file is missing?
--
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE home page?

2008-10-22 Thread Sebastian Bassi
On Wed, Oct 22, 2008 at 3:49 AM, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Depending on the answer you get here, you might send the same observation
> and question to [EMAIL PROTECTED]

OK, I've just sent it. Thank you.
--
http://mail.python.org/mailman/listinfo/python-list


doctest + shelve question

2009-03-06 Thread Sebastian Bartos
Hello list,

I have a question. I'm writing a simple object serialization module
using shelve to write arbitrary objects to a file (M.py). Now I have the
problem, that if I create a simple object in the doctest documentation
file M.txt like this:

>>> class tdata(object):
... def __init__(self, name):
... self.name = name
>>> tinst = tdata(u'foo')

and then run it with my module M:

>>> import M
>>> foo = M.serialize('/tmp/foo', tinst.name, tinst)

which calls:

class serialize(object):
def __init__(self, path, key, data):
db = shelve.open(path)
db[key.encode('utf-8')] = data
db.close()

then I get the following problem:

Failed example:
foo = M.serialize('/tmp/foo', tinst)
Exception raised:
Traceback (most recent call last):
  File "/usr/lib/python2.5/doctest.py", line 1228, in __run
compileflags, 1) in test.globs
...
  File "/usr/lib/python2.5/shelve.py", line 123, in __setitem__
p.dump(value)
PicklingError: Can't pickle : attribute lookup
__builtin__.tdata failed


If I do the same in the interactive interpreter, then it works fine.

Now, as I want to test an arbitrary data class, the doctest file is the
place to put the simple tdata class, but as far as I traced the problem,
it uses it's own namespace or something, and so does not work.

I'd like to keep a consistent doctest documentation here and not spawn
my project with additional test modules or similar.

Any idea on how I can make it work like as if it would be called from
the interactive interpreter? The documentation and Google were not too
helpful.

ps. Sys: Linux, Python: 2.5.2

thanks

-- 
Sebastian Bartos, 
keyserevr: pgp.mit.edu


signature.asc
Description: This is a digitally signed message part
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have certificate?

2009-03-23 Thread Sebastian Bassi
On Mon, Mar 23, 2009 at 9:15 PM, Muddy Coder  wrote:
> I wonder that does Python have certificate? You see, java, .NET, PHP,
> and so on, they have certificates for developers to get. Python is
> quite popular nowadays, I wonder is there such a thing? If so, I
> certainly want to get one. I searched, and

No, there is no certification for Python. Maybe in the future...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Automatically generating arithmetic operations for a subclass

2009-04-14 Thread Sebastian Wiesner


> I have a subclass of int where I want all the standard arithmetic
> operators to return my subclass, but with no other differences:
> 
> class MyInt(int):
> def __add__(self, other):
> return self.__class__(super(MyInt, self).__add__(other))
> # and so on for __mul__, __sub__, etc.
> 
> 
> My quick-and-dirty count of the __magic__ methods that need to be over-
> ridden comes to about 30. That's a fair chunk of unexciting boilerplate.
> 
> Is there a trick or Pythonic idiom to make arithmetic operations on a
> class return the same type, without having to manually specify each
> method? I'm using Python 2.5, so anything related to ABCs are not an
> option.
> 
> Does anyone have any suggestions?

Metaclasses can be used for this purpuse, see the example for a Roman number 
type [1]

[1] http://paste.pocoo.org/show/97258/

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)

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


Re: pyqt4 qTableWidget add items help

2009-04-18 Thread Sebastian Wiesner
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



[...]
> I've been trying
> 
> while(len(orders)> i):
> ui.tb1_tblOrders.setCurrentCell(i,0,orders[i][1])
> i+=1
> 
> which to me, says go add in the first column row with the first order,
> and it makes sense to me
Read the documentation [1] to learn, what ".setCurrentCell()" actually does 
and what its arguments are!  And please stop this wild guessing ...

The method you're searching for is ".setItem()" [2], which adds a new 
QTableWidgetItem [3] to a QTableWidget. 

[1] http://doc.trolltech.com/4.5/qtablewidget.html#setCurrentCell
[2] http://doc.trolltech.com/4.5/qtablewidget.html#setItem
[3] http://doc.trolltech.com/4.5/qtablewidgetitem.html

- -- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAknpr4sACgkQGV4vxEMMOxdnawCfTXO55EffBJMQ7h91RGtMIpZ/
hcYAoLQ9yF5u/hBgNRvqxGRlIy5lPDgb
=Q6ef
-END PGP SIGNATURE-

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


  1   2   3   >